function myRequest(url, param, callback) { wx.showLoading(); wx.request({ url: "https://gzguguan.com/XiAn/HrApp/public/api/" + url, //仅为示例,并非真实的接口地址 data: param, header: { 'content-type': 'application/json', // 默认值 'token': wx.getStorageSync("token"), }, success: function success(res) { wx.hideLoading(); if (res.data.code == 250) { wx.showModal({ content: '需要授权登录', showCancel: false, success(res) { if (res.confirm) { wx.navigateTo({ url: '../../pages/login/login' }); } else if (res.cancel) { console.log('用户点击取消') } } }) } else if (res.data.code == 255) { this.doLogin(); } else { callback(res.data); } } }); } //将方法暴露 module.exports = { method: myRequest, }