ng(firstParamMatch[0].length); console.log('27. 替换后 param_str:', param_str); } else { // 如果没有城市代码,在开头添加 console.log('28. 未找到城市代码,添加前 param_str:', param_str); param_str = '-' + href + param_str; console.log('29. 添加后 param_str:', param_str); } } } else { // Search 页面:保持原有逻辑 var index = param_str.indexOf('-'); if(index > 0){ param_str = href + param_str.substr(index); }else{ param_str = href; } } } //param_str = param_str.replace(/(-LC|-SC)/,''); // 对于 keywords 页面,确保 param_str 格式正确 // keywords 页面的筛选参数应该以 - 开头(如 -LW-ST-MH) if(isKeywordPage && param_str && !param_str.match(/^-/)) { // 如果 param_str 不是以 - 开头,说明可能是城市代码或其他格式 // 对于 keywords 页面,这种情况不应该出现,但为了兼容性,加上 - 前缀 param_str = '-' + param_str; } param_str += time; // 调试日志:最终结果 console.log('30. 最终 param_str (添加time后):', param_str); console.log('31. 最终 host:', host); let finalUrl = isKeywordPage ? (host + param_str) : (host + param_str); console.log('32. 最终 URL:', finalUrl); console.log('=== 筛选参数处理结束 ==='); // 对于 keywords 页面,URL 格式应该是 keywords/关键词-参数 // 对于 Search 页面,URL 格式应该是 Search/城市-参数 if(isKeywordPage) { // keywords 页面:host 已经是 keywords/关键词,param_str 是筛选参数(如 -LW-ST-MH?page=1) window.location.href = finalUrl; } else { // Search 页面:host 是 Search/,param_str 是城市-参数(如 china-LW-ST-MH?page=1) window.location.href = finalUrl; } });