import {axiosInstance} from './axiosInstance' let cache = {} as any let brandHotelsCache = undefined as undefined | any export default async (instance:string )=> { if(cache[instance]) { return cache[instance] } if(instance == 'bestNew'){ try{ const res = await axiosInstance.get('https://c.huamei2001.com/static/hmPicks/bestNewHotelImages.json') as any cache = res.data return cache }catch(e){ console.error(`getDesignExamples err1 ${JSON.stringify(e)}`) return [] } }else{ try{ if(!brandHotelsCache){ try{ const brandHotelsCacheRes = await axiosInstance.get('https://c.huamei2001.com/static/hmPicks/y3DesignBrands.json') as any brandHotelsCache = brandHotelsCacheRes.data }catch(e){ console.error(`getDesignExamples err2 ${JSON.stringify(e)}`) } } const brandHotels = brandHotelsCache[instance] || [] const images = [] as any[] for(let h of brandHotels){ try{ const hotelImagesRes = await axiosInstance.get(`https://c.huamei2001.com/static/hmPicks/y3DesignImages/${h["酒店名称"]}.json`) as any const hotelImages = hotelImagesRes.data images.push(...hotelImages.map((im:any)=>{ return { ...im, '开业时间':h['开业时间'] } })) }catch(e){ console.error(`getDesignExamples err3 ${JSON.stringify(e)}`) } } cache[instance] = images return cache[instance] }catch(e){ console.error(`getDesignExamples err4 ${JSON.stringify(e)}`) return [] } } }