nav.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  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. this.$msg.getMsg(this.$storage.get('airportName'))
  88. },
  89. test() {
  90. uni.navigateTo({
  91. url: "/pages/search/index"
  92. })
  93. },
  94. compareDesc(propertyName) {
  95. return function(object1, object2) {
  96. var value1 = object1[propertyName];
  97. var value2 = object2[propertyName];
  98. if(value2 < value1) {
  99. return -1;
  100. } else if(value2 > value1) {
  101. return 1;
  102. } else {
  103. return 0;
  104. }
  105. }
  106. },
  107. //搜索框输入事件
  108. inputSearch() {
  109. this.$emit('input', this.searchText)
  110. },
  111. clickOrder() {
  112. this.$emit('fall')
  113. }
  114. },
  115. }
  116. </script>
  117. <style lang="scss" scoped>
  118. .nav-content {
  119. >.nav {
  120. width: 100%;
  121. height: 2.375rem;
  122. display: flex;
  123. justify-content: center;
  124. align-items: center;
  125. padding-top: 2.25rem;
  126. color: rgb(255, 255, 255);
  127. font-family: Noto Sans SC;
  128. font-size: 1rem;
  129. position: relative;
  130. // background: rgba(234, 241, 245,0.2);
  131. >.log {
  132. width: .375rem;
  133. height: .75rem;
  134. font-size: .75rem;
  135. position: absolute;
  136. left: 1.5rem;
  137. background: url('../../static/ico.png') no-repeat;
  138. background-size: 100% 100%;
  139. }
  140. >.nav-sech {
  141. width: 18.5625rem;
  142. height: 1.875rem;
  143. display: flex;
  144. align-items: center;
  145. background: rgba(234, 241, 245, 0.2);
  146. border-radius: 4px;
  147. .secah {
  148. width: 3.75rem;
  149. height: 80%;
  150. display: flex;
  151. align-items: center;
  152. justify-content: center;
  153. color: rgb(255, 255, 255);
  154. font-family: Noto Sans SC;
  155. font-size: 14px;
  156. font-weight: 400;
  157. border-right: .0625rem solid rgb(255, 255, 255);
  158. }
  159. .my-input-placeholder {
  160. color: rgb(170, 195, 207);
  161. }
  162. .input-nav {
  163. padding-left: .625rem;
  164. color: rgb(170, 195, 207);
  165. }
  166. }
  167. >.up {
  168. position: absolute;
  169. right: 1.5rem;
  170. color: rgb(255, 255, 255);
  171. font-family: Noto Sans SC;
  172. font-size: .875rem;
  173. font-weight: 500;
  174. }
  175. }
  176. }
  177. </style>