Ver Fonte

2023-12-29 礼品兑换跳转详情页面修改携带参数方式

zhiquz há 1 ano atrás
pai
commit
cf9d1db0a8
2 ficheiros alterados com 9 adições e 6 exclusões
  1. 7 4
      pages/zbs-detail/detail.vue
  2. 2 2
      pages/zbs-exchange/exchange.vue

+ 7 - 4
pages/zbs-detail/detail.vue

@@ -63,6 +63,9 @@ export default {
 			return this.$store.state.userinfo;
 		}
 	},
+	onLoad() {
+		this.item = JSON.parse(decodeURIComponent(option.item))
+	},
 	onShow() {
 		this.getBound()
 	},
@@ -134,10 +137,10 @@ export default {
 				}
 		}
 	},
-	created() {
-		//加载完成后开启监听全局 MESSAGE 事件
-		this.item = getApp().globalData.detail; //从兑换列表页面进入当前页面后从 getApp().globalData.detail 取值
-	}
+	// created() {
+	// 	//加载完成后开启监听全局 MESSAGE 事件
+	// 	this.item = getApp().globalData.detail; //从兑换列表页面进入当前页面后从 getApp().globalData.detail 取值
+	// }
 };
 </script>
 

+ 2 - 2
pages/zbs-exchange/exchange.vue

@@ -120,9 +120,9 @@
 			exchange(data) {
 				if (data.surplus) {
 					//如果有货
-					getApp().globalData.detail = data; //把兑换列表保存到 globalData 中
+					// getApp().globalData.detail = data; //把兑换列表保存到 globalData 中
 					uni.navigateTo({
-						url: '../zbs-detail/detail' //去商品详情页面时
+						url: '../zbs-detail/detail?item=' + encodeURIComponent(JSON.stringify(data))
 					});
 				} else {
 					uni.showModal({