const BASE_URL=‘https://mp.yjgyl.com.cn’ //域名
export const myRequest = (options) =>{ 导出
return new Promise ((resolve,reject) =>{
uni.request({
url:BASE_URL+options.url,
header:{
‘content-type’:‘application/json’,
},
method:options.methods,
data:options.data || {},
success:(res) =>{
if(res.data.code !== 0){
return uni.showToast({
title:‘获取失败’
})
}
resolve (res)
},
fail:(err) =>{
uni.showToast({
title:‘获取失败’
})
reject(err)
}
})
})
}
import {myRequest} from ‘路径’ //页面引入