vehicleModel.vue 4.7 KB

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