import { HospitalInfoAction, $response } from '@/api/index.js' const getFuzzyLocation = (cb) => { wx.getFuzzyLocation({ type: 'wgs84', success(res) { HospitalInfo(res.latitude, res.longitude, cb) }, fail() { HospitalInfo(26.536252, 101.715271, cb) } }) } const HospitalInfo = async (latitude, longitude, cb) => { const hospital_id = uni.getStorageSync('HOSPITAL_ID') const response = await HospitalInfoAction({ id: hospital_id ?? 0, latitude, longitude }) $response(response, () => { uni.setStorageSync('HOSPITAL_ID', response.data.info.id) cb(response.data.info) }) } const hospital = (cb = () => {}) => { getFuzzyLocation(cb) } export default hospital