123456789101112131415161718192021222324252627282930313233 |
- var rootDocment = 'https://ad.wenxingshuju.com';//域名
- function req(url, method, data, cb, fail_cb, selfHeader) {
- var dataes = {'admin_id':wx.getStorageSync('admin_id'),
- 'ttl':wx.getStorageSync('ttl'),
- 'sign':wx.getStorageSync('sign')
- }
- var header = {
- 'sessionKey':wx.getStorageSync('session_key')?wx.getStorageSync('session_key'):false
- }
- const app = getApp()
- wx.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' || res.data.errno == '4001')&&url.indexOf('verified')==-1&&url.indexOf('loginByUnionId')==-1){
- if(wx.getStorageSync('isLogin')){
- wx.clearStorage()
- app.login({})
- }
- }else{
- return typeof cb == "function" && cb(res.data)
- }
- },
- fail: function (err) {
- return typeof fail_cb == "function" && fail_cb(err)
- }
- })
- }
- module.exports = {
- req: req
- }
|