123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- const baseUrl="http://api.app.jiuweiyun.cn/api";
- const request=function(url,dataPraams,method="POST"){
-
- url=baseUrl+url;
-
- // 显示loading
- uni.showLoading({
- title: '加载中'
- });
-
- return new Promise((resolve,reject)=>{
- uni.request({
- url,
- method,
- data:dataPraams,
- success:function(res){
- uni.hideLoading();
- const {data}=res
- const { code, msg}=data
-
- if(code===200){
- resolve(data)
- }else{
- // uni.showToast({
- // title: msg,
- // icon:"none",
- // duration: 3500
- // })
- reject(data)
- }
- },
- fail:function(err){
- console.log('失败',err)
- uni.hideLoading();
- uni.showToast({
- title:"网络加载失败",
- icon:"none",
- duration: 3500
- })
- reject(err)
- }
- })
- })
-
- }
- export default request;
|