nav.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  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. })
  75. this.$storage.setJson('airportList',this.airportList);
  76. let num = this.valueIndex;
  77. this.$storage.set('airportName',this.airportList[num])
  78. }
  79. })
  80. },
  81. change(e){
  82. this.valueIndex = e.detail.value
  83. this.$emit('airport',this.airportList[this.valueIndex])
  84. this.$storage.set('airportName',this.airportList[this.valueIndex])
  85. this.$storage.set('airport',this.valueIndex);
  86. },
  87. test() {
  88. uni.navigateTo({
  89. url: "/pages/search/index"
  90. })
  91. },
  92. //搜索框输入事件
  93. inputSearch() {
  94. this.$emit('input', this.searchText)
  95. },
  96. clickOrder() {
  97. this.$emit('fall')
  98. }
  99. },
  100. }
  101. </script>
  102. <style lang="scss" scoped>
  103. .nav-content {
  104. >.nav {
  105. width: 100%;
  106. height: 2.375rem;
  107. display: flex;
  108. justify-content: center;
  109. align-items: center;
  110. padding-top: 2.25rem;
  111. color: rgb(255, 255, 255);
  112. font-family: Noto Sans SC;
  113. font-size: 1rem;
  114. position: relative;
  115. // background: rgba(234, 241, 245,0.2);
  116. >.log {
  117. width: .375rem;
  118. height: .75rem;
  119. font-size: .75rem;
  120. position: absolute;
  121. left: 1.5rem;
  122. background: url('../../static/ico.png') no-repeat;
  123. background-size: 100% 100%;
  124. }
  125. >.nav-sech {
  126. width: 18.5625rem;
  127. height: 1.875rem;
  128. display: flex;
  129. align-items: center;
  130. background: rgba(234, 241, 245, 0.2);
  131. border-radius: 4px;
  132. .secah {
  133. width: 3.75rem;
  134. height: 80%;
  135. display: flex;
  136. align-items: center;
  137. justify-content: center;
  138. color: rgb(255, 255, 255);
  139. font-family: Noto Sans SC;
  140. font-size: 14px;
  141. font-weight: 400;
  142. border-right: .0625rem solid rgb(255, 255, 255);
  143. }
  144. .my-input-placeholder {
  145. color: rgb(170, 195, 207);
  146. }
  147. .input-nav {
  148. padding-left: .625rem;
  149. color: rgb(170, 195, 207);
  150. }
  151. }
  152. >.up {
  153. position: absolute;
  154. right: 1.5rem;
  155. color: rgb(255, 255, 255);
  156. font-family: Noto Sans SC;
  157. font-size: .875rem;
  158. font-weight: 500;
  159. }
  160. }
  161. }
  162. </style>