details.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. <template>
  2. <view class="container">
  3. <view class="list-box"></view>
  4. <view class="list">
  5. <view class="list-title">{{ list.name }}</view>
  6. <view class="flex list-item">
  7. <view class="item-name">价格</view>
  8. <view class="item-tpl">{{ list.cost_money * 1 }}{{ list._cost_money_type }}</view>
  9. </view>
  10. <view class="flex list-item" v-if="list.stand_money > 0">
  11. <view class="item-name">质押FIL数量(用户自行支付)</view>
  12. <view class="item-tpl">{{ list.stand_money * 1 }}</view>
  13. </view>
  14. <view class="flex list-item">
  15. <view class="item-name">托管运维费</view>
  16. <view class="item-tpl">{{ list.service_ratio }}%</view>
  17. </view>
  18. <view class="flex list-item">
  19. <view class="item-name">上架期</view>
  20. <view class="item-tpl">{{ list.stand_time }}天</view>
  21. </view>
  22. <!-- <view class="flex list-item">
  23. <view class="item-name">封装期</view>
  24. <view class="item-tpl">{{list.first_step_time}}</view>
  25. </view> -->
  26. <view class="flex list-item">
  27. <view class="item-name">合约期</view>
  28. <view class="item-tpl">{{ list.first_step_time + list.second_step_time + list.third_step_time }}天</view>
  29. </view>
  30. <!-- <view class="tpl" v-if="list.stand_money > 0">需完成应质押的FIL后,才能开始进入50天封装期</view> -->
  31. <view class="num-box flex">
  32. <view class="num-title">购买数量(1T)</view>
  33. <uni-number-box class="step" :value="num" :disabled="false" @eventChange="numberChange"></uni-number-box>
  34. </view>
  35. <view class="flex money-box">
  36. <view class="money-name">金额</view>
  37. <view class="money-num">{{ money * 1 }}{{ list._cost_money_type }}</view>
  38. </view>
  39. <view class="flex money-box">
  40. <view class="money-name">交易密码</view>
  41. <view class="money-num"><input class="input-box" type="password" v-model="password" placeholder="请输入交易密码" /></view>
  42. </view>
  43. <view class="pay-box">支付方式:{{ list._cost_money_type }}</view>
  44. <!-- <view class="list-title">IPFS独享算力包-1T</view> -->
  45. <view class="tips">说明:</view>
  46. <view class="explain"><rich-text :nodes="list.detail"></rich-text></view>
  47. <view class="check_box flex_item">
  48. <view><radio style="transform: scale(0.75)" @click="Getcheckbox" color="#6786FB" :checked="checked" /></view>
  49. <view class="">
  50. 请阅读并同意
  51. <text @click="ToIndex">《矿机租赁协议》</text>
  52. </view>
  53. </view>
  54. <view class="submit-box">
  55. <view class="submit" @click="pay()">{{ type == 3 ? '立即质押' : '立即购买' }}</view>
  56. </view>
  57. </view>
  58. </view>
  59. </template>
  60. <script>
  61. import { miningDateils, buyMining } from '@/api/calculation.js';
  62. import uniNumberBox from '@/components/uni-number-box.vue';
  63. export default {
  64. components: {
  65. uniNumberBox
  66. },
  67. data() {
  68. return {
  69. id: '',
  70. type: '',
  71. num: 1,
  72. password: '',
  73. money: '',
  74. price: '',
  75. list: {
  76. },
  77. checked: false
  78. };
  79. },
  80. onLoad(option) {
  81. this.id = option.id;
  82. this.type = option.type;
  83. this.loadData();
  84. },
  85. watch: {
  86. num(newVal, oldVal) {
  87. this.money = this.num * this.price;
  88. }
  89. },
  90. onShow() {},
  91. methods: {
  92. async loadData() {
  93. let obj = this;
  94. miningDateils({}, obj.id).then(({ data }) => {
  95. obj.list = data;
  96. obj.money = obj.list.cost_money;
  97. obj.price = obj.list.cost_money;
  98. });
  99. },
  100. //阅读并同意
  101. Getcheckbox() {
  102. let obj = this;
  103. obj.checked = !obj.checked;
  104. },
  105. ToIndex() {
  106. uni.navigateTo({
  107. url: '/pages/finance/xieyi'
  108. });
  109. },
  110. pay() {
  111. let obj = this;
  112. if (obj.password == '') {
  113. obj.$api.msg('请输入交易密码!');
  114. return;
  115. }
  116. if (obj.checked == false) {
  117. obj.$api.msg('请阅读并同意协议!');
  118. return;
  119. }
  120. buyMining(
  121. {
  122. num: obj.num,
  123. trade_psw: obj.password
  124. },
  125. obj.id
  126. )
  127. .then(data => {
  128. obj.$api.msg(data.msg);
  129. obj.password = '';
  130. obj.num = 1;
  131. })
  132. .catch(e => {
  133. obj.password = '';
  134. obj.num = 1;
  135. if (e.msg == '交易密码错误') {
  136. return;
  137. }
  138. console.log(e);
  139. var reg = new RegExp('购买矿机所需的');
  140. if (e.msg.match(reg) == -1) {
  141. } else {
  142. setTimeout(function() {
  143. uni.navigateTo({
  144. url: '/pages/finance/recharge'
  145. });
  146. }, 1000);
  147. }
  148. });
  149. },
  150. numberChange(data) {
  151. let obj = this;
  152. obj.num = data.number;
  153. }
  154. }
  155. };
  156. </script>
  157. <style lang="scss" scoped>
  158. page {
  159. min-height: 100%;
  160. background-color: #ffffff;
  161. .container {
  162. width: 100%;
  163. }
  164. }
  165. .list-box {
  166. background-color: #5771df;
  167. width: 100%;
  168. height: 200rpx;
  169. }
  170. .list {
  171. margin: 0rpx 31rpx;
  172. padding: 45rpx 35rpx;
  173. background-color: #ffffff;
  174. border-radius: 15rpx;
  175. position: relative;
  176. top: -100rpx;
  177. .list-title {
  178. font-size: 34rpx;
  179. font-weight: 500;
  180. color: #333333;
  181. padding-bottom: 35rpx;
  182. }
  183. .list-item {
  184. font-size: 24rpx;
  185. font-weight: 500;
  186. color: #666666;
  187. padding-bottom: 35rpx;
  188. .item-tpl {
  189. font-size: 24rpx;
  190. font-weight: bold;
  191. color: #333333;
  192. }
  193. .tpls {
  194. color: #faba38;
  195. }
  196. }
  197. .tpl {
  198. font-size: 26rpx;
  199. font-weight: 500;
  200. color: #faba38;
  201. padding-bottom: 98rpx;
  202. }
  203. .num-box {
  204. font-size: 30rpx;
  205. font-weight: 500;
  206. color: #333333;
  207. padding-bottom: 83rpx;
  208. }
  209. .money-box {
  210. font-size: 32rpx;
  211. font-weight: 500;
  212. color: #333333;
  213. padding-bottom: 102rpx;
  214. .money-num {
  215. font-weight: bold;
  216. .input-box {
  217. text-align: right;
  218. }
  219. }
  220. }
  221. .pay-box {
  222. font-size: 24rpx;
  223. font-weight: 500;
  224. color: #333333;
  225. padding-bottom: 60rpx;
  226. }
  227. .tips {
  228. font-size: 26rpx;
  229. font-weight: 500;
  230. color: #5771df;
  231. padding-bottom: 25rpx;
  232. }
  233. .explain {
  234. word-wrap: break-word;
  235. font-size: 26rpx;
  236. font-weight: 500;
  237. color: #666666;
  238. line-height: 38rpx;
  239. }
  240. }
  241. .submit-box {
  242. .submit {
  243. background-color: #5771df;
  244. color: #ffffff;
  245. text-align: center;
  246. padding: 25rpx 0rpx;
  247. border-radius: 50rpx;
  248. }
  249. }
  250. .check_box {
  251. padding: 25rpx 25rpx;
  252. font-size: 28rpx;
  253. padding-bottom: 60rpx;
  254. text {
  255. color: #6786fb;
  256. }
  257. }
  258. </style>