index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708
  1. <template>
  2. <view class="content">
  3. <view class="main">
  4. <scroll-view scroll-y="true" class="scroll-view">
  5. <view class="list-scroll-view">
  6. <view class="top">
  7. <u-swiper :list="info.file" height="300px" keyName="url" @change="e => currentNum = e.current"
  8. :autoplay="false" indicatorStyle="right: 20px" radius="0">
  9. <template #indicator>
  10. <view class="indicator-num">
  11. <text
  12. class="indicator-num__text">{{ currentNum + 1 }}/{{ info.file?.length }}</text>
  13. </view>
  14. </template>
  15. </u-swiper>
  16. </view>
  17. <view class="bottom">
  18. <view class="one">
  19. <view class="left">
  20. <view class="money">
  21. <text>{{info.real_pay||'0'}}</text>
  22. <text>万</text>
  23. </view>
  24. <view class="price">
  25. <text>新车含税价</text>
  26. <text>{{info.price||'0'}}万</text>
  27. </view>
  28. </view>
  29. <view class="right">
  30. <button class="button" size="mini" type="default" open-type="getPhoneNumber"
  31. @getphonenumber="PhoneNumber">聊聊价格</button>
  32. </view>
  33. </view>
  34. <view class="two">
  35. <view class="two_1 textOver">{{info.series||'暂无'}} {{info.year||'暂无'}}款
  36. {{info.style||'暂无'}}
  37. </view>
  38. <view class="two_2">
  39. <view class="other">
  40. <span>{{info.series}}</span>&nbsp;
  41. <u-icon name="arrow-right" size="12"></u-icon>
  42. </view>
  43. <view class="other">
  44. <span>{{info.rank}}·</span>
  45. <span>第{{info.rankNum}}名</span>&nbsp;
  46. <u-icon name="arrow-right" size="12"></u-icon>
  47. </view>
  48. </view>
  49. <view class="two_3">
  50. <view class="left">
  51. <text>分期购车</text>
  52. <text>首付{{info.first_pay}}万开回家</text>
  53. </view>
  54. <view class="right">
  55. <u-icon name="arrow-right" size="16"></u-icon>
  56. </view>
  57. </view>
  58. </view>
  59. <view class="two thr">
  60. <view class="thr_1">
  61. <text>档案</text>
  62. <view class="info">
  63. <view class="list">
  64. <view class="info_1">{{moment(info.f_time).format('YYYY-MM')||'暂无日期'}}</view>
  65. <view class="info_2">上牌时间</view>
  66. </view>
  67. <view class="list">
  68. <view class="info_1">{{info.mileage||'暂无'}}万公里</view>
  69. <view class="info_2">表显里程</view>
  70. </view>
  71. <view class="list">
  72. <view class="info_1">{{getDict(info.emission,'emission')}}</view>
  73. <view class="info_2">排放标准</view>
  74. </view>
  75. <view class="list">
  76. <view class="info_1">{{info.place||'暂无'}}</view>
  77. <view class="info_2">车源地</view>
  78. </view>
  79. <u-icon name="arrow-right" size="16" @tap="toRecord"></u-icon>
  80. </view>
  81. </view>
  82. <view class="thr_1">
  83. <text>参数</text>
  84. <view class="info">
  85. <view class="list">
  86. <view class="info_1">{{getDict(info.displacement,'displacement')}}</view>
  87. <view class="info_2">发动机</view>
  88. </view>
  89. <view class="list">
  90. <view class="info_1">{{info.wheelbase}}</view>
  91. <view class="info_2">轴距</view>
  92. </view>
  93. <view class="list">
  94. <view class="info_1">{{getDict(info.type,'type')}}</view>
  95. <view class="info_2">变速箱</view>
  96. </view>
  97. <view class="list">
  98. <view class="info_1">{{info.oil}}L</view>
  99. <view class="info_2">百公里油耗</view>
  100. </view>
  101. </view>
  102. </view>
  103. </view>
  104. <view class="two four">
  105. <view class="four_1">
  106. <view class="left">
  107. <image class="image"
  108. :src="shop.logo&&shop.logo?.length>0?shop.logo[0].url:'https://cdn.uviewui.com/uview/album/1.jpg'">
  109. </image>
  110. </view>
  111. <view class="right">
  112. <view class="right_1" @tap="toShop">
  113. <text>{{shop.name||'暂无'}}</text>
  114. <u-icon :bold="true" color="#000" name="arrow-right" size="16"></u-icon>
  115. </view>
  116. <view class="right_2">
  117. <text>在售车源: </text>
  118. <text>{{shop.num||0}}辆</text>
  119. </view>
  120. </view>
  121. </view>
  122. <view class="four_2">
  123. <u-button icon="phone" text="咨询卖家车况" size="normal" type="info"
  124. @click="toChat"></u-button>
  125. </view>
  126. </view>
  127. <view class="two five">
  128. <view class="name">实拍</view>
  129. <view class="text">外观漆面</view>
  130. <view class="five_1">
  131. <view class="five_1">
  132. <image class="image"
  133. :src="info.file&&info.file?.length>0?info.file[0].url:'https://cdn.uviewui.com/uview/album/1.jpg'">
  134. </image>
  135. </view>
  136. <view class="five_2">
  137. <image class="image"
  138. :src="info.file&&info.file?.length>1?info.file[1].url:'https://cdn.uviewui.com/uview/album/5.jpg'">
  139. </image>
  140. <image class="image"
  141. :src="info.file&&info.file?.length>2?info.file[2].url:'https://cdn.uviewui.com/uview/album/2.jpg'">
  142. </image>
  143. </view>
  144. </view>
  145. <view class="text">中控内饰</view>
  146. <view class="five_2">
  147. <image class="image"
  148. :src="info.file&&info.file?.length>3?info.file[3].url:'https://cdn.uviewui.com/uview/album/3.jpg'">
  149. </image>
  150. <image class="image"
  151. :src="info.file&&info.file?.length>4?info.file[4].url:'https://cdn.uviewui.com/uview/album/4.jpg'">
  152. </image>
  153. </view>
  154. <view class="five_3">
  155. <u-button text="查看更多图片" size="normal" type="info" @click="toMore"></u-button>
  156. </view>
  157. </view>
  158. <view class="six">
  159. <view class="title">为你推荐</view>
  160. <view class="listL">
  161. <view class="list" v-for="(item, index) in list" :key="index" @tap="toView(item)">
  162. <view class="list_1">
  163. <view class="left">
  164. <image class="image"
  165. :src="item.file&&item.file.length>0?item.file[0].url:''">
  166. </image>
  167. </view>
  168. <view class="right">
  169. <view class="name textOver">{{item.series||'暂无'}} {{item.year||'暂无'}}款
  170. {{item.style||'暂无'}}
  171. </view>
  172. <view class="other">
  173. <text v-if="item.year">{{item.year||'暂无'}}年 | </text>
  174. <text v-if="item.mileage">{{item.mileage||'暂无'}}公里 | </text>
  175. <text v-if="item.place">{{item.place||'暂无'}}</text>
  176. </view>
  177. <view class="money">
  178. <text>{{item.total_money||'0'}}</text>
  179. <text>万</text>
  180. </view>
  181. </view>
  182. </view>
  183. </view>
  184. </view>
  185. </view>
  186. </view>
  187. </view>
  188. </scroll-view>
  189. </view>
  190. <view class="foot">
  191. <view class="foot_1">
  192. <view class="left" @click="toChat">
  193. <u-icon color="#000" name="red-packet" size="20"></u-icon>
  194. <text>分期购车</text>
  195. </view>
  196. <view class="left" @click="toCollect">
  197. <u-icon color="#000" name="heart" size="20"></u-icon>
  198. <text>收藏</text>
  199. </view>
  200. </view>
  201. <view class="foot_2">
  202. <button class="left-btn" @click="toChat">联系卖家</button>
  203. <button class="right-btn" @click="toChat">询底价</button>
  204. </view>
  205. </view>
  206. </view>
  207. </template>
  208. <script setup lang="ts">
  209. import moment from 'moment';
  210. import { getCurrentInstance, computed, ref } from 'vue';
  211. //该依赖已内置不需要单独安装
  212. import { onLoad } from "@dcloudio/uni-app";
  213. // 请求接口
  214. const $api = getCurrentInstance()?.appContext.config.globalProperties.$api;
  215. // openid
  216. const openid = computed(() => {
  217. return uni.getStorageSync('openid');
  218. })
  219. // 基本信息
  220. const config = ref({});
  221. // id
  222. const id = ref('');
  223. // 轮播图
  224. const currentNum = ref(1);
  225. // 详情
  226. const info = ref({});
  227. // 店铺
  228. const shop = ref({});
  229. // 列表
  230. const list = ref([]);
  231. // 字典表
  232. const emissionList = ref([]);
  233. const boxTypeList = ref([]);
  234. const displacementList = ref([]);
  235. onLoad(async (options) => {
  236. id.value = options && options.id
  237. await searchConfig();
  238. await search();
  239. })
  240. // config信息
  241. const searchConfig = async () => {
  242. config.value = uni.getStorageSync('config');
  243. };
  244. // 查询
  245. const search = async () => {
  246. if (id.value) {
  247. const res = await $api(`car/${id.value}`, 'GET', {});
  248. if (res.errcode === 0) {
  249. info.value = res.data
  250. await searchShop(res.data?.shop)
  251. await searchOther();
  252. } else {
  253. uni.showToast({
  254. title: res.errmsg || '',
  255. icon: 'error',
  256. });
  257. }
  258. }
  259. };
  260. // 店铺信息
  261. const searchShop = async (e) => {
  262. if (!e) return
  263. const res = await $api(`shop/${e}`, 'GET', {});
  264. if (res.errcode === 0) {
  265. shop.value = res.data
  266. } else {
  267. uni.showToast({
  268. title: res.errmsg || '',
  269. icon: 'error',
  270. });
  271. }
  272. };
  273. // 查询其他信息
  274. const searchOther = async () => {
  275. const info = {
  276. skip: 0,
  277. limit: 20,
  278. status: '0',
  279. shop: shop.value._id
  280. }
  281. const arr = await $api('car', 'GET', {
  282. ...info,
  283. });
  284. if (arr.errcode === 0) {
  285. list.value = arr.data
  286. shop.value.num = arr.total
  287. } else {
  288. uni.showToast({
  289. title: arr.errmsg || '',
  290. icon: 'error',
  291. });
  292. }
  293. let res;
  294. // 变速箱
  295. res = await $api(`dictData`, 'GET', { code: 'boxType', is_use: '0' });
  296. if (res.errcode === 0) boxTypeList.value = res.data;
  297. // 排放标准
  298. res = await $api(`dictData`, 'GET', { code: 'emission', is_use: '0' });
  299. if (res.errcode === 0) emissionList.value = res.data;
  300. // 排量
  301. res = await $api(`dictData`, 'GET', { code: 'displacement', is_use: '0' });
  302. if (res.errcode === 0) displacementList.value = res.data;
  303. };
  304. // 数据处理
  305. const getDict = (data, model) => {
  306. let list;
  307. switch (model) {
  308. case 'type':
  309. list = boxTypeList.value;
  310. break;
  311. case 'emission':
  312. list = emissionList.value;
  313. break;
  314. case 'displacement':
  315. list = displacementList.value;
  316. break;
  317. default:
  318. break;
  319. }
  320. if (!list) return;
  321. const res = list.find((f) => f.value == data);
  322. return res?.label || '暂无';
  323. };
  324. // 获取手机号
  325. const PhoneNumber = (e) => {
  326. console.log(e);
  327. };
  328. // 档案
  329. const toRecord = () => {
  330. uni.navigateTo({
  331. url: `/pagesHome/record/index?id=${info.value.id || info.value._id}`
  332. })
  333. };
  334. // 查看详情
  335. const toView = (item) => {
  336. uni.navigateTo({
  337. url: `/pagesHome/car/index?id=${item.id || item._id}`
  338. })
  339. };
  340. // 联系卖家
  341. const toChat = (item) => {
  342. uni.makePhoneCall({
  343. phoneNumber: shop.value?.tel,
  344. success: function () {
  345. console.log('拨打电话成功');
  346. },
  347. fail: function () {
  348. console.log('拨打电话失败');
  349. }
  350. });
  351. };
  352. // 店铺详情
  353. const toShop = () => {
  354. uni.navigateTo({
  355. url: `/pagesHome/shop/index?id=${shop.value.id || shop.value._id}&name=${shop.value.name}`
  356. })
  357. };
  358. // 查看更多图片
  359. const toMore = () => {
  360. uni.navigateTo({
  361. url: `/pagesHome/picture/index?id=${info.value.id || info.value._id}`
  362. })
  363. };
  364. // 收藏
  365. const toCollect = () => {
  366. console.log('收藏');
  367. };
  368. </script>
  369. <style lang="scss" scoped>
  370. .content {
  371. display: flex;
  372. flex-direction: column;
  373. width: 100vw;
  374. height: 100vh;
  375. .main {
  376. position: relative;
  377. flex-grow: 1;
  378. .top {
  379. position: relative;
  380. .indicator-num {
  381. padding: 2px 0;
  382. background-color: rgba(0, 0, 0, 0.35);
  383. border-radius: 5px;
  384. width: 35px;
  385. @include flex;
  386. justify-content: center;
  387. &__text {
  388. color: var(--mainColor);
  389. font-size: var(--font12Size);
  390. }
  391. }
  392. }
  393. .bottom {
  394. background-color: #f1f1f1;
  395. .one {
  396. display: flex;
  397. justify-content: space-between;
  398. align-items: center;
  399. padding: 3vw;
  400. background: linear-gradient(to bottom, #FFE4B5, #f1f1f1);
  401. .left {
  402. .money {
  403. color: var(--fF0Color);
  404. font-size: var(--font12Size);
  405. text:first-child {
  406. font-size: var(--font18Size);
  407. }
  408. }
  409. .price {
  410. margin: 1vw 0 0 0;
  411. color: var(--f69Color);
  412. font-size: var(--font12Size);
  413. }
  414. }
  415. .right {
  416. .button {
  417. background-color: var(--fFFColor);
  418. }
  419. }
  420. }
  421. .two {
  422. margin: 2vw 3vw;
  423. padding: 2vw;
  424. background-color: var(--mainColor);
  425. border-radius: 5px;
  426. .two_1 {
  427. font-size: var(--font16Size);
  428. font-weight: bold;
  429. }
  430. .two_2 {
  431. display: flex;
  432. align-items: center;
  433. margin: 2vw 0 0 0;
  434. padding: 2vw 0;
  435. border-bottom: 1px solid var(--f5Color);
  436. .other {
  437. display: flex;
  438. align-items: center;
  439. color: var(--f828Color);
  440. font-size: var(--font12Size);
  441. margin: 0 5px 0 0;
  442. }
  443. }
  444. .two_3 {
  445. display: flex;
  446. align-items: center;
  447. justify-content: space-between;
  448. padding: 2vw 0;
  449. .left {
  450. display: flex;
  451. justify-content: space-between;
  452. align-items: center;
  453. text {
  454. font-size: var(--font14Size);
  455. margin: 0 5px 0 0;
  456. }
  457. text:first-child {
  458. background-color: rgba(255, 127, 80, 0.35);
  459. color: #FF7F50;
  460. padding: 2px 5px;
  461. font-size: var(--font12Size);
  462. }
  463. }
  464. }
  465. }
  466. .thr {
  467. .thr_1 {
  468. display: flex;
  469. .info {
  470. display: flex;
  471. width: 89%;
  472. margin: 0 0 2vw 0;
  473. .list {
  474. font-size: var(--font14Size);
  475. text-align: center;
  476. width: 19vw;
  477. .info_2 {
  478. color: var(--f828Color);
  479. margin: 1vw 0 0 0;
  480. }
  481. }
  482. }
  483. text {
  484. margin: 0 2vw 0 0;
  485. color: var(--f828Color);
  486. font-size: var(--font14Size);
  487. }
  488. }
  489. }
  490. .four {
  491. .four_1 {
  492. display: flex;
  493. align-items: center;
  494. .left {
  495. .image {
  496. width: 120px;
  497. height: 80px;
  498. }
  499. }
  500. .right {
  501. margin: 0 0 0 2vw;
  502. .right_1 {
  503. display: flex;
  504. align-items: center;
  505. font-size: var(--font16Size);
  506. font-weight: bold;
  507. text {
  508. margin: 0 1vw 1vw 0;
  509. }
  510. }
  511. .right_2 {
  512. margin: 2vw 0 0 0;
  513. color: var(--f828Color);
  514. font-size: var(--font14Size);
  515. }
  516. }
  517. }
  518. .four_2 {
  519. margin: 2vw 0 0 0;
  520. }
  521. }
  522. .five {
  523. .name {
  524. font-size: var(--font16Size);
  525. }
  526. .text {
  527. padding: 2vw 0;
  528. color: var(--f69Color);
  529. font-size: var(--font14Size);
  530. }
  531. .five_1 {
  532. border-radius: 5px;
  533. .image {
  534. width: 100%;
  535. height: 230px;
  536. border-radius: 5px;
  537. }
  538. }
  539. .five_2 {
  540. display: flex;
  541. justify-content: space-between;
  542. border-radius: 5px;
  543. .image {
  544. width: 49%;
  545. height: 120px;
  546. border-radius: 5px;
  547. }
  548. }
  549. .five_3 {
  550. margin: 2vw 0 0 0;
  551. }
  552. }
  553. .six {
  554. padding: 0 2vw 2vw 2vw;
  555. .title {
  556. font-size: var(--font16Size);
  557. padding: 0 1vw;
  558. }
  559. .listL {
  560. display: flex;
  561. flex-wrap: wrap;
  562. justify-content: space-between;
  563. .list {
  564. width: 47vw;
  565. margin: 2vw 0 0 0;
  566. border-radius: 5px;
  567. border: 1px solid var(--f5Color);
  568. background-color: var(--mainColor);
  569. .list_1 {
  570. .left {
  571. .image {
  572. width: 100%;
  573. height: 120px;
  574. border-radius: 5px 5px 0 0;
  575. }
  576. }
  577. .right {
  578. display: flex;
  579. flex-direction: column;
  580. justify-content: space-between;
  581. padding: 0 2vw;
  582. .name {
  583. font-size: var(--font14Size);
  584. }
  585. .other {
  586. color: var(--f85Color);
  587. font-size: var(--font12Size);
  588. }
  589. .money {
  590. color: var(--fF0Color);
  591. font-size: var(--font12Size);
  592. margin: 0 0 1vw 0;
  593. text:first-child {
  594. font-size: var(--font18Size);
  595. }
  596. }
  597. }
  598. }
  599. }
  600. }
  601. }
  602. }
  603. }
  604. .foot {
  605. display: flex;
  606. justify-content: space-between;
  607. align-items: center;
  608. height: 8vh;
  609. padding: 2vw 1vw;
  610. .foot_1 {
  611. display: flex;
  612. justify-content: space-between;
  613. width: 25%;
  614. .left {
  615. display: flex;
  616. flex-direction: column;
  617. align-items: center;
  618. font-size: var(--font14Size);
  619. }
  620. }
  621. .foot_2 {
  622. display: flex;
  623. justify-content: space-around;
  624. align-items: center;
  625. width: 73%;
  626. .left-btn {
  627. background-color: var(--fF0Color);
  628. color: var(--mainColor);
  629. font-size: var(--font16Size);
  630. }
  631. .right-btn {
  632. background-color: var(--fFFColor);
  633. color: var(--mainColor);
  634. width: 45vw;
  635. font-size: var(--font16Size);
  636. }
  637. }
  638. }
  639. }
  640. .scroll-view {
  641. position: absolute;
  642. top: 0;
  643. left: 0;
  644. right: 0;
  645. bottom: 0;
  646. .list-scroll-view {
  647. display: flex;
  648. flex-direction: column;
  649. }
  650. }
  651. </style>