SilurianYang / uni-simple-router

A simple, lightweight 'uni-app' routing plugin
https://v2.hhyang.cn/v2/
MIT License
749 stars 164 forks source link

encodeURIComponent(JSON.stringify(a)) 源码报错 #324

Closed siwf closed 3 years ago

siwf commented 3 years ago

"uni-simple-router": "2.0.6"

小程序内嵌h5, h5页面拉起微信支付 向小程序传参 encodeURIComponent(JSON.stringify(a))
这个时候支付成功或者失败路由跳转时候会报以下错误

VM5236 WAService.js:2 SyntaxError: Unexpected token t in JSON at position 10 at JSON.parse () at Object.h [as createRoute] (vendor.js?t=wechat&s=1632390873394&v=5aeaf07762f545a241d35db92fda89e1:10268) at Object.t.createToFrom (vendor.js?t=wechat&s=1632390873394&v=5aeaf07762f545a241d35db92fda89e1:10268) at s (vendor.js?t=wechat&s=1632390873394&v=5aeaf07762f545a241d35db92fda89e1:10268) at vendor.js?t=wechat&s=1632390873394&v=5aeaf07762f545a241d35db92fda89e1:10268 at Object.t.lockDetectWarn (vendor.js?t=wechat&s=1632390873394&v=5aeaf07762f545a241d35db92fda89e1:10268) at Object.c [as lockNavjump] (vendor.js?t=wechat&s=1632390873394&v=5aeaf07762f545a241d35db92fda89e1:10268) at Object.push (vendor.js?t=wechat&s=1632390873394&v=5aeaf07762f545a241d35db92fda89e1:10268) at fail (pay.js:236) at Object.forEach.s. (VM5236 WAService.js:2)(env: Windows,mp,1.05.2108130; lib: 2.19.4)

报错 的原因是代码 image

SilurianYang commented 3 years ago

试试 v2.0.8 或者你打印下当前页面的 options

https://github.com/SilurianYang/uni-simple-router/blob/7e986c6ea856da22801be329ad55c8e7fd2fd35d/src/public/methods.ts#L224-L248

siwf commented 3 years ago

@SilurianYang { pay: "%7B%22timeStamp%22%3A%221632645711%22%2C%22package%22%3A%22prepay_id%3Dwx261641517071536ccc8a93bc764bf10000%22%2C%22paySign%22%3A%22A5ED8436BBA2688822DEA60E5C42563A%22%2C%22appId%22%3A%22wx1958146ffc65738f%22%2C%22signType%22%3A%22MD5%22%2C%22nonceStr%22%3A%221df5b4873a379dfe907448eedb36a4b5%22%2C%22order_id%22%3A%225767309046764421129%22%2C%22amount%22%3A1000%2C%22successUrl%22%3A%22https%3A%2F%2Fwww.jdxlt.com%2Fintake_v2%2Fevaluation_center%22%7D" }

SilurianYang commented 3 years ago

试试v2.0.8能否正常运行

siwf commented 3 years ago

@SilurianYang 好的我试试 应该是encodeURI两次导致的

siwf commented 3 years ago

@SilurianYang 问题解决 非常感谢