转移到PC
This commit is contained in:
@@ -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
|
||||
// });
|
||||
// }
|
||||
// });
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user