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.

42 lines
1.0 KiB

1 year 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', "f6350745-d4ac-4e1a-82f2-7e1a6efd8a3f")
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;