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

414 lines
11 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">
3 weeks ago
<template v-if="platform == 'ios'">
<view class="item" v-if="a=='wx-1' || a=='ali-1' || a=='integral-1' || a=='ios-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="a" v-if="a=='integral-1'"><image src="@/static/yue.png"></image>余额支付<text>账户余额{{userInfo.money}}</text></view>
<view class="a" v-if="a=='ios-1'"><image src="@/static/pgzf.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>
<template v-else>
<view class="item" v-if="a=='wx-1' || a=='ali-1' || a=='integral-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="a" v-if="a=='integral-1'"><image src="@/static/yue.png"></image>余额支付<text>账户余额{{userInfo.money}}</text></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>
2 months ago
</template>
</view>
<view class="fd">
<view class="btn" @click="toCreate()">立即充值</view>
</view>
</view>
</u-popup>
<unverified :isPopup="isPopup" />
3 months ago
</view>
</template>
3 weeks ago
<script>
const systemInfo = uni.getSystemInfoSync();
3 months ago
export default {
data() {
3 weeks ago
return {
platform: "ios",
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
}
},
1 month ago
onReady() {
3 weeks ago
const that = this;
that.platform = systemInfo.platform;
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: "温馨提示",
4 weeks ago
content: "已开启青少年模式,不可充值!"
2 months ago
})
return ;
}
2 months ago
if(!this.payType){
uni.showToast({
icon: "none",
position: "bottom",
title: "请选择支付方式"
})
return ;
4 weeks ago
}
if(this.payType == 'integral-1'){
if(this.obj.giveCoins > this.userInfo.money){
uni.showToast({
icon: "none",
position: "bottom",
title: "账户余额不足"
})
return ;
}
3 weeks ago
}
if(this.platform == 'ios'){
if(this.payType == 'ios-1'){
plus.payment.getChannels((channels) => {
console.log(channels);
for (var i in channels) {
var channel = channels[i];
if (channel.id == 'appleiap'){
console.log("苹果")
let iap = channel;
//支付参数
iap.requestOrder(['chunwanProPackage'], function(orderList){
//必须调用此方法才能进行 iap 支付
console.log('requestOrder success: ' + JSON.stringify(orderList))
// that.applePay(orderList[0])
},function(e){
console.log('requestOrder failed: ' + JSON.stringify(e));
// console.log('暂不支持苹果 iap 支付')
});
}
}
}, function(e) {
console.log("获取iap支付通道失败:" + e.message);
});
return ;
}
}
2 months ago
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({
4 weeks ago
payType: that.payType =='wx-1'?1:(that.payType=='ali-1'?2:3),
2 months ago
outTradeNo
})
if(code == 200){
4 weeks ago
uni.hideLoading()
if(that.payType == 'integral-1'){
uni.showToast({
title: "支付成功"
})
that.payType = ""
setTimeout(()=>{
that.getUserInfo();
that.getList();
},2000)
return ;
}
2 months ago
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(()=>{
4 weeks ago
that.getUserInfo();
2 months ago
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){
3 weeks ago
this.payInfo = res1.data.content.split(",");
console.log(this.payInfo)
2 months ago
}
},
//查询个人信息
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({
1 month 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;
4 weeks ago
align-items: center;
text{
margin-left: 20rpx;
font-size: 22rpx;
color: #999999;
}
2 months ago
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>