fix: 适配多平台url编码规则,修复双重编码问题

针对H5和小程序/App平台分别处理url参数编码:
1. H5平台需要手动encodeURIComponent避免参数解析错误
2. 小程序/App平台由uni内部自动编码,避免双重编码导致参数解码异常
同时重构了工具类中的编码逻辑,统一多场景下的平台适配规则
This commit is contained in:
2026-07-10 11:29:16 +08:00
parent 897a8157e7
commit a90245b201
2 changed files with 36 additions and 11 deletions

View File

@@ -50,9 +50,18 @@ export default {
helpDetail(e) {
// #ifndef MP-WEIXIN
if (e.link_address) {
// H5:浏览器不自动编码,需要手动 encodeURIComponent
// 其他小程序平台(HarmonyOS 等):uni.redirectTo 内部会自动编码,不能再 encode,否则双重编码
// #ifdef H5
uni.redirectTo({
url: '/pages_tool/webview/webview?src=' + encodeURIComponent(e.link_address)
});
// #endif
// #ifndef H5
uni.redirectTo({
url: '/pages_tool/webview/webview?src=' + e.link_address
});
// #endif
} else {
this.$util.redirectTo('/pages_tool/help/detail', {
id: e.id