import Vue from 'vue' const baseUrl = 'https://boat-server.njrenzhou.cn/'; Vue.prototype.$baseUrl = baseUrl export function request(prams) { return new Promise((resolve, reject) => { let url; url = baseUrl + prams.url; uni.request({ url: url, data: prams.data, method: prams.method, header: { "userToken": uni.getStorageSync('userToken') }, success: (res) => { if (res.data.code == 200 || res.data.code == 400){ resolve(res.data); }else if(res.data.code == 402){ uni.showModal({ title: "温馨提示", content: "当前账号已失效,是否重新登录?", confirmColor: "#2B62B2", success(res) { uni.hideLoading() uni.clearStorageSync(); uni.navigateTo({ url: "/pages/login/login" }) } }) }else { reject(res.data); uni.showToast({ icon: "none", title: res.data.msg, duration: 3000 }); } }, fail: (err) => { reject(err); }, complete: () => { //console.log('请求完成') } }); }) }