pay.vue 9.3 KB

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