|
|
@ -21,7 +21,7 @@ const service = axios.create({ |
|
|
|
// request拦截器,在请求之前做一些处理
|
|
|
|
service.interceptors.request.use( |
|
|
|
config => { |
|
|
|
const language = uni.getStorageSync("language")|| 'en_US'; |
|
|
|
const language = uni.getStorageSync("language") || 'en_US'; |
|
|
|
// console.log('语言', language)
|
|
|
|
if (constant.SHOW_DIALOG) { |
|
|
|
// uni.showLoading({
|
|
|
@ -29,21 +29,58 @@ service.interceptors.request.use( |
|
|
|
// mask: true
|
|
|
|
// })
|
|
|
|
} |
|
|
|
|
|
|
|
console.log(config.url) |
|
|
|
if (config.url.indexOf("/api/index/register") !== -1 || |
|
|
|
config.url.indexOf("/api/user/login") !== -1 || |
|
|
|
config.url.indexOf("/api/user/forgotPassword") !== -1 || |
|
|
|
config.url.indexOf("/api/user/updatePassword") !== -1 || |
|
|
|
config.url.indexOf("/api/user/bindBank") !== -1 || |
|
|
|
config.url.indexOf("/api/user/updatePayPassword") !== -1 || |
|
|
|
config.url.indexOf("/api/index/sendEmailCode") !== -1 || |
|
|
|
config.url.indexOf("/api/user/loginOut") !== -1 || |
|
|
|
config.url.indexOf("/api/recharge/recharge") !== -1 || |
|
|
|
config.url.indexOf("/api/withdraw/withdrawAddressAdd") !== -1 || |
|
|
|
config.url.indexOf("/api/withdraw/withdraw") !== -1 || |
|
|
|
config.url.indexOf("/api/mine/mineSubmit") !== -1 || |
|
|
|
config.url.indexOf("/api/contract/order") !== -1 || |
|
|
|
config.url.indexOf("/api/contract/setWinOrLossStopPrice") !== -1 || |
|
|
|
config.url.indexOf("/api/contract/cancel") !== -1 || |
|
|
|
config.url.indexOf("/api/contract/closed") !== -1 || |
|
|
|
config.url.indexOf("/api/transfer/transfer") !== -1 || |
|
|
|
config.url.indexOf("/api/exchange/exchangeCoin") !== -1 || |
|
|
|
config.url.indexOf("/api/charity/charitySubmit") !== -1 || |
|
|
|
config.url.indexOf("/api/steps/receivStepsAward") !== -1 || |
|
|
|
config.url.indexOf("/api/withdraw/withdrawAddressDel") !== -1 |
|
|
|
) { |
|
|
|
console.log(config.url) |
|
|
|
uni.showLoading({ |
|
|
|
title: 'loading', |
|
|
|
mask: true |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
if (config.url.indexOf("/api/recharge/rechargeConfig") !== -1 |
|
|
|
|| config.url.indexOf("/api/recharge/rechargeList") !== -1 |
|
|
|
|| config.url.indexOf("/api/withdraw/withdrawConfig") !== -1 |
|
|
|
|| config.url.indexOf("/api/withdraw/withdrawList") !== -1 |
|
|
|
|| config.url.indexOf("/api/contract/orderList") !== -1 |
|
|
|
) { |
|
|
|
uni.hideLoading() |
|
|
|
} |
|
|
|
|
|
|
|
if (config.url.indexOf('market') > -1) { |
|
|
|
// #ifdef H5
|
|
|
|
config.baseURL = constant.H5_MARKET_URL; |
|
|
|
// #endif
|
|
|
|
// #ifdef APP-PLUS
|
|
|
|
config.baseURL = constant.MARKET_URL |
|
|
|
// #endif
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// #ifdef H5
|
|
|
|
config.baseURL = constant.H5_MARKET_URL; |
|
|
|
// #endif
|
|
|
|
// #ifdef APP-PLUS
|
|
|
|
config.baseURL = constant.MARKET_URL |
|
|
|
// #endif
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
const ticket = uni.getStorageSync('ticket') |
|
|
|
if (ticket) { |
|
|
|
if(!config.data){ |
|
|
|
if (!config.data) { |
|
|
|
config.data = {}; |
|
|
|
} |
|
|
|
config.data['ticket'] = ticket |
|
|
@ -70,7 +107,7 @@ service.interceptors.request.use( |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (config.method == 'post') { |
|
|
|
if (config.method == 'post') { |
|
|
|
dataStr = decodeURIComponent(qs.stringify(config.data)).split('&'); |
|
|
|
} |
|
|
|
//console.log(config.url,111111,config.data,dataStr)
|
|
|
@ -82,9 +119,9 @@ service.interceptors.request.use( |
|
|
|
|
|
|
|
var keys = []; |
|
|
|
let sign = ''; |
|
|
|
|
|
|
|
|
|
|
|
var t = Date.now() - 2901; |
|
|
|
|
|
|
|
|
|
|
|
config.data['lang'] = language; |
|
|
|
for (var k in config.data) |
|
|
|
keys.push(k); |
|
|
@ -92,8 +129,8 @@ service.interceptors.request.use( |
|
|
|
return a < b ? -1 : 1; |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
keys.forEach(function(e) { |
|
|
@ -105,10 +142,10 @@ service.interceptors.request.use( |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
var key = "key=" + constant.KEY; |
|
|
|
|
|
|
|
|
|
|
|
// console.log(sign + key)
|
|
|
|
var key = "key=" + constant.KEY; |
|
|
|
|
|
|
|
|
|
|
|
// console.log(sign + key)
|
|
|
|
sign = md5(sign + key); |
|
|
|
if (config.method == 'post') { |
|
|
|
config.data['sign'] = sign |
|
|
@ -125,8 +162,8 @@ service.interceptors.request.use( |
|
|
|
return config; |
|
|
|
}, |
|
|
|
error => { |
|
|
|
// console.error(error);
|
|
|
|
// for debug
|
|
|
|
// console.error(error);
|
|
|
|
// for debug
|
|
|
|
uni.hideLoading(); |
|
|
|
return Promise.reject(error); |
|
|
|
} |
|
|
@ -134,45 +171,45 @@ service.interceptors.request.use( |
|
|
|
|
|
|
|
//配置成功后的拦截器
|
|
|
|
service.interceptors.response.use(res => { |
|
|
|
|
|
|
|
uni.hideLoading() |
|
|
|
|
|
|
|
res=res.data; |
|
|
|
// console.log('数据',res)
|
|
|
|
|
|
|
|
uni.hideLoading() |
|
|
|
|
|
|
|
res = res.data; |
|
|
|
// console.log('数据',res)
|
|
|
|
// console.log(res.data)
|
|
|
|
// console.log(res.data.data[0].nameAlias)
|
|
|
|
if (res.code===0||res.success) { |
|
|
|
if (res.code === 0 || res.success) { |
|
|
|
return res.data; |
|
|
|
} |
|
|
|
|
|
|
|
uni.showToast({ |
|
|
|
title: res.errMsg, |
|
|
|
icon: 'none', |
|
|
|
duration: 1500 |
|
|
|
} |
|
|
|
|
|
|
|
uni.showToast({ |
|
|
|
title: res.errMsg, |
|
|
|
icon: 'none', |
|
|
|
duration: 1500 |
|
|
|
}) |
|
|
|
if (res.errCode === 'SYS.0006') { |
|
|
|
uni.setStorageSync('ticket', null); |
|
|
|
uni.setStorageSync('logInfo', null); |
|
|
|
uni.reLaunch({ |
|
|
|
url: '/pages/login/index' |
|
|
|
}) |
|
|
|
if (res.errCode === 'SYS.0006') { |
|
|
|
uni.setStorageSync('ticket',null); |
|
|
|
uni.setStorageSync('logInfo',null); |
|
|
|
uni.reLaunch({ |
|
|
|
url: '/pages/login/index' |
|
|
|
}) |
|
|
|
// #ifdef H5
|
|
|
|
var url = location.href; |
|
|
|
if (url.indexOf('pages') > -1) { |
|
|
|
uni.setStorage({ |
|
|
|
key: 'url', |
|
|
|
data: url, |
|
|
|
success: function() { |
|
|
|
// console.log('success')
|
|
|
|
} |
|
|
|
}); |
|
|
|
} else { |
|
|
|
uni.removeStorageSync('url') |
|
|
|
} |
|
|
|
// #endif
|
|
|
|
// #ifdef H5
|
|
|
|
var url = location.href; |
|
|
|
if (url.indexOf('pages') > -1) { |
|
|
|
uni.setStorage({ |
|
|
|
key: 'url', |
|
|
|
data: url, |
|
|
|
success: function() { |
|
|
|
// console.log('success')
|
|
|
|
} |
|
|
|
}); |
|
|
|
} else { |
|
|
|
uni.removeStorageSync('url') |
|
|
|
} |
|
|
|
uni.$emit('refreshQrCode') |
|
|
|
return Promise.reject(res.errMsg); |
|
|
|
// #endif
|
|
|
|
} |
|
|
|
uni.$emit('refreshQrCode') |
|
|
|
return Promise.reject(res.errMsg); |
|
|
|
}, error => { |
|
|
|
uni.hideLoading(); |
|
|
|
return Promise.reject(error) |
|
|
|