initiatePurchase.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638
  1. <template>
  2. <div class="product-detail-page">
  3. <!-- 顶部返回按钮 -->
  4. <div class="head">
  5. <img @click="back" src="@/assets/images/back.png" class="arrow_img" />
  6. <span>{{ $t('lang349') }}</span>
  7. </div>
  8. <div class="box">
  9. <div class="box_item">
  10. <div class="flex">
  11. <img :src="product.thum" alt="" class="pic" />
  12. <div class="right">
  13. <div class="name_box">
  14. <div class="name">{{ product.name }}</div>
  15. <div class="flex sb reflash">
  16. <span class="flex">
  17. {{ $t('lang383') }}
  18. <svg width="18" height="20" viewBox="16 -8 100 100" xmlns="http://www.w3.org/2000/svg">
  19. <path
  20. d="M70,35
  21. C56,28 38,40 40,54
  22. C40,64 50,74 70,66"
  23. fill="none"
  24. stroke="black"
  25. stroke-width="6"
  26. stroke-linecap="round"
  27. />
  28. <line x1="52" y1="29" x2="52" y2="73" stroke="black" stroke-width="5.2" stroke-linecap="round" />
  29. <line x1="63" y1="29" x2="63" y2="73" stroke="black" stroke-width="5.2" stroke-linecap="round" />
  30. </svg>
  31. <span class="reflash_price">{{ maxPrice }}</span>
  32. </span>
  33. <van-icon name="replay" size="14px" color="#808080" @click="getBuyingMaxPrice(0)" />
  34. </div>
  35. </div>
  36. </div>
  37. </div>
  38. <div class="pt">
  39. <div class="title">{{ $t('lang371') }}</div>
  40. <div class="flex grey">{{ $t('lang384') + configInfo.min_buy_price }}</div>
  41. <div class="flex">
  42. <svg width="43" height="43" viewBox="25 0 100 100" xmlns="http://www.w3.org/2000/svg">
  43. <path
  44. d="M70,35
  45. C56,28 38,40 40,54
  46. C40,64 50,74 70,66"
  47. fill="none"
  48. stroke="black"
  49. stroke-width="6"
  50. stroke-linecap="round"
  51. />
  52. <line x1="52" y1="29" x2="52" y2="73" stroke="black" stroke-width="5.2" stroke-linecap="round" />
  53. <line x1="63" y1="29" x2="63" y2="73" stroke="black" stroke-width="5.2" stroke-linecap="round" />
  54. </svg>
  55. <van-field v-model="qiuPrice" :placeholder="$t('lang385') + configInfo.min_buy_price" type="number" />
  56. </div>
  57. </div>
  58. </div>
  59. <div class="box_item">
  60. <div class="title flex sb">
  61. {{ $t('lang370') }}
  62. <van-stepper v-model="qiuNumber" min="1" :max="maxCount" />
  63. </div>
  64. <div class="flex grey">{{ $t('lang386').replace('XX', maxCount) }}</div>
  65. </div>
  66. <div class="box_item">
  67. <div class="title">{{ $t('lang364') }}</div>
  68. <div class="flex grey">
  69. {{ $t('lang363') + '(' + $t('lang362') }}:
  70. <svg width="12" height="22" viewBox="32 0 50 96" xmlns="http://www.w3.org/2000/svg">
  71. <path
  72. d="M70,35
  73. C56,28 38,40 40,54
  74. C40,64 50,74 70,66"
  75. fill="none"
  76. stroke="black"
  77. stroke-width="6"
  78. stroke-linecap="round"
  79. />
  80. <line x1="52" y1="29" x2="52" y2="73" stroke="black" stroke-width="5.2" stroke-linecap="round" />
  81. <line x1="63" y1="29" x2="63" y2="73" stroke="black" stroke-width="5.2" stroke-linecap="round" />
  82. </svg>
  83. {{ balance }})
  84. </div>
  85. </div>
  86. <div class="box_item">
  87. <div class="title">{{ $t('lang356') }}</div>
  88. <div class="flex">
  89. <van-checkbox v-model="checked" class="black" shape="square" checked-color="#29b286" icon-size="16px"
  90. >{{ $t('lang357') }} <span class="green" @click.stop="blogPopop = true">{{ $t('lang358') }}</span></van-checkbox
  91. >
  92. </div>
  93. </div>
  94. <div class="box_item">
  95. <div class="title">{{ $t('lang359') }}</div>
  96. <div class="flex grey desc" v-html="configInfo.serve_desc"></div>
  97. </div>
  98. </div>
  99. <div class="btn_box flex sb">
  100. <div class="left">
  101. <div class="flex">
  102. <svg width="28" height="28" viewBox="28 -4 100 96" xmlns="http://www.w3.org/2000/svg">
  103. <path
  104. d="M70,35
  105. C56,28 38,40 40,54
  106. C40,64 50,74 70,66"
  107. fill="none"
  108. stroke="black"
  109. stroke-width="6"
  110. stroke-linecap="round"
  111. />
  112. <line x1="52" y1="29" x2="52" y2="73" stroke="black" stroke-width="5.2" stroke-linecap="round" />
  113. <line x1="63" y1="29" x2="63" y2="73" stroke="black" stroke-width="5.2" stroke-linecap="round" />
  114. </svg>
  115. <span class="price"> {{ Math.floor(qiuNumber * qiuPrice * 100) / 100 || '--' }} </span>
  116. </div>
  117. <span class="font">{{ $t('lang387').replace('XX', qiuNumber) }}</span>
  118. </div>
  119. <!-- <div class="btn" style="width: 70%">{{ $t('lang372') }}</div> -->
  120. <van-button class="btn" style="width: 70%" :disabled="!checked" type="primary" @click="submit">{{ $t('lang372') }}</van-button>
  121. </div>
  122. <van-overlay :show="loading">
  123. <div class="wrapper" @click.stop>
  124. <van-loading type="spinner" class="loading" />
  125. </div>
  126. </van-overlay>
  127. <van-popup v-model="blogPopop" round position="bottom">
  128. <div class="blogModel">
  129. <div class="title"></div>
  130. <van-icon name="cross" class="close" size="20" @click="blogPopop = false" />
  131. <div class="body" v-html="blogData.body"></div>
  132. </div>
  133. </van-popup>
  134. </div>
  135. </template>
  136. <script>
  137. import { homeApi } from '@/api/index';
  138. import { Dialog, Notify, Toast } from 'vant';
  139. export default {
  140. data() {
  141. return {
  142. loading: false,
  143. submitPopop: false,
  144. number: 1,
  145. product: {},
  146. type: 0, // 1确认订单 2以求购价售出 3发起求购
  147. checked: false,
  148. qiuNumber: 1,
  149. qiuPrice: '',
  150. configInfo: {
  151. lock_time: 0,
  152. min_buy_price: 0,
  153. serve_desc: '',
  154. serve_fee: 0,
  155. max_buying_count: 0,
  156. zh_serve_agree: '',
  157. en_serve_agree: '',
  158. },
  159. balance: 0,
  160. maxPrice: 0,
  161. maxCount: 0,
  162. blogPopop: false,
  163. blogData: {},
  164. };
  165. },
  166. watch: {
  167. qiuPrice(val) {
  168. if (val) {
  169. this.maxCount = Math.floor(this.balance / val);
  170. }
  171. },
  172. },
  173. mounted() {
  174. this.product = JSON.parse(this.$route.query.product);
  175. this.init();
  176. },
  177. methods: {
  178. init() {
  179. this.getHoldProductOrderList();
  180. this.getMarketConfig();
  181. this.getBuyingMaxPrice(1);
  182. this.getUserInfo();
  183. },
  184. back() {
  185. this.$router.back();
  186. },
  187. getHoldProductOrderList() {
  188. homeApi.getHoldProductOrderList({ product_id: this.product.id }).then(res => {
  189. if (res.code == 200) {
  190. this.orderlist = res.data;
  191. } else {
  192. }
  193. });
  194. },
  195. getMarketConfig() {
  196. homeApi.getMarketConfig({}).then(res => {
  197. if (res.code == 200) {
  198. this.configInfo = res.data;
  199. this.getAnnouncementDetail();
  200. } else {
  201. }
  202. });
  203. },
  204. getBuyingMaxPrice(index) {
  205. homeApi.getBuyingMaxPrice({ product_id: this.product.id }).then(res => {
  206. if (res.code == 200) {
  207. this.maxPrice = res.data;
  208. if (!index) {
  209. this.$toast(this.$t('lang402'));
  210. }
  211. } else {
  212. }
  213. });
  214. },
  215. getUserInfo() {
  216. homeApi.getUserInfo({}).then(res => {
  217. if (res.code == 200) {
  218. this.balance = res.data.balance;
  219. } else {
  220. }
  221. });
  222. },
  223. submit() {
  224. if (!this.qiuPrice) {
  225. return this.$toast(this.$t('lang377'));
  226. }
  227. let _this = this;
  228. let params = {
  229. product_id: this.product.id,
  230. min_price: this.qiuPrice,
  231. stock: this.qiuNumber,
  232. };
  233. Dialog.confirm({
  234. title: _this.$t('lang136'),
  235. message: _this
  236. .$t('lang376')
  237. .replace('XX', Math.floor(_this.qiuNumber * _this.qiuPrice * 100) / 100)
  238. .replace(
  239. 'CC',
  240. `<svg width="12" height="22" viewBox="28 -20 50 96" xmlns="http://www.w3.org/2000/svg">
  241. <path
  242. d="M70,35
  243. C56,28 38,40 40,54
  244. C40,64 50,74 70,66"
  245. fill="none"
  246. stroke="#646566"
  247. stroke-width="6"
  248. stroke-linecap="round"
  249. />
  250. <line x1="52" y1="29" x2="52" y2="73" stroke="#646566" stroke-width="5.2" stroke-linecap="round" />
  251. <line x1="63" y1="29" x2="63" y2="73" stroke="#646566" stroke-width="5.2" stroke-linecap="round" />
  252. </svg>`
  253. ),
  254. confirmButtonText: _this.$t('lang111'),
  255. cancelButtonText: _this.$t('lang135'),
  256. })
  257. .then(() => {
  258. this.loading = true;
  259. homeApi.setBuying(params).then(res => {
  260. if (res.code == 200) {
  261. _this.loading = false;
  262. Toast({ message: _this.$t('lang152') });
  263. _this.$router.back();
  264. } else if (res.code == 15001) {
  265. _this.loading = false;
  266. setTimeout(() => {
  267. _this.$router.push('recharge');
  268. }, 300);
  269. } else {
  270. _this.loading = false;
  271. }
  272. });
  273. })
  274. .catch(() => {
  275. // on cancel
  276. });
  277. },
  278. navigatorTo(name, id) {
  279. if (name == 'service') {
  280. console.log(this.$i18n.locale);
  281. if (this.$i18n.locale == 'zh-cn') {
  282. this.$router.push({ name, query: { id: this.configInfo.zh_serve_agree } });
  283. } else if (this.$i18n.locale == 'en') {
  284. this.$router.push({ name, query: { id: this.configInfo.en_serve_agree } });
  285. }
  286. } else {
  287. this.$router.push({ name, query: { id: id } });
  288. }
  289. },
  290. getAnnouncementDetail() {
  291. if (this.$i18n.locale == 'zh-cn') {
  292. let params = {
  293. id: this.configInfo.zh_serve_agree,
  294. };
  295. homeApi.getAnnouncementDetail(params).then(res => {
  296. if (res.code == 200) {
  297. this.blogData = res.data;
  298. }
  299. });
  300. } else if (this.$i18n.locale == 'en') {
  301. let params = {
  302. id: this.configInfo.en_serve_agree,
  303. };
  304. homeApi.getAnnouncementDetail(params).then(res => {
  305. if (res.code == 200) {
  306. this.blogData = res.data;
  307. }
  308. });
  309. }
  310. },
  311. },
  312. };
  313. </script>
  314. <style lang="less" scoped>
  315. .head {
  316. position: fixed;
  317. top: 0;
  318. left: 0;
  319. width: 100%;
  320. display: flex;
  321. align-items: center;
  322. justify-content: center;
  323. color: rgba(#000, 0.8);
  324. letter-spacing: 1.5px;
  325. font-weight: 550;
  326. background: #fff;
  327. padding: 14px 0;
  328. z-index: 99;
  329. .arrow_img {
  330. position: absolute;
  331. left: 20px;
  332. width: 10px;
  333. height: 16px;
  334. // transform: translate(0, -50%);
  335. }
  336. }
  337. .box {
  338. width: 100%;
  339. // height: 100vh;
  340. color: #000;
  341. font-size: 13px;
  342. padding: 64px 14px 120px;
  343. box-sizing: border-box;
  344. // background-color: #fff;
  345. .grey {
  346. color: #535353;
  347. }
  348. .black {
  349. color: #000;
  350. }
  351. .grey-8 {
  352. color: #535353;
  353. }
  354. &_item {
  355. font-size: 12px;
  356. letter-spacing: 1px;
  357. padding: 10px;
  358. border-radius: 12px;
  359. margin-bottom: 10px;
  360. background-color: #fff;
  361. .pic {
  362. width: 80px;
  363. height: 80px;
  364. border-radius: 8px;
  365. }
  366. .right {
  367. padding-left: 14px;
  368. .name_box {
  369. color: #808080;
  370. font-size: 13px;
  371. .name {
  372. color: #000;
  373. font-size: 16px;
  374. font-weight: 600;
  375. line-height: 160%;
  376. }
  377. }
  378. .qiu {
  379. padding-top: 8px;
  380. &_price {
  381. font-size: 17px;
  382. font-weight: 600;
  383. // margin-left: -2px;
  384. margin-top: -3px;
  385. }
  386. }
  387. }
  388. .title {
  389. font-size: 14px;
  390. font-weight: 600;
  391. line-height: 160%;
  392. padding-bottom: 8px;
  393. }
  394. .price {
  395. font-size: 13px;
  396. font-weight: 600;
  397. margin-left: -2px;
  398. }
  399. .green {
  400. color: #29b286;
  401. }
  402. .van-checkbox {
  403. padding-top: 6px;
  404. }
  405. .desc {
  406. font-size: 11px;
  407. line-height: 150%;
  408. padding-top: 3px;
  409. }
  410. .yuji {
  411. width: 100%;
  412. // padding-top: 8px;
  413. }
  414. .font {
  415. color: #808080;
  416. font-size: 11px;
  417. }
  418. .snlist {
  419. flex-wrap: wrap;
  420. // justify-content: space-around;
  421. justify-content: flex-start;
  422. gap: 10px; /* 横向和纵向间距 */
  423. padding-top: 8px;
  424. &_item {
  425. font-size: 11px;
  426. text-align: center;
  427. padding: 4px 6px;
  428. border-radius: 4px;
  429. // margin: 0 10px 10px 0;
  430. width: calc((100% - 20px) / 3); /* 3列,减去两个gap */
  431. background-color: #f5f5f5;
  432. }
  433. .snlist_item_active {
  434. position: relative;
  435. color: #29b286;
  436. background-color: #cfe9e0;
  437. svg {
  438. position: absolute;
  439. bottom: -6px;
  440. right: -7px;
  441. font-size: 1px;
  442. width: 8px;
  443. z-index: 100;
  444. fill: #fff;
  445. }
  446. }
  447. .snlist_item_active_tag {
  448. bottom: 0px;
  449. right: 0px;
  450. width: 0;
  451. height: 0;
  452. z-index: 9;
  453. position: absolute;
  454. border-width: 8px 8px;
  455. border-color: rgba(0, 0, 0, 0) #29b286 #29b286 rgba(0, 0, 0, 0);
  456. border-style: solid;
  457. border-radius: 4px;
  458. margin: 0;
  459. padding: 0;
  460. box-sizing: border-box;
  461. }
  462. }
  463. .reflash {
  464. font-size: 10px;
  465. color: #000;
  466. width: calc(100vw - 150px);
  467. padding: 6px 8px;
  468. border-radius: 6px;
  469. margin-top: 8px;
  470. background-color: #f5f5f5;
  471. &_price {
  472. font-size: 16px;
  473. font-weight: 600;
  474. margin-left: -6px;
  475. }
  476. }
  477. .pt {
  478. padding-top: 10px;
  479. }
  480. /deep/ .van-checkbox__icon .van-icon {
  481. border-radius: 2px;
  482. border-color: #29b286 !important;
  483. }
  484. /deep/.van-stepper__input {
  485. background-color: #fff;
  486. }
  487. /deep/.van-stepper__plus,
  488. /deep/.van-stepper__minus {
  489. transform: scale(0.9);
  490. border-radius: 50%;
  491. }
  492. /deep/.van-field {
  493. font-size: 18px;
  494. font-weight: 600;
  495. margin-left: -10px;
  496. }
  497. /deep/.van-field__control::placeholder {
  498. font-size: 15px;
  499. font-weight: normal;
  500. }
  501. /deep/.van-field__control::-webkit-input-placeholder {
  502. font-size: 15px;
  503. font-weight: normal;
  504. }
  505. /deep/.van-field__control::-moz-placeholder {
  506. font-size: 15px;
  507. font-weight: normal;
  508. }
  509. /deep/.van-field__control::-ms-input-placeholder {
  510. font-size: 15px;
  511. font-weight: normal;
  512. }
  513. }
  514. }
  515. .flex {
  516. display: flex;
  517. align-items: center;
  518. }
  519. .sb {
  520. justify-content: space-between;
  521. }
  522. .bottom {
  523. padding: 14px 14px;
  524. background-color: #fff;
  525. /deep/.van-tab {
  526. flex: none;
  527. font-weight: 600;
  528. color: #c5c5c5;
  529. font-size: 13px;
  530. letter-spacing: 0.5px;
  531. margin-right: 10px;
  532. }
  533. /deep/.van-tabs__nav--line {
  534. padding-bottom: 10px;
  535. }
  536. }
  537. .warn {
  538. position: fixed;
  539. bottom: 75px;
  540. left: 0;
  541. width: 100%;
  542. text-align: center;
  543. padding: 4px 0;
  544. font-size: 11px;
  545. color: #fc9611;
  546. font-weight: 600;
  547. background-color: #f8efe0;
  548. }
  549. .btn_box {
  550. position: fixed;
  551. bottom: 0;
  552. left: 0;
  553. width: 100%;
  554. height: 68px;
  555. padding: 10px 14px;
  556. border-top: 1px solid rgba(#c7c7c7, 0.3);
  557. background-color: #fff;
  558. .btn {
  559. display: flex;
  560. align-items: center;
  561. flex-direction: column;
  562. justify-content: center;
  563. width: 100%;
  564. height: 100%;
  565. box-sizing: border-box;
  566. color: #fff;
  567. font-size: 15px;
  568. text-align: center;
  569. font-weight: 600;
  570. letter-spacing: 1px;
  571. padding: 12px 10px;
  572. border-radius: 22px;
  573. border: none;
  574. background-color: #29b286;
  575. }
  576. .submit {
  577. width: 58%;
  578. background-color: #17ab79;
  579. }
  580. .left {
  581. color: #000;
  582. font-size: 14px;
  583. flex-direction: column;
  584. .price {
  585. font-size: 18px;
  586. font-weight: 600;
  587. margin-left: -10px;
  588. // margin-top: -3px;
  589. }
  590. .font {
  591. font-size: 12px;
  592. }
  593. }
  594. }
  595. .blogModel {
  596. color: #000;
  597. font-size: 15px;
  598. .close {
  599. position: absolute;
  600. right: 20px;
  601. top: 10px;
  602. }
  603. .title {
  604. padding: 20px 20px 26px;
  605. text-align: center;
  606. }
  607. .body {
  608. max-height: 600px;
  609. overflow: auto;
  610. padding: 0 14px 20px;
  611. }
  612. }
  613. /deep/.van-button--disabled {
  614. opacity: 0.6;
  615. }
  616. .wrapper {
  617. // display: flex;
  618. // justify-content: center;
  619. .loading {
  620. position: absolute;
  621. left: 46%;
  622. top: 46%;
  623. }
  624. }
  625. </style>