sadjv3_user/my/vip/index.vue

849 lines
21 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<view class="content">
<view class="bgbox" style="" v-if="vipData.isVip!='1'">
<view class="bgbox-top">
<image src="../../static/vip/banner9.jpg" mode=""></image>
</view>
<view class="quanyi_view">
<view class="quanyi_titview">
<view class="quanyi_titview-list" v-if="vipData.isVip!=1">
<view v-for="(item,index) in vipList" :key='index' @click="select(item)" class="vip-list">
<!-- <view class="biaoqian">新用户特惠</view> -->
<view class="text-center flex flex-direction justify-between padding-tb radius"
:class="selNum == item.id?'active': 'noactive'">
<view class="text-bold" style="font-size: 36rpx;">{{item.vipName}}</view>
<view class="text-bold text-money" style="font-size: 30rpx;">
<text class="text-xxl" style="margin-bottom:16rpx;font-size: 37rpx;margin-left:-10rpx;color: #D33232;">
<text style="font-size: 14px;">
</text>
{{item.money}}
</text>
<text v-if="item.oldMoney" class="text-xxl" style="font-size: 13px;margin-left:-10rpx;color: #848484;text-decoration-line: line-through;">
<text style="font-size: 13px;">
</text>
{{item.oldMoney}}
</text>
</view>
</view>
</view>
</view>
<view class="save_vipbtn" v-if="vipData.isVip!=1" @tap="openShow">立即开通</view>
<view class="footer">
<image v-if="showAgree" @tap="isShowAgree"
src="../../static/duihao.png"
style="width: 30upx;height: 30upx;"></image>
<image v-else @tap="isShowAgree"
src="https://api.shengqianxiong.com.cn/img/20201112/1e9102fc891f4d86a13c7b2ba6921cba.png"
style="width: 30upx;height: 30upx;"></image>
<text style="margin-left: 10upx;margin-right: 0;">同意</text>
<!-- 协议地址 -->
<navigator url="/pages/my/hyXy" open-type="navigate" style="color: #019c88;">《会员协议》</navigator>
</view>
<!-- <view class="quanyi-line"><image style="width:100%;height:180px;object-fit: contain;" src="../../static/vip/Equity4.png"></image></view> -->
<view class="quanyi_titname">~VIP超值权益~</view>
<view class="quanyi_itemview" style="margin-bottom: 60rpx;">
<view class="quanyi_listitem">
<image src="../../static/vip/Equity2.png"></image>
<view class="listitem_name">会员优享{{rateStr}}折</view>
</view>
<view class="quanyi_listitem">
<image src="../../static/vip/Equity1.png"></image>
<view class="listitem_name">专属客服</view>
</view>
<view class="quanyi_listitem">
<image src="../../static/vip/Equity3.png"></image>
<view class="listitem_name">极速退款</view>
</view>
</view>
</view>
</view>
</view>
<view class="bgbox" style="" v-else>
<view class="bgbox-top-show">
<image class="bgbox-top-img" v-if="vipNameType=='0'" src="../../static/vip/membership2.png" mode=""></image>
<image class="bgbox-top-img" v-if="vipNameType=='1'" src="../../static/vip/membership.png" mode=""></image>
<image class="bgbox-top-img" v-if="vipNameType=='2'" src="../../static/vip/membership3.png" mode=""></image>
<view class="bgbox-top-show-youxiao">
到期时间 {{timeVipEnd}}
</view>
</view>
<view class="bgbox-mian">VIP超值权益</view>
<view class="quanyi_view">
<view class="quanyi_titview">
<view class="quanyi_titname">~VIP超值权益~</view>
<view class="quanyi_itemview" style="margin-bottom: 60rpx;">
<view class="quanyi_listitem">
<image src="../../static/vip/Equity2.png"></image>
<view class="listitem_name">会员优享{{rateStrs}}折</view>
</view>
<view class="quanyi_listitem">
<image src="../../static/vip/Equity1.png"></image>
<view class="listitem_name">专属客服</view>
</view>
<view class="quanyi_listitem">
<image src="../../static/vip/Equity3.png"></image>
<view class="listitem_name">极速退款</view>
</view>
</view>
</view>
</view>
</view>
<!-- 支付方式 -->
<u-popup v-model="showpay" mode="bottom">
<view class="popup_pay">
<view style="background-color: #fff;">
<view style="padding: 0 20upx;margin-top: 30rpx;margin-bottom: 20rpx;">
<view
style="display: flex;height: 100upx;align-items: center;padding: 20upx 0;justify-content: center;"
v-for="(item,index) in openLists" :key='index'>
<image :src="item.image" style="width: 55upx;height: 55upx;border-radius: 50upx;">
</image>
<view style="font-size: 30upx;margin-left: 20upx;width: 70%;">
{{item.text}}
</view>
<radio-group name="openWay" style="margin-left: 45upx;" @tap='selectWay(item.id)'>
<label class="tui-radio">
<radio color="#019c88" :checked="openWay === item.id ? true : false" />
</label>
</radio-group>
</view>
</view>
</view>
<view class="pay_btn" @click="pay()">确认支付</view>
</view>
</u-popup>
</view>
</template>
<script>
export default {
data() {
return {
showAgree: false, //协议是否选择
timeVipEnd: '',
customStyle: {
width: '250rpx',
color: '#402321',
background: "#DFC5A7",
border: 0,
fontWeight: '700'
},
avatar: '',
userName: '匿名',
vipList: [],
selNum: 0,
newPrice: 0,
money: 0,
price: 0,
MemberList: [],
isVip: true,
openLists: [],
openWay: 2,
showpay: false,
vipData:[],
vipShow:false,
rateStr:'',
vipNameType:'',
rateStrs:''
}
},
onLoad() {
this.avatar = uni.getStorageSync('avatar')
this.userName = uni.getStorageSync('userName')
// #ifdef MP-WEIXIN
this.openWay = 1;
this.openLists = [{
image: '../static/icon_weixin.png',
text: '微信',
id: 1
}, {
image: '../../static/images/lingqian.png',
text: '余额',
id: 3
}]
// #endif
// #ifndef MP-WEIXIN
this.openWay = 1;
this.openLists = [{
image: '../static/icon_weixin.png',
text: '微信',
id: 1
}, {
image: '../static/zhifubao.png',
text: '支付宝',
id: 2
}, {
image: '../../static/images/lingqian.png',
text: '余额',
id: 3
}]
// #endif
this.getVipList()
this.getvipEndTime();
this.getMemberList()
this.getMoney()
this.getIsVip()
},
methods: {
isShowAgree() {
//是否选择协议
this.showAgree = !this.showAgree;
},
select(e) {
this.selNum = e.id;
this.price = e.money;
this.vipData.rateStr=e.rateStr;
this.rateStr=e.rateStr;
console.log("rateStr",e)
},
selectWay: function(id) {
this.openWay = id;
},
getvipEndTime() {
this.$Request.get("/app/UserVip/selectUserVip").then(res => {
if (res.code == 0) {
var data= res.data.endTime||{};
this.$queue.setData('isVIP',res.data.isVip);
this.vipNameType=res.data.vipNameType
this.vipData=res.data;
this.rateStrs=res.data.vipDetails.rate/10
console.log("isVIP------------------->",this.vipData)
this.timeVipEnd = data.slice(0,16);
this.getVipList(res.data.vipNameType)
}
});
},
//获取VIP列表
getVipList(vipNameType) {
var that=this;
var vipNameType=vipNameType;
that.$Request.get('/app/VipDetails/selectVipDetails').then(res => {
if (res.code == 0) {
that.vipList = res.data;
// that.rateStr=that.vipList[0].rateStr;
// for(var i=0;i<res.data.length;i++){
// if(vipNameType==res.data[i].vipNameType){
// that.rateStr=res.data[i].rateStr
// that.selNum = res.data[i].id
// that.price = res.data[i].money
// }
// }
that.rateStr=res.data[0].rateStr
that.selNum = res.data[0].id
that.price = res.data[0].money
// for(var i=0;i<res.data.length;i++){
// that.selNum = res.data[i].id
// that.price = res.data[i].money
// }
}
})
},
// 获取特权列表
getMemberList() {
this.$Request.get('/app/member/selectMemberList').then(res => {
if (res.code == 0) {
this.MemberList = res.data
}
})
},
getIsVip() {
this.$Request.get("/app/UserVip/isUserVip").then(res => {
if (res.code == 0) {
this.isVip = res.data;
this.$queue.setData('isVIP',this.isVip)
if (this.isVip) {
this.getvipEndTime();
}
}
});
},
// 我的金元
getMoney() {
this.$Request.get("/app/userMoney/selectMyMoney").then(res => {
if (res.code == 0 && res.data) {
this.money = res.data.money
}
});
},
openShow(){
if (this.showAgree == false) {
uni.showToast({
icon: 'none',
position: 'bottom',
title: '请同意《会员协议》'
});
}else{
this.showpay=true
}
},
pay() {
this.getMoney()
this.showpay = false;
// this.$queue.showLoading('支付中...')
let that = this;
let data = {
id: this.selNum,
type: '2'
}
if (this.openWay == 1) {
// #ifdef MP-WEIXIN
that.$Request.postT("/app/wxPay/payUserVip", {
vipDetailsId: that.selNum,
type: 3
}).then(red => {
if (red.code == 0) {
uni.requestPayment({
provider: 'wxpay',
timeStamp: red.data.timestamp,
nonceStr: red.data.noncestr,
package: red.data.package,
signType: red.data.signType,
paySign: red.data.sign,
success: function(redd) {
uni.hideLoading();
uni.showToast({
title: '开通成功!'
})
setTimeout(function() {
that.isVip = true
that.getIsVip()
}, 1000)
},
fail: function(err) {
uni.hideLoading();
that.$queue.showToast(
'支付失败');
}
});
} else {
uni.showToast({
title: red.msg,
icon: 'none'
})
}
});
// #endif
// #ifdef H5
let ua = navigator.userAgent.toLowerCase();
console.log(ua)
if (ua.indexOf('micromessenger') !== -1) {
that.$Request.post("/app/wxPay/payUserVip", {
vipDetailsId: that.selNum,
type: 2
}).then(red => {
if (red.code == 0) {
uni.hideLoading();
uni.showToast({
title: '开通成功!'
})
that.getIsVip()
that.callPay(red.data);
} else {
uni.showToast({
title: red.msg,
icon: 'none'
})
}
});
}else{
that.$Request.post("/app/wxPay/payUserVip", {
vipDetailsId: that.selNum,
type: 4
}).then(red => {
if (red.code == 0) {
uni.hideLoading();
uni.showToast({
title: '开通成功!'
})
that.getIsVip()
const urlArr = window.location.href;
const hostUrl = urlArr.split("/");
const callBack = hostUrl[0] + "//" + hostUrl[2] + "/";
const url = '&redirect_url=' + callBack + 'my/vip/index';
window.location = red.data.mweb_url + url
} else {
uni.showToast({
title: red.msg,
icon: 'none'
})
}
});
}
// #endif
// #ifdef APP-PLUS
that.$Request.post("/app/wxPay/payUserVip", {
vipDetailsId: that.selNum,
type: 1
}).then(red => {
if (red.code == 0) {
uni.hideLoading();
uni.showToast({
title: '开通成功!'
})
that.getIsVip()
console.log(JSON.stringify(red))
that.setPayment('wxpay', JSON.stringify(red
.data));
} else {
uni.showToast({
title: red.msg,
icon: 'none'
})
}
});
// #endif
} else if (this.openWay == 2) {
// #ifdef H5
that.$Request.post("/app/aliPay/payUserVip ", {
vipDetailsId: that.selNum,
classify: 2
}).then(red => {
if (red.code == 0) {
uni.hideLoading();
uni.showToast({
title: '开通成功!'
})
that.getIsVip()
const div = document.createElement('div')
div.innerHTML = red.data //此处form就是后台返回接收到的数据
document.body.appendChild(div)
document.forms[0].submit()
} else {
uni.showToast({
title: red.msg,
icon: 'none'
})
}
});
// #endif
// #ifdef APP-PLUS
that.$Request.post("/app/aliPay/payUserVip", {
vipDetailsId: that.selNum,
classify: 1
}).then(red => {
if (red.code == 0) {
uni.hideLoading();
uni.showToast({
title: '开通成功!'
})
that.getIsVip()
that.setPayment('alipay', red.data);
} else {
uni.showToast({
title: red.msg,
icon: 'none'
})
}
});
// #endif
} else if (this.openWay == 3) {
if (this.money >= this.price) {
this.$Request.postT('/app/artificer/payUserVip', {
vipDetailsId: this.selNum
}).then(res => {
console.log(res.data)
if (res.code == 0) {
this.isVip = true
uni.showToast({
title: '开通成功!'
})
that.getIsVip()
// setTimeout(function() {
// uni.navigateBack()
// },1000)
} else {
this.$queue.showToast(res.msg)
}
})
} else {
uni.showModal({
title: '提示',
content: '当前账户余额不足,请充值',
success: function(res) {
if (res.confirm) {
console.log('用户点击确定');
uni.navigateTo({
url: '/my/wallet/index'
})
} else if (res.cancel) {
console.log('用户点击取消');
}
}
})
}
}
},
callPay: function(response) {
if (typeof WeixinJSBridge === "undefined") {
if (document.addEventListener) {
document.addEventListener('WeixinJSBridgeReady', this.onBridgeReady(response), false);
} else if (document.attachEvent) {
document.attachEvent('WeixinJSBridgeReady', this.onBridgeReady(response));
document.attachEvent('onWeixinJSBridgeReady', this.onBridgeReady(response));
}
} else {
this.onBridgeReady(response);
}
},
onBridgeReady: function(response) {
let that = this;
if (!response.package) {
return;
}
WeixinJSBridge.invoke(
'getBrandWCPayRequest', {
"appId": response.appid, //公众号名称,由商户传入
"timeStamp": response.timestamp, //时间戳自1970年以来的秒数
"nonceStr": response.noncestr, //随机串
"package": response.package,
"signType": response.signType, //微信签名方式:
"paySign": response.sign //微信签名
},
function(res) {
if (res.err_msg === "get_brand_wcpay_request:ok") {
// 使用以上方式判断前端返回,微信团队郑重提示:
//res.err_msg将在用户支付成功后返回ok但并不保证它绝对可靠。
uni.hideLoading();
that.isVip = true
that.getIsVip()
uni.showToast({
title: '开通成功!'
})
} else {
uni.hideLoading();
}
WeixinJSBridge.log(response.err_msg);
}
);
},
setPayment(name, order) {
let that = this;
uni.requestPayment({
provider: name,
orderInfo: order, //微信、支付宝订单数据
success: function(res) {
uni.hideLoading();
that.isVip = true
that.getIsVip()
uni.showToast({
title: '开通成功!'
})
},
fail: function(err) {
uni.hideLoading();
console.log(12)
}
});
}
},
computed: {
}
}
</script>
<style lang="scss" scoped>
.text-money{
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.quanyi-line{
width: 95%;
margin: 0 auto;
}
.quanyi-img{
width: 200px;
height: 200px;
object-fit: contain; // 图片保持原有尺寸比例,内容被缩放。
}
.footer {
margin-top: 17px;
font-size: 12px;
color: #666666;
text-align: center;
display: flex;
align-items: inherit;
width: 100%;
justify-content: center;
margin-bottom: 17px;
}
.bgbox-mian{
width: 360rpx;
height: 66rpx;
line-height: 66rpx;
border: 1px solid #f1d9b4;
font-weight: bold;
font-size: 38rpx;
text-align: center;
color: #e5c091;
margin: 40px auto 100px auto;
}
/deep/.padding-tb{
padding: 22px 0px;
}
.quanyi_titview-list{
width: 94%;
margin: 25px auto;
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-around;
}
.vip-list{
display: inline-block;
/*width: 201.39rpx;*/
height: 239.58rpx;
margin: 10rpx 10rpx;
position: relative;
}
.biaoqian{
width: 72px;
height: 25px;
line-height: 25px;
text-align: center;
background: linear-gradient(-90deg, #0CA891, #23BBA2);
border-radius: 17rpx;
font-weight: bold;
font-size: 20rpx;
color: #FFFFFF;
border-radius: 30rpx;
position: absolute;
top: 0;
margin-top: -11px;
margin-left: 3px;
}
.bgbox-top-img{
margin-top: 220rpx;
}
.bgbox-top-show-youxiao{
width: 448rpx;
height: 42rpx;
background: #ff9f65;
border-radius: 21rpx;
font-weight: 400;
font-size: 31rpx;
color: #FFE5D1;
line-height: 42rpx;
text-align: center;
text-shadow: 0rpx 0rpx 3rpx rgba(255,159,101,0.48);
margin-bottom: 70px;
position: absolute;
bottom: 0;
left: 0;
margin-left: 82px;
margin-bottom: 32px;
}
.bgbox-top-show image{
width: 620rpx;
height:360rpx;
}
.bgbox-top-show{
width: 100%;
height: 636.11rpx;
//background-image: url(../../static/vip/background-img6.png);
background-size: 100% 100%;
background-position: center center;
background-repeat: no-repeat;
background-size: cover;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
position: relative;
}
.bgbox-top{
width: 100%;
height: 500rpx;
// background-image: url("../../static/vip/banner9.jpg");
// background-repeat: no-repeat;
// background-size: 100%;
display: flex;
flex-direction: column;
}
.bgbox-top image{
width: 100%;
height: 100%;
}
.content {
width: 100%;
min-height: 100vh;
background: url(../../static/vip/banner10.jpg);
background-size: 100% 100%;
}
.bgimg {
position: absolute;
height: 100vh;
width: 100%;
}
.bgbox{
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
}
.noactive {
color: #414345;
width: 216rpx;
height: 250rpx;
background: #ECECEC;
border-radius: 20rpx;
}
.active {
color: #414345;
width: 216rpx;
height: 250rpx;
background: linear-gradient(0deg, #E5FFF7, #D5F5EB);
border-radius: 28rpx;
border:1px solid #019C88;
}
.save_vipbtn {
width: 95%;
height: 88rpx;
line-height: 88rpx;
text-align: center;
font-weight: bold;
font-size: 38rpx;
border-radius: 44rpx;
color: #FFFFFF;
background: linear-gradient(-90deg, #2EC5AC, #08A28A);
text-shadow: 0rpx 2rpx 3rpx rgba(0,127,106,0.48);
margin: 33px auto 22px auto;
}
.quanyi_view {
.quanyi_titview {
width: 100%;
.quanyi_itemview {
margin-top: 20rpx;
display: flex;
width: 100%;
flex-direction: row;
justify-content: space-around;
.quanyi_listitem {
width: 25%;
text-align: center;
margin-top: 40rpx;
.listitem_name {
margin-top: 18rpx;
font-weight: 400;
font-size: 25rpx;
color: #bea586;
white-space: nowrap;
}
image {
width: 70rpx;
height: 70rpx;
}
}
}
.quanyi_titname {
width: 100%;
text-align: center;
font-weight: 400;
font-size: 25rpx;
color: #edd3ac;
margin-top:40rpx;
}
image {
width: 114rpx;
height: 2rpx
}
}
image {
width: 749rpx;
height: 200rpx;
}
}
.popup_pay {
width: 100%;
position: relative;
padding-bottom: 45rpx;
}
.pay_btn {
width: 90%;
margin: 0 auto;
text-align: center;
background: linear-gradient(to right, #019c88, #2ebe93);
height: 80upx;
border-radius: 60rpx;
color: #ffffff;
line-height: 80upx;
}
.vip_kapian {
// background: url(../../static/vipqy.png);
background-size: cover;
width: 100%;
height: 332rpx;
padding: 30rpx 0 0 40rpx;
image {
width: 686rpx;
height: 320rpx;
position: absolute;
}
.kapian_name {
font-size: 42rpx;
font-family: YouSheBiaoTiHei;
font-weight: bold;
color: #fdd193;
}
.kapian_text {
font-size: 26rpx;
font-family: PingFang SC;
color: #fdd193;
margin-top: 16rpx;
}
.kapian_ktname {
font-size: 28rpx;
font-family: PingFang SC;
color: #fdd193;
margin-top: 24rpx;
}
.kapian_ktmoney {
font-size: 26rpx;
font-family: PingFang SC;
font-weight: 800;
color: #fdd193;
margin-top: 10rpx;
text {
font-size: 44rpx;
}
}
}
</style>