|
@@ -48,8 +48,11 @@
|
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
|
+const router = useRoute()
|
|
|
const AREA_TEXT = '地域'
|
|
|
|
|
|
+const areaId = useRouteParam("area")
|
|
|
+
|
|
|
const filterList = ref([])//地域列表
|
|
|
|
|
|
const curFilter = ref({})//当前筛选条件(国家)
|
|
@@ -66,19 +69,37 @@ const dropDownMenuRef = ref(null)
|
|
|
// 获取筛选列表
|
|
|
async function getFilters() {
|
|
|
const { data } = await request(`website/tourism/projectTravelNotes/travelNotesDirectoryList`).finally(()=>{closeToast()})
|
|
|
- if (!Array.isArray(data)) return
|
|
|
+
|
|
|
+ if (!Array.isArray(data)) return getList()
|
|
|
+ const routerAreaId = 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'})
|
|
|
item.children.map((item2, index2) => {
|
|
|
data[index].children[index2].id = item2.countryId
|
|
|
data[index].children[index2].text = item2.countryName
|
|
|
data[index].children[index2].areaId = item.areaId
|
|
|
+ data[index].children[index2].areaName = item.areaName
|
|
|
})
|
|
|
}
|
|
|
})
|
|
|
+ if(routerAreaId){
|
|
|
+
|
|
|
+ }
|
|
|
filterList.value = [{ id: 0, text: '全部', children: [{ id: 0, text: '全部' }] }, ...data]
|
|
|
+ getList()
|
|
|
}
|
|
|
|
|
|
// 监听地域筛选框收起
|
|
@@ -114,10 +135,13 @@ async function getList() {
|
|
|
pageSize: pageSize.value,
|
|
|
}
|
|
|
|
|
|
- if (curFilter.value.id) {
|
|
|
- param.areaId = curFilter.value.areaId
|
|
|
- param.countryId = curFilter.value.id
|
|
|
+ if(curFilter.value.areaId) param.areaId = curFilter.value.areaId
|
|
|
+
|
|
|
+ if(curFilter.value.id) {
|
|
|
+ const countryId = curFilter.value.id.split(',')
|
|
|
+ if(!countryId[1]) param.countryId = curFilter.value.id
|
|
|
}
|
|
|
+
|
|
|
if (travelWriteType.value) {
|
|
|
param.travelWriteType = travelWriteType.value
|
|
|
}
|
|
@@ -150,7 +174,7 @@ function handleFilterClick(item) {
|
|
|
dataList.value = []
|
|
|
getList()
|
|
|
dropDownMenuRef.value && dropDownMenuRef.value.close()
|
|
|
- document.title=`${item.id?'游记-'+item.text:'旅游笔记'}`
|
|
|
+ document.title=`${item.id?'游记-'+item.areaName+'-'+item.text:'旅游笔记'}`
|
|
|
}
|
|
|
|
|
|
function transferCount(num=0){
|
|
@@ -170,8 +194,7 @@ function convertTag(str=''){
|
|
|
return str.split('&')
|
|
|
}
|
|
|
|
|
|
-onMounted(() => {
|
|
|
- getList()
|
|
|
+onMounted( async () => {
|
|
|
getFilters()
|
|
|
})
|
|
|
|