Commit 04104c20 by 李嘉林

feat: 优化

parent 2afaa98a
...@@ -65,7 +65,8 @@ export default { ...@@ -65,7 +65,8 @@ export default {
let pageUrl1 = (this.page.startsWith('http://') || this.page.startsWith('https://'))? (this.page + this.params) : this.link+this.page+this.params let pageUrl1 = (this.page.startsWith('http://') || this.page.startsWith('https://'))? (this.page + this.params) : this.link+this.page+this.params
let pageUrl = forUrlAddKey(decodeURIComponent(pageUrl1)); let pageUrl = forUrlAddKey(decodeURIComponent(pageUrl1));
console.log(pageUrl,'--pageUrl') console.log(pageUrl,'--pageUrl')
return pageUrl + this.ss + this.timestamp; let newPageUrl = this.removeEmptyQueryParams(pageUrl + this.ss + this.timestamp);
return newPageUrl;
} }
}, },
onLoad(options) { onLoad(options) {
...@@ -122,7 +123,7 @@ export default { ...@@ -122,7 +123,7 @@ export default {
}); });
} }
} }
this.pageUrl1 = this.pageUrl; this.pageUrl1 = this.removeEmptyQueryParams(this.pageUrl);
}, },
onShow(){ onShow(){
console.log('--onShow--') console.log('--onShow--')
...@@ -141,7 +142,7 @@ export default { ...@@ -141,7 +142,7 @@ export default {
setTimeout(() => { setTimeout(() => {
this.showPage = true; this.showPage = true;
}, 0); }, 0);
this.pageUrl1 = this.pageUrl + `&tim=${new Date().getTime()}` this.pageUrl1 = this.removeEmptyQueryParams(this.pageUrl + `&tim=${new Date().getTime()}`)
wx.removeStorageSync("reloadTabbarPage"); wx.removeStorageSync("reloadTabbarPage");
console.log(this.pageUrl1,'--this.pageUrl1') console.log(this.pageUrl1,'--this.pageUrl1')
} }
...@@ -155,6 +156,31 @@ export default { ...@@ -155,6 +156,31 @@ export default {
getMessage(res) { getMessage(res) {
this.$emit("getMessage",res); this.$emit("getMessage",res);
}, },
// 将多余的参数删除: ?abc=&cba=1 => ?cba=1
removeEmptyQueryParams(url) {
try {
// 分割URL,分离基础URL和查询字符串
const [baseUrl, queryPart] = url.split('?');
// 若没有查询字符串,直接返回基础URL
if (!queryPart) return baseUrl;
// 分割查询字符串为参数数组
const queryParams = queryPart.split('&');
// 过滤掉空值参数
const filteredParams = queryParams.filter(param => {
const [key, value] = param.split('=');
return value;
});
// 重新组合查询字符串并附加到基础URL上
const cleanedQuery = filteredParams.join('&');
return baseUrl + (cleanedQuery ? `?${cleanedQuery}` : '');
} catch (err) {
console.log('parseUrlError:', err);
return url;
}
}
}, },
}; };
</script> </script>
\ No newline at end of file
...@@ -479,6 +479,11 @@ export default { ...@@ -479,6 +479,11 @@ export default {
employeeId: paramsObj.setGuideEmployeeId, employeeId: paramsObj.setGuideEmployeeId,
}) })
} }
} else {
// 不是导购进入移除参数
wx.removeStorageSync(this.$store.state.mixid+'setGuideEmployeeId');
wx.removeStorageSync(this.$store.state.mixid+'guide_QRCodeType');
wx.removeStorageSync(this.$store.state.mixid+'temp_QRCodeType');
} }
if (paramsObj.QRCodeType) { if (paramsObj.QRCodeType) {
wx.setStorageSync(this.$store.state.mixid+'guide_QRCodeType', paramsObj.QRCodeType); wx.setStorageSync(this.$store.state.mixid+'guide_QRCodeType', paramsObj.QRCodeType);
......
...@@ -374,11 +374,16 @@ export default { ...@@ -374,11 +374,16 @@ export default {
// 判断是否为导购分享进入 // 判断是否为导购分享进入
if (paramsObj.setGuideEmployeeId) { if (paramsObj.setGuideEmployeeId) {
wx.setStorageSync(this.$store.state.mixid + 'setGuideEmployeeId', paramsObj.setGuideEmployeeId); wx.setStorageSync(this.$store.state.mixid + 'setGuideEmployeeId', paramsObj.setGuideEmployeeId);
}
if (paramsObj.QRCodeType) { if (paramsObj.QRCodeType) {
wx.setStorageSync(this.$store.state.mixid+'guide_QRCodeType', paramsObj.QRCodeType); wx.setStorageSync(this.$store.state.mixid+'guide_QRCodeType', paramsObj.QRCodeType);
wx.setStorageSync(this.$store.state.mixid+'temp_QRCodeType', paramsObj.QRCodeType); wx.setStorageSync(this.$store.state.mixid+'temp_QRCodeType', paramsObj.QRCodeType);
} }
} else {
// 非导购方式进入移除本地缓存
wx.removeStorageSync(this.$store.state.mixid+'setGuideEmployeeId');
wx.removeStorageSync(this.$store.state.mixid+'guide_QRCodeType');
wx.removeStorageSync(this.$store.state.mixid+'temp_QRCodeType');
}
wx.setStorageSync('attractingCustomerChannelId',paramsObj.attractingCustomerChannelId); wx.setStorageSync('attractingCustomerChannelId',paramsObj.attractingCustomerChannelId);
wx.setStorageSync(this.$store.state.mixid+'storeId',paramsObj.storeId); wx.setStorageSync(this.$store.state.mixid+'storeId',paramsObj.storeId);
wx.setStorageSync(this.$store.state.mixid+'sellerId',paramsObj.sellerId); wx.setStorageSync(this.$store.state.mixid+'sellerId',paramsObj.sellerId);
......
...@@ -212,13 +212,13 @@ export default { ...@@ -212,13 +212,13 @@ export default {
if (wx.getStorageSync("_ma_sid")) { if (wx.getStorageSync("_ma_sid")) {
this.link += `&_ma_sid=${wx.getStorageSync("_ma_sid")}`; this.link += `&_ma_sid=${wx.getStorageSync("_ma_sid")}`;
} }
this.useLink = this.link; this.useLink = this.removeEmptyQueryParams(this.link);
console.log(this.useLink,'--this.useLink') console.log(this.useLink,'--this.useLink')
}, },
}, },
methods: { methods: {
setLink(data) { setLink(data) {
this.link = data; this.link = this.removeEmptyQueryParams(data);
console.log(this.useLink,89999999) console.log(this.useLink,89999999)
}, },
getSsoBcakUrl(link) { getSsoBcakUrl(link) {
...@@ -290,6 +290,31 @@ export default { ...@@ -290,6 +290,31 @@ export default {
title: "网页加载失败 请右上角刷新", title: "网页加载失败 请右上角刷新",
}); });
}, },
// 将多余的参数删除: ?abc=&cba=1 => ?cba=1
removeEmptyQueryParams(url) {
try {
// 分割URL,分离基础URL和查询字符串
const [baseUrl, queryPart] = url.split('?');
// 若没有查询字符串,直接返回基础URL
if (!queryPart) return baseUrl;
// 分割查询字符串为参数数组
const queryParams = queryPart.split('&');
// 过滤掉空值参数
const filteredParams = queryParams.filter(param => {
const [key, value] = param.split('=');
return value;
});
// 重新组合查询字符串并附加到基础URL上
const cleanedQuery = filteredParams.join('&');
return baseUrl + (cleanedQuery ? `?${cleanedQuery}` : '');
} catch (err) {
console.log('parseUrlError:', err);
return url;
}
}
}, },
}; };
</script> </script>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment