已按照官方文档 添加了onShareAppMessage分享好友 再添加 onShareTimeline分享朋友圈 但页面不生效 按钮置灰 其他页面生效了
这是首页的
onShareAppMessage((res) => {
console.log("点击分享了");
if (res) {
const par = {
requestParam: {
userid: userInfo.value.id,
companyId: userInfo.value.companyId,
},
appName: "shop",
moduleName: "share",
responseParam: res,
logMethod: "post",
logUri: `/pages/mallHome/mallHome?userId=${userInfo.value.id}&companyId=${userInfo.value.companyId}`,
logDesc: "首页分享",
logType: 8,
remark: "分享小程序",
};
paramLog(par);
}
return {
title: "小程序",
path: `/pages/mallHome/mallHome?userId=${userInfo.value.id}&companyId=${userInfo.value.companyId}`,
};
});
onShareTimeline(() => {
return {
title: `测试小程序`,
query: ``,
};
});
这是其他页面的
onShareAppMessage((res) => {
if (res.from === "button") {
console.log(res.target);
}
const promise = new Promise((resolve, reject) => {
setTimeout(() => {
resolve({
title: info.value.title,
path: `/subpackage/pages/goodDetail/goodDetails?userId=${
userInfo.value.id
}&companyId=${userInfo.value.companyId}&id=${JSON.stringify(id.value)}`,
});
}, 10);
});
isShow.value = false;
const par = {
requestParam: {
userid: userInfo.value.id,
companyId: userInfo.value.companyId,
id: id.value,
},
appName: "shop",
moduleName: "share",
responseParam: res,
logMethod: "post",
logUri: `/subpackage/pages/goodDetail/goodDetails?userId=${
userInfo.value.id
}&companyId=${userInfo.value.companyId}&id=${JSON.stringify(id.value)}`,
logDesc: "商品分享",
logType: 8,
remark: `${shopObj.value.title.split("-")[0] || shopObj.value.title}`,
};
paramLog(par);
return {
promise,
};
});
onShareTimeline(() => {
const par = {
requestParam: {
userid: userInfo.value.id,
companyId: userInfo.value.companyId,
id: id.value,
},
appName: "shop",
moduleName: "share",
responseParam: "",
logMethod: "post",
logUri: `/subpackage/pages/goodDetail/goodDetails?userId=${
userInfo.value.id
}&companyId=${userInfo.value.companyId}&id=${JSON.stringify(id.value)}`,
logDesc: "商品分享朋友圈",
logType: 8,
remark: `${shopObj.value.title.split("-")[0] || shopObj.value.title}`,
};
paramLog(par);
return {
title: `${shopObj.value.title.split("-")[0] || shopObj.value.title}`,
query: `
userId=${userInfo.value.id}
&companyId=${userInfo.value.companyId}
&id=${JSON.stringify(id.value)}
&shareTime=${JSON.stringify(true)}
&list=${JSON.stringify(list.value)}
&info=${JSON.stringify(info.value)}
&shopInfo=${JSON.stringify(shopInfo.value)}`,
imageUrl: urlBase.value + mainImg.value,
};
});
不是在组件里面加的嘛,页面没有调用隐藏分享功能的api嘛
组件中的页面不会生效,需要宿主页面里加