// const BASE_URL = "/api"; const BASE_URL = "https://lottery.api.86698.cn"//"http://192.168.110.39:8000"// export const baseUrl = BASE_URL const request = (url, method, data = {}, showLoading = false) => { return new Promise((resolve, reject) => { const token = getApp().globalData.token if (token == "") { uni.reLaunch({ url: "/pages/index/index" }) return false } if (showLoading) { uni.showLoading({ title: "" }) } let api = baseUrl + url let tempData = data uni.request({ url: api, data: tempData, method: method, header: { // 'Content-Type': 'application/x-www-form-urlencoded', 'content-type': 'application/json', 'token': token }, success: res => { uni.hideLoading() if (res.data.code == 401) { uni.removeStorageSync('token') uni.reLaunch({ url: "/pages/index/index" }) } else { resolve(res); } }, fail: (error) => { uni.hideLoading() console.log('接口异常api', api) console.log('接口异常入参', tempData) console.log('接口异常返参', error) reject(error); }, complete() { uni.hideLoading() } }) }) } export default { request }