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;