张文飞 3 年之前
父節點
當前提交
a2aa1eb45c
共有 3 個文件被更改,包括 34 次插入29 次删除
  1. 30 0
      App.vue
  2. 3 0
      pages/homePage/homePage.vue
  3. 1 29
      static/mixin.js

+ 30 - 0
App.vue

@@ -23,6 +23,7 @@
 			this.globalData.projectId = projectId||'';
 			this.globalData.shareToken = shareToken||'';
 			this.regist();
+			this.signJsapiTicket();
 		},
 		onShow: function() {
 			document.body.style.setProperty("background-color",this.globalData.color4);
@@ -66,6 +67,35 @@
 					}
 				}
 			},
+			async signJsapiTicket(){
+				let url =  location.href.split('#')[0]
+				let parmas = {
+					url: url,
+				}
+				let self = this;
+				let res = await this.$myRequest({
+					url: '/wechat/signJsapiTicket',
+					data: parmas,
+					method:"GET",
+				});
+				if(res.data.success){
+				   let single =	res.data.single;
+				   wx.config({
+				   	debug: true, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
+				   	appId: config.appid, // 必填,公众号的唯一标识
+				   	timestamp: single.timestamp, // 必填,生成签名的时间戳
+				   	nonceStr: single.nonceStr, // 必填,生成签名的随机串
+				   	signature: single.signature, // 必填,签名
+				       jsApiList: ["updateAppMessageShareData","updateTimelineShareData",'showMenuItems'] // 必填,需要使用的JS接口列表
+				   });
+				   wx.ready(function() {
+				   	
+				   });
+				   wx.error(function(res) {
+				   	// config信息验证失败会执行error函数,如签名过期导致验证失败,具体错误信息可以打开config的debug模式查看,也可以在返回的res参数中查看,对于SPA可以在这里更新签名。
+				   });
+				}
+			},
 		},
 		globalData: {
 			token: "",

+ 3 - 0
pages/homePage/homePage.vue

@@ -502,6 +502,9 @@
 				});
 				if(res.data.success){
 					let single = res.data.single;
+					uni.showModal({
+						content:"location.origin+location.pathname"+location.origin+location.pathname
+					})
 					this.config(single.shareName,single.shareRemark,location.origin+location.pathname +"?shareToken="+this.shareToken,single.shareLogoImage)
 				}
 			}

+ 1 - 29
static/mixin.js

@@ -12,35 +12,7 @@ export default {
 				this.signJsapiTicket();
 			},
 			methods:{
-				async signJsapiTicket(){
-					let url =  location.href.split('#')[0]
-					let parmas = {
-						url: url,
-					}
-					let self = this;
-					let res = await this.$myRequest({
-						url: '/wechat/signJsapiTicket',
-						data: parmas,
-						method:"GET",
-					});
-					if(res.data.success){
-					   let single =	res.data.single;
-					   wx.config({
-					   	debug: true, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
-					   	appId: config.appid, // 必填,公众号的唯一标识
-					   	timestamp: single.timestamp, // 必填,生成签名的时间戳
-					   	nonceStr: single.nonceStr, // 必填,生成签名的随机串
-					   	signature: single.signature, // 必填,签名
-					       jsApiList: ["updateAppMessageShareData","updateTimelineShareData",'showMenuItems'] // 必填,需要使用的JS接口列表
-					   });
-					   wx.ready(function() {
-					   	
-					   });
-					   wx.error(function(res) {
-					   	// config信息验证失败会执行error函数,如签名过期导致验证失败,具体错误信息可以打开config的debug模式查看,也可以在返回的res参数中查看,对于SPA可以在这里更新签名。
-					   });
-					}
-				},
+				
 				config(title,desc,link,imgUrl){
 					wx.showMenuItems({
 						menuList: [ "menuItem:share:appMessage","menuItem:share:timeline"] // 要显示的菜单项,所有menu项见附录3