Commit 433e696a authored by leiqingsong's avatar leiqingsong

添加微信分享

parent 53cd2d41
...@@ -357,30 +357,47 @@ export default { ...@@ -357,30 +357,47 @@ export default {
// 分享 // 分享
handleShare() { handleShare() {
let url = `http://oysales.oywanhao.com:8087/activeDetail?id=${this.active_id}&active_type=${this.active_type}`; let url = `http://oysales.oywanhao.com:8087/activeDetail?id=${this.active_id}&active_type=${this.active_type}`;
wx.invoke(
"shareToExternalContact",
{
title: `${this.activityName}`, // 分享标题
desc: `${this.des}`, // 分享描述
link: url, // 分享链接
imgUrl: "" // 分享封面
},
function(res) {
if (res.err_msg == "shareToExternalContact:ok") {
console.log("分享成功");
} else {
console.log(res.err_msg, "错误信息");
}
}
);
let env = window.navigator.userAgent.toLowerCase(); let env = window.navigator.userAgent.toLowerCase();
if ( if (
env.match(/MicroMessenger/i) == "micromessenger" && env.match(/MicroMessenger/i) == "micromessenger" &&
env.match(/wxwork/i) == "wxwork" env.match(/wxwork/i) == "wxwork"
) { ) {
console.log("企业微信客户端"); console.log("企业微信客户端");
wx.invoke(
"shareToExternalContact",
{
title: `${this.activityName}`, // 分享标题
desc: `${this.des}`, // 分享描述
link: url, // 分享链接
imgUrl: "" // 分享封面
},
function(res) {
if (res.err_msg == "shareToExternalContact:ok") {
console.log("分享成功");
} else {
console.log(res.err_msg, "错误信息");
}
}
);
} else if (env.match(/micromessenger/i) == "micromessenger") { } else if (env.match(/micromessenger/i) == "micromessenger") {
console.log("微信客户端"); console.log("微信客户端");
wx.ready(function() {
wx.onMenuShareTimeline({
title: `${this.activityName}`, // 分享标题
link: url, // 分享链接,将当前登录用户转为puid,以便于发展下线
imgUrl: "", // 分享图标
success: function() {
// 用户确认分享后执行的回调函数
},
cancel: function() {
// 用户取消分享后执行的回调函数
}
});
wx.error(function(res) {
// config信息验证失败会执行error函数,如签名过期导致验证失败,具体错误信息可以打开config的debug模式查看,也可以在返回的res参数中查看,对于SPA可以在这里更新签名。
alert("errorMSG:" + res);
});
});
} }
} }
}, },
......
...@@ -238,7 +238,7 @@ export default { ...@@ -238,7 +238,7 @@ export default {
this.flag = sessionStorage.getItem("role"); this.flag = sessionStorage.getItem("role");
} }
} else { } else {
// this.zReadyUserId() this.zReadyUserId()
this.zTestGetNowUrlInfo() this.zTestGetNowUrlInfo()
} }
this.GET_CurrentActive() this.GET_CurrentActive()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment