var rootDocment = 'https://center.wenxingshuju.com';//域名 // var rootDocment = 'https://oms.wenxingshuju.com'; //域名 function req (url, method, data, cb, fail_cb, selfHeader) { var dataes = { 'admin_id': uni.getStorageSync('admin_id'), 'ttl': uni.getStorageSync('ttl'), 'sign': uni.getStorageSync('sign') } var header = { 'sessionKey': uni.getStorageSync('session_key') ? uni.getStorageSync('session_key') : false } const app = getApp() uni.request({ url: rootDocment + url, data: data ? Object.assign(data, dataes) : dataes, method: method, header: selfHeader ? Object.assign(selfHeader, header) : header, success: function (res) { if ((res.data.errno == '4002') && url.indexOf('verified') == -1 && url.indexOf('login') == -1) { if (wx.getStorageSync('isLogin')) { wx.clearStorage() uni.redirectTo({ url: '/pages/login/login' }) } } else { return typeof cb == "function" && cb(res.data) } }, fail: function (err) { return typeof fail_cb == "function" && fail_cb(err) } }) } module.exports = { req: req, rootDocment: rootDocment }