You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
775 B
JavaScript
37 lines
775 B
JavaScript
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 = () => {},status=false) => {
|
|
if(status){
|
|
getFuzzyLocation(cb)
|
|
}else{
|
|
HospitalInfo(26.536252, 101.715271, cb)
|
|
}
|
|
|
|
|
|
}
|
|
export default hospital |