123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- //设置域名
- const dev_baseUrl = 'http://192.168.77.47:14001/ma-meeting'; //测试
- const pro_baseUrl = 'https://common.hz-hanghui.com:8087/ma-meeting'; //正式
- //是否是正式环境
- const wx_rlxf = true
- const baseUrl = wx_rlxf ? pro_baseUrl : dev_baseUrl;
- //https请求
- const request = e => {
- let userInfo = wx.getStorageSync('userInfo');
- return new Promise(function (resolve, reject) {
- wx.request({
- url: wx_rlxf ? (pro_baseUrl + e.url) : (dev_baseUrl + e.url),
- data: e.data,
- method: e.method,
- header: {
- 'content-type': e.type,
- 'Authorization': userInfo ? userInfo.token : null,
- },
- success: res => {
- if (res.data.code == 200) {
- resolve(res.data)
- } else if (res.data.code == 401) {
- wx.removeStorageSync('userInfo')
- } else {
- wx.showToast({
- icon: 'none',
- title: res.data.msg,
- })
- };
- },
- fail: error => {
- wx.hideLoading()
- }
- })
- })
- }
- module.exports = {
- wx_rlxf: wx_rlxf,
- baseUrl,
- dev_baseUrl: dev_baseUrl,
- pro_baseUrl: pro_baseUrl,
- request: request,
- }
|