|
@@ -94,7 +94,8 @@
|
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
|
-const router = useRoute()
|
|
|
+const route = useRoute()
|
|
|
+const router = useRouter()
|
|
|
|
|
|
// 推荐项目
|
|
|
const { data } = await useMyFetch(
|
|
@@ -126,22 +127,12 @@ async function getFilters() {
|
|
|
const { data } = await request(`/website/tourism/projectTravelNotes/travelNotesDirectoryList`).finally(() => { closeToast() })
|
|
|
|
|
|
if (!Array.isArray(data)) return getList()
|
|
|
- const routerAreaId = null
|
|
|
+ let country = null;
|
|
|
data.map((item, index) => {
|
|
|
data[index].id = item.areaId
|
|
|
data[index].text = item.areaName
|
|
|
-
|
|
|
- // 处理地址栏带area参数的情况
|
|
|
- if (router.query.area == item.areaId) {
|
|
|
- curFilter.value.areaId = router.query.area
|
|
|
- document.title = item.areaName
|
|
|
- areaIndex.value = index + 1
|
|
|
- curFilter.value.id = item.areaId + ',all'
|
|
|
- areaFilterTitle.value = item.areaName
|
|
|
- }
|
|
|
-
|
|
|
if (Array.isArray(item.children)) {
|
|
|
- data[index].children.unshift({ countryName: '全部', countryId: item.areaId + ',all' })
|
|
|
+ data[index].children.unshift({ countryName: '全部', countryId: item.areaId+',all' })
|
|
|
item.children.map((item2, index2) => {
|
|
|
data[index].children[index2].id = item2.countryId
|
|
|
data[index].children[index2].text = item2.countryName
|
|
@@ -149,11 +140,43 @@ async function getFilters() {
|
|
|
data[index].children[index2].areaName = item.areaName
|
|
|
})
|
|
|
}
|
|
|
+
|
|
|
+ if(route.query.area && item.areaId == route.query.area){
|
|
|
+ curFilter.value.areaId = route.query.area
|
|
|
+ document.title = item.areaName
|
|
|
+ areaIndex.value = index + 1
|
|
|
+ areaFilterTitle.value = item.areaName
|
|
|
+ }
|
|
|
+
|
|
|
+ if(route.query.country){
|
|
|
+ const con = item.children.filter(c=>c.countryId == route.query.country)[0]
|
|
|
+ if(con){
|
|
|
+ country = con
|
|
|
+ }
|
|
|
+ }
|
|
|
})
|
|
|
- if (routerAreaId) {
|
|
|
+ if(country){
|
|
|
+ curFilter.value.countryId = route.query.country
|
|
|
+ curFilter.value.id = route.query.country
|
|
|
+ areaFilterTitle.value = country.areaName +'-'+country.countryName
|
|
|
+ }else{
|
|
|
+ if(curFilter.value.areaId){
|
|
|
+ curFilter.value.countryId = curFilter.value.areaId + ',all'
|
|
|
+ curFilter.value.id = curFilter.value.areaId + ',all'
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(route.query.country && !route.query.area){
|
|
|
+ data.map((item,index)=>{
|
|
|
+ item.children.map(subItem=>{
|
|
|
+ if(subItem.id == route.query.country){
|
|
|
+ areaIndex.value = index + 1
|
|
|
+ }
|
|
|
+ })
|
|
|
+ })
|
|
|
}
|
|
|
filterList.value = [{ id: 0, text: '全部', children: [{ id: 0, text: '全部' }] }, ...data]
|
|
|
getList()
|
|
|
+ getRecommend()
|
|
|
}
|
|
|
|
|
|
// 监听地域筛选框收起
|
|
@@ -222,20 +245,32 @@ function handleAreaClick(index) {
|
|
|
// 选择国家
|
|
|
function handleFilterClick(item) {
|
|
|
curFilter.value = item
|
|
|
- if (!item.id) {
|
|
|
- areaFilterTitle.value = AREA_TEXT
|
|
|
- } else {
|
|
|
- const areaText = filterList.value[areaIndex.value].text || ''
|
|
|
- const cityText = item.text || ''
|
|
|
- activeIndex.value = areaIndex.value
|
|
|
- areaFilterTitle.value = areaText + '-' + cityText
|
|
|
+ // if (!item.id) {
|
|
|
+ // areaFilterTitle.value = AREA_TEXT
|
|
|
+ // } else {
|
|
|
+ // const areaText = filterList.value[areaIndex.value].text || ''
|
|
|
+ // const cityText = item.text || ''
|
|
|
+ // activeIndex.value = areaIndex.value
|
|
|
+ // areaFilterTitle.value = areaText + '-' + cityText
|
|
|
+ // }
|
|
|
+ // pageNum.value = 1
|
|
|
+ // dataList.value = []
|
|
|
+ // getList()
|
|
|
+ // getRecommend()
|
|
|
+ // dropDownMenuRef.value && dropDownMenuRef.value.close()
|
|
|
+ // document.title = `${item.id ? '游记-' + item.areaName + '-' + item.text : '旅游笔记'}`
|
|
|
+
|
|
|
+ let search =''
|
|
|
+ if(item.areaId) search+='area='+item.areaId
|
|
|
+ if(item.id) {
|
|
|
+ const i = item.countryId.split(',')
|
|
|
+ if(!i[1]){
|
|
|
+ search+=`${item.areaId?'&':''}country=${item.id}`
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
- pageNum.value = 1
|
|
|
- dataList.value = []
|
|
|
- getList()
|
|
|
- getRecommend()
|
|
|
- dropDownMenuRef.value && dropDownMenuRef.value.close()
|
|
|
- document.title = `${item.id ? '游记-' + item.areaName + '-' + item.text : '旅游笔记'}`
|
|
|
+ location.search=`${search}`
|
|
|
+
|
|
|
}
|
|
|
|
|
|
function transferCount(num = 0) {
|
|
@@ -272,7 +307,7 @@ async function getRecommend(){
|
|
|
}
|
|
|
onMounted(async () => {
|
|
|
getFilters()
|
|
|
- getRecommend()
|
|
|
+
|
|
|
})
|
|
|
|
|
|
useSeoMeta({
|