Wechat's official account uses js-sdk injection to get configuration information fields.

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
      });
    }
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b2b269-2ba88.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b2b269-2ba88.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?