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;