details.vue 6.1 KB

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