mulDetail.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439
  1. <template>
  2. <div>
  3. <div class="head">
  4. <img @click="back" src="@/assets/images/back.png" class="arrow_img" />
  5. <span>{{ $t('lang321') }}</span>
  6. </div>
  7. <div class="home_page">
  8. <div class="goods_info flex_col">
  9. <img :src="product.thum" alt="" />
  10. <span class="goods_info_title">{{ product.title }}</span>
  11. <div class="flex jsb">
  12. <div class="flex_col">
  13. <span class="key">APY:</span>
  14. <span class="value_2">{{ Math.round(Number(product.income_reta) * 100 * 100) / 100 || 0 }}</span>
  15. </div>
  16. <div class="flex_col">
  17. <span class="key">{{ $t('lang478') }}:</span>
  18. <span class="value_1">{{ product.day_num || 0 }}</span>
  19. </div>
  20. </div>
  21. </div>
  22. <div class="goods_list">
  23. <div class="goods_list_box">
  24. <!-- <van-checkbox-group v-model="result" ref="checkboxGroup"> -->
  25. <div class="goods_list_box_item flex jsb" v-for="(item, index) in product.product_list" :key="index">
  26. <div class="flex">
  27. <img :src="item.thum" alt="" />
  28. <span class="name">{{ item.name }}</span>
  29. </div>
  30. <div class="flex" @click="chooseProduct(item.id, index)">
  31. <span class="orderSn" v-if="order_no[item.id]">{{ JSON.parse(order_no[item.id]).order_no }}</span>
  32. <span class="tip" v-else>{{ $t('lang331') }}</span>
  33. <!-- <van-checkbox :name="item.id" icon-size="16px" checked-color="#21926F"> </van-checkbox> -->
  34. <div :class="[order_no[item.id] ? 'checkbox checkbox-active' : 'checkbox']">
  35. <van-icon name="success" size="13px" color="#fff" v-if="order_no[item.id]" />
  36. </div>
  37. </div>
  38. </div>
  39. <!-- </van-checkbox-group> -->
  40. </div>
  41. <div class="flex payType">
  42. <span class="key">{{ $t('lang398') }}</span>
  43. <van-radio-group v-model="pay_type" direction="horizontal" icon-size="17px" checked-color="#21926f">
  44. <van-radio name="1" v-if="product.token && Number(product.token) > 0">{{$t('lang174')}}:{{ product.token }}</van-radio>
  45. <van-radio name="2" v-if="product.teac && Number(product.teac) > 0">TeaC:{{ product.teac }}</van-radio>
  46. </van-radio-group>
  47. </div>
  48. <div class="desc" v-html="product.detail"></div>
  49. </div>
  50. <div class="btn_box">
  51. <van-button class="btn" @click="submit">{{ $t('lang325') }}</van-button>
  52. <div class="btn_checkbox flex">
  53. <van-checkbox icon-size="16px" checked-color="#21926f" v-model="readProtocol"> </van-checkbox>
  54. <span style="padding-left: 6px">
  55. {{ $t('lang480') }}<span style="color: #29b286" @click="toPage">《{{ $t('lang481') }}》</span>
  56. </span>
  57. </div>
  58. </div>
  59. <van-popup v-model="showOrders" round closeable>
  60. <div class="orderpopup">
  61. <div class="orderpopup_title">{{ $t('lang334') }}</div>
  62. <van-radio-group v-model="radio" class="orderpopup_list" v-if="orderlist.length > 0">
  63. <div v-for="(item, index) in orderlist" :key="index" class="orderpopup_item flex jsb">
  64. <span :class="[radio == item ? 'radio-active' : '']">
  65. {{ item.order_no }}
  66. </span>
  67. <van-radio :name="JSON.stringify(item)" icon-size="18px" checked-color="#21926f"></van-radio>
  68. </div>
  69. </van-radio-group>
  70. <div class="nodata" v-else>
  71. <span>{{ $t('lang60') }} </span>
  72. </div>
  73. <van-button type="default" class="btn" @click="chooseOrder">{{ $t('lang111') }}</van-button>
  74. </div>
  75. </van-popup>
  76. </div>
  77. <van-overlay :show="show">
  78. <div class="wrapper" @click.stop>
  79. <van-loading type="spinner" class="loading" color="#29b286" />
  80. </div>
  81. </van-overlay>
  82. </div>
  83. </template>
  84. <script>
  85. import { mapState } from 'vuex';
  86. import { homeApi } from '@/api/index';
  87. import { Dialog } from 'vant';
  88. export default {
  89. data() {
  90. return {
  91. showOrders: false,
  92. orderlist: [],
  93. page: 1,
  94. radio: {},
  95. product: {},
  96. order_no: {}, // 存放已选择订单
  97. show: false,
  98. pay_type: -1,
  99. readProtocol: false,
  100. };
  101. },
  102. mounted() {
  103. this.getInfo();
  104. },
  105. methods: {
  106. //返回上一页
  107. back() {
  108. this.$router.back();
  109. },
  110. toPage(){
  111. if (this.$i18n.locale == 'zh-cn') {
  112. this.$router.push({ name: 'protocol' ,query: {id: this.product.announcement_id.zh }});
  113. } else if (this.$i18n.locale == 'en') {
  114. this.$router.push({ name: 'protocol' ,query: {id: this.product.announcement_id.en }});
  115. }
  116. },
  117. getInfo() {
  118. homeApi.pledgeDetail({ id: this.$route.query.id }).then(res => {
  119. if (res.code == 200) {
  120. this.product = res.data;
  121. } else {
  122. this.$toast(res.msg);
  123. }
  124. });
  125. },
  126. holdProductList(product_id) {
  127. homeApi.holdProductList({ product_id }).then(res => {
  128. if (res.code == 200) {
  129. this.orderlist = res.data;
  130. } else {
  131. this.$toast(res.msg);
  132. }
  133. });
  134. },
  135. chooseProduct(id, index) {
  136. console.log(id, index);
  137. // if (this.result.indexOf(id) >= 0) {
  138. // this.order_no[id] = '';
  139. // this.result.splice(this.result.indexOf(id), 1);
  140. // } else {
  141. this.showOrders = true;
  142. this.holdProductList(id);
  143. this.productId = id;
  144. this.radio = this.order_no[this.productId];
  145. console.log(this.radio);
  146. // }
  147. },
  148. chooseOrder() {
  149. if (!this.radio) {
  150. return this.$toast(this.$t('lang330'));
  151. }
  152. this.order_no[this.productId] = this.radio;
  153. this.showOrders = false;
  154. this.productId = '';
  155. console.log('order_no', this.order_no);
  156. console.log('radio', this.radio);
  157. this.radio = {};
  158. },
  159. submit() {
  160. console.log(Object.assign({}, this.order_no));
  161. if (JSON.stringify(this.order_no) == '{}') {
  162. return this.$toast(this.$t('lang330'));
  163. }
  164. let order_id = {};
  165. for (const key in this.order_no) {
  166. const value = JSON.parse(this.order_no[key]);
  167. order_id[key] = value.id;
  168. }
  169. if (this.pay_type == -1) {
  170. return this.$toast(this.$t('lang470'));
  171. }
  172. if (!this.readProtocol) {
  173. return this.$toast(this.$t('lang479'));
  174. }
  175. let _this = this;
  176. Dialog.confirm({
  177. title: _this.$t('lang136'),
  178. message: _this.$t('lang327'),
  179. confirmButtonText: _this.$t('lang111'),
  180. cancelButtonText: _this.$t('lang135'),
  181. })
  182. .then(() => {
  183. _this.show = true
  184. let params = { pledge_id: _this.$route.query.id, pay_type: _this.pay_type, order_id: order_id };
  185. homeApi.createPledge(params).then(res => {
  186. if (res.code == 200) {
  187. _this.show = false
  188. _this.$toast(_this.$t('lang326'));
  189. _this.$router.push({ name: 'storing' });
  190. } else {
  191. _this.show = false
  192. _this.$toast(res.msg);
  193. }
  194. });
  195. })
  196. .catch(() => {
  197. // on cancel
  198. });
  199. },
  200. },
  201. computed: {
  202. ...mapState(['account']),
  203. },
  204. };
  205. </script>
  206. <style lang="less" scoped>
  207. .head {
  208. position: fixed;
  209. top: 0;
  210. left: 0;
  211. width: 100%;
  212. display: flex;
  213. align-items: center;
  214. justify-content: center;
  215. color: rgba(#000, 0.8);
  216. letter-spacing: 1.5px;
  217. font-weight: 550;
  218. background: #fff;
  219. padding: 14px 0;
  220. z-index: 99;
  221. .arrow_img {
  222. position: absolute;
  223. left: 20px;
  224. width: 10px;
  225. height: 16px;
  226. // transform: translate(0, -50%);
  227. }
  228. }
  229. .home_page {
  230. min-height: 100vh;
  231. padding: 60px 16px 110px;
  232. .jsb {
  233. justify-content: space-between;
  234. }
  235. .goods_info {
  236. padding: 16px;
  237. border-radius: 10px;
  238. background-color: #fff;
  239. img {
  240. width: 100%;
  241. border-radius: 10px;
  242. }
  243. &_title {
  244. font-size: 16px;
  245. font-weight: 600;
  246. color: #000;
  247. letter-spacing: 1px;
  248. padding: 13px 0 10px;
  249. }
  250. .value_1 {
  251. color: #29b286;
  252. font-size: 18px;
  253. font-weight: 600;
  254. }
  255. .value_1::after {
  256. content: 'TeaC';
  257. font-size: 13px;
  258. font-weight: normal;
  259. }
  260. .value_2::after {
  261. content: '%';
  262. font-size: 13px;
  263. font-weight: normal;
  264. }
  265. .value_2 {
  266. color: #ed5111;
  267. font-size: 18px;
  268. font-weight: 600;
  269. // padding-right: 50px;
  270. }
  271. .key {
  272. color: #4b4b4b;
  273. font-size: 12px;
  274. padding-top: 10px;
  275. }
  276. }
  277. .goods_list {
  278. color: #000;
  279. padding: 16px;
  280. border-radius: 10px;
  281. margin-top: 16px;
  282. background-color: #fff;
  283. &_box {
  284. padding-bottom: 8px;
  285. &_item {
  286. padding-bottom: 8px;
  287. img {
  288. width: 45px;
  289. height: 45px;
  290. border-radius: 50%;
  291. }
  292. .name {
  293. font-size: 14px;
  294. width: 90px;
  295. margin-left: 6px;
  296. white-space: nowrap;
  297. overflow: hidden;
  298. text-overflow: ellipsis;
  299. }
  300. .tip {
  301. color: #b9b9b9;
  302. font-size: 12px;
  303. padding-right: 6px;
  304. }
  305. .orderSn {
  306. color: #000;
  307. font-size: 12px;
  308. padding-right: 6px;
  309. }
  310. .checkbox {
  311. width: 16px;
  312. height: 16px;
  313. border-radius: 50%;
  314. border: 0.0625rem solid #c8c9cc;
  315. }
  316. .checkbox-active {
  317. display: flex;
  318. align-items: center;
  319. justify-content: center;
  320. background-color: #21926f;
  321. }
  322. }
  323. }
  324. .desc {
  325. font-size: 14px;
  326. line-height: 160%;
  327. letter-spacing: 1px;
  328. padding-top: 16px;
  329. }
  330. }
  331. .btn_box {
  332. text-align: center;
  333. position: fixed;
  334. bottom: 0;
  335. left: 0;
  336. right: 0;
  337. padding: 16px 20px;
  338. background-color: #fff;
  339. .btn {
  340. width: 100%;
  341. color: #fff;
  342. letter-spacing: 2px;
  343. border-radius: 20px;
  344. margin-bottom: 10px;
  345. background-color: #29b286;
  346. }
  347. .btn_checkbox {
  348. color: #000;
  349. font-size: 12px;
  350. justify-content: center;
  351. }
  352. }
  353. .nodata {
  354. font-size: 13px;
  355. padding: 60px;
  356. color: #4b4b4b;
  357. text-align: center;
  358. }
  359. .orderpopup {
  360. width: 300px;
  361. height: fit-content;
  362. color: #000;
  363. padding: 16px 30px 0;
  364. &_title {
  365. text-align: center;
  366. }
  367. &_list {
  368. min-height: 100px;
  369. max-height: 160px;
  370. margin: 28px 0 10px;
  371. overflow: auto;
  372. }
  373. &_item {
  374. color: #9b9b9b;
  375. font-size: 15px;
  376. padding-bottom: 10px;
  377. .radio-active {
  378. color: #000;
  379. }
  380. }
  381. .btn {
  382. width: 100%;
  383. color: #21926f;
  384. letter-spacing: 2px;
  385. border: 0;
  386. border-top: 1px solid rgba(#cccccc, 0.8);
  387. border-radius: 0;
  388. background-color: #fff;
  389. }
  390. }
  391. .payType {
  392. .key {
  393. color: #4b4b4b;
  394. font-size: 12px;
  395. flex: 1;
  396. white-space: nowrap;
  397. }
  398. ::v-deep .van-radio__label {
  399. color: #21926f;
  400. font-size: 13px;
  401. margin-left: 4px;
  402. }
  403. }
  404. }
  405. .flex {
  406. display: flex;
  407. align-items: center;
  408. }
  409. .flex_col {
  410. display: flex;
  411. flex-direction: column;
  412. }
  413. .flex_end {
  414. align-items: flex-end;
  415. }
  416. ::v-deep .van-popup__close-icon {
  417. color: #575757;
  418. }
  419. .wrapper {
  420. // display: flex;
  421. // justify-content: center;
  422. .loading {
  423. position: absolute;
  424. left: 46%;
  425. top: 46%;
  426. }
  427. }
  428. </style>