owner.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. <template>
  2. <view>
  3. <!-- 选择车型 -->
  4. <u-popup v-model="showRight" mode="right">
  5. <scroll-view :scroll-top="0" scroll-y="true" :style="{ height: winHeight + 'px' }">
  6. <block>
  7. <view class="vehicle-list-item">
  8. <!-- <view v-if="list.data && list.data.length" :id="list.letter" class="vehicle-list-item-title">{{ list.letter }}</view> -->
  9. <view class="uni-list">
  10. <view v-if="vehicle" v-for="(item, index) in vehicle" :key="index" class="vehicle-list-item-contect" hover-class="uni-list-item--hover"
  11. @click="chooseVehicle(item)">
  12. <view v-if="item.name" class="uni-list-item__content">{{ item.name }}</view>
  13. </view>
  14. </view>
  15. </view>
  16. </block>
  17. </scroll-view>
  18. </u-popup>
  19. <!-- 选择品牌 -->
  20. <u-index-list :scrollTop="scrollTop" :index-list="indexList">
  21. <view v-for="(item, index) in list" :key="index">
  22. <u-index-anchor :index="item.letter" />
  23. <!-- 第一个渲染宫格 -->
  24. <view v-if="index==0" class="list-cell u-border-bottom">
  25. <u-grid :col="5">
  26. <u-grid-item v-for="(item, index1) in item.data" :key="index1" @click="chooseEvent(item)">
  27. <u-image width="80rpx" height="80rpx" :fade="false" :src="item.img" @click="chooseEvent(item)"></u-image>
  28. <view class="grid-text">{{item.name}}</view>
  29. </u-grid-item>
  30. </u-grid>
  31. </view>
  32. <!-- 其它渲染列表 -->
  33. <view v-else class="list-cell u-border-bottom" v-for="(item, index2) in item.data" :key="index2" @click="chooseEvent(item)">
  34. <u-image width="60rpx" height="60rpx" :src="item.img" @click="chooseEvent(item)"></u-image> <text class="anchor-text">{{item.name}}</text>
  35. </view>
  36. </view>
  37. </u-index-list>
  38. </view>
  39. </template>
  40. <script>
  41. var _self;
  42. import {
  43. carBrands
  44. } from '@/components/brand.js'
  45. export default {
  46. data() {
  47. return {
  48. showRight: false,
  49. scrollTop: 0,
  50. indexList: [],//
  51. list: [],//全部品牌列表
  52. vehicle: [],//车型列表
  53. select_path: {},
  54. winHeight: uni.getSystemInfoSync().windowHeight,
  55. params: [],
  56. brand:'',//品牌
  57. name:'',//车型
  58. }
  59. },
  60. onShow() {
  61. _self = this;
  62. },
  63. created() {
  64. let _obj = []
  65. _obj.push({
  66. 'letter': 'HOT',
  67. 'data': []
  68. });
  69. //热门车型数据
  70. carBrands.HotBrand.filter(item => {
  71. _obj[0].data.push({
  72. 'brand': item.initials + '-' + item.name,
  73. 'name': item.name,
  74. 'img': item.pic_image,
  75. 'id': item.id
  76. })
  77. })
  78. // 车型列表
  79. carBrands.car_brand.filter(item => {
  80. var _index = _obj.findIndex(_item => {
  81. return _item.letter == item.initials ? true : false;
  82. })
  83. if (-1 == _index) {
  84. _obj.push({
  85. 'letter': item.initials,
  86. 'data': [{
  87. 'brand': item.initials + '-' + item.name,
  88. 'name': item.name,
  89. 'img': item.pic_image,
  90. 'id': item.id
  91. }]
  92. })
  93. } else {
  94. _obj[_index].data.push({
  95. 'brand': item.initials + '-' + item.name,
  96. 'name': item.name,
  97. 'img': item.pic_image,
  98. 'id': item.id
  99. })
  100. }
  101. })
  102. this.list = _obj;
  103. this.indexList = this.list.map(val => {
  104. return val.letter;
  105. })
  106. },
  107. onPageScroll(e) {
  108. _self.scrollTop = e.scrollTop;
  109. },
  110. methods: {
  111. //选择品牌
  112. chooseEvent(e) {
  113. console.log(e);
  114. this.brand = e.name
  115. let _obj = []
  116. this.$http('/addons/ddrive/banner/car_type', {
  117. brand_id: e.id
  118. }, "POST").then(data => {
  119. console.log(data);
  120. data.car_type.filter(item => {
  121. _obj.push({
  122. 'name': item.name
  123. })
  124. this.vehicle = _obj;
  125. })
  126. })
  127. this.showRight = true;
  128. },
  129. //选择车辆
  130. chooseVehicle(e) {
  131. console.log(e);
  132. uni.$emit('brand',{
  133. brand: this.brand,
  134. name: e.name
  135. })
  136. uni.navigateBack({
  137. })
  138. }
  139. }
  140. }
  141. </script>
  142. <style lang="scss" scoped>
  143. .list-cell {
  144. display: flex;
  145. box-sizing: border-box;
  146. width: 100%;
  147. padding: 10px 24rpx;
  148. overflow: hidden;
  149. color: $u-content-color;
  150. font-size: 14px;
  151. line-height: 30px;
  152. background-color: #fff;
  153. }
  154. .anchor-text {
  155. margin-left: 20rpx;
  156. }
  157. .vehicle-list-item-title {
  158. min-width: 300rpx;
  159. padding: 24upx 30upx;
  160. line-height: 1.5;
  161. background-color: #f7f7f7;
  162. font-size: 32upx
  163. }
  164. .vehicle-list-item-contect {
  165. font-size: 32upx;
  166. padding: 24upx 30upx;
  167. width: 100%;
  168. box-sizing: border-box;
  169. flex: 1;
  170. position: relative;
  171. display: flex;
  172. flex-direction: row;
  173. justify-content: space-between;
  174. align-data: center;
  175. border-bottom: 1rpx solid #eee;
  176. ;
  177. }
  178. </style>