转移到PC

This commit is contained in:
2022-02-08 13:58:35 +08:00
parent 62a7d349cc
commit d5b8f1b930
13 changed files with 148 additions and 59 deletions
+58 -9
View File
@@ -1,11 +1,12 @@
let wechatInstance;
function signToWechat(config, readFunction) {
function signToWechat(config, shareConfig) {
if (!wx) {
console.warn('请安装微信网页JS-SDK, url: https://res2.wx.qq.com/open/js/jweixin-1.6.0.js');
}
const defaultConfig = {
...config,
debug: false,
jsApiList: [
'onMenuShareTimeline',
'onMenuShareAppMessage',
@@ -16,15 +17,63 @@ function signToWechat(config, readFunction) {
'updateTimelineShareData'
],
};
return new Promise((resolve) => {
console.log('defaultConfig', defaultConfig);
wx.config(defaultConfig);
wx.ready(function() {
console.warn('wechat sdk config success');
wechatInstance = wx;
resolve(wx);
readFunction && readFunction(wx)
console.log('sign', wx);
wx.config(defaultConfig);
wx.ready(function() {
console.log('wechat sdk config success');
wechatInstance = wx;
wx.onMenuShareAppMessage({
title: shareConfig.title,
desc: shareConfig.desc,
link: shareConfig.link,
imgUrl: shareConfig.imgUrl,
complete: res => {
shareConfig.callback && shareConfig.callback({
key: 'updateAppMessageShareData',
...res
});
}
});
// // 分享朋友圈
wx.onMenuShareTimeline({
title: shareConfig.title,
link: shareConfig.link,
imgUrl: shareConfig.imgUrl,
complete: res => {
shareConfig.callback && shareConfig.callback({
key: 'updateTimelineShareData',
...res
});
}
});
// wx.updateAppMessageShareData({
// title: shareConfig.title,
// desc: shareConfig.desc,
// link: shareConfig.link,
// imgUrl: shareConfig.imgUrl,
// complete: res => {
// shareConfig.callback && shareConfig.callback({
// key: 'updateAppMessageShareData',
// ...res
// });
// }
// });
// // 分享朋友圈
// wx.updateTimelineShareData({
// title: shareConfig.title,
// link: shareConfig.link,
// imgUrl: shareConfig.imgUrl,
// complete: res => {
// shareConfig.callback && shareConfig.callback({
// key: 'updateTimelineShareData',
// ...res
// });
// }
// });
});
}