微信分享H5跳转小程序,但是签名一致还是会提示错误信息?
发布于 4 年前 作者 gongchao 11115 次浏览 来自 问答

目前使用APP微信分享H5界面,点击H5跳转到小程序,现在卡在签名校验这一块了,我配置的信息读取到的签名与签名检验的一致 ,但还是提示:errmsg config: invalid signature ,网上扒拉好多资料也是白搭,很费解啊,请问各位大神有没有思路方法的分享一下,谢谢了

下面是js里代码:

<script src=“https://res2.wx.qq.com/open/js/jweixin-1.6.0.js”></script> 

&lt;wx-open-launch-weapp

	&nbsp; id="launch-btn"

	&nbsp; username="gh\_XX"

	&nbsp; path="/pages/home/index.html?shareuid={$shareuid}"

	&gt;

	&nbsp; &lt;template&gt;

	&nbsp; &nbsp; &lt;style&gt;.btn { padding: 12px;width: 150px;height: 40px;background-color: \#07C160;color: \#fff;}&lt;/style&gt;

	&nbsp; &nbsp; &lt;button class="btn"&gt;打开小程序&lt;button&gt;

	&nbsp; &lt;/template&gt;

	&lt;/wx-open-launch-weapp&gt;	

&lt;script type="text/javascript"&gt;

	var html\_rul = location.href.split('\#')\[0\];

	// html\_rul = encodeURIComponent(html\_rul); 这个加不加都一样报错

	$.ajax({

		url:'/wxshare/Share/getSignPackage',

		data:{html\_rul:html\_rul},

		type:'POST',

		dataType:'json',

		success:function(data){

			var signature=data.info.signature;

			var timestamp=data.info.timestamp;

			var nonceStr=data.info.nonceStr;

			var appId=data.info.appId;

			var rawString=data.info.rawString;

			var url=data.info.url;

			//alert(data.info.rawString);

			console.log(rawString);

			wx.config({&nbsp; &nbsp;&nbsp;

				debug:true, // 是否开启调试模式

				appId:appId,//'wxa4fc16dc02bb0f7d', // 必填,公众号的唯一标识&nbsp; &nbsp;&nbsp;

				timestamp:timestamp,//'1621308771' , // 必填,生成签名的时间戳

				nonceStr:nonceStr, //'UgGLN1qiFS9fkt88', // 必填,生成签名的随机串

				signature: signature,//'df5e2ea57e28a6b991cbec78dc5359928e58d4b7',// 必填,签名

				jsApiList:\['getLocation',

							'onMenuShareTimeline',

							'onMenuShareAppMessage'\], // 必填,需要使用的JS接口列表

				openTagList: \['wx-open-launch-weapp'\] // 可选,需要使用的开放标签列表,例如\['wx-open-launch-app'\]

			});&nbsp;

		},

		error:function(){

			return !1;

		}

	})

	//alert(location.href.split('\#')\[0\]);

	wx.ready(function () {

		console.log('ready');

	});

	wx.error(function (res) {

		console.log('error');

	});

	var btn = document.getElementById('launch-btn');

	btn.addEventListener('launch', function (e) {

		console.log('success');

	});

	btn.addEventListener('error', function (e) {

		console.log('fail', e.detail);

	});

&lt;/script&gt;
1 回复

公众号有没有配置好安全域名?

回到顶部