沈阳K11 横板
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

66 lines
2.0 KiB

import { useRootStore } from '@/store/root'
import { getConfig, getFacilitiesList, getWeather, getArtList } from '@/http/api/base'
import { getShopAndBuildingList } from '@/http/api/shop'
import { getDeviceInfo } from '@/http/api/building'
import { getShopListByFloor, getShopListByIndustry, getBrandInfo } from '@/http/api/brand'
import { getModuleList } from '@/http/api/home'
import Message from '@/base/Message/Message'
export const useInitConfigAndMallInfo = async () => {
try {
const _config = await getConfig()
const store = useRootStore()
store.SET_CONFIG(_config.data)
const [
_DeviceInfo,
_shopAndBuilding,
_facilityList,
_weather,
_shopListByFloor,
_shopListByIndustry,
_brandInfo,
_menuList,
_pictureList
] = await Promise.all([
getDeviceInfo(),
getShopAndBuildingList(),
getFacilitiesList(),
getWeather(),
getShopListByFloor(),
getShopListByIndustry(),
getBrandInfo(),
getModuleList(),
getArtList()
])
const { shopList, buildingList } = _shopAndBuilding.data
sortByFloorOrder(shopList)
store.SET_DEVICE(_DeviceInfo.data)
store.SET_SHOP_LIST(shopList)
store.SET_BUILDING_LIST(buildingList)
store.SET_BRAND_INFO(_brandInfo.data)
store.SET_SHOP_LIST_BY_FLOOR(_shopListByFloor.data.list)
store.SET_SHOP_LIST_BY_INDUSTRY(_shopListByIndustry.data.list)
store.SET_FACILITY_LIST(_facilityList.data)
store.SET_WEATHER(_weather.data)
_menuList.data.unshift({
moduleName: '主页',
status: 0
})
store.SET_MENU_LIST(_menuList.data)
store.SET_PICTURE_LIST(_pictureList.data)
} catch (error) {
console.log('开机读取JSON报错 :>> ', JSON.stringify(error))
Message({ text: '初始化数据失败', type: 'success' })
window.android.restartWebView()
}
}
function sortByFloorOrder(arr: Array<Shop>) {
arr.sort((a: Shop, b: Shop) => {
return b.floorOrder - a.floorOrder
})
}