do you want to get these three fields from the background
do you want to get these three fields from the background
Yes, you need to obtain it from the backend. First, store Wechat's official configuration file in the directory of the server where your page resides. It should be a txt file, and then use the url of the page as a parameter to request the backend API. The returned values of the API are those three fields
.$.ajax({
data: {
// url
url: encodeURI(location.href.split('-sharp')[0])
},
type: "GET",
url: "api/get-weixin-token",
success: function(data){
let timestamp = data.data.timestamp;
let noncestr = data.data.noncestr;
let signature = data.data.signature;
WxConfig(timestamp,noncestr,signature);
}
});
// config
function WxConfig(timestamp,noncestr,signature){
wx.config({
debug: false, // ,apialertpclogpc
appId: '', //
timestamp: timestamp, //
nonceStr: noncestr, //
signature: signature,//
jsApiList: ['onMenuShareTimeline','onMenuShareAppMessage','onMenuShareQQ','onMenuShareWeibo','onMenuShareQZone'] // JS
});
}