vehicleModel.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. <template>
  2. <view>
  3. <view style="padding: 20rpx;">
  4. <u-search placeholder="请输入品牌名称" v-model="name" @custom="custom"></u-search>
  5. </view>
  6. <u-index-list :indexList="indexList" v-if="!loading">
  7. <template v-for="(item, index) in itemArr">
  8. <!-- #ifdef APP-NVUE -->
  9. <u-index-anchor :text="indexList[index]" :key="index" v-if="item.length>0"></u-index-anchor>
  10. <!-- #endif -->
  11. <u-index-item :key="index">
  12. <!-- #ifndef APP-NVUE -->
  13. <u-index-anchor :text="indexList[index]" v-if="item.length>0"></u-index-anchor>
  14. <!-- #endif -->
  15. <view class="list" v-for="(item1, index1) in item" :key="index1">
  16. <view class="list__item" @click="choice(item1,index1)">
  17. <text class="list__item__user-name">{{item1.brand}}</text>
  18. <text class="list__item__user-tel">{{item1.tel}}</text>
  19. </view>
  20. <u-line></u-line>
  21. </view>
  22. </u-index-item>
  23. </template>
  24. </u-index-list>
  25. <u-loading-page loading-mode="spinner" :loading="loading"></u-loading-page>
  26. <u-popup :show="vehicleSeries" @close="vehicleSeries = false" mode="right" :closeable="true">
  27. <view style="padding-top: 10rpx;width: 650rpx;">
  28. <swiper class="box-c" style="height: 100vh;">
  29. <swiper-item class="child">
  30. <scroll-view :scroll-y="true">
  31. <view class="list" style="background-color: #FD4B09;" v-for="(item,index) in vehicleSeriesList" :key="index">
  32. <view class="list__item">
  33. <text class="list__item__user-name" style="color: #fff;">{{item.name}}</text>
  34. </view>
  35. <u-line></u-line>
  36. <view class="list" style="background-color: #fff;" v-for="(li,i) in item[item.name]" :key="i">
  37. <view class="list__item" @click="vehicleSeriesClick(li)">
  38. <text class="list__item__user-name">{{li.seriesName}}</text>
  39. </view>
  40. <u-line></u-line>
  41. </view>
  42. </view>
  43. </scroll-view>
  44. </swiper-item>
  45. </swiper>
  46. </view>
  47. </u-popup>
  48. </view>
  49. </template>
  50. <script>
  51. import {
  52. queryAllCustomer,
  53. queryInitialsCustomer,
  54. brandList
  55. } from '@/api/views/vehicle/brand.js'
  56. const indexList = () => {
  57. const indexList = []
  58. const charCodeOfA = 'A'.charCodeAt(0)
  59. for (let i = 0; i < 26; i++) {
  60. indexList.push(String.fromCharCode(charCodeOfA + i))
  61. }
  62. indexList.push('#')
  63. return indexList
  64. }
  65. export default {
  66. data() {
  67. return {
  68. name: '',
  69. indexList: indexList(),
  70. itemArrTwo: [],
  71. loading: true,
  72. vehicleSeries: false,
  73. vehicleSeriesList: [],
  74. form: {},
  75. params: {}
  76. }
  77. },
  78. onLoad(params) {
  79. this.params = {
  80. ...params,
  81. adminProfiles: uni.getStorageSync('userInfo').user_id
  82. }
  83. queryAllCustomer(this.params).then(res => {
  84. this.itemArrTwo = res.data
  85. this.loading = false
  86. })
  87. },
  88. computed: {
  89. itemArr() {
  90. return this.indexList.map((item, index) => {
  91. return this.itemArrTwo[index]
  92. })
  93. }
  94. },
  95. methods: {
  96. // queryInitials(item,index){
  97. // queryInitialsCustomer({initials:item}).then(res=>{
  98. // console.log(res.data)
  99. // })
  100. // },
  101. custom() {
  102. this.loading = true
  103. queryAllCustomer({
  104. ...this.params,
  105. brand: this.name
  106. }).then(res => {
  107. this.itemArrTwo = res.data
  108. this.loading = false
  109. })
  110. },
  111. choice(item1, index1) {
  112. this.form = item1
  113. uni.showLoading({
  114. title: '查询车系中',
  115. mask: true
  116. });
  117. brandList({
  118. brandId: item1.brandId
  119. }).then(res => {
  120. this.vehicleSeriesList = res.data
  121. uni.hideLoading();
  122. this.vehicleSeries = true
  123. })
  124. },
  125. vehicleSeriesClick(item) {
  126. uni.$u.route('/pages/views/vehicle/vehicleSeries', {
  127. brand: item.brand,
  128. seriesName: item.seriesName,
  129. brandId: item.brandId,
  130. seriesId: item.seriesId
  131. });
  132. }
  133. // confirm() {
  134. // let pages = getCurrentPages() // 获取当前页面栈的实例,以数组形式按栈的顺序给出,第一个元素为首页,最后一个元素为当前页面。
  135. // let prevPage = pages[pages.length - 2] //上一页页面实例
  136. // prevPage.$vm.otherFun(this.form)
  137. // uni.navigateBack()
  138. // }
  139. }
  140. }
  141. </script>
  142. <style lang="scss">
  143. .box-c,
  144. .child {
  145. display: flex;
  146. flex: 1;
  147. }
  148. .list {
  149. &__item {
  150. @include flex;
  151. padding: 6px 12px;
  152. align-items: center;
  153. justify-content: space-between;
  154. &__user-name {
  155. font-size: 32rpx;
  156. color: $u-main-color;
  157. }
  158. &__user-tel {
  159. font-size: 32rpx;
  160. margin-right: 20rpx;
  161. color: $u-main-color;
  162. }
  163. }
  164. &__footer {
  165. color: $u-tips-color;
  166. font-size: 14px;
  167. text-align: center;
  168. margin: 15px 0;
  169. }
  170. }
  171. </style>