只在ios有问题 安卓没毛病
微信分享thepermission value is offline verif ?showMenuitems:thepermission value is offline verifying 在第一次进入页面的时候 报错,返回在进或者刷新就可以了 import jweixin from "./wx_js_sdk.js" import {appWchatService} from "@/common/api.js" /** * @description 微信分享函数 * @param {Object} object {title(分享标题),desc(分享描述),imgurl(分享图标)} */ const getweixinSherConfig = function(object) { console.log(object, "微信分享") let __href = location.href.split("#")[0] let weixinConfig = null appWchatService({ URL: __href }).then(function(res) { console.log(res) weixinConfig = res.data alert(JSON.stringify(weixinConfig)) jweixin.config({ debug: true, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。 appId: weixinConfig.appid, // 必填,公众号的唯一标识 timestamp: weixinConfig.timestamp, // 必填,生成签名的时间戳 nonceStr: weixinConfig.noncestr, // 必填,生成签名的随机串 signature: weixinConfig.signature, // 必填,签名 jsApiList: ["onMenuShareTimeline", "onMenuShareAppMessage", "updateAppMessageShareData","updateTimelineShareData","showMenuItems","hideMenuItems"] // 必填,需要使用的JS接口列表 }) let href = location.href // object.link = href var title = location.title var NewObj = object if(!object.title){ NewObj.title = title } if(object.link == ""){ NewObj.link = href } console.log(NewObj,title,href,"123131231") jweixin.ready(function() { jweixin.onMenuShareAppMessage(NewObj) jweixin.onMenuShareTimeline(NewObj) jweixin.showMenuItems({ menuList: ["menuItem:share:appMessage", "menuItem:share:timeline", "menuItem:share:qq", "menuItem:share:weiboApp", "menuItem:favorite", "menuItem:share:facebook", "menuItem:share:QZone"] // 要显示的菜单项,所有menu项见附录3 }); //隐藏 jweixin.hideMenuItems({ menuList:[ "menuItem:copyUrl", //复制链接 "menuItem:openWithQQBrowser", "menuItem:openWithSafari", "menuItem:share:email" ] }) }); }) } export default getweixinSherConfig
2021-12-08