You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
340 lines
7.9 KiB
340 lines
7.9 KiB
<template>
|
|
<view class="recharge">
|
|
<view class="task-navbar">
|
|
<u-navbar title="充值金币" back-icon-color="#333333" title-color="#333333" :background="background"></u-navbar>
|
|
</view>
|
|
<view class="recharge-hd">
|
|
<text>{{userInfo.goldCoins}}</text>金币余额
|
|
</view>
|
|
<view class="recharge-bd">
|
|
<view class="item" v-for="(a,index) in list" :key="index">
|
|
<image src="@/static/coins.png"></image>
|
|
<view class="info"><view class="num"><text>{{a.coins}}</text>金币</view v-if="a.giveCoins">限时多送{{a.giveCoins}}金币</view>
|
|
<view class="btn" @click="toOpen(a)">¥{{a.price}}</view>
|
|
</view>
|
|
</view>
|
|
<view class="tips">提示:请勿相信非官方渠道的充值信息,禁止未成年人充值!请理性消费谨防诈骗行为,参考《平台公约》及《防诈骗指南》点击充值即表示您已同意《充值协议》</view>
|
|
<u-popup v-model="show" mode="bottom">
|
|
<view class="payPopup">
|
|
<view class="title">选择充值方式</view>
|
|
<view class="content">
|
|
<template v-for="(a,i) in payInfo">
|
|
<view class="item" v-if="a=='wx-1' || a=='ali-1'" :key="i" :class="tabIndex == i?'item-on':''" @click="tabItem(i,a)">
|
|
<view class="a" v-if="a=='wx-1'"><image src="@/static/wxpay.png"></image>微信支付</view>
|
|
<view class="a" v-if="a=='ali-1'"><image src="@/static/zfb.png"></image>支付宝支付</view>
|
|
<view class="b">
|
|
<image class="img1" src="@/static/icon-check.png"></image>
|
|
<image class="img2" src="@/static/icon-check-on.png"></image>
|
|
</view>
|
|
</view>
|
|
</template>
|
|
</view>
|
|
<view class="fd">
|
|
<view class="btn" @click="toCreate()">立即充值</view>
|
|
</view>
|
|
</view>
|
|
</u-popup>
|
|
<unverified :isPopup="isPopup" />
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
export default {
|
|
data() {
|
|
return {
|
|
tabIndex: -1,
|
|
isPopup: false,
|
|
show: false,
|
|
background: {
|
|
// 导航栏背景图
|
|
background: 'url(https://api.lyiyuan.cn/profile/upload/static/task-bg.png) center top no-repeat',
|
|
// 还可以设置背景图size属性
|
|
backgroundSize: '100 auto',
|
|
},
|
|
list: [],
|
|
userInfo: {},
|
|
payInfo: [],
|
|
obj: {}
|
|
}
|
|
},
|
|
onLoad() {
|
|
this.getList();
|
|
this.getConfigData();
|
|
this.getUserInfo();
|
|
uni.$on("closeSharePopup",res=>{
|
|
that.isPopup = false;
|
|
})
|
|
},
|
|
methods: {
|
|
toOpen(o) {
|
|
this.show = true;
|
|
this.obj = o;
|
|
},
|
|
tabItem(index,a){
|
|
this.tabIndex = index;
|
|
this.payType = a
|
|
},
|
|
//创建订单
|
|
async toCreate() {
|
|
const that = this;
|
|
if(this.userInfo.teenageMode == 1){
|
|
uni.showModal({
|
|
title: "温馨提示",
|
|
content: "已开启青少年模式,该功能已关闭"
|
|
})
|
|
return ;
|
|
}
|
|
if(!this.payType){
|
|
uni.showToast({
|
|
icon: "none",
|
|
position: "bottom",
|
|
title: "请选择支付方式"
|
|
})
|
|
return ;
|
|
}
|
|
that.show = false;
|
|
that.tabIndex = -1;
|
|
uni.showLoading({
|
|
title: "正在支付"
|
|
})
|
|
const {code, data, msg} = await that.$api.mealsetRechargeCreateOrder({
|
|
userId: uni.getStorageSync("userInfo").id,
|
|
mealsetId: this.obj.id
|
|
})
|
|
if(code == 200){
|
|
that.toPay(msg);
|
|
}else{
|
|
uni.showToast({
|
|
icon: "none",
|
|
position: "bottom",
|
|
title: msg
|
|
})
|
|
}
|
|
},
|
|
//支付
|
|
async toPay(outTradeNo) {
|
|
const that = this;
|
|
const {code, data, msg} = await that.$api.paymentOrder({
|
|
payType: that.payType =='wx-1'?1:2,
|
|
outTradeNo
|
|
})
|
|
if(code == 200){
|
|
uni.hideLoading()
|
|
uni.requestPayment({
|
|
provider: that.payType == 'ali-1'?'alipay':'wxpay',
|
|
orderInfo: that.payType == 'ali-1'?data.orderInfo:JSON.parse(data.orderInfo), //微信、支付宝订单数据 【注意微信的订单信息,键值应该全部是小写,不能采用驼峰命名】
|
|
success: function (res) {
|
|
uni.showToast({
|
|
title: "支付成功"
|
|
})
|
|
setTimeout(()=>{
|
|
that.getUserInfo();
|
|
that.getList();
|
|
},2000)
|
|
},
|
|
fail: function (err) {
|
|
console.log('fail:' + JSON.stringify(err));
|
|
}
|
|
});
|
|
}else{
|
|
uni.hideLoading();
|
|
uni.showToast({
|
|
icon: "none",
|
|
position: "bottom",
|
|
title: msg
|
|
})
|
|
}
|
|
},
|
|
//查询列表
|
|
async getList() {
|
|
const { code, data } = await this.$api.mealsetList({page: 1,limit: 9999});
|
|
if(code == 200){
|
|
this.list = data.list;
|
|
}
|
|
},
|
|
//字典查询
|
|
async getConfigData() {
|
|
const that = this;
|
|
let res1 = await that.$api.getConfigData({dictType: 'CONFIG_PAY_STATUS'});
|
|
if(res1.data.content){
|
|
this.payInfo = res1.data.content.split(",");
|
|
}
|
|
},
|
|
//查询个人信息
|
|
async getUserInfo() {
|
|
const { code, data , msg } = await this.$api.findUserInfo({userId: uni.getStorageSync("userInfo").id});
|
|
if(code == 200){
|
|
this.userInfo = data;
|
|
uni.setStorageSync("userInfo",data);
|
|
}else{
|
|
uni.showToast({
|
|
title: mgs,
|
|
position: "bottom",
|
|
icon: "none",
|
|
})
|
|
}
|
|
},
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style scoped lang="scss">
|
|
.recharge{
|
|
background: url(https://api.lyiyuan.cn/profile/upload/static/task-bg.png) center top no-repeat;
|
|
background-size: 100% auto;
|
|
overflow: hidden;
|
|
min-height: 100vh;
|
|
padding: 0 25rpx 0;
|
|
overflow: hidden;
|
|
.payPopup{
|
|
padding: 40rpx;
|
|
overflow: hidden;
|
|
.title{
|
|
font-weight: 500;
|
|
font-size: 36rpx;
|
|
color: #333333;
|
|
text-align: center;
|
|
}
|
|
.btn{
|
|
width: 100%;
|
|
line-height: 98rpx;
|
|
background: linear-gradient(0deg, #000000, #3D3B38);
|
|
box-shadow: 0px 4rpx 18rpx 0px rgba(42,41,39,0.34);
|
|
border-radius: 98rpx;
|
|
font-weight: 400;
|
|
text-align: center;
|
|
font-size: 30rpx;
|
|
color: #FFFFFF;
|
|
margin-top: 30rpx;
|
|
}
|
|
.content{
|
|
padding: 0 30rpx;
|
|
background: #FFFFFF;
|
|
border-radius: 20rpx;
|
|
margin-top: 20rpx;
|
|
.item{
|
|
padding: 30rpx 0;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: space-between;
|
|
font-weight: 400;
|
|
font-size: 28rpx;
|
|
color: #333333;
|
|
border-top: 1px solid #EAEAEA;
|
|
&:first-child{
|
|
border-top-color: #FFFFFF;
|
|
}
|
|
.a{
|
|
flex: 1;
|
|
display: flex;
|
|
align-items: center;
|
|
image{
|
|
width: 60rpx;
|
|
height: 60rpx;
|
|
margin-right: 10rpx;
|
|
}
|
|
}
|
|
.b{
|
|
font-size: 28rpx;
|
|
color: #CCCCCC;
|
|
display: flex;
|
|
align-items: center;
|
|
image{
|
|
width: 32rpx;
|
|
height: 32rpx;
|
|
margin-left: 20rpx;
|
|
}
|
|
.img1{
|
|
display: block;
|
|
}
|
|
.img2{
|
|
display: none;
|
|
}
|
|
}
|
|
&-on{
|
|
.b{
|
|
.img1{
|
|
display: none;
|
|
}
|
|
.img2{
|
|
display: block;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
.tips{
|
|
padding: 45rpx 0;
|
|
text-align: center;
|
|
font-weight: 500;
|
|
font-size: 24rpx;
|
|
color: #999999;
|
|
line-height: 40rpx;
|
|
}
|
|
&-hd{
|
|
width: 100%;
|
|
height: 200rpx;
|
|
background: linear-gradient(90deg, #17150E, #373632);
|
|
border-radius: 20rpx;
|
|
text-align: center;
|
|
font-weight: 500;
|
|
font-size: 24rpx;
|
|
color: #E7D4B8;
|
|
padding-top: 55rpx;
|
|
box-sizing: border-box;
|
|
margin-top: 30rpx;
|
|
text{
|
|
font-size: 44rpx;
|
|
display: block;
|
|
margin-bottom: 20rpx;
|
|
}
|
|
}
|
|
&-bd{
|
|
overflow: hidden;
|
|
.item{
|
|
width: 100%;
|
|
height: 126rpx;
|
|
background: #FFFFFF;
|
|
border-radius: 20rpx;
|
|
padding: 30rpx;
|
|
box-sizing: border-box;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: space-between;
|
|
margin-top: 20rpx;
|
|
image{
|
|
width: 60rpx;
|
|
height: 60rpx;
|
|
margin-right: 20rpx;
|
|
}
|
|
.btn{
|
|
width: 160rpx;
|
|
line-height: 70rpx;
|
|
background: linear-gradient(0deg, #000000, #3D3B38);
|
|
box-shadow: 0px 4rpx 18rpx 0px rgba(42,41,39,0.34);
|
|
font-weight: 500;
|
|
font-size: 28rpx;
|
|
color: #FFFFFF;
|
|
border-radius: 70rpx;
|
|
text-align: center;
|
|
}
|
|
.info{
|
|
flex: 1;
|
|
font-weight: 500;
|
|
font-size: 24rpx;
|
|
color: #999999;
|
|
.num{
|
|
font-size: 28rpx;
|
|
font-weight: 500;
|
|
color: #222222;
|
|
text{
|
|
|
|
font-size: 36rpx;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
</style>
|
|
|