nav.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  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" :placeholder="placeholder" />
  11. <uni-icons type="scan" size="26" @tap="scan" color="#fff"></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. },
  45. created(option) {
  46. this.airportList =this.$storage.getJson('airportList');
  47. if(!this.airportList){
  48. this.getAirportList()
  49. }
  50. },
  51. onUnload() {},
  52. onShow() {
  53. },
  54. mounted() {},
  55. methods: {
  56. scan(){
  57. this.$emit("scan")
  58. },
  59. async getAirportList(){
  60. let data={
  61. "serviceId": 14,
  62. "dataContent": [],
  63. "event": "0"
  64. }
  65. await this.$http.httpPost('/openApi/query',data).then(res => {
  66. this.airportList = []
  67. if(res.code == "0"){
  68. res.returnData.map(item =>{
  69. this.airportList.push(item['IATACode'])
  70. })
  71. this.$storage.setJson('airportList',this.airportList);
  72. let num = this.valueIndex;
  73. this.$storage.set('airportName',this.airportList[num])
  74. }
  75. })
  76. },
  77. change(e){
  78. this.valueIndex = e.detail.value
  79. this.$emit('airport',this.airportList[this.valueIndex])
  80. this.$storage.set('airport',this.valueIndex);
  81. },
  82. test() {
  83. uni.navigateTo({
  84. url: "/pages/search/index"
  85. })
  86. },
  87. //搜索框输入事件
  88. inputSearch() {
  89. this.$emit('input', this.searchText)
  90. },
  91. clickOrder() {
  92. this.$emit('fall')
  93. }
  94. },
  95. }
  96. </script>
  97. <style lang="scss" scoped>
  98. .nav-content {
  99. >.nav {
  100. width: 100%;
  101. height: 2.375rem;
  102. display: flex;
  103. justify-content: center;
  104. align-items: center;
  105. padding-top: 2.25rem;
  106. color: rgb(255, 255, 255);
  107. font-family: Noto Sans SC;
  108. font-size: 1rem;
  109. position: relative;
  110. // background: rgba(234, 241, 245,0.2);
  111. >.log {
  112. width: .375rem;
  113. height: .75rem;
  114. font-size: .75rem;
  115. position: absolute;
  116. left: 1.5rem;
  117. background: url('../../static/ico.png') no-repeat;
  118. background-size: 100% 100%;
  119. }
  120. >.nav-sech {
  121. width: 18.5625rem;
  122. height: 1.875rem;
  123. display: flex;
  124. align-items: center;
  125. background: rgba(234, 241, 245, 0.2);
  126. border-radius: 4px;
  127. .secah {
  128. width: 3.75rem;
  129. height: 80%;
  130. display: flex;
  131. align-items: center;
  132. justify-content: center;
  133. color: rgb(255, 255, 255);
  134. font-family: Noto Sans SC;
  135. font-size: 14px;
  136. font-weight: 400;
  137. border-right: .0625rem solid rgb(255, 255, 255);
  138. }
  139. .my-input-placeholder {
  140. color: rgb(170, 195, 207);
  141. }
  142. .input-nav {
  143. padding-left: .625rem;
  144. color: rgb(170, 195, 207);
  145. }
  146. }
  147. >.up {
  148. position: absolute;
  149. right: 1.5rem;
  150. color: rgb(255, 255, 255);
  151. font-family: Noto Sans SC;
  152. font-size: .875rem;
  153. font-weight: 500;
  154. }
  155. }
  156. }
  157. </style>