Commit fbb053a3 authored by 王玉鑫's avatar 王玉鑫

fix: 切回首页城市初始化修正

parent 11d22ed2
...@@ -187,7 +187,9 @@ const userInfo = computed(() => { ...@@ -187,7 +187,9 @@ const userInfo = computed(() => {
const showUserCenter = ref<boolean>(false); const showUserCenter = ref<boolean>(false);
const currentCity = ref<string>('全国'); const filterSpace = (name: string) => {
return name.replace(/\s+/g, '');
};
const { getProvinces } = useCity(); const { getProvinces } = useCity();
...@@ -236,6 +238,19 @@ const cityList = [ ...@@ -236,6 +238,19 @@ const cityList = [
}, },
]; ];
const currentCity = ref<string>('');
const initCity = () => {
const name = filterSpace(searchParamsStore.globalProvinceName);
const result = cityList
.map(({ items }) => items)
.flat()
.find((i) => name.indexOf(i) > -1);
currentCity.value = result || '全国';
};
initCity();
const dropdown = ref<DropdownInstance>(); const dropdown = ref<DropdownInstance>();
onMounted(() => { onMounted(() => {
...@@ -288,7 +303,7 @@ const changeCityStatus = (status: number) => { ...@@ -288,7 +303,7 @@ const changeCityStatus = (status: number) => {
/** 用于搜索条件的省名 */ /** 用于搜索条件的省名 */
const cityInFilter = computed(() => { const cityInFilter = computed(() => {
return provinceList.find((item) => { return provinceList.find((item) => {
return item.name.replace(/\s+/g, '').indexOf(currentCity.value) > -1; return filterSpace(item.name).indexOf(currentCity.value) > -1;
}); });
}); });
......
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