index.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766
  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" @tap="toPicture(0,info.file)"
  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" @tap="toPicture(1,info.file)"
  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" @tap="toPicture(2,info.file)"
  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" @tap="toPicture(3,info.file)"
  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" @tap="toPicture(4,info.file)"
  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 toPicture = (index, e) => {
  373. const urls = e.map((item, index) => {
  374. return item.url
  375. })
  376. uni.previewImage({
  377. current: index,
  378. urls
  379. })
  380. }
  381. // 查看更多图片
  382. const toMore = () => {
  383. uni.navigateTo({
  384. url: `/pagesHome/picture/index?id=${info.value.id || info.value._id}&shop=${shop.value._id}`
  385. })
  386. };
  387. // 收藏
  388. const toCollect = () => {
  389. console.log('收藏');
  390. };
  391. </script>
  392. <style lang="scss" scoped>
  393. .content {
  394. display: flex;
  395. flex-direction: column;
  396. width: 100vw;
  397. height: 100vh;
  398. .main {
  399. position: relative;
  400. flex-grow: 1;
  401. .top {
  402. position: relative;
  403. .indicator-num {
  404. padding: 2px 0;
  405. background-color: rgba(0, 0, 0, 0.35);
  406. border-radius: 5px;
  407. width: 35px;
  408. @include flex;
  409. justify-content: center;
  410. &__text {
  411. color: var(--mainColor);
  412. font-size: var(--font12Size);
  413. }
  414. }
  415. }
  416. .bottom {
  417. background-color: #f1f1f1;
  418. .one {
  419. display: flex;
  420. justify-content: space-between;
  421. align-items: center;
  422. padding: 3vw;
  423. background: linear-gradient(to bottom, #FFE4B5, #f1f1f1);
  424. .left {
  425. .money {
  426. color: var(--fF0Color);
  427. font-size: var(--font12Size);
  428. text:first-child {
  429. font-size: var(--font18Size);
  430. }
  431. }
  432. .price {
  433. margin: 1vw 0 0 0;
  434. color: var(--f69Color);
  435. font-size: var(--font12Size);
  436. }
  437. }
  438. .right {
  439. .button {
  440. background-color: var(--fFFColor);
  441. }
  442. }
  443. }
  444. .two {
  445. margin: 2vw 3vw;
  446. padding: 2vw;
  447. background-color: var(--mainColor);
  448. border-radius: 5px;
  449. .two_1 {
  450. font-size: var(--font16Size);
  451. font-weight: bold;
  452. }
  453. .two_2 {
  454. display: flex;
  455. align-items: center;
  456. margin: 2vw 0 0 0;
  457. padding: 2vw 0;
  458. border-bottom: 1px solid var(--f5Color);
  459. .other {
  460. display: flex;
  461. align-items: center;
  462. color: var(--f828Color);
  463. font-size: var(--font12Size);
  464. margin: 0 5px 0 0;
  465. }
  466. }
  467. .two_3 {
  468. display: flex;
  469. align-items: center;
  470. justify-content: space-between;
  471. padding: 2vw 0;
  472. .left {
  473. display: flex;
  474. justify-content: space-between;
  475. align-items: center;
  476. text {
  477. font-size: var(--font14Size);
  478. margin: 0 5px 0 0;
  479. }
  480. text:first-child {
  481. background-color: rgba(255, 127, 80, 0.35);
  482. color: #FF7F50;
  483. padding: 2px 5px;
  484. font-size: var(--font12Size);
  485. }
  486. }
  487. }
  488. }
  489. .thr {
  490. .thr_1 {
  491. display: flex;
  492. .info {
  493. display: flex;
  494. width: 89%;
  495. margin: 0 0 2vw 0;
  496. .list {
  497. font-size: var(--font14Size);
  498. text-align: center;
  499. width: 19vw;
  500. .info_2 {
  501. color: var(--f828Color);
  502. margin: 1vw 0 0 0;
  503. }
  504. }
  505. }
  506. text {
  507. margin: 0 2vw 0 0;
  508. color: var(--f828Color);
  509. font-size: var(--font14Size);
  510. }
  511. }
  512. }
  513. .thr2 {
  514. .thr_1 {
  515. display: flex;
  516. .info {
  517. display: flex;
  518. justify-content: space-around;
  519. width: 89%;
  520. margin: 0 0 2vw 0;
  521. .list {
  522. font-size: var(--font14Size);
  523. text-align: center;
  524. width: 19vw;
  525. .info_1 {
  526. font-weight: bold;
  527. }
  528. .info_2 {
  529. color: var(--f828Color);
  530. margin: 1vw 0 0 0;
  531. }
  532. }
  533. }
  534. text {
  535. width: 8vw;
  536. margin: 0 2vw 0 0;
  537. color: var(--f828Color);
  538. font-size: var(--font14Size);
  539. }
  540. }
  541. }
  542. .four {
  543. .four_1 {
  544. display: flex;
  545. align-items: center;
  546. .left {
  547. .image {
  548. width: 120px;
  549. height: 80px;
  550. }
  551. }
  552. .right {
  553. margin: 0 0 0 2vw;
  554. .right_1 {
  555. display: flex;
  556. align-items: center;
  557. font-size: var(--font16Size);
  558. font-weight: bold;
  559. text {
  560. margin: 0 1vw 1vw 0;
  561. }
  562. }
  563. .right_2 {
  564. margin: 2vw 0 0 0;
  565. color: var(--f828Color);
  566. font-size: var(--font14Size);
  567. }
  568. }
  569. }
  570. .four_2 {
  571. margin: 2vw 0 0 0;
  572. }
  573. }
  574. .five {
  575. .name {
  576. font-size: var(--font16Size);
  577. }
  578. .text {
  579. padding: 2vw 0;
  580. color: var(--f69Color);
  581. font-size: var(--font14Size);
  582. }
  583. .five_1 {
  584. border-radius: 5px;
  585. .image {
  586. width: 100%;
  587. height: 230px;
  588. border-radius: 5px;
  589. }
  590. }
  591. .five_2 {
  592. display: flex;
  593. justify-content: space-between;
  594. border-radius: 5px;
  595. .image {
  596. width: 49%;
  597. height: 120px;
  598. border-radius: 5px;
  599. }
  600. }
  601. .five_3 {
  602. margin: 2vw 0 0 0;
  603. }
  604. }
  605. .six {
  606. padding: 0 2vw 2vw 2vw;
  607. .title {
  608. font-size: var(--font16Size);
  609. padding: 0 1vw;
  610. }
  611. .listL {
  612. display: flex;
  613. flex-wrap: wrap;
  614. justify-content: space-between;
  615. .list {
  616. width: 47vw;
  617. margin: 2vw 0 0 0;
  618. border-radius: 5px;
  619. border: 1px solid var(--f5Color);
  620. background-color: var(--mainColor);
  621. .list_1 {
  622. .left {
  623. .image {
  624. width: 100%;
  625. height: 120px;
  626. border-radius: 5px 5px 0 0;
  627. }
  628. }
  629. .right {
  630. display: flex;
  631. flex-direction: column;
  632. justify-content: space-between;
  633. padding: 0 2vw;
  634. .name {
  635. font-size: var(--font14Size);
  636. }
  637. .other {
  638. color: var(--f85Color);
  639. font-size: var(--font12Size);
  640. }
  641. .money {
  642. color: var(--fF0Color);
  643. font-size: var(--font12Size);
  644. margin: 0 0 1vw 0;
  645. text:first-child {
  646. font-size: var(--font18Size);
  647. }
  648. }
  649. }
  650. }
  651. }
  652. }
  653. }
  654. }
  655. }
  656. .foot {
  657. display: flex;
  658. justify-content: space-between;
  659. align-items: center;
  660. height: 8vh;
  661. padding: 2vw 1vw;
  662. .foot_1 {
  663. display: flex;
  664. justify-content: center;
  665. width: 20%;
  666. .left {
  667. display: flex;
  668. flex-direction: column;
  669. align-items: center;
  670. font-size: var(--font14Size);
  671. }
  672. }
  673. .foot_2 {
  674. display: flex;
  675. justify-content: space-around;
  676. align-items: center;
  677. width: 85%;
  678. .left-btn {
  679. background-color: var(--fF0Color);
  680. color: var(--mainColor);
  681. font-size: var(--font16Size);
  682. }
  683. .right-btn {
  684. background-color: var(--fFFColor);
  685. color: var(--mainColor);
  686. width: 50vw;
  687. font-size: var(--font16Size);
  688. }
  689. }
  690. }
  691. }
  692. .scroll-view {
  693. position: absolute;
  694. top: 0;
  695. left: 0;
  696. right: 0;
  697. bottom: 0;
  698. .list-scroll-view {
  699. display: flex;
  700. flex-direction: column;
  701. }
  702. }
  703. </style>