vue hash模式下,微信js sdk的config始终失败,全网没有可靠有效的解决方案?

小程序 文章 2020-07-31 19:01 530 0 全屏看文

AI助手支持GPT4.0

vue hash模式下,微信js sdk的config始终失败,全网没有可靠有效的解决方案?

信息1:微信开发者工具版本号:

信息2:页面提交的appid已与后台接口、公众号后台校验一致且无误

信息3:公众号后台已在业务域名、js接口安全域名、网页授权域名都配置好了本次相关的域名。

信息4:页面链接为http://fsdb.xxxx.cn/gcableshop/#/(url为vue的hash模式结构,且中间已用xxxx替换省略一部分),提交给后台生成签名等相关参数的接口的url已经过location.href.split("#")[0]处理,此处为了截图方便展示,暂不使用encodeURIComponent,实际测试当中,不管是否使用encodeURIComponent都无法成功。接口返回如下

信息5:与微信JS接口签名校验工具进行对照,生成的签名一致。

信息6:按照接口返回的签名、随机字符串、时间戳以及公众号的appid进行wx.config,结果返回签名出错,错误码63002

信息7:vue引入js sdk的方式尝试过weixin-jsapi和weixin-js-sdk,都能调用到wx.config,但都是设置失败

信息8:通读文档附录5,并且照着全部检查了一遍,并没有找到不符合要求的地方。

信息9:在vue的生命周期中,created和mounted中都尝试过wx.config,都无法成功。

综上,提问:

1、vue hash模式下,真的无法使用微信的js sdk吗?在线等,急,信息已经发到非常详实,请不要再对这个问题草草了之,没有下文。

2、vue hash模式下,原本跟在#后面的参数,无法配置到分享的页面链接中,有什么方案可以解决这个问题吗?

问题1最急,还请重点回答这个。

Information 1: WeChat developer tool version number: Information 2: the appid submitted by the page has been consistent with the background interface, official account background check and error free 3: the official account has been configured in the business domain name, JS interface security domain name, and web domain authorization domain name. Message 4: page link is http://fsdb.xxxx.cn/gcableshop/#/ (the URL is the hash pattern structure of Vue, and some parts have been replaced by XXX in the middle). The URL submitted to the interface for generating signature and other related parameters in the background has passed location.href.split ("ා) [0] processing. For the sake of convenient display of screenshots, encodeurcomponent is not used for the moment. During the actual test, whether encoderur is used or not is not used Icomponents failed. The interface returns the following information 5: compared with wechat JS interface signature verification tool, the generated signature is consistent. Message 6: according to the signature, random string, time stamp and appid of the official account returned by the interface. wx.config 7: Vue has tried to introduce the way of JS SDK, Weixin JS API and Weixin JS SDK can be called wx.config , but the settings failed Message 8: read through Appendix 5 of the document, and check all of them, and no non-compliance is found. Message 9: in the life cycle of Vue, both created and mounted have been tried wx.config , can't succeed. To sum up, question: 1. Under Vue hash mode, can we really not use wechat's JS SDK? Online wait, urgent, information has been sent to very detailed, please don't rush to this problem, no more below. 2. In Vue hash mode, the parameters that originally follow ා, cannot be configured in the shared page link. Is there any solution to solve this problem? Question 1 is the most urgent one. Please focus on this.

回答:

我有一只傻狍子:
  1. vue hash模式是可以使用jssdk的,之前有一个项目就是这样使用的,问题不在于vue与其路由模式,建议还是检查签名的问题,如果你确定检查其他流程都没问题,可以检查下调用wx.config的参数是不是传入错误


2.分享链接是可以配置的,配置完sdk后, wx.updateAppMessageShareData 可以配置分享链接,将带#号的完整链接配置进去就行了

stop eating:

张有釜:

created和mounted都在vue的生命周期内进行

老兄 你试试先初始化wxjsdk 再挂载到全局的vue上

-EOF-

AI助手支持GPT4.0