index.vue 16 KB

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