测试接口需要异步

This commit is contained in:
gaofy 2023-12-28 14:27:25 +08:00
parent 4f1d83cf2e
commit 637286cab7
3 changed files with 26 additions and 9 deletions

View File

@ -5,12 +5,12 @@ const HOST = 'http://123.57.147.184:3001';
export const get = (url: any, params: any, success: any) => {
axios.get(HOST + url, params)
.then(res => {
success(res);
})
.catch(err => {
success(err);
});;
.then(res => {
success(res);
})
.catch(err => {
success(err);
});
};
export const post = (url: any, params: any, success: any) => {
axios.post(HOST + url, params)
@ -24,3 +24,9 @@ export const post = (url: any, params: any, success: any) => {
export const getMapJson = (name: string) => {
return axios.post('/static/json/' + name)
}
export const getData = (url: string, params?: any) => {
return axios.get(url, params)
}
export const postData = (url: string, params?: any) => {
return axios.post(url, params)
}

View File

@ -1,9 +1,17 @@
import {getData, postData} from '@/axios/index'
export const getHospitalsData = () => {
const hospitals = []
const hospitals = [] as any
hospitals.push({ label: '北京朝阳医院', value: '北京朝阳医院' })
hospitals.push({ label: '北京朝阳医院1', value: '北京朝阳医院1' })
hospitals.push({ label: '北京朝阳医院2', value: '北京朝阳医院2' })
return hospitals
return new Promise((resolve, reject) => {
getData('/url', {}).then((res: any) => {
resolve(hospitals)
}).catch((err: any) => {
resolve(hospitals)
})
})
}
export const getPhoneAreasData = () => {

View File

@ -126,7 +126,10 @@ import { getHospitalsData, getPhoneAreasData } from '@/static-data/core'
const router = useRouter()
const hospitals: any = getHospitalsData()
const hospitals = ref([] as any)
getHospitalsData().then((res: any) => {
hospitals.value = res
})
const phoneAreas: any = getPhoneAreasData()
const loginRules = reactive({