//设置域名 const dev_baseUrl = "http://192.168.8.21:14300/temporary-library"; //测试 const pro_baseUrl = "https://tx.hz-hanghui.com:8088/temporary-library"; //正式 const pro_bassurl2 = 'https://ldb-permit.hz-hanghui.com:8088/hanghui/outapi/alipay' //是否是正式环境 const wx_rlxf = true; const baseUrl = wx_rlxf ? pro_baseUrl : dev_baseUrl; //https请求 const url1 = (e) => wx_rlxf ? pro_baseUrl + e.url : dev_baseUrl + e.url const url2 = (e) => wx_rlxf ? pro_bassurl2 + e.url : pro_bassurl2 + e.url // https请求 const request = e => { const userInfo = my.getStorageSync({ key: "userInfo" }); let url = '' switch (e.extra) { case 1: url = url1(e) break; case 2: url = url2(e) break; case 3: url = e.url break; default: break; } return new Promise(function (resolve, reject) { my.request({ url: url, data: e.data, method: e.method, header: { "content-type": e.type, "Authorization": e.extra === 1 && userInfo.data ? userInfo.data.token : "" }, success: res => { if (res.data.code == 200) { resolve(res.data); } else { my.hideLoading(); my.showToast({ type: 'none', content: res.data.msg, duration: 3000 }); // reject(res.data); } }, fail: error => { my.hideLoading(); my.showToast({ content: error.errorMessage, duration: 3000, }); // reject(error.errMsg); } }); }); }; module.exports = { wx_rlxf: wx_rlxf, baseUrl, dev_baseUrl: dev_baseUrl, pro_baseUrl: pro_baseUrl, request: request };