620 lines
14 KiB
Vue
620 lines
14 KiB
Vue
<template>
|
||
<view class="member-card-box">
|
||
<navigation-bar-vue title="会员中心" style="width: 100%;" background-color="#262626"
|
||
title-color="#FFFFFF"></navigation-bar-vue>
|
||
<view class="main-body">
|
||
<!-- 会员卡展示区 -->
|
||
<view class="vip-box">
|
||
<view class="dl-menu-box">
|
||
<view v-for="(item,index) in memberCardList" @click="itemClick(index)" class="dl-menu"
|
||
:class="index==chooseCardIndex?'dl-menu click':'dl-menu'">
|
||
<!-- 这里的图标要换成动态配置的 -->
|
||
<image src="@/static/mine/huang.png" mode="aspectFit"></image>
|
||
{{item.cardName}}
|
||
</view>
|
||
</view>
|
||
<!-- 会员卡详情 -->
|
||
<view class="card-detail-box">
|
||
<view class="price-box">
|
||
<view
|
||
:class="['price-item',choosePriceIndex==index?'choose':'',1==index?'margin-left-right':'']"
|
||
v-for="(item,index) in memberCardList[chooseCardIndex].priceList"
|
||
@click="changePriceIndex(index)">
|
||
<image v-if="item.isHot" class="hot-img" src="@/static/mine/hot.png" mode="aspectFit">
|
||
</image>
|
||
<view class="text1">{{item.title}}</view>
|
||
<view class="text2"><text>¥</text>{{item.price}}</view>
|
||
<view class="text3">折合{{item.dayPrice}}元/天</view>
|
||
</view>
|
||
</view>
|
||
<!-- 购买 -->
|
||
<!-- #ifdef H5 -->
|
||
<view class="buy-button" @click="toOrder()">立即开通</view>
|
||
<!-- #endif -->
|
||
<!-- 调整h5 -->
|
||
<!-- #ifdef MP-WEIXIN -->
|
||
<view class="buy-button" @click="openVip()">立即开通</view>
|
||
|
||
<!-- #endif -->
|
||
<!-- 协议 -->
|
||
<view class="xieyi-box">
|
||
开通即代表您已阅读并同意<text
|
||
@click="handleUserAgrement(globalConfig.appInfo.agreements[2])">《{{globalConfig.appInfo.agreements[2].title}}》</text>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
<!-- 权益展示区 -->
|
||
<view class="rights-box">
|
||
<view class="rights-item title">
|
||
<view class="title-left">会员权益</view>
|
||
<view class="value-item" v-for="(item,index) in cardList">{{item.cardName}}</view>
|
||
</view>
|
||
<view class="rights-item item-bg" v-for="(item,index) in rightsList">
|
||
<view class="title-left">{{item.name}}</view>
|
||
<view :class="[i==cardList.length-1?'value-item yellow-bg':'value-item']"
|
||
v-for="(card,i) in cardList">
|
||
<view v-if="'02'==item.rightsType">
|
||
<!-- 数量限制 -->
|
||
<text v-if="0==item.cardRights[card.id]">无限</text>
|
||
<text v-else>{{item.cardRights[card.id]}}条</text>
|
||
</view>
|
||
<view v-else-if="'01'==item.rightsType">
|
||
<!-- 是否支持 -->
|
||
<text v-if="0==item.cardRights[card.id]">-</text>
|
||
<view v-else>
|
||
<uni-icons v-if="i==cardList.length-1" color="#3A3A38" type="checkmarkempty"
|
||
size="18"></uni-icons>
|
||
<uni-icons v-else color="#E8CEAD" type="checkmarkempty" size="18"></uni-icons>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
</template>
|
||
|
||
<script>
|
||
import navigationBarVue from '@/components/navigation/navigationBar.vue';
|
||
import {
|
||
baseCardList,
|
||
rightList
|
||
} from '@/api/business/base.js'
|
||
import {
|
||
saveOrder,
|
||
prepayment
|
||
} from '@/api/business/member.js'
|
||
import {
|
||
getToken
|
||
} from '@/utils/auth'
|
||
import {
|
||
getCodeUrl,
|
||
getWebAccessTokenAndOpenid,
|
||
gzhLogin
|
||
} from '@/api/wxApi'
|
||
export default {
|
||
components: {
|
||
navigationBarVue
|
||
},
|
||
data() {
|
||
return {
|
||
globalConfig: getApp().globalData.config,
|
||
ifAgree: 0,
|
||
//当前选中的会员卡下标
|
||
chooseCardIndex: 0,
|
||
//当前选中的会员卡付款下标
|
||
choosePriceIndex: 0,
|
||
//用户类型
|
||
userType: '02',
|
||
// 会员卡数组
|
||
memberCardList: [{
|
||
id: "1",
|
||
cardName: "箐英会员",
|
||
image: "",
|
||
priceList: [{
|
||
title: "年付会员",
|
||
price: 228,
|
||
dayPrice: 0.82,
|
||
isHot: true
|
||
}, {
|
||
title: "季付会员",
|
||
price: 78,
|
||
dayPrice: 0.82,
|
||
isHot: false
|
||
}, {
|
||
title: "月付会员",
|
||
price: 28,
|
||
dayPrice: 0.82,
|
||
isHot: false
|
||
}]
|
||
}, {
|
||
id: "2",
|
||
cardName: "钻石会员",
|
||
image: "",
|
||
priceList: [{
|
||
title: "年付会员",
|
||
price: 1228,
|
||
dayPrice: 0.82,
|
||
isHot: true
|
||
}, {
|
||
title: "季付会员",
|
||
price: 178,
|
||
dayPrice: 0.82,
|
||
isHot: false
|
||
}, {
|
||
title: "月付会员",
|
||
price: 128,
|
||
dayPrice: 0.82,
|
||
isHot: false
|
||
}]
|
||
}],
|
||
//权益对比的数组
|
||
cardList: [{
|
||
id: '1',
|
||
cardName: '非会员'
|
||
}, {
|
||
id: '2',
|
||
cardName: '箐英'
|
||
}, {
|
||
id: '3',
|
||
cardName: '钻石'
|
||
}],
|
||
rightsList: [{
|
||
name: "每日解锁通告上限",
|
||
// 权益类型 01-是否支持 | 02-数量限制
|
||
rightsType: '02',
|
||
cardRights: {
|
||
"1": 20,
|
||
"2": 0,
|
||
"3": 0
|
||
}
|
||
}, {
|
||
name: "高奖励&最新通告",
|
||
// 权益类型 01-是否支持 | 02-数量限制
|
||
rightsType: '01',
|
||
cardRights: {
|
||
"1": 0,
|
||
"2": 1,
|
||
"3": 1
|
||
}
|
||
}]
|
||
}
|
||
},
|
||
|
||
onLoad(options) {
|
||
let userTypeTemp = options.userType
|
||
this.initData(userTypeTemp);
|
||
//获取url中的search
|
||
if (options.code) {
|
||
userTypeTemp = options.state
|
||
let that = this
|
||
getWebAccessTokenAndOpenid(options.code).then(res => {
|
||
that.$store.dispatch('GzhLogin', res).then(() => {
|
||
that.initData(userTypeTemp);
|
||
that.loginSuccess()
|
||
}).catch((e) => {
|
||
uni.showToast({
|
||
icon: 'error',
|
||
duration: 2000,
|
||
title: e
|
||
});
|
||
})
|
||
})
|
||
} else {
|
||
this.toLogin(userTypeTemp)
|
||
}
|
||
},
|
||
|
||
methods: {
|
||
openVip() {
|
||
// 在你想触发跳转的地方
|
||
wx.openOfficialAccountProfile({
|
||
username: 'tonggaokuaijie', // 此处填写公众号的微信号
|
||
success: res => {},
|
||
fail: res => {}
|
||
})
|
||
|
||
},
|
||
// 登录成功后,处理函数
|
||
loginSuccess(result) {
|
||
// 设置用户信息
|
||
this.$store.dispatch('GetInfo').then(res => {
|
||
|
||
})
|
||
},
|
||
toLogin(userType) {
|
||
/*#ifdef APP-PLUS*/
|
||
// App端特有的逻辑
|
||
console.log('Running on App-Plus');
|
||
/*#endif*/
|
||
/*#ifdef H5*/
|
||
// 在浏览器端(H5)执行的逻辑
|
||
|
||
//未登录状态
|
||
getCodeUrl(userType, "pages/mine/member/member-card").then(res => {
|
||
window.location.href = res.codeUrl;
|
||
})
|
||
|
||
/*#endif*/
|
||
/*#ifdef MP-WEIXIN*/
|
||
// 微信小程序端执行的逻辑
|
||
console.log('Running on WeChat Mini Program');
|
||
/*#endif*/
|
||
|
||
},
|
||
/**初始化*/
|
||
initData(userType) {
|
||
|
||
if (getToken() && userType) {
|
||
this.userType = userType
|
||
this.getCardList(userType);
|
||
this.getRightsList(userType);
|
||
}
|
||
|
||
},
|
||
|
||
/**获取会员卡列表*/
|
||
getCardList(userType) {
|
||
baseCardList({
|
||
userType: userType
|
||
}).then(res => {
|
||
this.memberCardList = res.data
|
||
}).catch((e) => {
|
||
uni.showToast({
|
||
icon: 'error',
|
||
duration: 2000,
|
||
title: e
|
||
});
|
||
})
|
||
},
|
||
/**权益列表*/
|
||
getRightsList(userType) {
|
||
rightList({
|
||
userType: userType
|
||
}).then(res => {
|
||
this.cardList = res.data.cardList
|
||
this.rightsList = res.data.rightsList
|
||
console.log(this.cardList, 'cardList')
|
||
console.log(this.rightsList, 'rightsList')
|
||
}).catch((e) => {
|
||
uni.showToast({
|
||
icon: 'error',
|
||
duration: 2000,
|
||
title: e
|
||
});
|
||
})
|
||
},
|
||
/**
|
||
* 菜单点击
|
||
* @param {Object} index
|
||
*/
|
||
itemClick(index) {
|
||
this.chooseCardIndex = index
|
||
this.choosePriceIndex = 0
|
||
},
|
||
/**
|
||
* 切换选中的会员卡付款类型
|
||
* @param {Object} index
|
||
*/
|
||
changePriceIndex(index) {
|
||
this.choosePriceIndex = index
|
||
},
|
||
/**
|
||
* 阅读会员协议
|
||
*/
|
||
// 查看相关协议
|
||
handleUserAgrement(site) {
|
||
this.$tab.navigateTo(`/pages/common/richview/index?title=${site.title}&code=${site.code}`)
|
||
},
|
||
toOpenH5() {
|
||
|
||
},
|
||
/**生成订单*/
|
||
async toOrder() {
|
||
let data = {
|
||
userType: this.userType,
|
||
orderType: '01',
|
||
goodsId: this.memberCardList[this.chooseCardIndex].id,
|
||
goodsNum: 1,
|
||
goodsPrice: this.memberCardList[this.chooseCardIndex].priceList[this.choosePriceIndex].price,
|
||
}
|
||
if (this.memberCardList[this.chooseCardIndex].priceList[this.choosePriceIndex].title === '年付会员') {
|
||
data.goodsCycle = '03'
|
||
}
|
||
if (this.memberCardList[this.chooseCardIndex].priceList[this.choosePriceIndex].title === '季付会员') {
|
||
data.goodsCycle = '02'
|
||
}
|
||
if (this.memberCardList[this.chooseCardIndex].priceList[this.choosePriceIndex].title === '月付会员') {
|
||
data.goodsCycle = '01'
|
||
}
|
||
let that = this
|
||
saveOrder(data).then(res => {
|
||
if (res.code == 200) {
|
||
//吊起支付
|
||
let payData = {
|
||
orderNo: res.data.orderNo
|
||
}
|
||
prepayment(payData).then(paymentData => {
|
||
that.wxpay(paymentData)
|
||
})
|
||
// uni.navigateBack()
|
||
}
|
||
}).catch((e) => {
|
||
uni.showToast({
|
||
icon: 'error',
|
||
duration: 2000,
|
||
title: e
|
||
});
|
||
})
|
||
},
|
||
// 检测支付环境中的 WeixinJSBridge
|
||
wxpay(data) {
|
||
if (typeof WeixinJSBridge == "undefined") {
|
||
if (document.addEventListener) {
|
||
document.addEventListener('WeixinJSBridgeReady', onBridgeReady(data), false);
|
||
} else if (document.attachEvent) {
|
||
document.attachEvent('WeixinJSBridgeReady', onBridgeReady(data));
|
||
document.attachEvent('onWeixinJSBridgeReady', onBridgeReady(data));
|
||
}
|
||
} else {
|
||
this.onBridgeReady(data);
|
||
}
|
||
},
|
||
|
||
onBridgeReady(data) {
|
||
|
||
WeixinJSBridge.invoke(
|
||
'getBrandWCPayRequest', {
|
||
// 传入第一步后端接口返回的核心参数
|
||
"appId": data.appId, //公众号
|
||
"timeStamp": data.timeStamp, //时间戳
|
||
"nonceStr": data.nonceStr, //随机串
|
||
"package": data.packageVal, //prepay_id
|
||
"signType": data.signType, //微信签名方式RSA
|
||
"paySign": data.paySign //微信签名
|
||
},
|
||
function(res) {
|
||
// 支付成功
|
||
if (res.err_msg == "get_brand_wcpay_request:ok") {
|
||
// 使用以上方式判断前端返回,微信团队郑重提示:
|
||
//res.err_msg将在用户支付成功后返回ok,但并不保证它绝对可靠。
|
||
}
|
||
// 支付过程中用户取消
|
||
if (res.err_msg == "get_brand_wcpay_request:cancel") {
|
||
|
||
}
|
||
// 支付失败
|
||
if (res.err_msg == "get_brand_wcpay_request:fail") {
|
||
|
||
}
|
||
/**
|
||
* 其它
|
||
* 1、请检查预支付会话标识prepay_id是否已失效
|
||
* 2、请求的appid与下单接口的appid是否一致
|
||
* */
|
||
if (res.err_msg == "调用支付JSAPI缺少参数:total_fee") {
|
||
|
||
}
|
||
});
|
||
}
|
||
|
||
|
||
}
|
||
}
|
||
</script>
|
||
|
||
<style lang="scss">
|
||
.member-card-box {
|
||
width: 100%;
|
||
padding-top: calc(90rpx + var(--status-bar-height));
|
||
color: #363636;
|
||
font-size: 29rpx;
|
||
background-color: #262626;
|
||
height: 100%;
|
||
display: flex;
|
||
flex-direction: column;
|
||
align-items: center;
|
||
justify-content: center;
|
||
position: relative;
|
||
|
||
.main-body {
|
||
width: 100%;
|
||
height: calc(100vh - var(--status-bar-height) - var(--window-bottom) - 90rpx);
|
||
overflow-y: scroll;
|
||
padding: 20rpx;
|
||
display: flex;
|
||
flex-direction: column;
|
||
align-items: center;
|
||
justify-content: flex-start;
|
||
|
||
.vip-box {
|
||
width: 100%;
|
||
flex-direction: column;
|
||
align-items: center;
|
||
justify-content: flex-start;
|
||
padding-bottom: 20rpx;
|
||
|
||
.dl-menu-box {
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: flex-start;
|
||
width: 100%;
|
||
color: #888888;
|
||
padding-top: 20rpx;
|
||
|
||
.dl-menu {
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
font-size: 30rpx;
|
||
margin: 0 20rpx;
|
||
padding-bottom: 15rpx;
|
||
text-align: center;
|
||
|
||
image {
|
||
width: 38rpx;
|
||
height: 38rpx;
|
||
margin-right: 5rpx;
|
||
}
|
||
}
|
||
|
||
.click {
|
||
color: white;
|
||
font-weight: bold;
|
||
border-bottom: 2px solid white;
|
||
}
|
||
}
|
||
|
||
.card-detail-box {
|
||
width: 100%;
|
||
margin-top: 20rpx;
|
||
padding: 40rpx 20rpx 30rpx 20rpx;
|
||
border-radius: 20rpx;
|
||
border: 1rpx solid #96948C;
|
||
background-color: #1A1A1A;
|
||
display: flex;
|
||
flex-direction: column;
|
||
align-items: center;
|
||
justify-content: center;
|
||
|
||
.price-box {
|
||
width: 100%;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
|
||
.price-item {
|
||
display: flex;
|
||
flex-direction: column;
|
||
align-items: center;
|
||
justify-content: center;
|
||
width: 33%;
|
||
padding: 30rpx 20rpx;
|
||
color: #FAE4C8;
|
||
background-color: #302D29;
|
||
border-radius: 25rpx;
|
||
padding: 30rpx 20rpx;
|
||
position: relative;
|
||
|
||
.hot-img {
|
||
width: 80rpx;
|
||
height: 80rpx;
|
||
position: absolute;
|
||
top: -20px;
|
||
left: 0;
|
||
}
|
||
|
||
.text1 {
|
||
font-weight: bold;
|
||
font-size: 26rpx;
|
||
}
|
||
|
||
.text2 {
|
||
margin: 15rpx;
|
||
font-weight: bold;
|
||
font-size: 40rpx;
|
||
|
||
text {
|
||
font-size: 20rpx;
|
||
margin-right: 10rpx;
|
||
}
|
||
}
|
||
|
||
.text3 {
|
||
font-size: 20rpx;
|
||
}
|
||
|
||
|
||
}
|
||
|
||
.margin-left-right {
|
||
margin: 0 25rpx;
|
||
}
|
||
|
||
.choose {
|
||
color: #603B25 !important;
|
||
background-image: linear-gradient(to bottom, #F8DFC0, #EFCBA0);
|
||
}
|
||
}
|
||
|
||
.buy-button {
|
||
width: 100%;
|
||
padding: 20rpx 0;
|
||
color: #010000;
|
||
background-image: linear-gradient(to right, #F8DFC0, #EFCBA0);
|
||
margin-top: 40rpx;
|
||
text-align: center;
|
||
font-weight: bold;
|
||
font-size: 32rpx;
|
||
border-radius: 50rpx;
|
||
}
|
||
|
||
.xieyi-box {
|
||
width: 100%;
|
||
font-size: 20rpx;
|
||
color: #707070;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
margin-top: 20rpx;
|
||
|
||
text {
|
||
color: #FFFFFF;
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
}
|
||
|
||
.rights-box {
|
||
width: 100%;
|
||
padding: 0 20rpx 30rpx 20rpx;
|
||
border-radius: 20rpx;
|
||
border: 1rpx solid #96948C;
|
||
background-color: #363636;
|
||
color: #E8CEAD;
|
||
display: flex;
|
||
flex-direction: column;
|
||
align-items: center;
|
||
justify-content: center;
|
||
|
||
.rights-item {
|
||
width: 100%;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
|
||
.title-left {
|
||
width: 260rpx;
|
||
padding: 20rpx 0 20rpx 20rpx;
|
||
}
|
||
|
||
.value-item {
|
||
flex: 1;
|
||
text-align: center;
|
||
padding: 20rpx;
|
||
}
|
||
}
|
||
|
||
.title {
|
||
font-weight: bold;
|
||
}
|
||
|
||
.item-bg {
|
||
font-size: 24rpx;
|
||
background-color: #42403E;
|
||
border-radius: 15rpx;
|
||
margin-bottom: 20rpx;
|
||
|
||
.yellow-bg {
|
||
background-color: #F3D2A6;
|
||
border-radius: 0 15rpx 15rpx 0;
|
||
color: #3A3A38;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
</style>
|