限制微信公众号H5页面的部分功能
WXShare() {
var t, n, s, data = {};
data.url = location.href.split('#')[0];
$axios.post(`API`, $qs.stringify(data)).then(res => {
t = res.data.timestamp;
n = res.data.noncestr;
s = res.data.signature;
// 检测
wx.config({
debug: false,
appId: '公众号appId',
timestamp: t,
nonceStr: n,
signature: s,
// 检测是否支持当前API
jsApiList: ['checkJsApi', 'hideAllNonBaseMenuItem']
});
// 限制
wx.ready(function() {
// 限制微信分享给朋友、分享到朋友圈、收藏...
wx.hideAllNonBaseMenuItem();// 隐藏所有非基础按钮接口
});
}).catch(err => {
console.log(err);
});
}
注:微信公众平台开发提供的微信自定义分享功能、同时也提供了限制微信部分能力的入口和面板。
参考链接: 微信网页开发 —— JS-SDK文档