pay.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393
  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="flex list-item">
  31. <view class="item-name">电费</view>
  32. <view class="item-tpl">{{list.elect_fee|keept}}元/天</view>
  33. </view>
  34. <!-- <view class="tpl" v-if="list.stand_money > 0">需完成应质押的FIL后,才能开始进入50天封装期</view> -->
  35. <view class="num-box flex">
  36. <view class="num-title">购买数量({{ list.step * 1 }}T)</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. <!-- 交易密码 -->
  48. <!-- <view class="flex money-box">
  49. <view class="money-name">交易密码</view>
  50. <view class="money-num"><input class="input-box" type="password" v-model="password" placeholder="请输入交易密码" /></view>
  51. </view> -->
  52. <view class="pay-box">支付方式:{{ list._cost_money_type }}</view>
  53. <!-- <view class="list-title">IPFS独享算力包-1T</view> -->
  54. <!-- <view class="tips">说明:</view>
  55. <view class="explain"><rich-text :nodes="list.detail"></rich-text></view> -->
  56. <view class="check_box flex_item">
  57. <view><radio style="transform: scale(0.75)" @click="Getcheckbox" color="#6786FB" :checked="checked" /></view>
  58. <view class="">
  59. 请阅读并同意
  60. <text @click="ToIndex">《矿机租赁协议》</text>
  61. </view>
  62. </view>
  63. <view class="submit-box">
  64. <view class="submit" @click="pay()">{{ type == 3 ? '立即质押' : '立即购买' }}</view>
  65. </view>
  66. </view>
  67. <!-- 交易密码框 -->
  68. <view class="curtain" :class="{'ishiden':isHiden}" @touchmove.stop.prevent="moveHandle">
  69. <view class="psw-wrapper">
  70. <view class="psw-title">请输入支付密码</view>
  71. <input type="password" v-model="password" class="psw-ipt"/>
  72. <view class="psw-btn">
  73. <text @click="cancel">取消</text>
  74. <text class="psw-qd" @click="pswQd">确定</text>
  75. </view>
  76. </view>
  77. </view>
  78. </view>
  79. </template>
  80. <script>
  81. import { miningDateils, buyMining } from '@/api/calculation.js';
  82. import uniNumberBox from '@/components/uni-number-box.vue';
  83. export default {
  84. components: {
  85. uniNumberBox
  86. },
  87. data() {
  88. return {
  89. id: '',
  90. type: '',
  91. num: 1,
  92. step: 0,
  93. password: '',
  94. price: '',
  95. list: {
  96. },
  97. checked: false,
  98. isHiden: true
  99. };
  100. },
  101. filters: {
  102. Keept(value) {
  103. if(!value) {
  104. return '0.00'
  105. }
  106. value = Math.round(value* 100)/100;
  107. return value
  108. }
  109. },
  110. onLoad(option) {
  111. // this.list = JSON.parse(option.list)
  112. // console.log(this.list)
  113. this.id = option.id;
  114. this.type = option.type;
  115. this.loadData();
  116. },
  117. computed: {
  118. money() {
  119. return this.num * this.price *this.step ;
  120. }
  121. },
  122. onShow() {},
  123. methods: {
  124. async loadData() {
  125. let obj = this;
  126. miningDateils({}, obj.id).then(({ data }) => {
  127. obj.list = data;
  128. // obj.money = obj.list.cost_money;
  129. obj.price = obj.list.cost_money;
  130. obj.step = obj.list.step;
  131. });
  132. },
  133. //阅读并同意
  134. Getcheckbox() {
  135. let obj = this;
  136. obj.checked = !obj.checked;
  137. },
  138. ToIndex() {
  139. uni.navigateTo({
  140. url: '/pages/finance/xieyi'
  141. });
  142. },
  143. pay() {
  144. let obj = this;
  145. // if (obj.password == '') {
  146. // obj.$api.msg('请输入交易密码!');
  147. // return;
  148. // }
  149. if (obj.checked == false) {
  150. obj.$api.msg('请阅读并同意协议!');
  151. return;
  152. }
  153. //弹出输入交易密码
  154. this.isHiden = false
  155. // buyMining(
  156. // {
  157. // num: obj.num * obj.step,
  158. // trade_psw: obj.password
  159. // },
  160. // obj.id
  161. // )
  162. // .then(data => {
  163. // obj.$api.msg(data.msg);
  164. // obj.password = '';
  165. // obj.num = 1;
  166. // })
  167. // .catch(e => {
  168. // obj.password = '';
  169. // obj.num = 1;
  170. // if (e.msg == '交易密码错误') {
  171. // return;
  172. // }
  173. // console.log(e);
  174. // var reg = new RegExp('购买矿机所需的');
  175. // if (e.msg.match(reg) == -1) {
  176. // } else {
  177. // setTimeout(function() {
  178. // uni.navigateTo({
  179. // url: '/pages/finance/recharge'
  180. // });
  181. // }, 1000);
  182. // }
  183. // });
  184. },
  185. numberChange(data) {
  186. let obj = this;
  187. obj.num = data.number;
  188. },
  189. cancel() {
  190. this.password = ''
  191. this.isHiden = true
  192. },
  193. pswQd() {
  194. let obj = this;
  195. if( obj.password === '' ) {
  196. obj.$api.msg('请输入交易密码!');
  197. return
  198. }
  199. obj.isHiden = true
  200. buyMining(
  201. {
  202. num: obj.num * obj.step,
  203. trade_psw: obj.password
  204. },
  205. obj.id
  206. )
  207. .then(data => {
  208. obj.$api.msg(data.msg);
  209. obj.password = '';
  210. obj.num = 1;
  211. setTimeout(function() {
  212. uni.navigateTo({
  213. url: '/pages/calculation/myCalculation'
  214. });
  215. }, 1500);
  216. })
  217. .catch(e => {
  218. obj.password = '';
  219. obj.num = 1;
  220. if (e.msg == '交易密码错误') {
  221. return;
  222. }
  223. console.log(e);
  224. var reg = new RegExp('购买矿机所需的');
  225. if (e.msg.match(reg) == -1) {
  226. } else {
  227. setTimeout(function() {
  228. uni.navigateTo({
  229. url: '/pages/finance/recharge'
  230. });
  231. }, 1500);
  232. }
  233. });
  234. },
  235. moveHandle() {}
  236. }
  237. };
  238. </script>
  239. <style lang="scss" scoped>
  240. page {
  241. min-height: 100%;
  242. background-color: #ffffff;
  243. .container {
  244. width: 100%;
  245. }
  246. }
  247. .list-box {
  248. background-color: #5771df;
  249. width: 100%;
  250. height: 200rpx;
  251. }
  252. .list {
  253. margin: 0rpx 31rpx;
  254. padding: 45rpx 35rpx;
  255. background-color: #ffffff;
  256. border-radius: 15rpx;
  257. position: relative;
  258. top: -100rpx;
  259. .list-title {
  260. font-size: 34rpx;
  261. font-weight: 500;
  262. color: #333333;
  263. padding-bottom: 35rpx;
  264. }
  265. .list-item {
  266. font-size: 24rpx;
  267. font-weight: 500;
  268. color: #666666;
  269. padding-bottom: 35rpx;
  270. .item-tpl {
  271. font-size: 24rpx;
  272. font-weight: bold;
  273. color: #333333;
  274. }
  275. .tpls {
  276. color: #faba38;
  277. }
  278. }
  279. .tpl {
  280. font-size: 26rpx;
  281. font-weight: 500;
  282. color: #faba38;
  283. padding-bottom: 98rpx;
  284. }
  285. .num-box {
  286. font-size: 30rpx;
  287. font-weight: 500;
  288. color: #333333;
  289. padding-bottom: 83rpx;
  290. }
  291. .money-box {
  292. font-size: 32rpx;
  293. font-weight: 500;
  294. color: #333333;
  295. padding-bottom: 102rpx;
  296. .money-num {
  297. font-weight: bold;
  298. .input-box {
  299. text-align: right;
  300. }
  301. }
  302. }
  303. .pay-box {
  304. font-size: 32rpx;
  305. font-weight: 500;
  306. color: #333333;
  307. padding-bottom: 60rpx;
  308. }
  309. .tips {
  310. font-size: 26rpx;
  311. font-weight: 500;
  312. color: #5771df;
  313. padding-bottom: 25rpx;
  314. }
  315. .explain {
  316. word-wrap: break-word;
  317. font-size: 26rpx;
  318. font-weight: 500;
  319. color: #666666;
  320. line-height: 38rpx;
  321. }
  322. }
  323. .submit-box {
  324. .submit {
  325. background-color: #5771df;
  326. color: #ffffff;
  327. text-align: center;
  328. padding: 25rpx 0rpx;
  329. border-radius: 50rpx;
  330. }
  331. }
  332. .check_box {
  333. padding: 25rpx 25rpx;
  334. font-size: 28rpx;
  335. padding-bottom: 60rpx;
  336. text {
  337. color: #6786fb;
  338. }
  339. }
  340. .curtain {
  341. position: fixed;
  342. width: 100%;
  343. height: 100%;
  344. top: 0;
  345. background-color: rgba($color: #000000, $alpha: 0.2);
  346. .psw-wrapper {
  347. position: fixed;
  348. top: 50%;
  349. left: 50%;
  350. transform: translate(-50%,-100%);
  351. width: 548.6rpx;
  352. height: 344.4rpx;
  353. background-color: #FFFFFF;
  354. border-radius: 15rpx 15rpx;
  355. .psw-title {
  356. width: 100%;
  357. font-size: 35rpx;
  358. padding: 43rpx 0 49rpx;
  359. text-align: center;
  360. font-weight: 800;
  361. }
  362. .psw-ipt {
  363. display: block;
  364. background-color: #dce3ed;
  365. height: 90rpx;
  366. width: 464rpx;
  367. padding-left: 30rpx;
  368. margin: 0 auto;
  369. font-size: 80rpx;
  370. }
  371. .psw-btn text{
  372. display: inline-block;
  373. text-align: center;
  374. width: 50%;
  375. padding-top: 29rpx;
  376. font-size: 35rpx;
  377. }
  378. .psw-qd {
  379. color:#5771DF;
  380. }
  381. }
  382. }
  383. .ishiden {
  384. display: none;
  385. }
  386. </style>