sunchengjie 8 months ago
parent
commit
5fb36b3d0b
2 changed files with 42 additions and 34 deletions
  1. 35 32
      src/pages/express.vue
  2. 7 2
      src/pages/index.vue

+ 35 - 32
src/pages/express.vue

@@ -303,37 +303,7 @@ export default {
 		}
 	},
 	async created(){
-        const res = await getWxConfig({
-            url: window.location.protocol + '//' + window.location.host
-        })
-        //发送成功
-        var timestamp = res.wxConfig.timestamp;
-        var noncestr = res.wxConfig.nonceStr;
-        var signature = res.wxConfig.signature;
-        var appId = res.wxConfig.appId;
-        var url = window.location.protocol + '//' + window.location.host
-        wx.config({
-            debug: true, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
-            // debug : true, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
-            appId: appId, // 必填,公众号的唯一标识
-            timestamp: timestamp, // 必填,生成签名的时间戳
-            nonceStr: noncestr, // 必填,生成签名的随机串
-            signature: signature, // 必填,签名,见附录1
-            url,
-            jsApiList: [
-                "scanQRCode",
-            ], // 必填,需要使用的JS接口列表,所有JS接口列表见附录2
-			fail(err){
-				console(err)
-				console('fail')
-			},
-			error(err){
-				console.log(err)
-				console.log('error')
-			}
-			
-        })
-		debugger
+		await this.wxPower();
 
 		this.accountType = localStorage.getItem("accountType")
 		this.geLogisticsListAPIList()
@@ -357,7 +327,40 @@ export default {
 		console.log(this.isAddressIdTransfer, 'this.isAddressIdTransfer')
 	},
 	methods: {
-
+		async wxPower(index = 0){
+			if(index === 3) return
+			const res = await getWxConfig({
+				url: window.location.protocol + '//' + window.location.host
+			})
+			//发送成功
+			var timestamp = res.wxConfig.timestamp;
+			var noncestr = res.wxConfig.nonceStr;
+			var signature = res.wxConfig.signature;
+			var appId = res.wxConfig.appId;
+			var url = res.wxConfig.url
+			wx.config({
+				debug: true, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
+				// debug : true, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
+				appId: appId, // 必填,公众号的唯一标识
+				timestamp: timestamp, // 必填,生成签名的时间戳
+				nonceStr: noncestr, // 必填,生成签名的随机串
+				signature: signature, // 必填,签名,见附录1
+				url,
+				jsApiList: [
+					"scanQRCode",
+				], // 必填,需要使用的JS接口列表,所有JS接口列表见附录2
+				fail(err){
+					console(err)
+					console('fail')
+				},
+				error(err){
+					this.wxPower(index++)
+					console.log(err)
+					console.log('error')
+				}
+				
+			})
+		},
 		// 收件人信息弹框
 		changeAdderInfo() {
 			this.adderInfoShow = true

+ 7 - 2
src/pages/index.vue

@@ -4,13 +4,13 @@
 		<banner></banner>
 		<!-- 寄件按钮 -->
 		<div class="btn-two">
-			<router-link to="/Express">
+			<a @click="goPage(1)">
 				<img src="../assets/images/jkd.png" alt="">
 				<span>
 					<p>寄快递</p>
 					<!-- <p>放心寄 丢必赔</p> -->
 				</span>
-			</router-link>
+			</a>
 			<router-link to="Inexpress">
 				<img src="../assets/images/nbj.png" alt="">
 				<span>
@@ -57,6 +57,11 @@ export default {
 	methods: {
 		link() {
 			Toast("正在开发中,敬请期待!")
+		},
+		goPage(type){
+			if(type === 1){
+				window.location.href = window.location.href + "Express"
+			}
 		}
 	}
 };