IOS系统使用微信分享接口时候出现fail link must be in js secure domain list报错,在安卓实机上和微信开发工具上没有报错,路径上并没有中文字符,而且我还将路径后面的字符进行了转码也不行,不转码的时候也是不行的,安全域名为zhaodi.net.cn vue项目,微信相关代码如下
getWX_token() {
this.$ajax({
method: "post",
url: "notice/get_token/",
data: {
url: encodeURIComponent(location.href.split("#")[0])
}
})
.then(response => {
console.log(response);
this.wx_data = response.data;
this.wxApi();
})
.catch(error => {
Toast({
message: "服务器出错,请尝试刷新"
});
console.log(error + "测试错误");
});
},
wxApi() {
let data = this.wx_data;
let URIstring = this.$route.path;
URIstring = URIstring.slice(12);
console.log(URIstring);
let option = {
title: this.news.title,
link: "http://zhaodi.net.cn:443/prevueinfo/" + encodeURIComponent(URIstring),
imgUrl: "http://118.31.60.22/static/images/landimages/" + this.news.img,
desc: this.news.desc
};
console.log(option.link);
setTimeout(() => {
wxapi.wxRegister(data, option);
}, 400);
}
const wxApi = {
/**
* [wxRegister 微信Api初始化]
* @param {Function} callback [ready回调函数]
*/
wxRegister(data, option) { //data是微信配置信息,option是分享的配置内容
wx.config({
debug: true, // 开启调试模式
appId: data.app_id, // 必填,公众号的唯一标识
timestamp: data.timestamp, // 必填,生成签名的时间戳
nonceStr: data.noncestr, // 必填,生成签名的随机串
signature: data.signature, // 必填,签名,见附录1
jsApiList: [
'checkJsApi',
'updateTimelineShareData',
'updateAppMessageShareData',
'onMenuShareQQ',
'onMenuShareWeibo'
] // 必填,需要使用的JS接口列表,所有JS接口列表见附录2
})
wx.ready(function () {
wx.updateTimelineShareData({
title: option.title, // 分享标题
link: option.link, // 分享链接
imgUrl: option.imgUrl, // 分享图标
desc: option.desc, // 分享描述
success() {
// 用户成功分享后执行的回调函数
alert(option.title)
option.success()
},
cancel() {
// 用户取消分享后执行的回调函数
option.error()
}
});
wx.updateAppMessageShareData({
title: option.title, // 分享标题
desc: option.desc, // 分享描述
link: option.link, // 分享链接
imgUrl: option.imgUrl, // 分享图标
success() {
// 用户成功分享后执行的回调函数
alert(option.title)
option.success()
},
cancel() {
// 用户取消分享后执行的回调函数
option.error()
}
})
})
}
}