recharge.vue 10 KB

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