detail.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727
  1. <template>
  2. <div class="product-detail-page">
  3. <!-- 顶部返回按钮 -->
  4. <!-- <van-nav-bar title="NFTCHA-全球首个NFT茶交易平台" left-arrow @click-left="goBack" /> -->
  5. <div class="back" @click="goBack">
  6. <van-icon name="arrow-left" size="22" />
  7. </div>
  8. <!-- 商品图片轮播 -->
  9. <van-swipe class="product-swiper" autoplay="3000" indicator-color="#fff">
  10. <van-swipe-item class="swipe-item" v-for="(image, index) in product.info.img_url" :key="index">
  11. <!-- <img :src="image" alt="商品图片" /> -->
  12. <van-image class="product-image" style="width: 100%; height: 100%" radius="0" :src="image" />
  13. </van-swipe-item>
  14. </van-swipe>
  15. <!-- 商品信息 -->
  16. <div class="product-info">
  17. <div class="product-price-stock">
  18. <div class="left">
  19. <div class="price">
  20. <span>{{ product.info.price }}</span>
  21. <span class="small">{{ $t('lang174') }}</span>
  22. <span class="small">{{ product.info.cost_price }}{{ $t('lang174') }}</span>
  23. </div>
  24. <div class="tags">
  25. <van-tag class="tag" type="info">{{ $t('lang53') }}</van-tag>
  26. <span>{{ product.info.num }}{{ $t('lang52') }}</span>
  27. </div>
  28. </div>
  29. <div class="countdown" v-if="product.info.end_time - product.info.start_time > 0">
  30. <div class="flex">
  31. <img src="@/assets/images/trade/clock.png" alt="" class="clock" />
  32. <span style="white-space: nowrap">{{ $t('lang54') }}</span>
  33. </div>
  34. <van-count-down class="count" :time="product.info.end_time - product.info.start_time">
  35. <template #default="timeData">
  36. <span class="block">{{ timeData.hours }}</span>
  37. <span class="colon">{{ $t('lang9') }}</span>
  38. <span class="block">{{ timeData.minutes }}</span>
  39. <span class="colon">{{ $t('lang10') }}</span>
  40. <span class="block">{{ timeData.seconds }}</span>
  41. <span class="colon">{{ $t('lang12') }}</span>
  42. </template>
  43. </van-count-down>
  44. </div>
  45. <div class="countdown end" v-else>{{ $t('lang173') }}</div>
  46. </div>
  47. <div class="goods_info">
  48. <div class="flex jsb">
  49. <span class="title">{{ product.info.name }}</span>
  50. <span class="red">{{ $t('lang55') }}{{ product.info.stock }}{{ $t('lang7') }}</span>
  51. </div>
  52. <div class="tag">{{ $t('lang56') }}</div>
  53. </div>
  54. </div>
  55. <!-- 期数 -->
  56. <div class="issue">
  57. <div v-for="(item, index) in product.times" :key="index" :class="[item.status == 1 ? 'item current' : 'item']">
  58. <div class="flex jsb">
  59. <span>{{ item.title }}</span>
  60. <span> {{ item.start_time_text.split(' ')[0] }}~{{ item.end_time_text.split(' ')[0] }} </span>
  61. <span class="red">
  62. {{ item.price }}<span class="ssm">{{ $t('lang174') }}</span>
  63. </span>
  64. <span class="tag">{{ statusFn(item.status) }}</span>
  65. </div>
  66. <van-icon name="ellipsis" size="15" color="#aaaaaa" class="ellipsis-icon" />
  67. </div>
  68. </div>
  69. <!-- tag -->
  70. <div class="zp flex jsb">
  71. <div class="flex">
  72. <img src="@/assets/images/trade/safe.png" alt="" class="safe" />
  73. <span class="t"> {{ $t('lang57') }} </span>
  74. </div>
  75. <div>
  76. <span> {{ $t('lang58') }} </span>
  77. <van-icon name="arrow" />
  78. </div>
  79. </div>
  80. <!-- 购买记录 -->
  81. <div class="purchase-record">
  82. <div class="section-title">{{ $t('lang59') }}</div>
  83. <!-- <van-cell-group>
  84. <van-cell v-for="(record, index) in purchaseRecords" :key="index" :title="maskAddress(record.address)" :label="record.timeAgo" icon="user-o" />
  85. </van-cell-group> -->
  86. <div class="list">
  87. <div class="item flex jsb" v-for="(item, index) in product.order" :key="index">
  88. <div class="flex">
  89. <!-- <img :src="item.avatar" alt="" class="avatar" /> -->
  90. <div class="avatar"></div>
  91. <span>{{ item.address.slice(0, 6) + '****' + item.address.slice(item.address.length - 6, item.address.length) }}</span>
  92. </div>
  93. <div>
  94. <span>{{ formatTimeDifference(item.create_time * 1000) }}</span>
  95. </div>
  96. </div>
  97. <div class="more" v-if="product.order.length == 0">{{ $t('lang60') }}</div>
  98. <!-- <div class="more" v-else>{{ $t('lang61') }}</div> -->
  99. </div>
  100. </div>
  101. <!-- 商品详情 -->
  102. <div class="product-details">
  103. <div class="section-title">{{ $t('lang62') }}</div>
  104. <!-- <div class="box flex jsb">
  105. <div class="item">
  106. <span class="key">{{ $t('lang63') }}</span>
  107. <span class="val ellipsis">{{ product.info.name }}</span>
  108. </div>
  109. <div class="item">
  110. <span class="key">净含量:</span>
  111. <span class="val">100g</span>
  112. </div>
  113. <div class="item">
  114. <span class="key">所属系列:</span>
  115. <span class="val">春夏秋冬系列</span>
  116. </div>
  117. <div class="item">
  118. <span class="key">茶叶产地:</span>
  119. <span class="val">云南贵州</span>
  120. </div>
  121. </div> -->
  122. </div>
  123. <!-- 宣传图片 -->
  124. <!-- <img v-for="(item, index) in product.info.img_url" :key="index" :src="item" class="promo-image" alt="" /> -->
  125. <div v-html="product.info.details" class="promo-image"></div>
  126. <!-- 底部导航栏 -->
  127. <div class="bottom">
  128. <div class="flex">
  129. <div class="flex flex-c">
  130. <img src="@/assets/images/trade/custom.png" alt="" class="icon" />
  131. <span>{{ $t('lang67') }}</span>
  132. </div>
  133. <div class="flex flex-c" @click="toPage('invite')">
  134. <img src="@/assets/images/trade/share.png" alt="" class="icon" />
  135. <span>{{ $t('lang68') }}</span>
  136. </div>
  137. </div>
  138. <div class="buy" @click="cascaderShow = true">
  139. <van-button class="buy_btn" type="primary">{{ $t('lang27') }}</van-button>
  140. </div>
  141. </div>
  142. <van-popup v-model="cascaderShow" round position="bottom">
  143. <!-- <van-cascader v-model="cascaderValue" title="请选择所在地区" :options="options" @close="cascaderShow = false" @finish="onFinish" /> -->
  144. <div class="area">
  145. <div class="title">{{ $t('lang69') }}</div>
  146. <van-field v-model="search" :placeholder="$t('lang70')" class="input" right-icon="search" @click-right-icon="handleSearch" />
  147. <!-- <van-list v-model="loading" :finished="finished" finished-text="没有更多了" @load="onLoad" class="vanlist">
  148. <van-cell class="item" v-for="item in arealist" :key="item.id" :title="item.address" />
  149. </van-list> -->
  150. <van-radio-group v-model="areaId" @change="handleChoose" v-if="arealist.length > 0">
  151. <van-cell-group class="vanlist" @scroll="handleScroll">
  152. <van-cell class="item" v-for="item in arealist" :key="item.id" :title="item.address" clickable>
  153. <template #right-icon>
  154. <van-radio :name="item.id" icon-size="16px" checked-color="#29b286" />
  155. </template>
  156. </van-cell>
  157. </van-cell-group>
  158. </van-radio-group>
  159. <div class="nomore" v-else>
  160. <span>{{ $t('lang60') }}</span>
  161. </div>
  162. <div class="submit" @click="cascaderShow = true">
  163. <van-button class="submit_btn" type="primary" @click="submit">{{ $t('lang71') }}</van-button>
  164. </div>
  165. </div>
  166. </van-popup>
  167. <van-popup v-model="loading" round class="loading-popup">
  168. <div class="loading">
  169. <van-loading type="spinner" />
  170. </div>
  171. </van-popup>
  172. </div>
  173. </template>
  174. <script>
  175. import { homeApi } from '@/api/index';
  176. import { Dialog, Notify, Toast } from 'vant';
  177. export default {
  178. data() {
  179. return {
  180. product: {
  181. info: {},
  182. order: [],
  183. times: [],
  184. },
  185. time: 30 * 60 * 60 * 1000,
  186. cascaderShow: false,
  187. cascaderValue: '',
  188. currentIssue: 0,
  189. // 选项列表,children 代表子选项,支持多级嵌套
  190. options: [],
  191. arealist: [],
  192. search: '',
  193. areaId: '',
  194. loading: false,
  195. page: 1,
  196. };
  197. },
  198. mounted() {
  199. this.getPopularInfo(this.$route.query.id);
  200. },
  201. methods: {
  202. statusFn(status) {
  203. let result = '';
  204. switch (status) {
  205. case 0:
  206. result = this.$t('lang72');
  207. break;
  208. case 1:
  209. result = this.$t('lang73');
  210. break;
  211. case 2:
  212. result = this.$t('lang74');
  213. break;
  214. default:
  215. break;
  216. }
  217. return result;
  218. },
  219. formatTimeDifference(time) {
  220. const now = new Date();
  221. const past = new Date(time);
  222. const diff = now - past; // 时间差,单位为毫秒
  223. const seconds = Math.floor(diff / 1000);
  224. const minutes = Math.floor(seconds / 60);
  225. const hours = Math.floor(minutes / 60);
  226. const days = Math.floor(hours / 24);
  227. if (seconds < 60) {
  228. return `${seconds}${this.$t('lang75')}`;
  229. } else if (minutes < 60) {
  230. return `${minutes}${this.$t('lang76')}`;
  231. } else if (hours < 24) {
  232. return `${hours}${this.$t('lang77')}`;
  233. } else {
  234. return `${days}${this.$t('lang78')}`;
  235. }
  236. },
  237. goBack() {
  238. this.$router.back();
  239. },
  240. toPage(name) {
  241. this.$router.push({ name });
  242. },
  243. getPopularInfo(id) {
  244. homeApi.getPopularInfo({ ids: id }).then(res => {
  245. if (res.code == 200) {
  246. this.product = res.data;
  247. this.product.info.img_url = res.data.info.img_url.split(',');
  248. this.getProductAddres();
  249. } else {
  250. }
  251. });
  252. },
  253. maskAddress(address) {
  254. return address.replace(/(\w{4})\w*(\w{4})/, '$1****$2');
  255. },
  256. onFinish({ selectedOptions }) {
  257. this.cascaderShow = false;
  258. },
  259. onClose(e) {},
  260. onChange(e) {},
  261. handleScroll(event) {
  262. const container = event.target;
  263. const scrollTop = container.scrollTop; // 滚动距离
  264. const scrollHeight = container.scrollHeight; // 内容总高度
  265. const clientHeight = container.clientHeight; // 可视区域高度
  266. // 判断是否滑动到底部
  267. if (scrollTop + clientHeight >= scrollHeight - 10) {
  268. // console.log('到底了');
  269. if (this.page != -1) {
  270. this.page++; // 页数加 1
  271. this.getProductAddres(); // 触发加载更多
  272. }
  273. }
  274. },
  275. handleSearch() {
  276. this.page = 1; // 重置为 1,表示重新查询
  277. this.arealist = []; // 重置列表
  278. this.getProductAddres();
  279. },
  280. getProductAddres() {
  281. homeApi.getProductAddres({ product_id: this.$route.query.id, search: this.search, page: this.page }).then(res => {
  282. if (res.code == 200) {
  283. if (this.arealist.length >= res.data.total) {
  284. this.page = -1; // 重置为 -1,表示没有更多数据
  285. } else {
  286. this.arealist = [...this.arealist, ...res.data.data];
  287. console.log(this.arealist.length);
  288. if (this.arealist.length >= res.data.total) {
  289. this.page = -1; // 重置为 -1,表示没有更多数据
  290. }
  291. }
  292. } else {
  293. }
  294. });
  295. },
  296. handleChoose(e) {
  297. console.log(e);
  298. this.areaId = e;
  299. },
  300. submit() {
  301. // Dialog.confirm({
  302. // title: '标题',
  303. // message: '弹窗内容',
  304. // })
  305. // .then(() => {
  306. // // on confirm
  307. // })
  308. // .catch(() => {
  309. // // on cancel
  310. // });
  311. if (!this.areaId) {
  312. return Notify({ type: 'warning', message: this.$t('lang69') });
  313. }
  314. this.loading = true;
  315. homeApi.create({ order_id: this.product.info.id, product_id: this.product.info.product_id, area_id: this.areaId }).then(res => {
  316. if (res.code == 200) {
  317. this.loading = false;
  318. this.cascaderShow = false;
  319. this.areaId = '';
  320. Toast({ message: res.msg });
  321. this.$router.push('assets');
  322. } else if (res.code == 15000) {
  323. this.loading = false;
  324. setTimeout(() => {
  325. this.$router.push('recharge');
  326. }, 300);
  327. } else {
  328. this.loading = false;
  329. }
  330. });
  331. },
  332. },
  333. };
  334. </script>
  335. <style lang="less" scoped>
  336. .product-detail-page {
  337. // background-color: #fff;
  338. padding-bottom: 100px;
  339. }
  340. .product-swiper {
  341. height: 250px;
  342. width: 100vw;
  343. }
  344. .product-image {
  345. width: 100%;
  346. height: 100%;
  347. }
  348. .product-info {
  349. .product-price-stock {
  350. display: flex;
  351. justify-content: space-between;
  352. align-items: center;
  353. padding: 6px 14px;
  354. background: linear-gradient(to right, #1ab986, #25d7bb);
  355. .left {
  356. flex: 1;
  357. padding-right: 10px;
  358. .price {
  359. font-size: 22px;
  360. color: #fff;
  361. .small {
  362. color: #e7e7e7;
  363. font-size: 12px;
  364. padding-right: 6px;
  365. }
  366. .small:last-child {
  367. text-decoration: line-through;
  368. }
  369. }
  370. .tags {
  371. display: flex;
  372. align-items: center;
  373. justify-content: space-between;
  374. font-size: 11px;
  375. color: #f8f8f8;
  376. text-align: right;
  377. margin-top: 6px;
  378. .tag {
  379. white-space: nowrap;
  380. color: #1ab986;
  381. font-size: 11px;
  382. border-radius: 4px;
  383. background-color: #fff;
  384. }
  385. }
  386. }
  387. .end {
  388. text-align: center;
  389. line-height: 40px;
  390. }
  391. .countdown {
  392. min-width: 100px;
  393. height: 40px;
  394. font-size: 13px;
  395. border-left: 1px solid #f1f1f1;
  396. padding-left: 10px;
  397. .clock {
  398. width: 20px;
  399. height: 20px;
  400. margin-right: 4px;
  401. }
  402. .count {
  403. margin-top: 6px;
  404. }
  405. .colon {
  406. display: inline-block;
  407. margin: 0 4px;
  408. color: #fff;
  409. font-size: 11px;
  410. }
  411. .block {
  412. display: inline-block;
  413. width: 21px;
  414. color: #1ab986;
  415. font-size: 12px;
  416. text-align: center;
  417. border-radius: 4px;
  418. background-color: #fff;
  419. }
  420. }
  421. }
  422. .goods_info {
  423. padding: 8px 14px;
  424. background-color: #fff;
  425. .title {
  426. font-size: 16px;
  427. font-weight: 550;
  428. color: #3d3d3d;
  429. }
  430. .red {
  431. color: rgb(255, 48, 48);
  432. font-size: 11px;
  433. }
  434. .tag {
  435. color: #0db39a;
  436. font-size: 11px;
  437. padding-top: 8px;
  438. }
  439. }
  440. }
  441. .issue {
  442. color: #aaaaaa;
  443. font-size: 13px;
  444. padding: 16px 14px;
  445. margin: 8px 0;
  446. background-color: #ffffff;
  447. .item {
  448. .ellipsis-icon {
  449. transform: rotate(90deg);
  450. margin-left: 0.8em;
  451. }
  452. }
  453. .ssm {
  454. content: 'USDT';
  455. font-size: 8px;
  456. }
  457. .item:last-child {
  458. .ellipsis-icon {
  459. display: none;
  460. }
  461. }
  462. .tag {
  463. font-size: 12px;
  464. padding: 2px 6px;
  465. border-radius: 4px;
  466. background-color: #fff;
  467. }
  468. .current {
  469. color: #000;
  470. .red {
  471. color: rgb(255, 48, 48);
  472. }
  473. .tag {
  474. color: #29b286;
  475. background-color: #d4f0e7;
  476. }
  477. }
  478. }
  479. .zp {
  480. color: #3d3d3d;
  481. font-size: 12px;
  482. padding: 16px 14px;
  483. margin: 8px 0;
  484. background-color: #ffffff;
  485. white-space: nowrap;
  486. .safe {
  487. width: 22px;
  488. height: 22px;
  489. margin-right: 4px;
  490. }
  491. .t {
  492. font-size: 13px;
  493. white-space: wrap;
  494. }
  495. }
  496. .jsb {
  497. justify-content: space-between;
  498. }
  499. .flex {
  500. display: flex;
  501. align-items: center;
  502. }
  503. .section-title {
  504. font-size: 15px;
  505. font-weight: bold;
  506. margin-bottom: 8px;
  507. }
  508. .purchase-record {
  509. color: #3d3d3d;
  510. padding: 14px;
  511. background-color: #fff;
  512. .list {
  513. .item {
  514. font-size: 12px;
  515. padding-top: 14px;
  516. .avatar {
  517. width: 28px;
  518. height: 28px;
  519. border-radius: 50%;
  520. margin-right: 4px;
  521. background: linear-gradient(to bottom right, #29b286, #30d5a0);
  522. }
  523. }
  524. }
  525. .more {
  526. text-align: center;
  527. font-size: 12px;
  528. color: #aaaaaa;
  529. padding-top: 20px;
  530. }
  531. }
  532. .product-details {
  533. color: #3d3d3d;
  534. font-size: 12px;
  535. padding: 16px 14px;
  536. margin: 8px 0 0;
  537. background-color: #ffffff;
  538. .box {
  539. color: #aaaaaa;
  540. flex-wrap: wrap;
  541. padding: 7px 14px;
  542. border-radius: 10px;
  543. background-color: #ededed;
  544. .item {
  545. display: flex;
  546. align-items: center;
  547. width: 50%;
  548. padding: 7px 0px;
  549. .val {
  550. color: #000;
  551. width: 50%;
  552. // display: block;
  553. }
  554. }
  555. }
  556. }
  557. .ellipsis {
  558. overflow: hidden; /* 确保超出容器的文本被裁剪 */
  559. white-space: nowrap; /* 确保文本在一行内显示 */
  560. text-overflow: ellipsis; /* 使用省略号表示文本超出 */
  561. }
  562. .promo-image {
  563. width: 100%;
  564. img {
  565. width: 100% !important;
  566. }
  567. // margin-top: 14px;
  568. }
  569. .van-tabbar-item {
  570. font-size: 14px;
  571. }
  572. .bottom {
  573. position: fixed;
  574. bottom: 0;
  575. left: 0;
  576. width: 100%;
  577. height: 50px;
  578. background-color: #fff;
  579. display: flex;
  580. justify-content: space-between;
  581. align-items: center;
  582. padding: 0 14px;
  583. box-sizing: border-box;
  584. .flex-c {
  585. color: #3d3d3d;
  586. font-size: 10px;
  587. flex-direction: column;
  588. margin-right: 16px;
  589. .icon {
  590. width: 22px;
  591. height: 22px;
  592. margin-bottom: 3px;
  593. }
  594. }
  595. .buy {
  596. &_btn {
  597. height: 30px;
  598. line-height: 30px;
  599. font-size: 13px;
  600. background-color: #29b286;
  601. border: none;
  602. padding: 0 16px;
  603. white-space: nowrap;
  604. border-radius: 30px;
  605. }
  606. }
  607. }
  608. .back {
  609. position: fixed;
  610. z-index: 99;
  611. top: 14px;
  612. left: 14px;
  613. box-sizing: border-box;
  614. width: 40px;
  615. height: 40px;
  616. margin: auto auto;
  617. display: flex;
  618. align-items: center;
  619. justify-content: center;
  620. border-radius: 50%;
  621. background-color: #7a777b;
  622. }
  623. .area {
  624. padding: 20px 30px;
  625. width: 100%;
  626. box-sizing: border-box;
  627. position: relative;
  628. .title {
  629. color: #000;
  630. font-size: 15px;
  631. text-align: center;
  632. font-weight: bold;
  633. padding: 0 0 14px;
  634. }
  635. .vanlist {
  636. max-height: 350px;
  637. min-height: 350px;
  638. overflow: auto;
  639. box-sizing: border-box;
  640. margin: 20px 0;
  641. border: none !important;
  642. .item {
  643. padding: 12px 0 !important;
  644. border-bottom: 0.5px solid rgba(190, 190, 190, 0.15);
  645. }
  646. }
  647. .nomore {
  648. color: #aaa;
  649. text-align: center;
  650. font-size: 12px;
  651. height: 350px;
  652. padding: 40px 0;
  653. }
  654. .submit {
  655. width: 100%;
  656. // position: fixed;
  657. bottom: 30px;
  658. box-sizing: border-box;
  659. &_btn {
  660. width: 100%;
  661. height: 40px;
  662. line-height: 40px;
  663. font-size: 14px;
  664. background-color: #29b286;
  665. border: none;
  666. white-space: nowrap;
  667. border-radius: 30px;
  668. }
  669. }
  670. .input {
  671. width: 100%;
  672. border: 1px solid #29b286;
  673. border-radius: 20px;
  674. }
  675. ::v-deep .van-field__control {
  676. padding: 6px 12px;
  677. }
  678. ::v-deep .van-icon-search {
  679. font-size: 20px;
  680. color: #29b286;
  681. font-weight: bold;
  682. margin-right: 10px;
  683. }
  684. ::v-deep .van-hairline--top-bottom::after,
  685. ::v-deep.van-hairline-unset--top-bottom::after {
  686. border: none;
  687. }
  688. }
  689. ::v-deep .van-hairline--left::after {
  690. border-left-width: 0.005px !important;
  691. }
  692. ::v-deep .van-cascader__option,
  693. ::v-deep .van-cascader__title {
  694. color: #000;
  695. }
  696. .loading {
  697. padding: 50px 60px;
  698. border: none;
  699. background-color: rgba(#353535, 1);
  700. }
  701. .loading-popup {
  702. background-color: rgba(#353535, 0);
  703. }
  704. </style>