|
@@ -113,6 +113,51 @@ router.beforeEach(async (to, form, next) => {
|
|
}
|
|
}
|
|
next();
|
|
next();
|
|
});
|
|
});
|
|
|
|
+
|
|
|
|
+router.afterEach(async (to, form) => {
|
|
|
|
+ const url = encodeURIComponent(location.href.split('#')[0]);
|
|
|
|
+ const wx = Vue.prototype.$wx;
|
|
|
|
+ const res = await store.dispatch('weixin/jsAuth', { url });
|
|
|
|
+ if (res.errcode == '0') {
|
|
|
|
+ const { data } = res;
|
|
|
|
+ const shareUrl = 'http://broadcast.waityou24.cn/api/article/auth?redirect_uri=' + url;
|
|
|
|
+ wx.config({
|
|
|
|
+ debug: true,
|
|
|
|
+ appId: data.appid,
|
|
|
|
+ timestamp: data.timestamp,
|
|
|
|
+ nonceStr: data.noncestr,
|
|
|
|
+ signature: data.sign,
|
|
|
|
+ jsApiList: ['updateAppMessageShareData', 'updateTimelineShareData'],
|
|
|
|
+ });
|
|
|
|
+ wx.ready(() => {
|
|
|
|
+ wx.updateAppMessageShareData({
|
|
|
|
+ title: '测试',
|
|
|
|
+ desc: '测试内容',
|
|
|
|
+ // imgUrl: this.img,
|
|
|
|
+ link: shareUrl,
|
|
|
|
+ success: res => {
|
|
|
|
+ console.log('friend share');
|
|
|
|
+ },
|
|
|
|
+ error: err => {
|
|
|
|
+ alert(JSON.stringify(err));
|
|
|
|
+ },
|
|
|
|
+ });
|
|
|
|
+ wx.updateTimelineShareData({
|
|
|
|
+ title: '测试',
|
|
|
|
+ // desc: '测试内容',
|
|
|
|
+ // imgUrl: this.img,
|
|
|
|
+ link: shareUrl,
|
|
|
|
+ success: res => {
|
|
|
|
+ console.log('friends share');
|
|
|
|
+ },
|
|
|
|
+ error: err => {
|
|
|
|
+ alert(JSON.stringify(err));
|
|
|
|
+ },
|
|
|
|
+ });
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+});
|
|
|
|
+
|
|
const originalPush = VueRouter.prototype.push;
|
|
const originalPush = VueRouter.prototype.push;
|
|
VueRouter.prototype.push = function push(location, onResolve, onReject) {
|
|
VueRouter.prototype.push = function push(location, onResolve, onReject) {
|
|
if (onResolve || onReject) return originalPush.call(this, location, onResolve, onReject);
|
|
if (onResolve || onReject) return originalPush.call(this, location, onResolve, onReject);
|