index.vue 16 KB

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