123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266 |
- <template>
- <view class="container">
- <view class="box">充值金额</view>
- <view class="list dffs">
- <view class="button_money" @click="selItem(item, index)" v-for="(item, index) in rspData" :key="index" :class="[item.id == money ? 'sel' : '', 'li']">
- <view style="color: #0bb291;">{{ item.money }}元</view>
- <view style="font-size: 26rpx;font-weight: normal;color: #0bb291;">{{ item.bean }}学豆</view>
- </view>
- <!-- <input v-if="active == 5" type="number" placeholder-style="font-size:32rpx" v-model="money" placeholder="请输入自定义金额" /> -->
- </view>
- <view class="cen">
- <view class="cen-title textgrey">支付方式</view>
- <!-- //开启的支付方式 1:微信+支付宝 2:支付宝 3:微信 -->
- <view class="pay-item bb dffs">
- <image class="left-icon" src="/static/img/pro/paywx.png"></image>
- <text class="pay-til">微信</text>
- <image class="right-icon" src="/static/img/pro/paysel.png"></image>
- </view>
- </view>
- <navigator url="/pages/user/funManage/list?type=3" class="mt30 fontmid prosecond">充值记录></navigator>
- <u-button color="#00952E" shape="circle" class="custom-style" @click="submitClickEvent">立即支付</u-button>
- </view>
- </template>
- <script>
- import payPassWord from '@/components/pay-password-keyboard/pay-password-keyboard.vue';
- export default {
- components: {
- payPassWord
- },
- data() {
- return {
- cv_bean:0, //比例
- active: 0,
- total: '',
- payType: 2,
- money: '',
- rspData: [],
- // rspData: ['50', '100', '200', '500', '1000', '自定义'],
- customStyle: {
- background: '#00952E',
- width: '690rpx',
- marginTop: '40rpx'
- }
- };
- },
- onLoad(opt) {
-
- this.getBean();
- // this.money=this.rspData[0];
- // this.loadData();
- },
- methods: {
- // 选中
- selItem(item, index) {
- // if (index != 5) {
- // this.active = index;
- this.money = item.id;
- // } else {
- // this.active = 5;
- // this.money = '';
- // }
- },
-
- //组合充值金额
- moneyArray() {
- var cv_bean = this.cv_bean;
-
- var new_array = [];
-
- var array = ['50', '100', '200', '500', '1000', '自定义'];
-
- array.forEach(function(v,k)
- {
- let item = {};
- if(v != '自定义')
- {
- item.money = v + '元';
- item.s_bean = (parseInt(v) * parseInt(cv_bean)) + '学豆';
-
- }else{
- item.money = v;
- item.s_bean = '';
- }
-
- new_array.push(item);
-
- })
- this.rspData = new_array;
- // console.log('新: ',new_array);
- },
-
- //获取学豆比例配置
- getBean(){
- this.$api
- .request(`index/getRecharge`)
- .then(res => {
- if (res.code == 200) {
- // let cv_bean = res.data.cv_bean || 0;
- // this.cv_bean = cv_bean;
-
- // this.moneyArray();
- this.rspData=res.data;
- this.money = res.data[0].id;
- }
- });
- },
- submitClickEvent() {
- if (!this.money) {
- this.$api.toast('请输入或选择充值金额!');
- return;
- }
- this.$api
- .request(`payment/beanPay`, {
- id: this.money
- })
- .then(res => {
- if (res.code && res.code != 200) {
- // this.$refs.confirmBtn.stop();
- this.$api.toast(res.msg || '获取支付信息失败');
- return;
- }
- console.log(res);
- console.log(res, this.payType);
- const orderInfo = res;
- const { timeStamp, nonceStr, paySign } = orderInfo;
- const payParams = {
- provider: 'wxpay',
- orderInfo: res,
- timeStamp,
- nonceStr,
- package: orderInfo.package,
- signType: 'MD5',
- paySign,
- success: e => {
- this.$api.toast('支付成功');
- },
- fail: err => {
- if (err.errMsg.indexOf('取消') > -1 || err.errMsg.indexOf('cancel') > 1 || err.errMsg.indexOf('-2') > -1) {
- this.$api.toast('取消支付');
- } else {
- this.$api.toast('支付遇到错误,请稍候重试');
- console.log(err);
- }
- console.log(err);
- }
- };
- uni.requestPayment(payParams);
- });
- },
- // async loadData() {
- // this.$api.request(`recharge/getConfig`).then(res => {
- // if (res.code == '200') {
- // let data = res.data;
- // this.money = data[0];
- // this.rspData = data;
- // } else {
- // this.$api.toast(res.msg);
- // this.rspData = false;
- // }
- // });
- // }
- }
- };
- </script>
- <style lang="scss">
- page {
- background-color: #f5f5f5;
- }
- </style>
- <style lang="scss" scoped>
- .container {
- padding: 45rpx 30rpx;
- background-color: #fff;
-
- .button_money{
- display: flex;
- flex-direction:column;
- align-items: center;
- justify-content: center;
- }
-
- .box {
- font-size: 36rpx;
- font-family: PingFangSC-Semibold, PingFang SC;
- font-weight: 600;
- }
- .custom-style {
- background: #ed742e;
- width: 690rpx;
- margintop: 600rpx;
- color: #fff;
- margin-top: 40rpx;
- }
- .list {
- padding: 40rpx 0rpx 120rpx;
- flex-wrap: wrap;
- &:nth-of-type(3) {
- margin-right: 0;
- }
- .li {
- width: 218rpx;
- height: 110rpx;
- // line-height: 110rpx;
- background: #ffffff;
- // text-align: center;
- border-radius: 9rpx;
- color: #0bb291;
- font-size: 38rpx;
- font-family: PingFang SC;
- font-weight: bold;
- margin-right: 18rpx;
- margin-bottom: 22rpx;
- border: 1px solid #0bb291;
- &:nth-of-type(3n) {
- margin-right: 0;
- }
- }
- .sel {
- background: rgba(11, 178, 145, 0.1);
- border: 1px solid #0bb291;
- }
- input {
- margin-top: 42rpx;
- width: 690rpx;
- height: 86rpx;
- line-height: 86rpx;
- padding: 0 30rpx;
- border: 1px solid #dfdfdf;
- }
- }
- .cen {
- margin-bottom: 40rpx;
- .pay-item {
- background: #ffffff;
- width: 100%;
- margin-top: 20rpx;
- padding: 30rpx 0;
- .left-icon {
- width: 68rpx;
- height: 68rpx;
- }
- .pay-til {
- font-size: 32rpx;
- color: #333333;
- margin-left: 18rpx;
- flex: 1;
- }
- .right-icon {
- width: 36rpx;
- height: 36rpx;
- }
- }
- }
- .tips {
- width: 100%;
- padding: 26rpx 30rpx;
- text-align: left;
- }
- }
- </style>
|