UNPKG

@tplc/business

Version:

25 lines (22 loc) 705 B
import { ChildHotAddress } from '../components/lcb-city-select/api' /** 设置城市历史记录 */ export const setHistoryCity = (address?: ChildHotAddress) => { getApp().globalData!.currentCity = address uni.setStorageSync('cityHistory', { address, time: new Date().getTime(), }) } /** 获取城市历史记录如果超过3天就不使用历史 */ export const getHistoryCity = () => { const history = uni.getStorageSync('cityHistory') if ( history && new Date().getTime() - history.time < (uni.$lcb.constantsStore?.().mainConfig?.cityExpirationTime || 0) ) { return history.address as ChildHotAddress } else { return getApp().globalData!.currentCity } }