|
@@ -310,6 +310,31 @@ export default {
|
|
|
url: '/pages/home/cart?account=' + account + '&hdId=' + hdId
|
|
url: '/pages/home/cart?account=' + account + '&hdId=' + hdId
|
|
|
})
|
|
})
|
|
|
},
|
|
},
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 解码路由里的搜索词
|
|
|
|
|
+ * 首页跳转会 encodeURIComponent;微信/uni-app 可能再编一层,onLoad 只解一次时仍是 %E9..,需再解才是中文
|
|
|
|
|
+ */
|
|
|
|
|
+ decodeRouteKeyword(raw) {
|
|
|
|
|
+ let s = String(raw || '')
|
|
|
|
|
+ if (!s) {
|
|
|
|
|
+ return ''
|
|
|
|
|
+ }
|
|
|
|
|
+ // 最多解两层,兼容「只编一次已被框架解开」和「双重编码仍带 %」
|
|
|
|
|
+ let i = 0
|
|
|
|
|
+ while (i < 2 && s.indexOf('%') !== -1) {
|
|
|
|
|
+ i += 1
|
|
|
|
|
+ try {
|
|
|
|
|
+ const next = decodeURIComponent(s)
|
|
|
|
|
+ if (next === s) {
|
|
|
|
|
+ break
|
|
|
|
|
+ }
|
|
|
|
|
+ s = next
|
|
|
|
|
+ } catch (e) {
|
|
|
|
|
+ break
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return s
|
|
|
|
|
+ },
|
|
|
/**
|
|
/**
|
|
|
* 解析路由带入的筛选与搜索关键词
|
|
* 解析路由带入的筛选与搜索关键词
|
|
|
* searchText:首页搜索框跳转带入,回填搜索框并参与首次列表请求
|
|
* searchText:首页搜索框跳转带入,回填搜索框并参与首次列表请求
|
|
@@ -318,7 +343,7 @@ export default {
|
|
|
*/
|
|
*/
|
|
|
applyRouteFilter() {
|
|
applyRouteFilter() {
|
|
|
// 首页搜索跳转:回填关键词,init 随后 loadGoods 会带上 searchText
|
|
// 首页搜索跳转:回填关键词,init 随后 loadGoods 会带上 searchText
|
|
|
- const keyword = (this.option && this.option.searchText) ? String(this.option.searchText) : ''
|
|
|
|
|
|
|
+ const keyword = (this.option && this.option.searchText) ? this.decodeRouteKeyword(this.option.searchText) : ''
|
|
|
if (keyword) {
|
|
if (keyword) {
|
|
|
this.searchText = keyword
|
|
this.searchText = keyword
|
|
|
}
|
|
}
|