瑞梦思预约小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
1.2 KiB

3 years ago
const baseURL= 'http://192.168.0.111:8088/api/';
// const baseURL= "https://www.cyjyyjy.com/api/"
3 years ago
export function $http(methods,url,params){
var header = {
'content-type': 'application/json',
3 years ago
'Authorization':'Bearer '+ wx.getStorageSync('token') || '',
'dept': '22'
3 years ago
};
return new Promise((resolve,reject)=>{
wx.showLoading({
title: '正在加载中...',
})
wx.request({
url: baseURL + url,
method: methods,
header: header,
data: params || {},
success: res=> {
wx.hideLoading();
if(!res.data.success && res.data.status == 401){
// console.log('登陆失效')
wx.navigateTo({
url: '/pages/login/index',
})
return
}
if(res.data.success){
resolve(res);
} else{
wx.showToast({
title: '服务器错误,请稍后再试!',
3 years ago
icon: 'none'
})
reject(err)
3 years ago
}
},
fail: err=> {
wx.hideLoading();
wx.showToast({
title: '服务器错误,请稍后再试!',
3 years ago
icon: 'none'
3 years ago
})
reject(err)
}
})
})
}