screen.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  1. <template>
  2. <view class="body">
  3. <view class="content">
  4. <!-- p品牌 -->
  5. <view class="price">
  6. <view class="pricecon">品牌</view>
  7. <ul>
  8. <li :class="brandIndex==index? 'cssselect' : '' " v-for="(item,index) in brand " :key="index" @click="Clickbran(item,index)" >{{item.name}}</li>
  9. </ul>
  10. </view>
  11. <!-- 价格 -->
  12. <view class="price">
  13. <view class="pricecon">价格</view>
  14. <ul>
  15. <li :class="piceconIndex==index? 'cssselect' : '' " v-for="(item,index) in priceList " :key="index" @click="Clickpice(item,index)" >{{item.name}}</li>
  16. </ul>
  17. </view>
  18. <!-- 变速箱 -->
  19. <view class="price">
  20. <view class="pricecon">变速箱</view>
  21. <ul>
  22. <li :class="TransmissionIndex==index? 'cssselect' : '' " v-for="(item,index) in Transmission " :key="index" @click="Clicktransmission(item,index)" >{{item.name}}</li>
  23. </ul>
  24. </view>
  25. <!-- 里程 -->
  26. <view class="price">
  27. <view class="pricecon">里程 (万公里)</view>
  28. <ul>
  29. <li :class="mileageListIndex==index? 'cssselect' : '' " v-for="(item,index) in mileageList " :key="index" @click="ClickmileageList(item,index)">{{item.name}}</li>
  30. </ul>
  31. </view>
  32. <!-- 排量 -->
  33. <view class="price">
  34. <view class="pricecon">排量</view>
  35. <ul>
  36. <li :class="displacementIndex==index? 'cssselect' : '' " v-for="(item,index) in displacement " :key="index" @click="Clickdisplacement(item,index)" >{{item.name}}</li>
  37. </ul>
  38. </view>
  39. <!-- 排放标准 -->
  40. <view class="price">
  41. <view class="pricecon">排量标准</view>
  42. <ul>
  43. <li :class="emissionStandardIndex==index? 'cssselect' : '' " v-for="(item,index) in emissionStandard " :key="index" @click="ClickemissionStandard(item,index)" >{{item.name}}</li>
  44. </ul>
  45. </view>
  46. <!-- 车辆颜色 -->
  47. <view class="price">
  48. <view class="pricecon">车辆颜色</view>
  49. <ul>
  50. <li :class="VehicleColorIndex==index? 'cssselect' : '' " v-for="(item,index) in VehicleColor " :key="index" @click="ClickVehicleColor(item,index)" >{{item.name}}</li>
  51. </ul>
  52. </view>
  53. <!-- 座位 -->
  54. <view class="price">
  55. <view class="pricecon">座位数</view>
  56. <ul>
  57. <li :class="seatsIndex==index? 'cssselect' : '' " v-for="(item,index) in seats " :key="index" @click="Clickseats(item,index)" >{{item.name}}</li>
  58. </ul>
  59. </view>
  60. <!-- 车龄 -->
  61. <view class="price">
  62. <view class="pricecon">车龄(年)</view>
  63. <ul>
  64. <li :class="carAgeIndex==index? 'cssselect' : '' " v-for="(item,index) in carAge " :key="index" @click="ClickcarAge(item,index)" >{{item.name}}</li>
  65. </ul>
  66. </view>
  67. </view>
  68. <view class="foot">
  69. <view style="width: 20vw; height: 10vw; border-radius: 5px; text-align: center; line-height: 10vw; border: 1px solid lightgray;"> 重置</view>
  70. <view class="button" @click="goUserdList">为你找到{{count}}车型</view>
  71. </view>
  72. </view>
  73. </template>
  74. <script>
  75. export default{
  76. data(){
  77. return{
  78. selectIndex:'',
  79. brandIndex:-1,
  80. piceconIndex:-1,
  81. mileageListIndex:-1,
  82. TransmissionIndex:-1,
  83. emissionStandardIndex:-1,
  84. VehicleColorIndex:-1,
  85. carAgeIndex:-1,
  86. seatsIndex:-1,
  87. displacementIndex:-1,
  88. selected: {}, //选取的分类 ,用对象更方便存取数据
  89. brand:[],
  90. carbrand:'',//搜索
  91. carprice:'',
  92. cartransmission:'',
  93. carmileage:'',
  94. cardisplacement:'',
  95. caremission:'',
  96. carseat:'',
  97. caryear:'',
  98. carcolor:'',
  99. caryear:'',
  100. caroil_type:'',
  101. priceList:[
  102. { name:'不限',id:'' },
  103. { name:'三万以下',id:'0,3' },
  104. { name:'3-5万',id:'3,5' },
  105. { name:'5-8万',id:'5,8' },
  106. {name:'8-12万',id:'8,12' },
  107. { name:'12-18万',id:'12,18' },
  108. { name:'18-25万',id:'18,25' },
  109. {name:'25-35万',id:'25,35' },
  110. {name:'35-50万',id:'35,50' },
  111. {name:'50-70万',id:'50,70' },
  112. {name:'70万以上',id:'70' }
  113. ],
  114. produceAge:[],
  115. Transmission:[],
  116. mileageList:[
  117. {name:'不限',id:''},
  118. {name:'1万公里以内',id:'0,1'},
  119. {name:'1-3万公里',id:'1,3'},
  120. {name:'3-6万公里',id:'3,6'},
  121. {name:'6-10万公里',id:'6,10'},
  122. {name:'10-20万公里',id:'10,20'},
  123. {name:'20万公里以上',id:'20'}
  124. ],
  125. displacement:[],
  126. emissionStandard:[],
  127. dirve:[],
  128. VehicleColor:[],
  129. seats:[],
  130. count:0,
  131. userdCar:[],
  132. carAge:[
  133. {name:'不限',id:''},
  134. {name:'1年内',id:'0,1'},
  135. {name:'1-3年',id:'1,3'},
  136. {name:'3-5年',id:'3,5'},
  137. {name:'5-8年',id:'5,8'},
  138. {name:'8-10年',id:'8,10'},
  139. {name:'10年以上',id:'10'}
  140. ],
  141. fuel:[]
  142. }
  143. },
  144. onLoad() {
  145. this.SearchType()
  146. },
  147. methods:{
  148. // 二手车列表
  149. UsedCarList(name,brand,gearbox,color,displacement,emission,seat_count,oil_type,price_range,mileage__range,years_range){
  150. this.$api.getUsedCarList(name,brand,gearbox,color,displacement,emission,seat_count,oil_type,price_range,mileage__range,years_range,res=>{
  151. if(res.code==0){
  152. this.count=res.count
  153. this.userdCar=res.data
  154. }
  155. })
  156. },
  157. // 搜索
  158. Clickbran(item,index){
  159. this.brandIndex=index
  160. this.carbrand=item.id
  161. this.UsedCarList('',this.carbrand,this.cartransmission,this.carcolor,this.cardisplacement,this.caremission,this.carseat,this.caroil_type,this.carprice,this.carmileage,this.caryear)
  162. },
  163. //价格
  164. Clickpice(item,index){
  165. this.piceconIndex=index
  166. this.carprice=item.id
  167. this.UsedCarList('',this.carbrand,this.cartransmission,this.carcolor,this.cardisplacement,this.caremission,this.carseat,this.caroil_type,this.carprice,this.carmileage,this.caryear)
  168. },
  169. Clicktransmission(item,index){
  170. this.TransmissionIndex=index
  171. this.cartransmission=item.id
  172. this.UsedCarList('',this.carbrand,this.cartransmission,this.carcolor,this.cardisplacement,this.caremission,this.carseat,this.caroil_type,this.carprice,this.carmileage,this.caryear)
  173. },
  174. // 公里
  175. ClickmileageList(item,index){
  176. this.mileageListIndex=index
  177. this.carmileage=item.id
  178. this.UsedCarList('',this.carbrand,this.cartransmission,this.carcolor,this.cardisplacement,this.caremission,this.carseat,this.caroil_type,this.carprice,this.carmileage,this.caryear)
  179. },
  180. Clickdisplacement(item,index){
  181. this.displacementIndex=index
  182. this.cardisplacement=item.id
  183. this.UsedCarList('',this.carbrand,this.cartransmission,this.carcolor,this.cardisplacement,this.caremission,this.carseat,this.caroil_type,this.carprice,this.carmileage,this.caryear)
  184. },
  185. ClickemissionStandard(item,index){
  186. this.emissionStandardIndex=index
  187. this.caremission=item.id
  188. this.UsedCarList('',this.carbrand,this.cartransmission,this.carcolor,this.cardisplacement,this.caremission,this.carseat,this.caroil_type,this.carprice,this.carmileage,this.caryear)
  189. },
  190. ClickVehicleColor(item,index){
  191. this.VehicleColorIndex=index
  192. this.carcolor=item.id
  193. this.UsedCarList('',this.carbrand,this.cartransmission,this.carcolor,this.cardisplacement,this.caremission,this.carseat,this.caroil_type,this.carprice,this.carmileage,this.caryear)
  194. },
  195. Clickseats(item,index){
  196. this.seatsIndex=index
  197. this.carseat=item.id
  198. this.UsedCarList('',this.carbrand,this.cartransmission,this.carcolor,this.cardisplacement,this.caremission,this.carseat,this.caroil_type,this.carprice,this.carmileage,this.caryear)
  199. },
  200. ClickcarAge(item,index){
  201. this.carAgeIndex=index
  202. this.caryear=item.id
  203. this.UsedCarList('',this.carbrand,this.cartransmission,this.carcolor,this.cardisplacement,this.caremission,this.carseat,this.caroil_type,this.carprice,this.carmileage,this.caryear)
  204. },
  205. // 搜索跳转
  206. goUserdList(){
  207. uni.redirectTo({
  208. url:'/pages/index/buyCar?userdCar='+encodeURIComponent(JSON.stringify(this.userdCar))
  209. })
  210. },
  211. // 搜索类型
  212. SearchType(){
  213. this.$api.getSearchType(res=>{
  214. if(res.code==0){
  215. this.brand=res.data.brands
  216. this.Transmission=res.data.gearboxs
  217. this.VehicleColor=res.data.colors
  218. this.displacement=res.data.displacements
  219. this.emissionStandard=res.data.emissions
  220. this.seats=res.data.seat_counts
  221. this.fuel=res.data.oil_types
  222. }
  223. })
  224. },
  225. select(item){
  226. this.$set(this.selected, item.id, !this.selected[item.id]) //动态更新视图数据
  227. }
  228. }
  229. }
  230. </script>
  231. <style scoped lang="scss">
  232. .body{
  233. width: 100vw;
  234. height: 100vh;
  235. .content{
  236. width: 100vw;
  237. height: 90vh;
  238. overflow: auto;
  239. .price{
  240. width: 100vw;
  241. overflow: hidden;
  242. .pricecon{
  243. font-size: 0.9rem;
  244. font-weight: 550;
  245. width: 80vw;
  246. margin-top: 2vw;
  247. margin-left: 4vw;
  248. }
  249. ul{
  250. width: 100vw;
  251. display: flex;
  252. flex-wrap: wrap; // 强制换行
  253. li{
  254. width: 28vw;
  255. height: 8vw;
  256. margin-left: 2vw;
  257. margin-right: 2vw;
  258. font-size: 0.75rem;
  259. text-align: center;
  260. margin-top: 2vw;
  261. background-color: #f8f8f8;
  262. border: 1px solid #f8f8f8;
  263. line-height: 8vw;
  264. }
  265. }
  266. }
  267. }
  268. .cssselect{
  269. width: 28vw;
  270. height: 8vw;
  271. margin-left: 2vw;
  272. margin-right: 2vw;
  273. font-size: 0.75rem;
  274. text-align: center;
  275. margin-top: 2vw;
  276. line-height: 8vw;
  277. background-color: #fcacad;
  278. color: red;
  279. border: 1px solid red;
  280. }
  281. .foot{
  282. width: 100vw;
  283. height: 20vw;
  284. border-top: 1px solid lightgray;
  285. position: fixed;
  286. bottom: 0;
  287. display: flex;
  288. background-color: white;
  289. justify-content: space-around;
  290. align-items: center;
  291. }
  292. .button{
  293. width: 65vw;
  294. height: 10vw;
  295. text-align: center;
  296. line-height: 10vw;
  297. background-color: #f83036;
  298. color: white;
  299. border-radius: 5px;
  300. }
  301. }
  302. </style>