微信公众号禁用右上角分享
发表时间:2020-9-29
发布人:葵宇科技
浏览次数:57
// 禁用分享(请求后台接口获取appid,签名,时间戳等数据)
getJSSDK () {
const that = this
const url = api.getJSSDK
const routerPath = window.location.href.split('#')[0]
console.log(routerPath, 'routerPath')
that.$POST(url, { url: routerPath }, res => {
console.log(res, 'getJSSDK')
if (res.errorCode === 0) {
if (res.body) {
window.wx.config({
debug: false,
appId: res.body.appId,
timestamp: res.body.timestamp,
nonceStr: res.body.nonceStr,
signature: res.body.signature,
jsApiList: ['hideMenuItems'],
success: function (res) {
alert('成功')
console.log(res, '成功')
},
fail: function (res) {
alert('失败失败')
console.log(res, '失败')
},
complete: function (res) {
alert('complete')
console.log(res, '777777777777')
}
})
window.wx.ready(function () {
console.log('禁止分享')
window.wx.hideMenuItems({ // 要隐藏的菜单项,只能隐藏“传播类”和“保护类”按钮,所有menu项见附录3
menuList: ['menuItem:share:appMessage', 'menuItem:share:timeline', 'menuItem:share:timeline', 'menuItem:share:qq', 'menuItem:favorite', 'menuItem:share:QZone', 'menuItem:openWithSafari', 'menuItem:copyUrl', 'menuItem:share:email']
})
})
}
}
})
},