@tplc/business
Version:
18 lines (15 loc) • 545 B
text/typescript
import { ChildHotAddress } from '../components/lcb-city-select/api'
/** 设置城市历史记录 */
export const setHistoryCity = (address?: ChildHotAddress) => {
uni.setStorageSync('cityHistory', {
address,
time: new Date().getTime(),
})
}
/** 获取城市历史记录如果超过3天就不使用历史 */
export const getHistoryCity = () => {
const history = uni.getStorageSync('cityHistory')
if (history && new Date().getTime() - history.time < 3 * 24 * 60 * 60 * 1000) {
return history.address as ChildHotAddress
}
}