pay.vue 8.5 KB

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