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

fix: 首页切换区域,选中项与url参数不同步修正

parent 87b68d29
......@@ -144,6 +144,7 @@ import { useRoute } from 'vue-router';
// import cookie from 'js-cookie';
import { useCity } from '@/composable/useCity.ts';
import type { DropdownInstance } from 'element-plus';
import type { RouteLocationRaw } from 'vue-router';
const props = withDefaults(
defineProps<{
......@@ -248,12 +249,15 @@ const changeCityStatus = (status: number) => {
const handleCityClick = (cityName: string) => {
currentCity.value = cityName;
// cookie.set('city', cityName);
const cityInFilter = provinceList.filter((item) => {
return item.name.replace(/\s+/g, '').indexOf(cityName) > -1;
});
const jump = (params: RouteLocationRaw) => {
openPage(params);
router.replace(params);
};
if (cityInFilter.length) {
openPage({
jump({
name: route.name!,
query: {
city: cityInFilter[0].name,
......@@ -261,7 +265,7 @@ const handleCityClick = (cityName: string) => {
},
});
} else {
openPage({
jump({
name: route.name!,
query: {},
});
......@@ -275,7 +279,7 @@ const handleLogin = (type: 'loginByPhone' | 'register') => {
};
const toUserCenter = () => {
dropdown.value.handleClose();
dropdown.value!.handleClose();
if (!(route.name as string).includes(RouteName.userCenter)) {
router.push(RouteName.userCenter);
}
......
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