// const baseURL = "http://192.168.110.180:8888/3dshow"; const baseURL = "https://www.3dqueen.cloud/3dshow/v2/user"; export default function (url, options = {}) { return new Promise((resolve) => { if (options.method && options.method !== "GET") uni.showLoading({ title: "加载中" }); uni.request({ ...options, url: (options.baseURL ? options.baseURL : baseURL) + url, header: { Authorization: "Bearer " + uni.getStorageSync("access-token"), }, success(res) { uni.hideLoading(); console.log(res); if (res.statusCode === 200) { let data = res.data; // 兼容后端返回数据异常 if (!res.data.code && res.data.body) { data = res.data.body; } if (data.code === 4006) { console.log("invalid auth"); // #ifdef MP-WEIXIN uni.reLaunch({ url: "guide?token=null", }); // #endif // #ifdef H5 wx.miniProgram.reLaunch({ url: pageFrom + "?token=null", }); // #endif } resolve(data); } else { resolve({ code: res.statusCode, msg: res.errMsg, }); } }, fail(err) { uni.hideLoading(); console.log("error", err); resolve({ code: 500, msg: err.errMsg, }); }, }); }); }