From 16ca0d4cc65f8cc719cf453543d8f46773346a13 Mon Sep 17 00:00:00 2001 From: jinglong <1309572580@qq.com> Date: Sat, 6 Jul 2019 17:43:45 +0800 Subject: [PATCH] 调试分享 --- public/themes/simpleboot3_mobile/public/share.html | 119 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------------------------------------------- 1 file changed, 61 insertions(+), 58 deletions(-) diff --git a/public/themes/simpleboot3_mobile/public/share.html b/public/themes/simpleboot3_mobile/public/share.html index f41247b..a5d4b8e 100644 --- a/public/themes/simpleboot3_mobile/public/share.html +++ b/public/themes/simpleboot3_mobile/public/share.html @@ -2,68 +2,71 @@ <script src="http://res.wx.qq.com/open/js/jweixin-1.4.0.js"></script> <script> $(function () { - $.ajax({ - type: 'POST', - url: '/portal/login/wx_share_mobile', - data: { - }, - dataType: 'json', - async: false, - success: function(data) { - if (data.code == 1) { - var url = window.location.href; - var title_title = $(document).attr('title'); - // wx.config({ - // debug: false, - // appId: '{$data.appId}', - // timestamp: '{$data.timestamp}', - // nonceStr: '{$data.nonceStr}', - // signature: '{$data.signature}', - // jsApiList: [ - // 'updateAppMessageShareData', - // 'updateTimelineShareData', - // ] - // }); - wx.config({ - debug: true, - appId: data.appId, - timestamp: data.timestamp, - nonceStr: data.nonceStr, - signature: data.signature, - jsApiList: [ - 'updateAppMessageShareData', - 'updateTimelineShareData', - ] - }); - wx.ready(function () { //需在用户可能点击分享按钮前就先调用 - wx.updateAppMessageShareData({ - title: title_title, // 分享标题 - desc: url, // 分享描述 - link: url, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致 - imgUrl: '', // 分享图标 - success: function (e) { - alert('成功'); - wx_Share(); - } - }); - // wx.updateTimelineShareData({ - // title: title_title, // 分享标题 - // link: url, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致 - // imgUrl: '', // 分享图标 - // success: function () { - // // 设置成功 - // wx_Share(); - // alert('cheng') - // } + $('#wx_share').click(function(){ + $.ajax({ + type: 'POST', + url: '/portal/login/wx_share_mobile', + data: { + }, + dataType: 'json', + async: false, + success: function(data) { + if (data.code == 1) { + var url = window.location.href; + var title_title = $(document).attr('title'); + // wx.config({ + // debug: false, + // appId: '{$data.appId}', + // timestamp: '{$data.timestamp}', + // nonceStr: '{$data.nonceStr}', + // signature: '{$data.signature}', + // jsApiList: [ + // 'updateAppMessageShareData', + // 'updateTimelineShareData', + // ] // }); - }); - wx.error(function (res) { - // config信息验证失败会执行error函数,如签名过期导致验证失败,具体错误信息可以打开config的debug模式查看,也可以在返回的res参数中查看,对于SPA可以在这里更新签名。 - }); + wx.config({ + debug: true, + appId: data.appId, + timestamp: data.timestamp, + nonceStr: data.nonceStr, + signature: data.signature, + jsApiList: [ + 'updateAppMessageShareData', + 'updateTimelineShareData', + ] + }); + wx.ready(function () { //需在用户可能点击分享按钮前就先调用 + wx.updateAppMessageShareData({ + title: title_title, // 分享标题 + desc: url, // 分享描述 + link: url, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致 + imgUrl: '', // 分享图标 + success: function (e) { + alert('成功'); + wx_Share(); + } + }); + // wx.updateTimelineShareData({ + // title: title_title, // 分享标题 + // link: url, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致 + // imgUrl: '', // 分享图标 + // success: function () { + // // 设置成功 + // wx_Share(); + // alert('cheng') + // } + // }); + }); + wx.error(function (res) { + // config信息验证失败会执行error函数,如签名过期导致验证失败,具体错误信息可以打开config的debug模式查看,也可以在返回的res参数中查看,对于SPA可以在这里更新签名。 + }); + } } - } + }); }); + }); function wx_Share(){ -- libgit2 0.24.0