Przeglądaj źródła

更新会员显示问题

1410417013 5 miesięcy temu
rodzic
commit
3acecf6b5c

+ 22 - 1
my/vip/index.vue

@@ -335,7 +335,28 @@
 					console.log(res,'会员')
 					if (res.code == 0) {
 						this.vipExpirationTime = res.data.vipExpirationTime;
-						this.isVip = res.data.isVip==1?true:false
+						const vip=res.data.isVip==1?true:false
+						
+						// 2. 解析为时间戳(毫秒)
+						const expireTimestamp = new Date(this.vipExpirationTime).getTime();
+						// 获取当前时间的时间戳
+						const currentTimestamp = new Date().getTime();
+						console.log("当前时间",expireTimestamp,currentTimestamp);
+						if(vip==true){
+							// 3. 比较:当前时间 > 有效期 → 已过期
+							if (currentTimestamp > expireTimestamp) {
+							  console.log("当前时间已超过有效期");
+							  this.isVip = false
+							  // 这里写过期后的逻辑(比如提示用户、跳转页面等)
+							} else {
+							  this.isVip = true
+							  console.log("当前时间在有效期内");
+							}
+						}else{
+							this.isVip = false
+						}
+						
+						// this.isVip = res.data.isVip==1?true:false
 					}
 				});
 			},

+ 3 - 3
pages/index/shop/confirmOrder.vue

@@ -551,11 +551,11 @@ export default {
 		//获取会员立减金额
 		getvipMoney() {
 			let data = {
-				shopId: this.shopId,
+				// shopId: this.shopId,
 				userId: uni.getStorageSync('userId'),
-				originalPrice:this.totalPrice1
+				// originalPrice:this.totalPrice1
 			}
-			this.$Request.get('/app/vip/get-can-reduce',data).then((res) => {
+			this.$Request.get(`/app/vip/get-can-reduce/${this.dataList.orderId}`,data).then((res) => {
 				console.log(res, '会员立减',data)
 				if (res.code == 0 && res.data) {
 					this.Vipmoney=res.data

+ 3 - 3
pages/index/shop/payOrder.vue

@@ -532,11 +532,11 @@ export default {
 		//获取会员立减金额
 		getvipMoney() {
 			let data = {
-				shopId: this.shopId,
+				// shopId: this.shopId,
 				userId: uni.getStorageSync('userId'),
-				originalPrice:this.totalPrice1
+				// originalPrice:this.totalPrice1
 			}
-			this.$Request.get('/app/vip/get-can-reduce',data).then((res) => {
+			this.$Request.get(`/app/vip/get-can-reduce/${this.dataList.orderId}`,data).then((res) => {
 				console.log(res, '会员立减')
 				if (res.code == 0 && res.data) {
 					this.Vipmoney=res.data

+ 19 - 1
pages/my/index.vue

@@ -554,7 +554,7 @@ export default {
 					} else {
 						this.checkCertification = -1
 					}
-					this.isVip = res.data.isVip
+					// this.isVip = res.data.isVip
 					this.shopStatus = res.data.shopStatus
 					this.$queue.setData('avatar', res.data.avatar ? res.data.avatar : 'https://mxys.chuanghai-tech.com/wmfile/20250814/fff4dc5d02ea4af881db9685f2e1e61d.png')
 					this.$queue.setData('userId', res.data.userId)
@@ -563,6 +563,24 @@ export default {
 					this.$queue.setData('userName', res.data.userName ? res.data.userName : res.data.nickName)
 					this.avatar = res.data.avatar ? res.data.avatar : 'https://mxys.chuanghai-tech.com/wmfile/20250814/fff4dc5d02ea4af881db9685f2e1e61d.png'
 					this.userName = res.data.userName ? res.data.userName : res.data.nickName
+					
+					const vip=res.data.isVip==1?true:false
+					
+					// 2. 解析为时间戳(毫秒)
+					const expireTimestamp = new Date(res.data.vipExpirationTime).getTime();
+					// 获取当前时间的时间戳
+					const currentTimestamp = new Date().getTime();
+					if(vip==true){
+						// 3. 比较:当前时间 > 有效期 → 已过期
+						if (currentTimestamp > expireTimestamp) {
+						  this.isVip = false
+						  // 这里写过期后的逻辑(比如提示用户、跳转页面等)
+						} else {
+						  this.isVip = true
+						}
+					}else{
+						this.isVip = false
+					}
 				}
 			})
 		},