pay.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349
  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. console.log();
  135. // if (obj.list.cost_times > obj.list.luck_point - obj.list.exchange_point) {
  136. // obj.$api.msg('所需荣誉值不足!');
  137. // return;
  138. // }
  139. //弹出输入交易密码
  140. this.isHiden = false;
  141. },
  142. numberChange(data) {
  143. let obj = this;
  144. obj.num = data.number;
  145. },
  146. cancel() {
  147. this.password = '';
  148. this.isHiden = true;
  149. },
  150. pswQd() {
  151. let obj = this;
  152. if (obj.password === '') {
  153. obj.$api.msg('请输入交易密码!');
  154. return;
  155. }
  156. obj.isHiden = true;
  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. setTimeout(function() {
  169. uni.navigateTo({
  170. url: '/pages/market/myCalculation'
  171. });
  172. }, 1500);
  173. })
  174. .catch(e => {
  175. obj.password = '';
  176. obj.num = 1;
  177. if (e.msg == '交易密码错误') {
  178. return;
  179. }
  180. console.log(e);
  181. var reg = new RegExp('购买矿机所需的');
  182. if (e.msg.match(reg) == -1) {
  183. } else {
  184. setTimeout(function() {
  185. uni.navigateTo({
  186. url: '/pages/finance/recharge'
  187. });
  188. }, 1500);
  189. }
  190. });
  191. },
  192. moveHandle() {}
  193. }
  194. };
  195. </script>
  196. <style lang="scss" scoped>
  197. page {
  198. min-height: 100%;
  199. background-color: #ffffff;
  200. .container {
  201. width: 100%;
  202. }
  203. }
  204. .list-box {
  205. background: linear-gradient(0deg, #2e58ff, #32c6ff);
  206. width: 100%;
  207. height: 200rpx;
  208. }
  209. .list {
  210. margin: 0rpx 31rpx;
  211. padding: 45rpx 35rpx;
  212. background-color: #ffffff;
  213. border-radius: 15rpx;
  214. position: relative;
  215. top: -100rpx;
  216. .list-title {
  217. font-size: 34rpx;
  218. font-weight: 500;
  219. color: #333333;
  220. padding-bottom: 35rpx;
  221. }
  222. .list-item {
  223. font-size: 24rpx;
  224. font-weight: 500;
  225. color: #666666;
  226. padding-bottom: 35rpx;
  227. .item-tpl {
  228. font-size: 24rpx;
  229. font-weight: bold;
  230. color: #333333;
  231. }
  232. .tpls {
  233. color: #faba38;
  234. }
  235. }
  236. .tpl {
  237. font-size: 26rpx;
  238. font-weight: 500;
  239. color: #faba38;
  240. padding-bottom: 98rpx;
  241. }
  242. .num-box {
  243. font-size: 30rpx;
  244. font-weight: 500;
  245. color: #333333;
  246. padding-bottom: 83rpx;
  247. }
  248. .money-box {
  249. font-size: 32rpx;
  250. font-weight: 500;
  251. color: #333333;
  252. padding-bottom: 102rpx;
  253. .money-num {
  254. font-weight: bold;
  255. .input-box {
  256. text-align: right;
  257. }
  258. }
  259. }
  260. .pay-box {
  261. font-size: 32rpx;
  262. font-weight: 500;
  263. color: #333333;
  264. padding-bottom: 60rpx;
  265. }
  266. .tips {
  267. font-size: 26rpx;
  268. font-weight: 500;
  269. color: #60bab0;
  270. padding-bottom: 25rpx;
  271. }
  272. .explain {
  273. word-wrap: break-word;
  274. font-size: 26rpx;
  275. font-weight: 500;
  276. color: #666666;
  277. line-height: 38rpx;
  278. }
  279. }
  280. .submit-box {
  281. .submit {
  282. background: linear-gradient(0deg, #2e58ff, #32c6ff);
  283. color: #ffffff;
  284. text-align: center;
  285. padding: 25rpx 0rpx;
  286. border-radius: 50rpx;
  287. }
  288. }
  289. .check_box {
  290. padding: 25rpx 25rpx;
  291. font-size: 28rpx;
  292. padding-bottom: 60rpx;
  293. text {
  294. color: #60bab0;
  295. }
  296. }
  297. .curtain {
  298. position: fixed;
  299. width: 100%;
  300. height: 100%;
  301. top: 0;
  302. background-color: rgba($color: #000000, $alpha: 0.2);
  303. .psw-wrapper {
  304. position: fixed;
  305. top: 50%;
  306. left: 50%;
  307. transform: translate(-50%, -100%);
  308. width: 548.6rpx;
  309. height: 344.4rpx;
  310. background-color: #ffffff;
  311. border-radius: 15rpx 15rpx;
  312. .psw-title {
  313. width: 100%;
  314. font-size: 35rpx;
  315. padding: 43rpx 0 49rpx;
  316. text-align: center;
  317. font-weight: 800;
  318. }
  319. .psw-ipt {
  320. display: block;
  321. background-color: #dce3ed;
  322. height: 90rpx;
  323. width: 464rpx;
  324. padding-left: 30rpx;
  325. margin: 0 auto;
  326. font-size: 80rpx;
  327. }
  328. .psw-btn text {
  329. display: inline-block;
  330. text-align: center;
  331. width: 50%;
  332. padding-top: 29rpx;
  333. font-size: 35rpx;
  334. }
  335. .psw-qd {
  336. color: #2e58ff;
  337. }
  338. }
  339. }
  340. .ishiden {
  341. display: none;
  342. }
  343. </style>