@tplc/business
Version:
19 lines (16 loc) • 621 B
text/typescript
import { ChildHotAddress } from '../components/lcb-city-select/api'
import { getCityData } from './utils'
/** 设置城市历史记录 */
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')
const data = history?.address ? getCityData(history.address) : getApp().globalData!.currentCity
return getCityData(data)
}