Parcourir la source

支付宝扫码跳转获取值

DELL il y a 3 ans
Parent
commit
662faee128
2 fichiers modifiés avec 17 ajouts et 6 suppressions
  1. 8 5
      src/App.vue
  2. 9 1
      src/pages/lucky/index.vue

+ 8 - 5
src/App.vue

@@ -6,18 +6,21 @@
 			userInfo: {},
 		},
 		onLaunch: function(options) {
-			console.log(`====参数app====`, options.query);
 			if (options.query && options.query.qrCode) {
 				const { qrCode } = options.query
 				let parameter = urlParameter(qrCode)
-				uni.reLaunch({
-					url: `/pages/lucky/index?id=${ parameter.id }`
-				})
+				uni.setStorageSync('code', parameter.id)
 			}
 			uni.hideTabBar()
 		},
-		onShow: function() {
+		onShow: function(options) {
+			if (options.query && options.query.qrCode) {
+				const { qrCode } = options.query
+				let parameter = urlParameter(qrCode)
+				uni.setStorageSync('code', parameter.id)
+			}
 			this.updateManager()
+			
 		},
 		methods: {
 			updateManager() {

+ 9 - 1
src/pages/lucky/index.vue

@@ -112,7 +112,6 @@
 		},
 
 		onLoad(options) {
-			console.log(`====参数lucky====`, options.query);
 			if (options.id) {
 				this.serialNo = options.id
 				this.getDetail()
@@ -122,6 +121,15 @@
 				this.serialNo = obj.id
 				this.getDetail()
 			}
+			if(uni.getStorageSync('code')){
+				this.serialNo = uni.getStorageSync('code')
+			}
+		},
+		onShow() {
+			if(uni.getStorageSync('code')){
+				this.serialNo = uni.getStorageSync('code')
+				this.getDetail()
+			}
 		},
 
 		methods: {