| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623 | <template>	<view class="vip-content">		<view class="container-box">						<view class="title-box">				<image class="title-img" src="@/static/images/my/vip-title.png" mode="widthFix"></image>				<view class="desc">					甄选权益,开启您的按摩之旅				</view>			</view>			<!-- <image class="bgimg" src="../static/workbg.png" mode="widthFix"></image> -->			<!-- <image class="bgimg" src="/static/image/vip_bg.png" style="height: 100vh;"></image> -->			<view>				<!-- <image src="../../static/ktvip.png" style="margin: 80rpx 70rpx;width: 610rpx;height: 70rpx;"></image> -->				<view class="vip_kapian">					<!-- <image src="/static/image/vip_top.png"></image> -->					<view style="padding: 52rpx;">						<image class="img" src="/static/image/vip-text.png" mode=""></image>						<view class="kapian_text">会员享受超值VIP特权</view>						<!-- <view class="kapian_ktmoney" v-if="!isVip">¥ <text>{{payMoney}}</text> </view> -->						<view class="kapian_ktname" v-if="endTime">到期时间</view>						<view class="kapian_ktmoney" v-if="endTime">{{endTime}}</view>						<view class="kapian_ktmoney" v-if="!isVip">------</view>					</view>				</view>				<view class="save_vipbtn" v-if="!isVip" @tap="showpay = true">立即开通</view>				<!-- <view class="quanyi_view">					<image :src="quanyiImage" mode="widthFix"></image>				</view> -->				<view class="quanyi_view">					<view class="quanyi_titview">						<view class="flex justify-center align-center">							<image src="../../static/vipleft.png"></image>							<view class="quanyi_titname">VIP超值权益</view>							<image src="../../static/vipright.png"></image>						</view>						<view class="quanyi_itemview">							<view class="quanyi_listitem" v-for="(item,index) in gridData">								<image :src="item.image"></image>								<view class="listitem_name">{{item.title}}</view>							</view>						</view>						<!-- <view class="save_vipbtn">立即开通</view> -->						<view class="flex margin-top-xl flex-wrap justify-between" v-if="!isVip">							<view v-for="(item,index) in vipList" :key='index' @click="select(item)" class="text-center flex flex-direction justify-between padding-tb radius"									:class="selNum == item.id?'active': 'noactive'">									<view class="text-bold" style="font-size: 28rpx;" >{{item.vipName}}</view>									<view class="text-bold"  style="font-size: 28rpx;">¥<text  style="font-size: 48rpx;" >{{item.money}}</text></view>								</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: 60rpx;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="#2FB57A" :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 {				endTime: '',				customStyle: {					width: '250rpx',					color: '#402321',					background: "#DFC5A7",					border: 0,					fontWeight: '700'				},				gridData: [{						title: '专享九折',						image: '../static/1.png'					},					{						title: '身份标识',						image: '../static/3.png'					}				],				avatar: '',				userName: '匿名',				vipList: [],				selNum: 0,				newPrice: 0,				money: 0,				price: 0,				MemberList: [],				isVip: true,				openLists: [],				openWay: 2,				showpay: false,			}		},		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.getvipEndTime();			this.getVipList()			this.getMemberList()			this.getMoney()			this.getIsVip()		},		methods: {			selectWay: function(id) {				this.openWay = id;			},			getvipEndTime() {				this.$Request.get("/app/UserVip/selectUserVip").then(res => {					if (res.code == 0 && res.data) {						this.endTime = res.data.endTime					}				});			},			//获取VIP列表			getVipList() {				this.$Request.get('/app/VipDetails/selectVipDetails').then(res => {					if (res.code == 0) {						this.vipList = res.data						this.selNum = this.vipList[0].id						this.price = this.vipList[0].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					}				});			},			select(e) {				this.selNum = e.id				this.price = e.money			},			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) {								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) {								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) {							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) {							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) {							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								this.getIsVip()								uni.showToast({									title: '开通成功!'								})								// 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">	.vip-content {		width: 100%;		min-height: 100vh;		background: linear-gradient( 225deg, #13141D 0%, #55565D 35%, #15161F 100%);		.container-box{			padding: 80rpx 32rpx;			.title-box{				.title-img{					width: 340rpx;					height: 46rpx;				}				.desc{					font-size: 28rpx;					color: #707070;					margin-top: 36rpx;				}			}		}	}	.bgimg {		position: absolute;		height: 100vh;		width: 100%;	}	.noactive {		width: 216rpx;		height: 226rpx;		background: #4E4F55;		border-radius: 32rpx 32rpx 32rpx 32rpx;		border: 1rpx solid #F4E5BD;		color: #FEE3AD;	}	.active {		width: 216rpx;		height: 226rpx;		background: linear-gradient( 138deg, #FEE3AD 0%, #FFFFFF 20%, #BEA576 44%, #FFFFFF 71%, #FEE3AD 100%);		border-radius: 32rpx 32rpx 32rpx 32rpx;		color: #292929!important;	}	.save_vipbtn {		width: 686rpx;		height: 100rpx;		background: linear-gradient( 121deg, #F9D385 0%, #FFEDCB 49%, #FEE3AD 100%);		border-radius: 50rpx;		text-align: center;		line-height: 100rpx;		font-size: 32rpx;		font-family: PingFang SC;		font-weight: bold;		color: #56260A;		position: fixed;		left: 32rpx;		bottom: 100rpx;		z-index: 9999;	}	.quanyi_view {		margin-top: 36rpx;		.quanyi_titview {			.save_vipbtn {				width: 686rpx;				height: 100rpx;				background: linear-gradient(90deg, #FEDFB1 0%, #FDC673 100%);				border-radius: 50rpx;				text-align: center;				line-height: 100rpx;				margin: 100rpx 30rpx 0rpx;				font-size: 32rpx;				font-family: PingFang SC;				font-weight: bold;				color: #56260A;			}			.quanyi_itemview {				margin-top: 20rpx;				display: flex;				width: 100%;				flex-wrap: wrap;				.quanyi_listitem {					width: 25%;					text-align: center;					margin-top: 40rpx;					.listitem_name {						font-family: PingFang SC, PingFang SC;						margin-top: 24rpx;						font-weight: bold;						font-size: 28rpx;						color: #FEE3AD;					}					image {						width: 80rpx;						height: 80rpx;					}				}			}			.quanyi_titname {				font-weight: bold;				font-size: 36rpx;				color: #FEE3AD;				margin: 0rpx 12rpx;			}			image {				width: 114rpx;				height: 14rpx			}		}		image {			width: 749rpx;			height: 1255rpx;		}	}	.popup_pay {		width: 100%;		position: relative;		padding-bottom: 45rpx;	}	.pay_btn {		width: 90%;		margin: 0 auto;		text-align: center;		background: #2FB57A;		height: 80rpx;		border-radius: 16rpx;		color: #ffffff;		line-height: 80rpx;	}	.vip_kapian {		width: 686rpx;		height: 370rpx;		box-sizing: border-box;		background: url('@/static/image/vip_top.png') no-repeat;		background-size: 686rpx 370rpx;		margin-top: 63rpx;		.img {			width: 219rpx;			height: 55rpx;		}		.kapian_ktname,.kapian_text,.kapian_ktmoney {			font-size: 28rpx;			color: #707070;			font-family: PingFang SC;			margin-top: 26rpx;		}			}</style>
 |