index.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758
  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', {
  300. ...info,
  301. });
  302. if (arr.errcode === 0) {
  303. list.value = arr.data
  304. shop.value.num = arr.total
  305. } else {
  306. uni.showToast({
  307. title: arr.errmsg || '',
  308. icon: 'error',
  309. });
  310. }
  311. let res;
  312. // 变速箱
  313. res = await $api(`dictData`, 'GET', { code: 'boxType', is_use: '0' });
  314. if (res.errcode === 0) boxTypeList.value = res.data;
  315. // 排放标准
  316. res = await $api(`dictData`, 'GET', { code: 'emission', is_use: '0' });
  317. if (res.errcode === 0) emissionList.value = res.data;
  318. };
  319. // 数据处理
  320. const getDict = (data, model) => {
  321. let list;
  322. switch (model) {
  323. case 'type':
  324. list = boxTypeList.value;
  325. break;
  326. case 'emission':
  327. list = emissionList.value;
  328. break;
  329. default:
  330. break;
  331. }
  332. if (!list) return;
  333. const res = list.find((f) => f.value == data);
  334. return res?.label || '暂无';
  335. };
  336. // 获取手机号
  337. const PhoneNumber = (e) => {
  338. console.log(e);
  339. };
  340. // 档案
  341. const toRecord = () => {
  342. uni.navigateTo({
  343. url: `/pagesHome/record/index?id=${info.value.id || info.value._id}`
  344. })
  345. };
  346. // 查看详情
  347. const toView = (item) => {
  348. uni.navigateTo({
  349. url: `/pagesHome/car/index?id=${item.id || item._id}`
  350. })
  351. };
  352. // 联系卖家
  353. const toChat = (item) => {
  354. uni.makePhoneCall({
  355. phoneNumber: shop.value?.tel,
  356. success: function () {
  357. console.log('拨打电话成功');
  358. },
  359. fail: function () {
  360. uni.showToast({
  361. title: '拨打电话失败',
  362. icon: 'error',
  363. });
  364. }
  365. });
  366. };
  367. // 店铺详情
  368. const toShop = () => {
  369. uni.navigateTo({
  370. url: `/pagesHome/shop/index?id=${shop.value.id || shop.value._id}&name=${shop.value.name}`
  371. })
  372. };
  373. // 查看更多图片
  374. const toMore = () => {
  375. uni.navigateTo({
  376. url: `/pagesHome/picture/index?id=${info.value.id || info.value._id}&shop=${shop.value._id}`
  377. })
  378. };
  379. // 收藏
  380. const toCollect = () => {
  381. console.log('收藏');
  382. };
  383. </script>
  384. <style lang="scss" scoped>
  385. .content {
  386. display: flex;
  387. flex-direction: column;
  388. width: 100vw;
  389. height: 100vh;
  390. .main {
  391. position: relative;
  392. flex-grow: 1;
  393. .top {
  394. position: relative;
  395. .indicator-num {
  396. padding: 2px 0;
  397. background-color: rgba(0, 0, 0, 0.35);
  398. border-radius: 5px;
  399. width: 35px;
  400. @include flex;
  401. justify-content: center;
  402. &__text {
  403. color: var(--mainColor);
  404. font-size: var(--font12Size);
  405. }
  406. }
  407. }
  408. .bottom {
  409. background-color: #f1f1f1;
  410. .one {
  411. display: flex;
  412. justify-content: space-between;
  413. align-items: center;
  414. padding: 3vw;
  415. background: linear-gradient(to bottom, #FFE4B5, #f1f1f1);
  416. .left {
  417. .money {
  418. color: var(--fF0Color);
  419. font-size: var(--font12Size);
  420. text:first-child {
  421. font-size: var(--font18Size);
  422. }
  423. }
  424. .price {
  425. margin: 1vw 0 0 0;
  426. color: var(--f69Color);
  427. font-size: var(--font12Size);
  428. }
  429. }
  430. .right {
  431. .button {
  432. background-color: var(--fFFColor);
  433. }
  434. }
  435. }
  436. .two {
  437. margin: 2vw 3vw;
  438. padding: 2vw;
  439. background-color: var(--mainColor);
  440. border-radius: 5px;
  441. .two_1 {
  442. font-size: var(--font16Size);
  443. font-weight: bold;
  444. }
  445. .two_2 {
  446. display: flex;
  447. align-items: center;
  448. margin: 2vw 0 0 0;
  449. padding: 2vw 0;
  450. border-bottom: 1px solid var(--f5Color);
  451. .other {
  452. display: flex;
  453. align-items: center;
  454. color: var(--f828Color);
  455. font-size: var(--font12Size);
  456. margin: 0 5px 0 0;
  457. }
  458. }
  459. .two_3 {
  460. display: flex;
  461. align-items: center;
  462. justify-content: space-between;
  463. padding: 2vw 0;
  464. .left {
  465. display: flex;
  466. justify-content: space-between;
  467. align-items: center;
  468. text {
  469. font-size: var(--font14Size);
  470. margin: 0 5px 0 0;
  471. }
  472. text:first-child {
  473. background-color: rgba(255, 127, 80, 0.35);
  474. color: #FF7F50;
  475. padding: 2px 5px;
  476. font-size: var(--font12Size);
  477. }
  478. }
  479. }
  480. }
  481. .thr {
  482. .thr_1 {
  483. display: flex;
  484. .info {
  485. display: flex;
  486. width: 89%;
  487. margin: 0 0 2vw 0;
  488. .list {
  489. font-size: var(--font14Size);
  490. text-align: center;
  491. width: 19vw;
  492. .info_2 {
  493. color: var(--f828Color);
  494. margin: 1vw 0 0 0;
  495. }
  496. }
  497. }
  498. text {
  499. margin: 0 2vw 0 0;
  500. color: var(--f828Color);
  501. font-size: var(--font14Size);
  502. }
  503. }
  504. }
  505. .thr2 {
  506. .thr_1 {
  507. display: flex;
  508. .info {
  509. display: flex;
  510. justify-content: space-around;
  511. width: 89%;
  512. margin: 0 0 2vw 0;
  513. .list {
  514. font-size: var(--font14Size);
  515. text-align: center;
  516. width: 19vw;
  517. .info_1 {
  518. font-weight: bold;
  519. }
  520. .info_2 {
  521. color: var(--f828Color);
  522. margin: 1vw 0 0 0;
  523. }
  524. }
  525. }
  526. text {
  527. width: 8vw;
  528. margin: 0 2vw 0 0;
  529. color: var(--f828Color);
  530. font-size: var(--font14Size);
  531. }
  532. }
  533. }
  534. .four {
  535. .four_1 {
  536. display: flex;
  537. align-items: center;
  538. .left {
  539. .image {
  540. width: 120px;
  541. height: 80px;
  542. }
  543. }
  544. .right {
  545. margin: 0 0 0 2vw;
  546. .right_1 {
  547. display: flex;
  548. align-items: center;
  549. font-size: var(--font16Size);
  550. font-weight: bold;
  551. text {
  552. margin: 0 1vw 1vw 0;
  553. }
  554. }
  555. .right_2 {
  556. margin: 2vw 0 0 0;
  557. color: var(--f828Color);
  558. font-size: var(--font14Size);
  559. }
  560. }
  561. }
  562. .four_2 {
  563. margin: 2vw 0 0 0;
  564. }
  565. }
  566. .five {
  567. .name {
  568. font-size: var(--font16Size);
  569. }
  570. .text {
  571. padding: 2vw 0;
  572. color: var(--f69Color);
  573. font-size: var(--font14Size);
  574. }
  575. .five_1 {
  576. border-radius: 5px;
  577. .image {
  578. width: 100%;
  579. height: 230px;
  580. border-radius: 5px;
  581. }
  582. }
  583. .five_2 {
  584. display: flex;
  585. justify-content: space-between;
  586. border-radius: 5px;
  587. .image {
  588. width: 49%;
  589. height: 120px;
  590. border-radius: 5px;
  591. }
  592. }
  593. .five_3 {
  594. margin: 2vw 0 0 0;
  595. }
  596. }
  597. .six {
  598. padding: 0 2vw 2vw 2vw;
  599. .title {
  600. font-size: var(--font16Size);
  601. padding: 0 1vw;
  602. }
  603. .listL {
  604. display: flex;
  605. flex-wrap: wrap;
  606. justify-content: space-between;
  607. .list {
  608. width: 47vw;
  609. margin: 2vw 0 0 0;
  610. border-radius: 5px;
  611. border: 1px solid var(--f5Color);
  612. background-color: var(--mainColor);
  613. .list_1 {
  614. .left {
  615. .image {
  616. width: 100%;
  617. height: 120px;
  618. border-radius: 5px 5px 0 0;
  619. }
  620. }
  621. .right {
  622. display: flex;
  623. flex-direction: column;
  624. justify-content: space-between;
  625. padding: 0 2vw;
  626. .name {
  627. font-size: var(--font14Size);
  628. }
  629. .other {
  630. color: var(--f85Color);
  631. font-size: var(--font12Size);
  632. }
  633. .money {
  634. color: var(--fF0Color);
  635. font-size: var(--font12Size);
  636. margin: 0 0 1vw 0;
  637. text:first-child {
  638. font-size: var(--font18Size);
  639. }
  640. }
  641. }
  642. }
  643. }
  644. }
  645. }
  646. }
  647. }
  648. .foot {
  649. display: flex;
  650. justify-content: space-between;
  651. align-items: center;
  652. height: 8vh;
  653. padding: 2vw 1vw;
  654. .foot_1 {
  655. display: flex;
  656. justify-content: space-between;
  657. width: 25%;
  658. .left {
  659. display: flex;
  660. flex-direction: column;
  661. align-items: center;
  662. font-size: var(--font14Size);
  663. }
  664. }
  665. .foot_2 {
  666. display: flex;
  667. justify-content: space-around;
  668. align-items: center;
  669. width: 73%;
  670. .left-btn {
  671. background-color: var(--fF0Color);
  672. color: var(--mainColor);
  673. font-size: var(--font16Size);
  674. }
  675. .right-btn {
  676. background-color: var(--fFFColor);
  677. color: var(--mainColor);
  678. width: 45vw;
  679. font-size: var(--font16Size);
  680. }
  681. }
  682. }
  683. }
  684. .scroll-view {
  685. position: absolute;
  686. top: 0;
  687. left: 0;
  688. right: 0;
  689. bottom: 0;
  690. .list-scroll-view {
  691. display: flex;
  692. flex-direction: column;
  693. }
  694. }
  695. </style>