Micro-channel sharing, Andrews may ios signature is not valid

First, the first micro-channel sharing, you can share the success of Android, but under ios, signature failure

After confirming the basic configuration is not wrong (See the specific configuration of official documents) , found to be invalid URL signature cause.
Apple and Android browsers mechanisms in different micro letter, there are IOS caching problems, and IOS single page of the optimization problem, Andrews Jump for page refreshes when the current url to share, but Apple will not, Apple is coming through history not refreshed url so will lead to the signature fails
when jumping to share page, do not use the $router.push({ path: ‘分享页URL’})method,window.location.href=‘分享页URL’

Second, the secondary share the signature is invalid

After the first successful share, during the second share when iosit reported the signature is invalid, and finally found wrong or URL.
Due to the extra parameters to bring the post-secondary share the URL ?from=singlemessage&isappinstalled=0, wx.configuse at the time of obtaining the signature urlwith the signature server used urlinconsistent, leading to the signature is invalid.
The specific measures, the excess part of the URL interception

 //根据字段看网址是否拼接&字符串
    getQueryString(name) {
          var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
          var r = window.location.search.substr(1).match(reg);
          if (r != null)
              return unescape(r[2]);
          return null;
        },
        
		var from = _self.getQueryString('from');
        var appinstall =_self.getQueryString('appinstall');
        var isappinstalled =_self.getQueryString('isappinstalled');
        var sec = _self.getQueryString('sec');
        var timekey = _self.getQueryString('timekey');
        var code = _self.getQueryString('code'); //判断加上code是为了防止无限刷新
        var state = _self.getQueryString('state');
        var url = location.href;
        if(from || appinstall || isappinstalled || sec || timekey || code || state){//假如拼接上了 
            url = window.location.href.split('?')[0];
        }
        if (window.entryUrl == undefined) {
             window.entryUrl = location.href;
           }
export function isAndroid () {
      var u = navigator.userAgent
      var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Linux') > -1
      if (isAndroid) {
        return true
      } else {
        return false
      }
    }

URL obtain the signature of the time:url: isAndroid() ? url : window.entryUrl

Published 27 original articles · won praise 21 · views 4593

Guess you like

Origin blog.csdn.net/weixin_43997143/article/details/93723429