重写筛选组件和筛选参数全局化

This commit is contained in:
A1300399510
2024-03-22 17:16:42 +08:00
parent 172b7274a9
commit 5db2d47c2d
22 changed files with 284 additions and 57 deletions

View File

@@ -78,30 +78,35 @@ app.use(store).use(router).use(Axios)
api.index()
.then(res => {
store.state.seachTypeData = res.data.combination
store.state.indexData = res.data
store.state.ListSelectBtn = res.data.recommendedTab
store.state.user = res.data.user
store.state.nav = res.data.nav
store.state.wechat = res.data.wechat
store.state.apartment = res.data.config.apartment
store.state.schoolList = res.data.schoolList
store.state.advData = res.data.adv
store.state.typeKey = res.data.config.type
store.state.locationKey = res.data.config.location
const data = res.data
store.state.seachTypeData = data.combination
store.state.indexData = data
store.state.ListSelectBtn = data.recommendedTab
store.state.user = data.user
store.state.nav = data.nav
store.state.wechat = data.wechat
store.state.apartment = data.config.apartment
store.state.schoolList = data.schoolList
store.state.advData = data.adv
store.state.typeKey = data.config.type
store.state.locationKey = data.config.location
// 将 location 转换为对象 好用于级联选择器
const location = res.data.config.location || {}
const type = res.data.config.type || {}
const location = data.config.location || {}
const type = data.config.type || {}
store.state.locationObj = optimalValue(location)
store.state.typeObj = optimalValue(type)
store.state.brandKey = optimalValueArray(data.config.apartment.brand || [])
store.state.roomTypeKey = optimalValueArray(data.config.apartment.roomtype || [])
store.state.roomlistingsKey = optimalValueArray(data.config.apartment.roomlistings || [])
})
.finally(() => {
app.mount("#app")
})
// 优化值
// 优化值 1 1.1 1.2 类似的值
const optimalValue = data => {
let obj = {}
for (const key in data) {
@@ -120,3 +125,12 @@ const optimalValue = data => {
return obj || {}
}
// 优化值 数组 转对象
const optimalValueArray = data => {
let obj = {}
data.forEach(item => {
obj[item.id] = item.name
})
return obj
}