import functions from '@/utils/functions.js' import {host} from "@/config/host"; const service = (params,showToast = true) => { return new Promise((relove, reject) => { let token=uni.getStorageSync('token') let user=uni.getStorageSync('user') // console.log(params.url) if (!/^http/.test(params.url)){ // const rExp = new RegExp("(? { if (res.statusCode === 200) { let data = res.data; switch (data.code) { case 1001: uni.setStorageSync('token',data.data); service(params); break; case 1002: // todo 让用户重新登录 reject(data); break; case 202: if(showToast){ functions.error(data.msg); } reject(data); break; default: relove(data); } } else { if(showToast){ functions.error('连接服务器失败') } reject(); } }) }) } export default service;