12345678910111213141516171819202122232425262728293031323334353637 |
- var rootDocment = 'https://sph.wenxingshuju.com/wx_sph';//域名
- // var rootDocment = 'http://60.205.169.65:8025'
- // var rootDocment = 'http://60.205.169.65:8018'
- function req(url, method, data, cb, fail_cb, selfHeader) {
- var dataes = {'admin_id':swan.getStorageSync('admin_id'),
- 'ttl':swan.getStorageSync('ttl'),
- 'sign':swan.getStorageSync('sign')
- }
- var header = {
- 'sessionKey':swan.getStorageSync('session_key')?swan.getStorageSync('session_key'):false
- }
- const app = getApp()
- swan.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){
- var platform = swan.getStorageSync('platform');
- if(swan.getStorageSync('isLogin')){
- swan.clearStorage()
- swan.setStorageSync('platform', platform)
- app.login('/pages/index/index')
- }
- }else{
- return typeof cb == "function" && cb(res.data)
- }
- },
- fail: function (err) {
- return typeof fail_cb == "function" && fail_cb(err)
- }
- })
- }
- module.exports = {
- req: req
- }
|