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.

41 lines
1.0 KiB

12 months ago
function service(options = {}) {
let contentType = localStorage.token_type ? "application/json" : "application/x-www-form-urlencoded";
// contentType ="application/x-www-form-urlencoded";
contentType ="application/json";
// localStorage.setItem('token', "4810b80d-f047-4915-821d-d2baf661bb91")
let token = localStorage.getItem("token")
options.header = {
"content-type": contentType,
"Authorization": "Bearer "+token
// 'withCredentials': true,
// 'Blade-Auth':'bearer '+store.state.token,
// 'token_type': localStorage.token_type
};
return new Promise((resolve, reject) => {
options.success = (res) => {
if (res ) {
if(res.statusCode == 200){
if(res.data.code==0){
resolve(res.data);
}else {
reject(options.url + res.data.msg)
}
}else {
reject(options.url + res.data.msg)
}
} else {
reject(options.url + res.data.msg)
}
};
options.fail = (err) => {
reject(err);
};
uni.request(options);
});
}
export default service;