index.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  1. <template>
  2. <view class="layout-main" v-if="detailList.length">
  3. <van-tabs
  4. :ellipsis="false"
  5. :border="false"
  6. :active="tab"
  7. @change="tab = $event.detail.index"
  8. >
  9. <van-tab v-for="(item,index) in detailList" :key="index" class="height-max" :title="item.coin_name"></van-tab>
  10. </van-tabs>
  11. <!-- 申购数据和申购周期 -->
  12. <view class="m-md bg-form-panel-4 rounded p-md fn-center d-flex">
  13. <view class="w-6/12 d-flex align-center">
  14. <van-circle
  15. size="130"
  16. class="w-max"
  17. stroke-width="6"
  18. :value="detailList[tab].status*25"
  19. :color="{ '0%': '#27CAE0', '100%': '#4653EF' }"
  20. >
  21. <view class="color-light fn-center fn-10">
  22. <view class="label m-b-xs color-default">{{ $t("purchase.a0") }}</view>
  23. <view class="fn-11">1 {{ detailList[tab].coin_name }}≈</view>
  24. <view class="fn-11">
  25. <text class="fn-16">{{ detailList[tab].issue_price }}</text>
  26. USDT
  27. </view>
  28. <view class="fn-center fn-15 color-success">
  29. {{ detailList[tab].coin_name }}
  30. </view>
  31. </view>
  32. </van-circle>
  33. </view>
  34. <view>
  35. <view class="m-b-xs">
  36. <view class="label fn-10">{{ $t("purchase.a1") }}</view>
  37. <view class="color-light">{{ detailList[tab].subscribe_currency }}</view>
  38. </view>
  39. <view class="m-b-xs">
  40. <view class="label fn-10">{{ $t("purchase.a2") }}</view>
  41. <view class="color-light">{{$date(detailList[tab].expected_time_online) }}</view>
  42. </view>
  43. <view class="m-b-xs">
  44. <view class="label fn-10">{{ $t("purchase.a3") }}</view>
  45. <view class="color-light">{{$date(detailList[tab].start_subscription_time)}}</view>
  46. </view>
  47. <view class="m-b-xs">
  48. <view class="d-flex justify-center m-b-xs color-sell" style="font-weight: bold;">
  49. {{detailList[tab].buySum}}/{{detailList[tab].count}}
  50. </view>
  51. <van-progress :stroke-width="8" :percentage="getNumber(detailList[tab].buy_rate)" />
  52. </view>
  53. <view class="m-b-xs">
  54. <view class="label fn-10">{{ $t("purchase.a4") }}</view>
  55. <view class="color-light">{{$date(detailList[tab].end_subscription_time)}}</view>
  56. </view>
  57. </view>
  58. </view>
  59. <!-- 申购 -->
  60. <view class="m-md bg-panel-4 rounded p-md box-shadow">
  61. <view class="title p-b-xs border-b d-flex justify-between align-center">
  62. <view>{{ $t("purchase.a5") }}</view>
  63. <!-- <view> -->
  64. <v-link to="/pages/purchase/record">
  65. <van-icon class="fn-20 m-t-xs" name="todo-list-o" />
  66. </v-link>
  67. <!-- </view> -->
  68. </view>
  69. <view class="m-y-md">
  70. <view class="label">{{ $t("purchase.d1") }}</view>
  71. <v-picker
  72. :list="coinList"
  73. v-model="coin"
  74. range-label="coin_name"
  75. range-value="coin_name"
  76. class="border-b p-y-xs color-light"
  77. >
  78. <v-input
  79. disabled
  80. :value="activeCoin.coin_name"
  81. :placeholder="$t('purchase.a6')"
  82. >
  83. <template #right>
  84. <i class="iconfont">&#xe6e9;</i>
  85. </template>
  86. </v-input>
  87. </v-picker>
  88. <view class="tips m-t-xs fn-sm d-flex justify-between color-sell">
  89. <view
  90. >1 {{ activeCoin.coin_name }} ≈
  91. {{ omitTo(activeCoin.proportion_amount, 4) }}
  92. {{ detailList[tab].coin_name }}</view
  93. >
  94. <view class="color-sell"
  95. >{{ num || 0 }} {{ activeCoin.coin_name }} ≈ {{ total||0 }} {{ detailList[tab].coin_name }}</view
  96. >
  97. </view>
  98. </view>
  99. <view class="m-y-md">
  100. <view class="label">{{ $t("add.a3") }}</view>
  101. <view class="border-b p-y-xs color-light">
  102. <v-input type="number" v-model="num" :placeholder="$t('purchase.a8')">
  103. <template #right>
  104. <view
  105. class="color-success"
  106. @click="num = activeCoin.usable_balance * 1 || 0"
  107. >{{ $t("purchase.a9") }}</view
  108. >
  109. </template>
  110. </v-input>
  111. </view>
  112. </view>
  113. <v-button
  114. block
  115. class="w-max rounded-lg"
  116. type="green"
  117. ref="btn"
  118. @click="ifSubscribeNow"
  119. >{{ $t("purchase.b0") }}</v-button
  120. >
  121. </view>
  122. <!-- 周期 -->
  123. <view class="m-md bg-panel-4 rounded p-md box-shadow">
  124. <view class="title p-b-xs border-b">{{ $t("purchase.b1") }}</view>
  125. <van-steps
  126. :active="detailList[tab].status - 1"
  127. :steps="[
  128. {
  129. text: $t('purchase.b2'),
  130. desc: '',
  131. },
  132. {
  133. text: $t('purchase.b3'),
  134. desc: $date(detailList[tab].start_subscription_time)
  135. },
  136. {
  137. text: $t('purchase.b4'),
  138. desc: $date(detailList[tab].end_subscription_time)
  139. },
  140. {
  141. text: $t('purchase.b5'),
  142. desc: $date(detailList[tab].announce_time)
  143. }
  144. ]"
  145. active-color="#79D47C"
  146. align-center
  147. direction="vertical"
  148. >
  149. </van-steps>
  150. </view>
  151. <!-- 项目详情 -->
  152. <view class="m-md bg-panel-4 rounded p-md box-shadow">
  153. <view class="title p-b-xs border-b">{{ $t("purchase.b6") }}</view>
  154. <view class="m-t-md edit-content" style="overflow:auto;max-height:400upx;margin-bottom:70upx;" v-html="detailList[tab].project_details"></view>
  155. </view>
  156. </view>
  157. </template>
  158. <script>
  159. import Subscride from "@/api/subscride";
  160. import date from "@/utils/class/date";
  161. import math from "@/utils/class/math";
  162. export default {
  163. data() {
  164. return {
  165. coinList: [],
  166. detailList: [],
  167. num: "",
  168. coin: "",
  169. tab:0,
  170. };
  171. },
  172. watch:{
  173. tab(){
  174. this.subscribeTokenList()
  175. }
  176. },
  177. computed: {
  178. total() {
  179. if (!this.activeCoin.proportion_amount) return 0;
  180. return math.multiple(
  181. this.num || 0,
  182. this.activeCoin.proportion_amount * 1,
  183. 3
  184. );
  185. },
  186. activeCoin() {
  187. if (!this.coin) return {};
  188. return this.coinList.find((item) => item.coin_name == this.coin);
  189. },
  190. },
  191. methods: {
  192. getNumber(number){
  193. if(!number)return 0
  194. return Number(number).toFixed(0)
  195. },
  196. omitTo(num, idx) {
  197. if (!num) return 0;
  198. return math.omitTo(num, idx);
  199. },
  200. parseTime(num) {
  201. if (!num) return;
  202. return date.parseTime(num);
  203. },
  204. subscribeTokenList() {
  205. Subscride.subscribeTokenList({
  206. currency_type:this.detailList[this.tab].coin_name
  207. }).then((res) => {
  208. this.coinList = res.data;
  209. this.coin = this.coinList[0].coin_name;
  210. });
  211. },
  212. getInfo() {
  213. Subscride.subscribe().then((res) => {
  214. console.log(res.data,'21111')
  215. this.detailList = res.data;
  216. this.subscribeTokenList();
  217. });
  218. },
  219. // 选择币种
  220. selectCoin() {
  221. let arr = this.coinList.map((item) => {
  222. return {
  223. label: item.coin_name,
  224. value: item.coin_name,
  225. };
  226. });
  227. this.$picker(arr, { value: this.coin }).then((res) => {
  228. this.coin = res;
  229. });
  230. },
  231. // 提交询问
  232. ifSubscribeNow() {
  233. if(!this.num){
  234. return this.$toast(this.$t('purchase.d2'))
  235. }
  236. this.$dialog
  237. .confirm({
  238. title: this.$t("common.tips"),
  239. message: `${this.$t("purchase.b7")} ${
  240. this.activeCoin.coin_name
  241. } ${this.$t("purchase.b8")}?`,
  242. cancelButtonText: this.$t('common.cancelButtonText'),
  243. confirmButtonText:this.$t('common.confirmButtonText')
  244. })
  245. .then(() => {
  246. this.subscribeNow();
  247. })
  248. .catch(() => {});
  249. },
  250. // 申购
  251. subscribeNow() {
  252. let data = {
  253. amount: this.num,
  254. coin_name: this.activeCoin.coin_name,
  255. id:this.detailList[this.tab].id
  256. };
  257. Subscride.subscribeNow(data, { btn: this.$refs.btn })
  258. .then((res) => {
  259. if (res) {
  260. this.$toast.success(this.$t("purchase.b9"));
  261. this.num = "";
  262. }
  263. })
  264. .catch(() => {});
  265. },
  266. },
  267. created() {
  268. this.getInfo();
  269. },
  270. };
  271. </script>
  272. <style lang="scss" scoped>
  273. ::v-deep uni-canvas{
  274. width: 130px;
  275. height: 130px;
  276. }
  277. ::v-deep .van-step--finish{
  278. color:$light;
  279. }
  280. ::v-deep .van-step--vertical:first-child::before {
  281. background: transparent;
  282. }
  283. ::v-deep .van-step--vertical {
  284. .van-step__circle-container {
  285. background-color: transparent;
  286. .van-icon-checked {
  287. width: 14px;
  288. height: 14px;
  289. background: rgba($green, 0.7);
  290. font-size: 0;
  291. display: block;
  292. border-radius: 20px;
  293. &::after{
  294. content: '';
  295. display: block;
  296. font-size: 0;
  297. width: 8px;
  298. height: 8px;
  299. position: absolute;
  300. left: 50%;
  301. top: 50%;
  302. transform: translate(-50%,-50%);
  303. background: $green;
  304. border-radius: 20px;
  305. }
  306. }
  307. }
  308. }
  309. </style>