连云港陪玩陪聊
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.

342 lines
7.9 KiB

3 months ago
<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">
2 months ago
<text>{{userInfo.goldCoins}}</text>金币余额
3 months ago
</view>
<view class="recharge-bd">
2 months ago
<view class="item" v-for="(a,index) in list" :key="index">
3 months ago
<image src="@/static/coins.png"></image>
2 months ago
<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>
3 months ago
</view>
</view>
<view class="tips">提示:请勿相信非官方渠道的充值信息禁止未成年人充值!请理性消费谨防诈骗行为参考平台公约防诈骗指南点击充值即表示您已同意充值协议</view>
2 months ago
<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" />
3 months ago
</view>
</template>
<script>
export default {
data() {
return {
2 months ago
tabIndex: -1,
isPopup: false,
show: false,
3 months ago
background: {
// 导航栏背景图
2 months ago
background: 'url(https://api.lyiyuan.cn/profile/upload/static/task-bg.png) center top no-repeat',
3 months ago
// 还可以设置背景图size属性
backgroundSize: '100 auto',
},
2 months ago
list: [],
userInfo: {},
payInfo: [],
obj: {}
3 months ago
}
},
2 months ago
onReady() {
const that = this;
2 months ago
this.getList();
this.getConfigData();
this.getUserInfo();
uni.$on("closeSharePopup",res=>{
that.isPopup = false;
})
},
3 months ago
methods: {
2 months ago
toOpen(o) {
this.show = true;
this.obj = o;
},
tabItem(index,a){
this.tabIndex = index;
this.payType = a
},
//创建订单
async toCreate() {
2 months ago
const that = this;
if(this.userInfo.teenageMode == 1){
uni.showModal({
title: "温馨提示",
1 month ago
content: "已开启青少年模式,不可充值!"
2 months ago
})
return ;
}
2 months ago
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() {
2 months ago
const { code, data } = await this.$api.mealsetList({page: 1,limit: 9999});
2 months ago
if(code == 200){
2 months ago
this.list = data.list;
2 months ago
}
},
//字典查询
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({
2 months ago
title: msg,
2 months ago
position: "bottom",
icon: "none",
})
}
},
3 months ago
}
}
</script>
<style scoped lang="scss">
.recharge{
2 months ago
background: url(https://api.lyiyuan.cn/profile/upload/static/task-bg.png) center top no-repeat;
3 months ago
background-size: 100% auto;
overflow: hidden;
min-height: 100vh;
padding: 0 25rpx 0;
overflow: hidden;
2 months ago
.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;
}
}
}
}
}
}
3 months ago
.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;
}
2 months ago
.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;
}
3 months ago
.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>