buyCar.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533
  1. <template>
  2. <view class="body">
  3. <view class="header">
  4. <view style="margin-right: 6vw;" :class=" index==0? 'xuanzhong' : 'Car'" @click="switchTab(0)">新车</view>
  5. <view :class=" index==1? 'xuanzhong' : 'Car'" @click="switchTab(1)">二手车</view>
  6. </view>
  7. <view class="content">
  8. <!-- 新车 -->
  9. <view class="newCar" v-if="index==0? true : false ">
  10. <view class="search">
  11. <p>
  12. <image style="width: 5vw; height: 5vw; margin-top: 1vw; " src="../../static/search.png"></image>
  13. </p>
  14. <p style="margin-left: 2vw;"> <input style="font-size: 0.75rem; width: 60vw; height: 10vw;"
  15. type="text" name="" v-model="CarName" id="" placeholder="搜索车辆" @blur="searchCar"> </p>
  16. </view>
  17. <!-- 项 -->
  18. <view class="content_up">
  19. <view
  20. style=" width: 100vw; height: 7vw; font-size: 0.9rem; font-weight: 550; padding-left: 8vw; padding-top: 2vw;">
  21. 热门车系
  22. </view>
  23. <view class="content_con">
  24. <view class="model" v-for="(item,index) in NewCarList" :key="index"
  25. @click="newDetial(item)">
  26. <view style="margin-left: 2vw; margin-top: 2vw;">
  27. <image style="width: 15vw; height: 15vw;" :src="item.img.url"></image>
  28. </view>
  29. <view style="margin-top: 5vw; margin-left: 3vw;">
  30. <p
  31. style="width: 40vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.75rem; ">
  32. {{item.name}}
  33. </p>
  34. <p> <span style="font-size: 0.75rem;">指导价:</span> <span
  35. style="font-size: 0.75rem; color: red;">{{Number(item.min_price/10000)}}万起</span>
  36. </p>
  37. </view>
  38. <view
  39. style="width: 20vw; margin-left: 2vw; margin-top: 6vw; height: 8vw; background-color: #fff5f5; color: red; text-align: center; font-size: 0.75rem; line-height: 8vw; border-radius: 4vw;">
  40. <p>{{item.brand_name}} </p>
  41. </view>
  42. </view>
  43. </view>
  44. </view>
  45. </view>
  46. <!-- 二手车 -->
  47. <view class="oldCar" v-if="index==1? true : false ">
  48. <view class="search">
  49. <p>
  50. <image style="width: 5vw; height: 5vw; margin-top: 1vw; " src="../../static/search.png"></image>
  51. </p>
  52. <p style="margin-left: 2vw;"> <input style="font-size: 0.75rem; width: 60vw; height: 10vw;"
  53. type="text" name="" id="" placeholder="搜索车辆"> </p>
  54. </view>
  55. <!-- 买车/卖车 -->
  56. <view style="display: flex; justify-content: space-around; margin-top: 2vw;">
  57. <view style="display: flex;" @click="BuyUsedCar">
  58. <p style="margin-top:2vw;">
  59. <image style="width: 8vw; height: 6vw;" src="../../static/buyCar.png"></image>
  60. </p>
  61. <p style="font-size: 0.9rem; margin-top: 2vw; margin-left: 2vw;">买二手车 </p>
  62. <!-- <u-popup :show="show" mode="top">
  63. <view style="width: 100vw; height: 50vh;">
  64. <text>出淤泥而不染,濯清涟而不妖</text>
  65. </view>
  66. </u-popup> -->
  67. </view>
  68. <view style="display: flex;" @click="sellCar">
  69. <p style="margin-top:2vw;">
  70. <image style="width: 8vw; height: 6vw;" src="../../static/sellCar.png"></image>
  71. </p>
  72. <p style="font-size: 0.9rem; margin-top: 2vw; margin-left: 2vw;">卖二手车</p>
  73. </view>
  74. </view>
  75. <!-- 点击筛选 -->
  76. <view class="screen">
  77. <view style="display: flex;" @click="screen">
  78. <p style="font-size: 0.75rem;">筛选</p>
  79. <p>
  80. <image style="width: 5vw; height: 5vw;" src="../../static/screen.png"></image>
  81. </p>
  82. </view>
  83. <!-- <view style="display: flex;">
  84. <p style="font-size: 0.75rem;" @click="sortList">默认排序</p>
  85. <p v-if="sortHeight<20? true : false ">
  86. <image style="width: 5vw; height: 5vw;" src="../../static/xiangxia.png"></image>
  87. </p>
  88. <view class="sort" :style="{ height:sortHeight +'vw'}">
  89. <view v-if="sortHeight>20? true : false ">
  90. <p style="font-size: 0.95rem; margin-top: 3vw;">默认排序</p>
  91. <p style="font-size: 0.95rem; margin-top: 3vw; ">价格从低到高</p>
  92. <p style="font-size: 0.95rem; margin-top: 3vw; ">价格从高到低</p>
  93. </view>
  94. </view>
  95. </view> -->
  96. <view style="display: flex;">
  97. <p style="font-size: 0.75rem;" @click="brands">品牌</p>
  98. <p v-if="brand>20? true : false ">
  99. <image style="width: 5vw; height: 5vw;" src="../../static/xiangxia.png"></image>
  100. </p>
  101. <view class="caragecss" :style="{ height:brand +'vw'}">
  102. <view style=" width: 98vw;flex-wrap: wrap; display: flex;" v-if="brand>20? true : false ">
  103. <p class="agecss" v-for="(item,index) in brandList " @click="screenCarList(item,1)">
  104. {{item.name}}</p>
  105. </view>
  106. </view>
  107. </view>
  108. <view style="display: flex;">
  109. <p style="font-size: 0.75rem;" @click="carAges">车龄(年)</p>
  110. <p>
  111. <image style="width: 5vw; height: 5vw;" src="../../static/xiangxia.png"></image>
  112. </p>
  113. <view class="caragecss" :style="{ height:carAge +'vw'}">
  114. <view style=" width: 98vw; flex-wrap: wrap; display: flex;" v-if="carAge>20? true : false ">
  115. <p class="agecss" v-for="(item,index) in carAgeList " @click="screenCarList(item,2)">
  116. {{item.name}}</p>
  117. </view>
  118. </view>
  119. </view>
  120. <view style="display: flex;">
  121. <p style="font-size: 0.75rem;" @click="mileages">里程(万公里)</p>
  122. <p v-if="mileage>20? true : false ">
  123. <image style="width: 5vw; height: 5vw;" src="../../static/xiangxia.png"></image>
  124. </p>
  125. <view class="caragecss" :style="{ height:mileage +'vw'}">
  126. <view style=" width: 98vw; flex-wrap: wrap; display: flex;"
  127. v-if="mileage>20? true : false ">
  128. <p class="agecss" v-for="(item,index) in mileageList " @click="screenCarList(item,3)">
  129. {{item.name}}</p>
  130. </view>
  131. </view>
  132. </view>
  133. </view>
  134. <!-- 内容 -->
  135. <view class="usedCar">
  136. <view class="userCarContent">
  137. <view class="model" v-for="(item,index) in userdCar" :key="index"
  138. @click="oldCarDetial(item.id)">
  139. <view style="margin-left: 2vw; margin-top: 2vw;">
  140. <image style="width: 15vw; height: 15vw;" :src="item.picture.url"></image>
  141. </view>
  142. <view style="margin-top: 5vw; margin-left: 3vw;">
  143. <p
  144. style="width: 40vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.75rem; ">
  145. {{item.brand_name}}
  146. </p>
  147. <p> <span style="font-size: 0.75rem;">指导价:</span> <span
  148. style="font-size: 0.75rem; color: red;">{{Number(item.sale_price/10000)}}万起</span>
  149. </p>
  150. </view>
  151. <view
  152. style="width: 20vw; margin-left: 2vw; margin-top: 6vw; height: 8vw; background-color: #fff5f5; color: red; text-align: center; font-size: 0.75rem; line-height: 8vw; border-radius: 4vw;">
  153. <p> {{item.status_text}} </p>
  154. </view>
  155. </view>
  156. </view>
  157. </view>
  158. </view>
  159. </view>
  160. </view>
  161. </template>
  162. <script>
  163. export default {
  164. data() {
  165. return {
  166. show: true,
  167. index: 0,
  168. sortHeight: 0,
  169. brand: 0,
  170. carAge: 0,
  171. mileage: 0,
  172. NewCarList: [],
  173. CarName: '',
  174. userdname: '',
  175. userdCar: [],
  176. brandList: [],
  177. carAgeList: [{
  178. name: '不限',
  179. id: ''
  180. },
  181. {
  182. name: '1年内',
  183. id: '0,1'
  184. },
  185. {
  186. name: '1-3年',
  187. id: '1,3'
  188. },
  189. {
  190. name: '3-5年',
  191. id: '3,5'
  192. },
  193. {
  194. name: '5-8年',
  195. id: '5,8'
  196. },
  197. {
  198. name: '8-10年',
  199. id: '8,10'
  200. },
  201. {
  202. name: '10年以上',
  203. id: '10'
  204. }
  205. ],
  206. mileageList: [{
  207. name: '不限',
  208. id: ''
  209. },
  210. {
  211. name: '1万公里以内',
  212. id: '0,1'
  213. },
  214. {
  215. name: '1-3万公里',
  216. id: '1,3'
  217. },
  218. {
  219. name: '3-6万公里',
  220. id: '3,6'
  221. },
  222. {
  223. name: '6-10万公里',
  224. id: '6,10'
  225. },
  226. {
  227. name: '10-20万公里',
  228. id: '10,20'
  229. },
  230. {
  231. name: '20万公里以上',
  232. id: '20'
  233. }
  234. ],
  235. }
  236. },
  237. onLoad(option) {
  238. if (option.userdCar) {
  239. this.userdCar = JSON.parse(decodeURIComponent(option.userdCar))
  240. this.index = 1
  241. }
  242. this.SearchType()
  243. this.getNewCarList(1, '')
  244. },
  245. methods: {
  246. // 二手车列表
  247. UsedCarList(name, brand, gearbox, color, displacement, emission, seat_count, oil_type, price_range,
  248. mileage__range, years_range) {
  249. this.$api.getUsedCarList(name, brand, gearbox, color, displacement, emission, seat_count, oil_type,
  250. price_range, mileage__range, years_range, res => {
  251. if (res.code == 0) {
  252. this.userdCar = res.data
  253. }
  254. })
  255. },
  256. screenCarList(item, index) {
  257. this.mileage = 0
  258. this.brand = 0,
  259. this.carAge = 0
  260. if (index == 1) {
  261. this.UsedCarList(this.userdname, item.id, '', '', '', '', '', '', '', '', '')
  262. } else if (2) {
  263. this.UsedCarList(this.userdname, '', '', '', '', '', '', '', '', '', item.id)
  264. } else if (3) {
  265. this.UsedCarList(this.userdname, '', '', '', '', '', '', '', '', item.id, '')
  266. }
  267. },
  268. // 搜索类型
  269. SearchType() {
  270. this.$api.getSearchType(res => {
  271. if (res.code == 0) {
  272. this.brandList = res.data.brands
  273. }
  274. })
  275. },
  276. searchCar() {
  277. this.getNewCarList('', this.CarName)
  278. },
  279. getNewCarList(is_hot, name) {
  280. this.$api.getNewCar(is_hot, name, res => {
  281. if (res.code == 0) {
  282. this.NewCarList = res.data
  283. }
  284. })
  285. },
  286. oldCarDetial(id) {
  287. uni.navigateTo({
  288. url: '/pages/index/oldCarDetial?id=' + id
  289. })
  290. },
  291. mileages() {
  292. if (this.mileage > 1) {
  293. this.mileage = 0
  294. } else {
  295. this.mileage = 50
  296. this.sortHeight = 0,
  297. this.brand = 0,
  298. this.carAge = 0
  299. }
  300. },
  301. carAges() {
  302. if (this.carAge > 1) {
  303. this.carAge = 0
  304. } else {
  305. this.carAge = 50
  306. this.mileage = 0
  307. this.sortHeight = 0,
  308. this.brand = 0
  309. }
  310. },
  311. sortList() {
  312. if (this.sortHeight > 1) {
  313. this.sortHeight = 0
  314. } else {
  315. this.sortHeight = 50
  316. this.mileage = 0
  317. this.brand = 0,
  318. this.carAge = 0
  319. }
  320. },
  321. brands() {
  322. if (this.brand > 1) {
  323. this.brand = 0
  324. } else {
  325. this.brand = 80
  326. this.mileage = 0
  327. this.sortHeight = 0,
  328. this.carAge = 0
  329. }
  330. },
  331. switchTab(index) {
  332. this.index = index
  333. if (index == 1) {
  334. this.UsedCarList(this.userdname, '', '', '', '', '', '', '', '', '', '')
  335. }
  336. },
  337. screen() {
  338. uni.navigateTo({
  339. url: '/pages/index/screen'
  340. })
  341. },
  342. sellCar() {
  343. uni.navigateTo({
  344. url: '/pages/index/sellCar'
  345. })
  346. },
  347. BuyUsedCar() {
  348. uni.navigateTo({
  349. url: '/pages/index/buyUsedCar'
  350. })
  351. },
  352. newDetial(item) {
  353. uni.navigateTo({
  354. url: '/pages/index/newCarDetial?DetialInfo=' + encodeURIComponent(JSON.stringify(item))
  355. })
  356. }
  357. }
  358. }
  359. </script>
  360. <style scoped lang="scss">
  361. .body {
  362. width: 100vw;
  363. height: 100vh;
  364. .sort {
  365. z-index: 999;
  366. position: absolute;
  367. width: 100vw;
  368. transition: 0.3s;
  369. height: 20vh;
  370. top: 43vw;
  371. background-color: #f8f8f8;
  372. left: 0;
  373. box-sizing: border-box;
  374. overflow-y: auto;
  375. border-radius: 0px 0px 10px 10px;
  376. }
  377. .caragecss {
  378. z-index: 999;
  379. position: absolute;
  380. width: 100vw;
  381. transition: 0.3s;
  382. height: 20vh;
  383. top: 43vw;
  384. display: flex;
  385. background-color: white;
  386. left: 0;
  387. box-sizing: border-box;
  388. overflow-y: auto;
  389. border-radius: 0px 0px 10px 10px;
  390. width: 100vw;
  391. display: flex;
  392. flex-wrap: wrap; // 强制换行
  393. }
  394. .agecss {
  395. width: 28vw;
  396. height: 8vw;
  397. margin-left: 2vw;
  398. margin-right: 2vw;
  399. font-size: 0.75rem;
  400. text-align: center;
  401. margin-top: 2vw;
  402. background-color: #f8f8f8;
  403. border: 1px solid #f8f8f8;
  404. line-height: 8vw;
  405. }
  406. .header {
  407. display: flex;
  408. width: 100vw;
  409. height: 11vw;
  410. margin-bottom: 1vw;
  411. justify-content: center;
  412. font-size: 0.8rem;
  413. line-height: 10vw;
  414. background-color: white;
  415. .Car {
  416. margin-right: 4vw;
  417. }
  418. .xuanzhong {
  419. text-align: center;
  420. color: red;
  421. height: 10vw;
  422. width: 13vw;
  423. border-bottom: 1px solid red;
  424. }
  425. }
  426. // 内容
  427. .content {
  428. .newCar {
  429. width: 100vw;
  430. height: 93vh;
  431. overflow: hidden;
  432. .search {
  433. box-sizing: border-box;
  434. padding: 0 4vw;
  435. width: 90vw;
  436. margin-left: 5vw;
  437. height: 12vw;
  438. border-radius: 7vw;
  439. background-color: #f8f8f8;
  440. display: flex;
  441. margin-top: 1vw;
  442. align-items: center;
  443. }
  444. }
  445. .content_up {
  446. width: 100vw;
  447. height: 93vh;
  448. .content_con {
  449. width: 100vw;
  450. height: 80vh;
  451. overflow-y: auto;
  452. background-color: white;
  453. padding: 0 4vw 0 4vw;
  454. .model {
  455. width: 90vw;
  456. height: 20vw;
  457. display: flex;
  458. margin-top: 2vw;
  459. background-color: #f8f8f8;
  460. }
  461. }
  462. }
  463. .oldCar {
  464. width: 100vw;
  465. height: 93vh;
  466. overflow: hidden;
  467. .search {
  468. box-sizing: border-box;
  469. padding: 0 4vw;
  470. width: 90vw;
  471. margin-left: 5vw;
  472. height: 12vw;
  473. border-radius: 7vw;
  474. background-color: #f8f8f8;
  475. display: flex;
  476. margin-top: 1vw;
  477. align-items: center;
  478. }
  479. .screen {
  480. width: 100vw;
  481. display: flex;
  482. margin-top: 1vw;
  483. justify-content: space-around;
  484. }
  485. .usedCar {
  486. width: 100vw;
  487. height: 77vh;
  488. .userCarContent {
  489. width: 100vw;
  490. height: 77vh;
  491. overflow-y: auto;
  492. display: flex;
  493. flex-direction: column;
  494. box-sizing: border-box;
  495. padding-left: 5vw;
  496. padding-bottom: 4vw;
  497. background-color: #f8f8f8;
  498. .model {
  499. width: 90vw;
  500. height: 20vw;
  501. display: flex;
  502. margin-top: 2vw;
  503. background-color: white;
  504. }
  505. }
  506. }
  507. }
  508. }
  509. }
  510. </style>