1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- var rootDocment = 'https://data.kuxuan.com';//域名
- // var rootDocment = 'http://47.93.151.217:8006';//测试域名
- // var rootDocment = 'http://apitbk.726p.com';//预发域名
- var md5 = require('./md5.js');
- var count = 0;
- wx.setStorageSync('doneLogin',false)
- 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
- }
- 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'){
- if(wx.getStorageSync('isLogin')){
- wx.clearStorage()
- wx.showToast({
- title: res.data.err,
- icon: 'none',
- duration: 2000
- })
- wx.redirectTo({
- url: '/pages/welcome/welcome',
- })
- }
- }else{
- count = 0;
- return typeof cb == "function" && cb(res.data)
- }
- },
- fail: function (err) {
- return typeof fail_cb == "function" && fail_cb(err)
- }
- })
- }
- module.exports = {
- req: req
- }
|