res = await cloudbase.callFunction({
name:'web',
data:{
$url:'huajiSsoUrl',
readApiForm:readApiForm,
createApiForm:createApiForm,
}
});
console.log('ssoUrl',res.result.data);
window.location.href = res.result.data;
//-------------------------
let reqUrl = "http://cb.upservce.com/#/pagesCmn/product/ShareProductDetail?id="+that.product._id;
//提供分享公众号能力
res = await cloudbase.callFunction({
name:'web',
data:{
$url:'signWeixin',
url:reqUrl,
needRefreshSignature:false
}
});
let signRet = JSON.parse(res.result.data);
console.log('sign',res.result.data);
jweixin.config({
debug: signRet.debug, // 调试,发布的时候改为false
appId: signRet.appId,//'wxc42ba3b82548c8b6',
nonceStr: signRet.nonceStr,
timestamp: signRet.timestamp,
signature: signRet.signature,
jsApiList: signRet.jsApiList,//[ 'updateAppMessageShareData','updateTimelineShareData','onMenuShareAppMessage','onMenuShareTimeline', 'onMenuShareQQ', 'onMenuShareQZone'],
});
jweixin.ready(() => { //需在用户可能点击分享按钮前就先调用
//旧:群分享
jweixin.onMenuShareAppMessage({
title: that.product.title, // 分享标题
desc: that.product.detail.content, // 分享描述
link: reqUrl, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
imgUrl: that.product.cover, // 分享图标
success: function () {
// 设置成功
console.log('success');
}
});
//旧:分享朋友圈
jweixin.onMenuShareTimeline({
title: that.product.title, // 分享标题
desc: that.product.detail.content, // 分享描述
link: reqUrl, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
imgUrl: that.product.cover, // 分享图标
success: function () {
// 设置成功
console.log('success');
}
});
//新接口
jweixin.updateAppMessageShareData({
title: that.product.title, // 分享标题
desc: that.product.detail.content, // 分享描述
link: reqUrl, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
imgUrl: that.product.cover, // 分享图标
success: function () {
// 设置成功
console.log('success');
}
});
});
jweixin.error ((res)=>{
console.log('jweixin.error',res);
//刷新后再分享
cloudbase.callFunction({
name:'web',
data:{
$url:'signWeixin',
url:reqUrl,
needRefreshSignature:true
}
});
setTimeout (() => {
uni.showToast({
icon:'none',
title:'产品授权变更,需刷新后重新分享!'
});
} , 500 );
});
//-------------------------