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.
49 lines
1.3 KiB
49 lines
1.3 KiB
//本地 |
|
// export const BASE_URL = 'http://192.168.16.3:8088/crk' |
|
// export const API_URL = 'http://192.168.16.3:8088/crk' |
|
export const BASE_URL = 'http://192.168.139.1:8088/crk' |
|
export const API_URL = 'http://192.168.139.1:8088/crk' |
|
//线上 |
|
// export const BASE_URL = 'https://www.huastech.com.cn/zcpd-app/zcpd' |
|
// export const API_URL = 'https://www.huastech.com.cn/zcpd-app' |
|
export const $http = (path , options) => { |
|
return new Promise((resolve,reject) => { |
|
const token = uni.getStorageSync("token"); |
|
uni.request({ |
|
url: BASE_URL+path, |
|
data: options || {}, |
|
method: "POST", |
|
header: { |
|
'content-type': 'application/json;charset:utf-8', |
|
"Authorization":"Bearer " + token, |
|
}, |
|
success: res => { |
|
// console.log(res) |
|
// if(res.data.code){ |
|
// if(res.data.msg == 'TOKEN_ERROR'){ |
|
// uni.removeStorageSync('userinfo') |
|
// uni.removeStorageSync('token') |
|
// uni.removeStorageSync('avatar') |
|
// return uni.showToast({ |
|
// title: '请先登陆', |
|
// icon: 'error' |
|
// }) |
|
// }else{ |
|
// return uni.showToast({ |
|
// title:res.data.msg, |
|
// icon: 'error' |
|
// }) |
|
// } |
|
// } |
|
resolve(res) |
|
}, |
|
fail: err => { |
|
uni.showToast({ |
|
title: '请求接口失败', |
|
icon: 'error' |
|
}) |
|
reject(err) |
|
} |
|
}) |
|
}) |
|
} |