details.vue 6.2 KB

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