|
@@ -160,55 +160,7 @@
|
|
this.shareToken = res.data.single;
|
|
this.shareToken = res.data.single;
|
|
}
|
|
}
|
|
},
|
|
},
|
|
- 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: false, // 开启调试模式,调用的所有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() {
|
|
|
|
- // config信息验证后会执行ready方法,所有接口调用都必须在config接口获得结果之后,config是一个客户端的异步操作,所以如果需要在页面加载时就调用相关接口,则须把相关接口放在ready函数中调用来确保正确执行。对于用户触发时才调用的接口,则可以直接调用,不需要放在ready函数中。
|
|
|
|
- wx.updateAppMessageShareData({ //分享给朋友
|
|
|
|
- title: self.dataInfo.name, // 分享标题
|
|
|
|
- desc: self.dataInfo.shareRemark, // 分享描述
|
|
|
|
- link: location.origin+location.pathname + "?projectId="+self.projectId+"&shareToken="+self.shareToken, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
|
|
|
|
- imgUrl: self.dataInfo.shareImg, // 分享图标
|
|
|
|
- success: function() {
|
|
|
|
- // 设置成功
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- wx.updateTimelineShareData({ //分享到朋友圈
|
|
|
|
- title: self.dataInfo.name, // 分享标题
|
|
|
|
- link: location.origin+location.pathname + "?projectId="+self.projectId+"&shareToken="+self.shareToken, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
|
|
|
|
- imgUrl: self.dataInfo.shareImg, // 分享图标
|
|
|
|
- success: function() {
|
|
|
|
- // 设置成功
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- wx.showMenuItems({
|
|
|
|
- menuList: [ "menuItem:share:appMessage","menuItem:share:timeline"] // 要显示的菜单项,所有menu项见附录3
|
|
|
|
- });
|
|
|
|
- });
|
|
|
|
- wx.error(function(res) {
|
|
|
|
- // config信息验证失败会执行error函数,如签名过期导致验证失败,具体错误信息可以打开config的debug模式查看,也可以在返回的res参数中查看,对于SPA可以在这里更新签名。
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
|
|
+
|
|
async detailDatahandle() {
|
|
async detailDatahandle() {
|
|
if (getApp().globalData.userId) {
|
|
if (getApp().globalData.userId) {
|
|
var parmas = {
|
|
var parmas = {
|
|
@@ -227,7 +179,7 @@
|
|
this.dataInfo = res.data.single
|
|
this.dataInfo = res.data.single
|
|
this.reloadCategoryList()
|
|
this.reloadCategoryList()
|
|
this.reloadInfos();
|
|
this.reloadInfos();
|
|
- this.signJsapiTicket();
|
|
|
|
|
|
+ this.config(this.dataInfo.name,this.dataInfo.shareRemark,location.origin+location.pathname + "?projectId="+this.projectId+"&shareToken="+this.shareToken,this.dataInfo.shareImg)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
},
|