|
|
<template> <view> <view class="block"> <!-- <view class="title"> 我的账户 </view> --> <view class="content"> <view class="my"> 我的账户余额:{{yue}} 元 <text v-if="userinfo.djmoney" style="font-size: 25upx;color: red;">--冻结:{{userinfo.djmoney}}</text> <view class="tx" @click="totx()">提现</view> </view> <view v-if="userinfo.djmoney" style="font-size: 24upx;color: red;margin-top: 30upx;">温馨提示:申请提现待到账金额为冻结金额</view> </view> </view> <view class="block"> <view class="title"> 充值金额 </view> <view class="content"> <view class="amount"> <view class="list"> <view v-if="!giftamountList.length" class="box" v-for="(amount,index) in amountList" :key="index" @tap="select(amount,index)" :class="{'on':amount == inputAmount}"> {{amount}}元 </view> <view v-if="giftamountList.length" class="box" v-for="(amount,index) in amountList" :key="index" @tap="select(amount,index)" :class="{'on':amount == inputAmount}"> {{amount}}元送{{giftamountList[index]}}元 </view> </view> <view class="num"> <view class="text"> 自定义充值金额 </view> <view class="input"> <input v-model="inputAmount" :placeholder="lessdesc" @input='inputamountchange'/> </view> </view> </view> </view> </view> <view class="block"> <view class="title"> 选择支付方式 </view> <view class="content"> <view class="pay-list"> <view class="row" @tap="paytype='wxpay'"> <view class="left"> <image src="/static/img/wxpay.png"></image> </view> <view class="center"> 微信支付 </view> <view class="right"> <radio :checked="paytype=='wxpay'" color="#f06c7a" /> </view> </view> </view> </view> </view> <uni-popup ref="popup" type="center" :maskClick="maskclose" :custom="custom"> <view class="order"> <view class="colseorder" @click="doclose"> <image src="/static/img/close.png"></image> </view> <view class="ordercontent"> <view class="title">订单信息</view> <view class="info"> <view class="infolist"> <view class="addnumtitle">类型:</view> <view class="addnumtitle">余额充值</view> </view> <view class="infolist"> <view class="addnumtitle">支付金额:</view> <view class="addnum">{{inputAmount}}元</view> </view> <view class="infolist"> <view class="addnumtitle">优惠金额:</view> <view class="addnum">{{gitmoney}}元</view> </view> <view class="infolist"> <view class="addnumtitle">到账金额:</view> <view class="addnum">{{(Number(inputAmount)+Number(gitmoney))}}元</view> </view> </view> <view class="addbt" @click="doaddmoney">确认充值</view> </view> </view> </uni-popup> <view class="pay"> <view class="btn" @tap="doDeposit">立即充值</view> <!-- <view class="tis"> 点击立即充值,即代表您同意 <view class="terms"> <navigator url="../../../pages/xieyi/xieyi?type=1"> 《条款协议》 </navigator> </view> </view> --> </view> </view> </template>
<script> import uniPopup from "@/components/uni-popup/uni-popup.vue" export default { components: {uniPopup}, data() { return { maskclose:false, custom:true, inputAmount:'',//金额
amountList:[10,50,100],//预设3个可选快捷金额
giftamountList:[],//送金额
paytype:'wxpay',//支付类型,
yue:0.00, seleteindex:-1,//选中赠送列表下标
gitmoney:'0', timerId: null, lessmoney:1, lessdesc:'不低于1元', userinfo:[] } }, onLoad(e){ }, onShow(){ let getuserinfo=uni.getStorageSync('userinfo'); this.getbaseinfo('defaultmoney'); this.getbaseinfo('lessczje');; this.getuserinfo(getuserinfo.uid,getuserinfo.aid); }, methods: { async getuserinfo(uid,aid) { let reinfo=await this.$api.userinfo({action:'userinfo',uid:uid,aid:aid}); this.yue=reinfo.data.yue; this.userinfo=reinfo.data; }, //获取充值活动数据
async getbaseinfo(key){ let getdata= await this.$api.baseinfo({action:'baseinfo',key:key}); if(getdata.data.info!=''){ if(key=='defaultmoney'){ this.amountList=getdata.data.info; }else if(key=='lessczje'){ this.lessdesc="不低于"+getdata.data.info+"元"; this.lessmoney=parseFloat(getdata.data.info); } //this.giftamountList=info.data.giftamountList;
} }, async wxpay(money,openid,uid) { let userinfo = uni.getStorageSync('userinfo'); let reinfo=await this.$api.czwxpay({action:'czwxpay',openid:openid,addmoney:money,uid:uid,aid:userinfo.aid}); console.log(reinfo,'返回'); let t=this; uni.requestPayment({ provider: 'wxpay', timeStamp: reinfo.data.timeStamp, nonceStr: reinfo.data.nonceStr, package: reinfo.data.package, signType: 'MD5', paySign: reinfo.data.paySign, success: function (res) { //console.log('success:' + JSON.stringify(res));
uni.showToast({ title:'充值成功' }) setTimeout(function(e){ uni.reLaunch({ url:'/pages/user/user' }) },1000) }, fail: function (err) { uni.showToast({ title:'支付失败'+reinfo.msg,icon:'fail' }) } }); }, select(amount,index){ this.inputAmount = amount; this.seleteindex=index; }, inputamountchange(val){ console.log(val.target.value,'输入') }, doDeposit(){ let getuserinfo=uni.getStorageSync('userinfo'); if(getuserinfo.openid==''||getuserinfo.openid==null){ uni.navigateTo({ url:'/pages/user/login' }) }else{ console.log(this.lessmoney,'最低金额') if(this.inputAmount<this.lessmoney){ uni.showToast({title:'充值金额不低于'+this.lessmoney+'元',icon:'none'}); return ; } if (parseFloat(this.inputAmount).toString() == "NaN") { uni.showToast({title:'请输入正确金额',icon:'none'}); return ; } // if(this.inputAmount%10!=0){
// uni.showToast({title:'请输入10的整数金额',icon:'none'});
// return ;
// }
if(parseFloat(this.inputAmount).toFixed(2)!=parseFloat(this.inputAmount)){ uni.showToast({title:'最多只能输入两位小数哦~',icon:'none'}); return ; } this.$refs.popup.open(); } }, doclose(){ this.btstatus=false; this.$refs.popup.close() }, doaddmoney(){ var getmoney=this.inputAmount; var getgifmoney=this.gitmoney; let getuserinfo=uni.getStorageSync('userinfo'); this.wxpay(getmoney,getuserinfo.openid,getuserinfo.uid) console.log(getgifmoney+'--'+this.inputAmount,'金额'); }, totx(){ uni.navigateTo({url:'/pages/user/tixian'}) } } } </script>
<style lang="scss"> .block{ width: 100%; padding: 20upx 3%; .title{ width: 100%; font-size: 34upx; } .content{ .my{ width: 100%; height: 120upx; display: flex; align-items: center; font-size: 30upx; border-bottom: solid 1upx #eee; } .tx{ padding: 15rpx 35rpx; background-color: #00B7B8; color: #FFFFFF; float: right; position: absolute; right: 20rpx; top: 45rpx; border-radius: 10upx; } .amount{ width: 100%; .list{ display: flex; flex-flow:row wrap; justify-content: space-between; padding: 20upx 0; .box{ width: 31%; height: 120upx; display: flex; justify-content: center; align-items: center; border-radius: 10upx; box-shadow: 0upx 5upx 20upx rgba(0,0,0,0.05); font-size: 36upx; background-color: #52B4F5; color: #FFFFFF; margin-top:15upx; &.on{ background-color: #f06c7a; color: #fff; } } } .num{ margin-top: 10upx; display: flex; justify-content: flex-end; align-items: center; .text{ padding-right: 10upx; font-size: 30upx; } .input{ width: 30.2vw; border-bottom: solid 2upx #999; justify-content: flex-end; align-items: center; input{ margin: 0 20upx; height: 60upx; font-size: 30upx; color: #f06c7a; justify-content: flex-end; align-items: center; } } } } .pay-list{ width: 100%; border-bottom: solid 1upx #eee; .row{ width: 100%; height: 120upx; display: flex; align-items: center; .left{ width: 100upx; flex-shrink: 0; display: flex; align-items: center; image{ width: 60upx; height: 60upx; } } .center{ width: 100%; font-size: 30upx; } .right{ width: 100upx; flex-shrink: 0; display: flex; justify-content: flex-end; } } } } } .pay{ margin-top: 20upx; width: 100%; display: flex; justify-content: center; flex-wrap: wrap; .btn{ width: 70%; height: 80upx; border-radius: 80upx; display: flex; justify-content: center; align-items: center; color: #fff; background-color: #f06c7a; box-shadow: 0upx 5upx 10upx rgba(0,0,0,0.2); } .tis{ margin-top: 20upx; width: 100%; font-size: 24upx; display: flex; justify-content: center; align-items: baseline; color: #999; .terms{ color: #5a9ef7; } } } .order{ width: 550rpx; height: 580rpx; background-color: #FFFFFF; border-radius: 25rpx; } .colseorder{ position: absolute; right: -8px; top: -8px; image{ width: 60rpx; height: 60rpx; } } .ordercontent{ padding: 20rpx; } .title{ color:#444f62; border-bottom: 1rpx #e7e8ea solid; } .infolist{ padding: 20rpx 5rpx; display: flex; justify-content: space-around; border-bottom: 1rpx #e7e8ea solid; align-items: center; } .addnum{ color: #ff1f3a; font-weight: bold; margin-left: 50rpx; font-size: 30rpx; } .addnumtitle{ margin-left: -50rpx; color:#444f62; } .addnumtitle{ margin-left: -50rpx; color: #49586d; font-size: 30rpx; } .addbt{ color: #FFFFFF; font-size: 35rpx; background-color: #00bca2; padding: 10rpx 30rpx; display: flex; justify-content: center; margin-top: 30rpx; border-radius: 15rpx; } </style>
|