recharge.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600
  1. <template>
  2. <view class="content">
  3. <view class="top_box">
  4. <text class="yue-tit">当前余额:</text>
  5. <!-- | parseFloatNum -->
  6. <text class="yue-num">{{ (now_money*1).toFixed(3)}}USDT</text>
  7. </view>
  8. <view class="line_box"></view>
  9. <view class="cz_box">
  10. <view class="cz_wrap">
  11. <text class="cz_tit">USDT</text>
  12. <input class="cz_input" type="number" v-model="money" @focus="changeNum()" placeholder="请输入充值金额"
  13. placeholder-class="placeholder" />
  14. </view>
  15. <view class="zc_list_box">
  16. <view class="zc_list_price" :class="{ seletPrice: seletNum == item }" @click="seletChange(item, index)"
  17. v-for="(item, index) in list" :key="index">
  18. {{ item}}USDT
  19. </view>
  20. </view>
  21. </view>
  22. <view class="line_box"></view>
  23. <button class="add-btn up" @click="!payLoding ? confirm() : ''">立即充值</button>
  24. <view class="curtain" :class="{'ishiden':isHiden}" @touchmove.stop.prevent="moveHandle">
  25. <view class="psw-wrapper">
  26. <view class="psw-title">请输入支付密码</view>
  27. <input type="password" v-model="password" class="psw-ipt" />
  28. <view class="psw-btn">
  29. <text @click="cancel">取消</text>
  30. <text class="psw-qd" @click="pswQd">确定</text>
  31. </view>
  32. </view>
  33. </view>
  34. </view>
  35. </template>
  36. <script>
  37. import {
  38. miningDateils,
  39. buyMining,
  40. mymining,
  41. charge
  42. } from '@/api/calculation.js';
  43. import {
  44. recharge,
  45. wallet
  46. } from '@/api/finance.js';
  47. import {
  48. getMoneyStyle
  49. } from '@/utils/rocessor.js';
  50. // import { rechargeWechat, rechargeIndex } from '@/api/wallet.js';
  51. // import { rechargeWechat, rechargeRoutine, rechargeIndex } from '@/api/wallet.js';
  52. import {
  53. mapState
  54. } from 'vuex';
  55. // import { spreadCommission, userBalance,moneyChong } from '@/api/wallet.js';
  56. export default {
  57. // filters: {
  58. // getMoneyStyle,
  59. // // 去处小数点后的0
  60. // parseFloatNum(clock) {
  61. // return parseFloat(clock);
  62. // }
  63. // },
  64. data() {
  65. return {
  66. password:'',
  67. type: 'weixin',
  68. money: '', //充值金额
  69. payLoding: false, //是否加载中
  70. isHiden: true,//是否显示
  71. list: [
  72. "300",
  73. "200",
  74. "150",
  75. "100",
  76. "50"
  77. ],
  78. now_money: '',
  79. seletNum: '300', // 选中
  80. zhuyi: [],
  81. quota: '', // 送的钱
  82. typeText: 0, // 0-微信 1-佣金
  83. };
  84. },
  85. onLoad(options) {
  86. this.loadData();
  87. },
  88. onShow() {
  89. this.loadData();
  90. },
  91. computed: {
  92. // #ifdef H5
  93. // ...mapState(['weichatObj', 'userInfo'])
  94. // #endif
  95. // #ifdef MP
  96. ...mapState(['userInfo'])
  97. // #endif
  98. },
  99. methods: {
  100. pswQd() {
  101. let obj = this;
  102. if (obj.password === '') {
  103. obj.$api.msg('请输入交易密码!');
  104. return
  105. }
  106. obj.isHiden = true
  107. console.log(obj.id ,'131',obj.num,'12',obj.password);
  108. charge({
  109. trade_psw: obj.password,
  110. num:obj.money
  111. }
  112. )
  113. .then(data => {
  114. obj.$api.msg(data.msg);
  115. obj.password = '';
  116. obj.num = 1;
  117. setTimeout(function() {
  118. uni.navigateTo({
  119. url: '/pages/user/charge'
  120. });
  121. }, 1500);
  122. })
  123. .catch(e => {
  124. obj.password = '';
  125. obj.num = 1;
  126. if (e.msg == '交易密码错误') {
  127. return;
  128. }
  129. console.log(e);
  130. var reg = new RegExp('购买矿机所需的');
  131. if (e.msg.match(reg) == -1) {} else {
  132. setTimeout(function() {
  133. uni.navigateTo({
  134. url: '/pages/finance/recharge'
  135. });
  136. }, 1500);
  137. }
  138. });
  139. },
  140. cancel() {
  141. this.password = ''
  142. this.isHiden = true
  143. },
  144. buy() {
  145. this.isHiden = false
  146. },
  147. // 跳转
  148. navTo(url) {
  149. uni.navigateTo({
  150. url: url
  151. });
  152. },
  153. changeNum() {
  154. this.seletNum = this.money = '';
  155. console.log(this.seletNum, this.money);
  156. },
  157. seletChange(item, index) {
  158. this.seletNum = item;
  159. this.seletMoney = item;
  160. this.money = item
  161. },
  162. // 切换选中对象
  163. // tabRadio(e) {
  164. // this.type = e.detail.value;
  165. // if (e.detail.value == 'weixin') {
  166. // this.typeText = 0
  167. // } else {
  168. // this.typeText = 1
  169. // }
  170. // },
  171. // 充值金额
  172. rechargeXuan(item) {
  173. this.money = item.price;
  174. this.quota = item.quota;
  175. },
  176. // loadData() {
  177. // moneyChong({}).then(({
  178. // data
  179. // }) => {
  180. // console.log(data, "123456789");
  181. // this.list = data.recharge_quota;
  182. // });
  183. // userBalance({}).then(({
  184. // data
  185. // }) => {
  186. // this.now_money = data.now_money;
  187. // });
  188. // },
  189. //获取余额
  190. loadData() {
  191. let obj = this
  192. wallet().then(res => {
  193. console.log(res, 'da2');
  194. obj.now_money = res.data.back.USDT.money.money
  195. })
  196. },
  197. // 提交
  198. confirm() {
  199. //是否输入金额,如不是提示充值金额
  200. let obj = this;
  201. obj.isHiden = false
  202. obj.payLoding = true;
  203. if (!obj.money) {
  204. obj.$api.msg('请输入金额');
  205. obj.payLoding = false;
  206. return;
  207. }
  208. },
  209. }
  210. };
  211. </script>
  212. <style lang="scss">
  213. page {
  214. height: 100%;
  215. background: #ffffff;
  216. }
  217. .top_box {
  218. padding: 20rpx 26rpx 20rpx 47rpx;
  219. display: flex;
  220. align-items: center;
  221. justify-content: space-between;
  222. .yue-tit {
  223. font-size: 28rpx;
  224. font-family: PingFang SC;
  225. font-weight: 500;
  226. color: #333333;
  227. }
  228. .yue-num {
  229. font-size: 30rpx;
  230. font-family: PingFang SC;
  231. font-weight: bold;
  232. color: #ff6f0f;
  233. }
  234. }
  235. .line_box {
  236. width: 100%;
  237. height: 20rpx;
  238. background: #f8f8f8;
  239. }
  240. .cz_box {
  241. padding: 40rpx 20rpx 20rpx;
  242. .cz_wrap {
  243. display: flex;
  244. align-items: center;
  245. justify-content: space-between;
  246. padding-bottom: 20rpx;
  247. border-bottom: 1px solid #e6e6e6;
  248. .cz_tit {
  249. font-size: 32rpx;
  250. font-family: PingFang SC;
  251. font-weight: 500;
  252. }
  253. .cz_input {
  254. text-align: right;
  255. font-size: 32rpx;
  256. font-family: PingFang SC;
  257. font-weight: 500;
  258. // color: #BFBFBF;
  259. }
  260. }
  261. .zc_list_box {
  262. display: flex;
  263. flex-wrap: wrap;
  264. .zc_list_price {
  265. width: 202rpx;
  266. height: 60rpx;
  267. // background: #f0f0f0;
  268. border-radius: 8rpx;
  269. margin-top: 36rpx;
  270. margin-right: 50rpx;
  271. display: flex;
  272. align-items: center;
  273. justify-content: center;
  274. &:nth-child(3n) {
  275. margin-right: 0;
  276. }
  277. }
  278. .seletPrice {
  279. // background: linear-gradient(143.2747deg, #fff, #f3f3f3);
  280. background: #141E47;
  281. border: 3rpx solid #141E47;
  282. color: #ffffff;
  283. }
  284. }
  285. }
  286. .recha-box {
  287. padding: 50rpx 30rpx 0;
  288. display: flex;
  289. flex-wrap: wrap;
  290. .recha-frame {
  291. width: 210rpx;
  292. height: 181rpx;
  293. border: 1px solid #dbdede;
  294. border-radius: 20rpx;
  295. display: flex;
  296. align-items: center;
  297. flex-direction: column;
  298. justify-content: center;
  299. margin-right: 30rpx;
  300. margin-bottom: 30rpx;
  301. &:nth-child(3n) {
  302. margin-right: 0;
  303. }
  304. .recha-top {
  305. display: flex;
  306. align-items: center;
  307. .recha-img {
  308. width: 64rpx;
  309. height: 62rpx;
  310. }
  311. .recha-tit {
  312. margin-left: 10rpx;
  313. font-size: 36rpx;
  314. font-family: PingFang SC;
  315. font-weight: bold;
  316. color: #333333;
  317. }
  318. }
  319. .recha-song {
  320. margin-top: 20rpx;
  321. font-size: $font-base;
  322. font-family: PingFang SC;
  323. font-weight: bold;
  324. color: #ff9900;
  325. }
  326. }
  327. .select-frame {
  328. border: 1px solid #ef041f;
  329. }
  330. }
  331. .rechar-box {
  332. padding: 30rpx 20rpx 0;
  333. .rechar-title {
  334. font-size: 32rpx;
  335. font-family: PingFang SC;
  336. font-weight: bold;
  337. color: #333333;
  338. margin-bottom: 10rpx;
  339. }
  340. .rechar-text {
  341. font-size: 28rpx;
  342. font-family: PingFang SC;
  343. font-weight: bold;
  344. color: #333333;
  345. }
  346. }
  347. .cz-type {
  348. margin-top: 22rpx;
  349. display: flex;
  350. justify-content: space-between;
  351. padding: 32rpx;
  352. align-items: center;
  353. .type-left {
  354. display: flex;
  355. align-items: center;
  356. .icon {
  357. height: 38rpx;
  358. image {
  359. width: 48rpx;
  360. height: 38rpx;
  361. }
  362. }
  363. .iconweixin {
  364. color: #36cb59;
  365. }
  366. .tit {
  367. margin-left: 12rpx;
  368. font-size: 30rpx;
  369. color: #333333;
  370. }
  371. }
  372. .type-right {
  373. image {
  374. width: 36rpx;
  375. height: 36rpx;
  376. }
  377. }
  378. }
  379. .add-btn {
  380. &.modified {}
  381. &.up {
  382. color: #FFFFFF;
  383. background: #141E47;
  384. }
  385. margin-top: 100rpx;
  386. display: flex;
  387. align-items: center;
  388. justify-content: center;
  389. width: 604rpx;
  390. height: 90rpx;
  391. border: 2rpx solid #FFFFFF;
  392. border-radius: 10rpx;
  393. font-size: 36rpx;
  394. font-family: PingFang SC;
  395. font-weight: 500;
  396. color: #F21F5D;
  397. line-height: 90rpx;
  398. text-align: center;
  399. }
  400. .row-box {
  401. margin-top: 30rpx;
  402. padding: 20rpx 30rpx;
  403. background: #fff;
  404. .title {
  405. font-size: $font-base + 2rpx;
  406. color: $font-color-dark;
  407. }
  408. .row {
  409. display: flex;
  410. align-items: center;
  411. position: relative;
  412. height: 80rpx;
  413. .tit {
  414. flex-shrink: 0;
  415. width: 40rpx;
  416. font-size: 30rpx;
  417. color: $font-color-dark;
  418. }
  419. .input {
  420. flex: 1;
  421. font-size: 30rpx;
  422. color: $font-color-dark;
  423. }
  424. .iconlocation {
  425. font-size: 36rpx;
  426. color: $font-color-light;
  427. }
  428. .buttom {
  429. color: $font-color;
  430. font-size: $font-base;
  431. }
  432. }
  433. }
  434. .list {
  435. padding-left: 30rpx;
  436. margin-top: 30rpx;
  437. background-color: #ffffff;
  438. .box {
  439. display: flex;
  440. align-items: center;
  441. width: 100%;
  442. height: 120rpx;
  443. border-bottom: 1px solid $border-color-light;
  444. padding-right: 25rpx;
  445. .icon {
  446. font-size: 48rpx;
  447. padding-right: 20rpx;
  448. display: flex;
  449. }
  450. .yongjing {
  451. width: 48rpx;
  452. height: 48rpx;
  453. }
  454. .iconweixin1 {
  455. color: #18bf16;
  456. }
  457. .iconzhifubao {
  458. color: #08aaec;
  459. }
  460. .title-box {
  461. flex-grow: 1;
  462. text-align: left;
  463. .title {
  464. font-size: $font-base + 2rpx;
  465. color: $font-color-base;
  466. }
  467. .node {
  468. font-size: $font-sm;
  469. color: $font-color-light;
  470. }
  471. }
  472. }
  473. }
  474. /deep/ .uni-radio-input {
  475. width: 45rpx;
  476. height: 45rpx;
  477. }
  478. .active-bg {
  479. background: linear-gradient(143.2747deg, #ff6a00, #ee0979) !important;
  480. color: #FFFFFF !important;
  481. }
  482. .curtain {
  483. position: fixed;
  484. width: 100%;
  485. height: 100%;
  486. top: 0;
  487. background-color: rgba($color: #000000, $alpha: 0.2);
  488. .psw-wrapper {
  489. position: fixed;
  490. top: 50%;
  491. left: 50%;
  492. transform: translate(-50%, -100%);
  493. width: 548.6rpx;
  494. height: 344.4rpx;
  495. background-color: #FFFFFF;
  496. border-radius: 15rpx 15rpx;
  497. .psw-title {
  498. width: 100%;
  499. font-size: 35rpx;
  500. padding: 43rpx 0 49rpx;
  501. text-align: center;
  502. font-weight: 800;
  503. }
  504. .psw-ipt {
  505. display: block;
  506. background-color: #dce3ed;
  507. height: 90rpx;
  508. width: 464rpx;
  509. padding-left: 30rpx;
  510. margin: 0 auto;
  511. font-size: 80rpx;
  512. }
  513. .psw-btn text {
  514. display: inline-block;
  515. text-align: center;
  516. width: 50%;
  517. padding-top: 29rpx;
  518. font-size: 35rpx;
  519. }
  520. .psw-qd {
  521. color: #5771DF;
  522. }
  523. }
  524. }
  525. .ishiden {
  526. display: none;
  527. }
  528. </style>