index.vue 18 KB

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