nav.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. <template>
  2. <view class="nav-content">
  3. <view class="nav">
  4. <view class="log" v-if="navtype" @tap="clickOrder">
  5. </view>
  6. <view class="nav-sech">
  7. <picker v-if="airportList && airportList.length>0" class="secah" @change="change" :value="valueIndex" :range="airportList">
  8. <view>{{airportList[valueIndex]}}</view>
  9. </picker>
  10. <input class="uni-input input-nav" @tap="test" disabled="true" v-model="flightNo" :placeholder="placeholder" />
  11. <uni-icons type="clear" size="26" @tap="clear" color="#fff" v-if="flightNo!=''"></uni-icons>
  12. </view>
  13. </view>
  14. </view>
  15. </template>
  16. <script>
  17. export default {
  18. data() {
  19. return {
  20. searchText: '', //搜索内容
  21. placeholder: '请输入航班号或行李号',
  22. array: [],
  23. airportList:[],
  24. valueIndex:this.index
  25. }
  26. },
  27. props: {
  28. navname: {
  29. type: String,
  30. default: ''
  31. },
  32. navtype: {
  33. type: Boolean,
  34. default: true
  35. },
  36. navtypes: {
  37. type: Boolean,
  38. default: false
  39. },
  40. index:{
  41. type: Number,
  42. default: 0
  43. },
  44. flightNo:{
  45. type: String,
  46. default: ''
  47. },
  48. },
  49. created(option) {
  50. this.airportList =this.$storage.getJson('airportList');
  51. if(!this.airportList){
  52. this.getAirportList()
  53. }
  54. },
  55. onUnload() {},
  56. onShow() {
  57. },
  58. mounted() {},
  59. methods: {
  60. clear(){
  61. this.$emit("clear")
  62. },
  63. async getAirportList(){
  64. let data={
  65. "serviceId": 14,
  66. "dataContent": [],
  67. "event": "0"
  68. }
  69. await this.$http.httpPost('/openApi/query',data).then(res => {
  70. this.airportList = []
  71. if(res.code == "0"){
  72. res.returnData.map(item =>{
  73. this.airportList.push(item['IATACode'])
  74. this.airportList.sort()
  75. })
  76. this.$storage.setJson('airportList',this.airportList);
  77. let num = this.valueIndex;
  78. this.$storage.set('airportName',this.airportList[num])
  79. }
  80. })
  81. },
  82. change(e){
  83. this.valueIndex = e.detail.value
  84. this.$emit('airport',this.airportList[this.valueIndex])
  85. this.$storage.set('airportName',this.airportList[this.valueIndex])
  86. this.$storage.set('airport',this.valueIndex);
  87. },
  88. test() {
  89. uni.navigateTo({
  90. url: "/pages/search/index"
  91. })
  92. },
  93. compareDesc(propertyName) {
  94. return function(object1, object2) {
  95. var value1 = object1[propertyName];
  96. var value2 = object2[propertyName];
  97. if(value2 < value1) {
  98. return -1;
  99. } else if(value2 > value1) {
  100. return 1;
  101. } else {
  102. return 0;
  103. }
  104. }
  105. },
  106. //搜索框输入事件
  107. inputSearch() {
  108. this.$emit('input', this.searchText)
  109. },
  110. clickOrder() {
  111. this.$emit('fall')
  112. }
  113. },
  114. }
  115. </script>
  116. <style lang="scss" scoped>
  117. .nav-content {
  118. >.nav {
  119. width: 100%;
  120. height: 2.375rem;
  121. display: flex;
  122. justify-content: center;
  123. align-items: center;
  124. padding-top: 2.25rem;
  125. color: rgb(255, 255, 255);
  126. font-family: Noto Sans SC;
  127. font-size: 1rem;
  128. position: relative;
  129. // background: rgba(234, 241, 245,0.2);
  130. >.log {
  131. width: .375rem;
  132. height: .75rem;
  133. font-size: .75rem;
  134. position: absolute;
  135. left: 1.5rem;
  136. background: url('../../static/ico.png') no-repeat;
  137. background-size: 100% 100%;
  138. }
  139. >.nav-sech {
  140. width: 18.5625rem;
  141. height: 1.875rem;
  142. display: flex;
  143. align-items: center;
  144. background: rgba(234, 241, 245, 0.2);
  145. border-radius: 4px;
  146. .secah {
  147. width: 3.75rem;
  148. height: 80%;
  149. display: flex;
  150. align-items: center;
  151. justify-content: center;
  152. color: rgb(255, 255, 255);
  153. font-family: Noto Sans SC;
  154. font-size: 14px;
  155. font-weight: 400;
  156. border-right: .0625rem solid rgb(255, 255, 255);
  157. }
  158. .my-input-placeholder {
  159. color: rgb(170, 195, 207);
  160. }
  161. .input-nav {
  162. padding-left: .625rem;
  163. color: rgb(170, 195, 207);
  164. }
  165. }
  166. >.up {
  167. position: absolute;
  168. right: 1.5rem;
  169. color: rgb(255, 255, 255);
  170. font-family: Noto Sans SC;
  171. font-size: .875rem;
  172. font-weight: 500;
  173. }
  174. }
  175. }
  176. </style>