sunchengjie 9 ay önce
ebeveyn
işleme
bdd192be79
2 değiştirilmiş dosya ile 57 ekleme ve 53 silme
  1. 49 50
      src/App.vue
  2. 8 3
      src/main.js

+ 49 - 50
src/App.vue

@@ -20,60 +20,59 @@ 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") {
-	// 		const res = await checkIsLogin();
-	// 		if (res.msg !== "success") {
-	// 			this.$router.push({ path: '/Login' })
+	// 	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
 	// 		}
 	// 	}
-	// 	window.localStorage.setItem('CourierScanUrl', location.href.split('#')[0])
-	// 	const res = await getWxConfig({
-	// 		// url: window.location.href
-	// 		url: encodeURI(window.location.href.split('#')[0])
-	// 	})
-
-	// 	//发送成功
-	// 	var timestamp = res.wxConfig.timestamp;
-	// 	var noncestr = res.wxConfig.nonceStr;
-	// 	var signature = res.wxConfig.signature;
-	// 	var appId = res.wxConfig.appId;
-	// 	var jsapiTicket = res.jsapi_ticket
-	// 	var url = res.wxConfig.url
-	// 	wx.config({
-	// 		debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
-	// 		// debug : true, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
-	// 		appId: appId, // 必填,公众号的唯一标识
-	// 		timestamp: timestamp, // 必填,生成签名的时间戳
-	// 		nonceStr: noncestr, // 必填,生成签名的随机串
-	// 		signature: signature, // 必填,签名,见附录1
-	// 		jsApiList: [
-	// 			"scanQRCode",
-	// 		], // 必填,需要使用的JS接口列表,所有JS接口列表见附录2
-	// 		jsApiTicket: jsapiTicket, 
-	// 		url: url
-	// 	});
-	// 	//  res => {
-	// 	// 	//发送失败
-	// 	// 	Toast("网络错误!")
-	// 	// }
+	// 	wx.config(this.configData)
 	// },
+
+	async created() {
+		if (this.$route.path !== "/Login") {
+			const res = await checkIsLogin();
+			if (res.msg !== "success") {
+				this.$router.push({ path: '/Login' })
+			}
+		}
+		window.localStorage.setItem('CourierScanUrl', location.href.split('#')[0])
+		const res = await getWxConfig({
+			url: window.location.href
+		})
+
+		//发送成功
+		var timestamp = res.wxConfig.timestamp;
+		var noncestr = res.wxConfig.nonceStr;
+		var signature = res.wxConfig.signature;
+		var appId = res.wxConfig.appId;
+		var jsapiTicket = res.jsapi_ticket
+		var url = res.wxConfig.url
+		wx.config({
+			debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
+			// debug : true, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
+			appId: appId, // 必填,公众号的唯一标识
+			timestamp: timestamp, // 必填,生成签名的时间戳
+			nonceStr: noncestr, // 必填,生成签名的随机串
+			signature: signature, // 必填,签名,见附录1
+			jsApiList: [
+				"scanQRCode",
+			], // 必填,需要使用的JS接口列表,所有JS接口列表见附录2
+			jsApiTicket: jsapiTicket, 
+			url: url
+		});
+		//  res => {
+		// 	//发送失败
+		// 	Toast("网络错误!")
+		// }
+	},
 	methods: {
 		reload() {
 			this.isRouterAlive = false; //先关闭,

+ 8 - 3
src/main.js

@@ -53,10 +53,15 @@ router.beforeEach((to, from, next) => {
 		} else if (!localStorage.getItem('courierOpenid')) {
 			console.log('无openId')
 			getWxOpenId().then(() => {
+				
 				if(to.path == '/') {
-					console.log('window.location.reload()')
-					// window.location.reload()
-					next()
+					if(sessionstorage.getItem("isReload") === 'isReloadVlaue'){
+						window.location.reload()
+						next()
+					}else{
+						sessionStorage.setItem("isReload",'isReloadVlaue')
+						next()
+					}
 				}else {
 					next()
 				}