vipRecharge.vue 10 KB

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