recharge.vue 12 KB

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