sunchengjie 9 mesi fa
parent
commit
58a0e25972
2 ha cambiato i file con 28 aggiunte e 42 eliminazioni
  1. 4 18
      src/App.vue
  2. 24 24
      src/main.js

+ 4 - 18
src/App.vue

@@ -20,21 +20,6 @@ export default {
 			isRouterAlive: true //控制视图是否显示的变量
 		}
 	},
-	// async created() {
-	// 	const res = await getWxConfig({url: encodeURI(window.location.href.split('#')[0])})
-	// 	if(res.code === 0) {
-	// 		this.configData = {
-	// 			debugger: true, 
-	// 			appId:res.data.appId,
-	// 			timestamp:res.data.timestamp,
-	// 			nonceStr:res.data.nonceStr,
-	// 			signature:res.data.signature,
-	// 			jsApiList:['checkJsApi','scanoRcode','getLocation','updateAppMessageshareData'],
-	// 			url:res.data.url
-	// 		}
-	// 	}
-	// 	wx.config(this.configData)
-	// },
 
 	async created() {
 		if (this.$route.path !== "/Login") {
@@ -45,7 +30,8 @@ export default {
 		}
 		window.localStorage.setItem('CourierScanUrl', location.href.split('#')[0])
 		const res = await getWxConfig({
-			url: window.location.href
+			// url: window.location.href
+			url: encodeURI(window.location.href.split('#')[0])
 		})
 
 		//发送成功
@@ -54,7 +40,7 @@ export default {
 		var signature = res.wxConfig.signature;
 		var appId = res.wxConfig.appId;
 		var jsapiTicket = res.jsapi_ticket
-		var url = res.wxConfig.url
+		var url = window.location.href
 		wx.config({
 			debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
 			// debug : true, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
@@ -65,7 +51,7 @@ export default {
 			jsApiList: [
 				"scanQRCode",
 			], // 必填,需要使用的JS接口列表,所有JS接口列表见附录2
-			jsApiTicket: jsapiTicket, 
+			jsApiTicket: jsapiTicket,
 			url: url
 		});
 		//  res => {

+ 24 - 24
src/main.js

@@ -54,36 +54,36 @@ router.beforeEach((to, from, next) => {
 			console.log('无openId')
 			getWxOpenId().then(() => {
 				
-				if(to.path == '/' && from.path == '/') {
-					if(sessionstorage.getItem("isReload") === 'isReloadVlaue'){
-						next()
-						window.location.reload()
-						console.log('有isReloadVlaue')
-					}else{
-						sessionStorage.setItem("isReload",'isReloadVlaue')
-						next()
-						console.log('无isReloadVlaue')
-					}
-				}else {
+				// if(to.path == '/' && from.path == '/') {
+				// 	if(sessionstorage.getItem("isReload") === 'isReloadVlaue'){
+				// 		next()
+				// 		window.location.reload()
+				// 		console.log('有isReloadVlaue')
+				// 	}else{
+				// 		sessionStorage.setItem("isReload",'isReloadVlaue')
+				// 		next()
+				// 		console.log('无isReloadVlaue')
+				// 	}
+				// }else {
 					next()
-				}
+				// }
 			})
 			console.log('overallExample.getOpenid()走完了')
 		} else {
 			console.log('什么都有')
-			if(to.path == '/' && from.path == '/') {
-				if(sessionstorage.getItem("isReload") === 'isReloadVlaue'){
-					next()
-					window.location.reload()
-					console.log('有isReloadVlaue')
-				}else{
-					sessionStorage.setItem("isReload",'isReloadVlaue')
-					next()
-					console.log('无isReloadVlaue')
-				}
-			}else {
+			// if(to.path == '/' && from.path == '/') {
+			// 	if(sessionstorage.getItem("isReload") === 'isReloadVlaue'){
+			// 		next()
+			// 		window.location.reload()
+			// 		console.log('有isReloadVlaue')
+			// 	}else{
+			// 		sessionStorage.setItem("isReload",'isReloadVlaue')
+			// 		next()
+			// 		console.log('无isReloadVlaue')
+			// 	}
+			// }else {
 				next()
-			}
+			// }
 		}
 	} else {
 		console.log('无登录权限')