pay.vue 9.0 KB

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