连云港陪玩陪聊
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.
 
 
 
 
 
 
chunwan/pages/users/center/index.vue

647 lines
17 KiB

<template>
<view class="task">
<view class="task-navbar">
<u-navbar title="会员中心" back-icon-color="#333333" title-color="#333333" :background="background"></u-navbar>
</view>
<view class="task-content">
<view class="info">
<view class="a">
<view class="fl">
<view class="pic">
<image :src="userInfo.faceImage?userInfo.faceImage:userInfo.img"></image>
</view>
<view class="xinxi">
<view class="name">{{userInfo.realname}}<text v-if="userInfo.memberflag >=1">LV.{{userInfo.memberflag}}</text></view>
<view class="status" v-if="userInfo.memberflag==0">您还不是会员</view>
<view class="status" v-else>{{userInfo.memberEndTime}}到期</view>
</view>
</view>
<image class="king" src="@/static/user-king.png"></image>
</view>
<view class="b" v-if="userInfo.memberflag==0">开通会员,尊享酷炫好玩会员特权</view>
</view>
<view class="title" v-if="userInfo.memberflag>=1">您的特权</view>
<view class="content" v-if="userInfo.memberflag>=1">
<view class="item">
<view class="a"><view class="btn">特权1</view><view class="txt">文字语音视频聊天折扣{{huiyuanInfo.wordVoiceDiscount}}折</view></view>
<view class="b">
<image src="@/static/icon-svip.png"></image>
</view>
</view>
<view class="item">
<view class="a"><view class="btn">特权2</view><view class="txt">每天可领金币{{huiyuanInfo.receiveCoins}}枚</view></view>
<view class="b">
<image src="@/static/icon-svip.png"></image>
</view>
</view>
<view class="item">
<view class="a"><view class="btn">特权3</view><view class="txt">可累积领取金币{{huiyuanInfo.totalReceiveCoins}}枚</view></view>
<view class="b">
<image src="@/static/icon-svip.png"></image>
</view>
</view>
<view class="item">
<view class="a"><view class="btn">特权4</view><view class="txt">每天免费信息数量{{huiyuanInfo.freeMsg}}条</view></view>
<view class="b">
<image src="@/static/icon-svip.png"></image>
</view>
</view>
<view class="item">
<view class="a"><view class="btn">特权5</view><view class="txt">每天免费语音时长{{huiyuanInfo.freeVoice}}分钟</view></view>
<view class="b">
<image src="@/static/icon-svip.png"></image>
</view>
</view>
<view class="item">
<view class="a"><view class="btn">特权5</view><view class="txt">每天免费视频时长{{huiyuanInfo.freeVideo}}分钟</view></view>
<view class="b">
<image src="@/static/icon-svip.png"></image>
</view>
</view>
</view>
<view class="title">{{userInfo.memberflag==0?'开通会员':'续费会员'}}</view>
<scroll-view scroll-x class="kaitong">
<view class="item" v-for="(a,i) in list" :class="tabIndex == i?'item-on':''" @click="tabItem(i)">
<view class="a">{{a.cycle}}{{a.danwei}}</view>
<view class="b">¥<text>{{a.presentPrice}}</text></view>
<view class="c">{{a.discount}}折</view>
<view class="d">原价¥{{a.originalPrice}}</view>
<view class="e">{{a.name}}</view>
</view>
</scroll-view>
<view class="title" v-if="list && list.length > 0">会员特权</view>
<view class="content" v-if="list && list.length > 0">
<view class="item">
<view class="a"><view class="btn">特权1</view><view class="txt">文字语音视频聊天折扣{{list[tabIndex].wordVoiceDiscount}}折</view></view>
<view class="b">
<image src="@/static/icon-svip.png"></image>
</view>
</view>
<view class="item">
<view class="a"><view class="btn">特权2</view><view class="txt">每天可领金币{{list[tabIndex].receiveCoins}}枚</view></view>
<view class="b">
<image src="@/static/icon-svip.png"></image>
</view>
</view>
<view class="item">
<view class="a"><view class="btn">特权3</view><view class="txt">可累积领取金币{{list[tabIndex].totalReceiveCoins}}枚</view></view>
<view class="b">
<image src="@/static/icon-svip.png"></image>
</view>
</view>
<view class="item">
<view class="a"><view class="btn">特权4</view><view class="txt">每天免费信息数量{{list[tabIndex].freeMsg}}条</view></view>
<view class="b">
<image src="@/static/icon-svip.png"></image>
</view>
</view>
<view class="item">
<view class="a"><view class="btn">特权5</view><view class="txt">每天免费语音时长{{list[tabIndex].freeVoice}}分钟</view></view>
<view class="b">
<image src="@/static/icon-svip.png"></image>
</view>
</view>
<view class="item">
<view class="a"><view class="btn">特权6</view><view class="txt">每天免费视频时长{{list[tabIndex].freeVideo}}分钟</view></view>
<view class="b">
<image src="@/static/icon-svip.png"></image>
</view>
</view>
</view>
<view class="title">支付方式</view>
<view class="pay" v-if="payInfo && payInfo.length >= 1">
<template v-for="(a,i) in payInfo">
<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="payIndex == i?'item-on':''" @click="tabPay(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="payIndex == i?'item-on':''" @click="tabPay(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>
</template>
</view>
<view class="agreement">
<image class="img1" @click="toggleImg()" v-if="isToggle" src="@/static/icon-check-on.png"></image>
<image class="img2" @click="toggleImg()" v-else src="@/static/icon-check.png"></image>
请阅读并同意<text @click="openPage()">《会员协议》</text>
</view>
</view>
<view class="task-fd" v-if="payInfo && payInfo.length >= 1">
<view class="btn" @click="toCreate()" v-if="list && list.length > 0">立即支付¥{{list[tabIndex].presentPrice}}</view>
</view>
</view>
</template>
<script>
const systemInfo = uni.getSystemInfoSync();
export default {
data() {
return {
platform: "ios",
list: [],
userInfo: {},
isToggle: false,
tabIndex: 0,
payIndex: -1,
background: {
// 导航栏背景图
background: 'url(https://api.lyiyuan.cn/profile/upload/static/task-bg.png) center top no-repeat',
// 还可以设置背景图size属性
backgroundSize: '100 auto',
},
payInfo: [],
payType: "",
huiyuanInfo: {}
};
},
onReady() {
this.platform = systemInfo.platform;
console.log(systemInfo.platform)
this.getUserInfo();
this.getList();
this.getConfigData();
},
methods: {
openPage() {
uni.navigateTo({
url: "/pages/users/about/index?type=CONFIG_MEMBERSHIP_AGREEMENT"
})
},
tabItem(i){
this.tabIndex = i;
},
tabPay(i,a){
this.payIndex = i;
this.payType = a
},
toggleImg() {
this.isToggle = !this.isToggle;
},
//查询会员权益
async membershipBenefits() {
const { code, data , msg } = await this.$api.membershipBenefits({userId: uni.getStorageSync("userInfo").id});
if(code == 200){
this.huiyuanInfo = data;
}else{
uni.showToast({
title: msg,
position: "bottom",
icon: "none",
})
}
},
//查询个人信息
async getUserInfo() {
const { code, data , msg } = await this.$api.findUserInfo({userId: uni.getStorageSync("userInfo").id});
if(code == 200){
this.userInfo = data;
if(data.memberflag>=1){
this.membershipBenefits();
}
}else{
uni.showToast({
title: msg,
position: "bottom",
icon: "none",
})
}
},
//会员列表
async getList() {
const {code, data } = await this.$api.memberList({});
if(code == 200){
this.list = data
}
},
//字典查询
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(",");
console.log(this.payInfo)
}
},
//创建订单
async toCreate() {
const that = this;
if(this.isToggle == false){
uni.showToast({
icon: "none",
position: "bottom",
title: "请选择会员协议"
})
return ;
}
if(!this.payType){
uni.showToast({
icon: "none",
position: "bottom",
title: "请选择支付方式"
})
return ;
}
if(this.payType == 'integral-1'){
if(this.list[this.tabIndex].presentPrice > this.userInfo.money){
uni.showToast({
icon: "none",
position: "bottom",
title: "账户余额不足"
})
return ;
}
}
if(this.platform == 'ios'){
if(this.payType == 'ios-1'){
uni.getProvider({
service: 'payment',
success: (res) => {
const iapChannel = res.providers.find((channel) => {
console.log(channel)
return (channel.id === 'appleiap')
})
// 如果 iapChannel 为 null,说明当前包没有包含iap支付模块。注意:HBuilder基座不包含 iap 通道
console.log(res)
}
});
}
return ;
}
uni.showLoading({
title: "正在支付"
})
const {code, data, msg} = await that.$api.memberCreateOrder({
userId: uni.getStorageSync("userInfo").id,
memberId: that.list[that.tabIndex].id
})
if(code == 200){
that.toPay(msg);
}else{
uni.hideLoading()
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:(that.payType=='ali-1'?2:3),
outTradeNo
})
if(code == 200){
console.log(data)
uni.hideLoading()
if(that.payType == 'integral-1'){
uni.showToast({
title: "支付成功"
})
that.payType = ""
that.getUserInfo();
that.getList();
return ;
}
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: "支付成功"
})
that.getUserInfo();
that.getList();
},
fail: function (err) {
console.log('fail:' + JSON.stringify(err));
}
});
}else{
uni.hideLoading()
uni.showToast({
icon: "none",
position: "bottom",
title: msg
})
}
},
}
}
</script>
<style scoped lang="scss">
.task{
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-bottom: 180rpx;
&-fd{
background-color: #F3F4F5;
width: 100%;
padding: 30rpx 25rpx;
box-sizing: border-box;
position: fixed;
left: 0;
bottom: 0;
z-index: 22;
.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;
text-align: center;
font-weight: 400;
font-size: 30rpx;
color: #FFFFFF;
letter-spacing: 5rpx;
}
}
&-content{
padding: 0 25rpx;
overflow: hidden;
margin-top: 20rpx;
.info{
width: 100%;
background: linear-gradient(90deg, #17150E, #373632);
border-radius: 20rpx;
padding: 40rpx 50rpx;
box-sizing: border-box;
.a{
width: 100%;
display: flex;
align-items: center;
margin-top: 10rpx;
.fl{
flex: 1;
display: flex;
align-items: center;
}
.king{
width: 135rpx;
height: 82rpx;
}
.pic{
width: 100rpx;
height: 100rpx;
margin-right: 20rpx;
image{
width: 100%;
height: 100%;
border-radius: 50%;
}
}
.xinxi{
flex: 1;
.name{
font-weight: 500;
font-size: 30rpx;
color: #E7D4B8;
display: flex;
align-items: center;
text{
margin-left: 20rpx;
display: block;
width: 88rpx;
height: 44rpx;
line-height: 44rpx;
background: #FED0A7;
border-radius: 20rpx 0px 20rpx 0px;
font-weight: 500;
font-size: 24rpx;
color: #693A16;
text-align: center;
}
}
.status{
font-weight: 500;
font-size: 24rpx;
color: #E7D4B8;
margin-top: 10rpx;
}
}
}
.b{
font-weight: 500;
font-size: 24rpx;
color: #E7D4B8;
margin-top: 30rpx;
}
}
.title{
font-weight: 500;
font-size: 32rpx;
color: #222222;
margin-top: 30rpx;
}
.agreement{
display: flex;
align-items: center;
justify-content: flex-start;
font-weight: 400;
font-size: 28rpx;
color: #999999;
margin-top: 30rpx;
image{
width: 32rpx;
height: 32rpx;
margin-right: 10rpx;
}
text{
color: #000000;
}
}
.pay{
padding: 0 30rpx;
background: #FFFFFF;
border-radius: 20rpx;
margin-top: 20rpx;
.item{
padding: 30rpx 0;
border-top: 1px solid #EAEAEA;
display: flex;
align-items: center;
justify-content: space-between;
font-weight: 400;
font-size: 28rpx;
color: #333333;
&:first-child{
border-top-color: #FFFFFF;
}
.a{
flex: 1;
text{
margin-left: 20rpx;
font-size: 22rpx;
color: #999999;
}
display: flex;
align-items: center;
image{
width: 60rpx;
height: 60rpx;
margin-right: 10rpx;
}
}
.b{
image{
width: 32rpx;
height: 32rpx;
margin-left: 20rpx;
}
.img1{
display: block;
}
.img2{
display: none;
}
}
&-on{
.b{
.img1{
display: none;
}
.img2{
display: block;
}
}
}
}
}
.kaitong{
white-space: nowrap;
margin-top: 40rpx;
.item{
display: inline-block;
width: 220rpx;
height: 280rpx;
background: #FFFFFF;
border: 1px solid #FFFFFF;
border-radius: 20rpx;
text-align: center;
position: relative;
margin-left: 20rpx;
&:first-child{
margin-left: 0;
}
.a{
font-weight: 500;
font-size: 30rpx;
color: #666666;
margin-top: 60rpx;
}
.b{
font-weight: 500;
font-size: 24rpx;
color: #222222;
margin-top: 10rpx;
text{
font-size: 36rpx;
}
}
.c{
font-weight: 500;
font-size: 30rpx;
color: #666666;
margin-top: 10rpx;
}
.d{
font-weight: 400;
font-size: 24rpx;
color: #999999;
text-decoration-line: line-through;
margin-top: 10rpx;
}
.e{
width: 98rpx;
line-height: 50rpx;
background: linear-gradient(0deg, #000000, #3D3B38);
box-shadow: 0px 4rpx 18rpx 0px rgba(42,41,39,0.34);
border-radius: 20rpx 0px 20rpx 0px;
position: absolute;
left: 0;
top: 0;
z-index: 2;
text-align: center;
font-weight: 500;
font-size: 24rpx;
color: #F3F4F5;
}
&-on{
background: #EDEDED;
border: 1px solid #000000;
}
}
}
.content{
margin-top: 10rpx;
overflow: hidden;
.item{
width: 100%;
height: 100rpx;
background: #FFFFFF;
border-radius: 20rpx;
display: flex;
align-items: center;
justify-content: space-between;
margin-top: 20rpx;
padding: 0 20rpx;
box-sizing: border-box;
.a{
flex: 1;
font-weight: 500;
font-size: 24rpx;
color: #222222;
display: flex;
align-items: center;
.btn{
width: 130rpx;
line-height: 50rpx;
border-radius: 50rpx;
text-align: center;
font-weight: 500;
font-size: 24rpx;
background: linear-gradient(0deg, #000000, #3D3B38);
box-shadow: 0px 4rpx 18rpx 0px rgba(42,41,39,0.34);
color: #FFFFFF;
margin-right: 20rpx;
}
.txt{
width: 420rpx;
}
}
.b{
margin-left: 40rpx;
image{
width: 64rpx;
height: 69rpx;
}
}
}
}
}
}
</style>