版本1.3.4
This commit is contained in:
@@ -1,17 +1,16 @@
|
||||
import axios from 'axios'
|
||||
import utils from '@/utils/encode'
|
||||
|
||||
const devUrl = 'http://192.168.0.33:48080' // 测试,不加密
|
||||
const testUrl = 'http://192.168.0.25:48080' // 测试,加密
|
||||
// const devUrl = 'http://192.168.0.13:48080' // 测试,不加密
|
||||
// const testUrl = 'http://192.168.0.25:48080' // 测试,加密
|
||||
const productionUrl = 'https://www.51xingka.net/oilApp' // 生产,加密
|
||||
|
||||
const env = process.env.NODE_ENV // 环境
|
||||
// const env = 'production' // 仅用于测试
|
||||
// const env = process.env.NODE_ENV // 环境
|
||||
const env = 'production' // 仅用于测试
|
||||
|
||||
const service = axios.create({
|
||||
baseURL: env=='production'?productionUrl:testUrl, //
|
||||
// baseURL: 'http://192.168.0.33:48080', //
|
||||
// baseURL: 'https://www.51xingka.net/oilApp', //生产
|
||||
baseURL: env=='production'?productionUrl:devUrl, //
|
||||
// baseURL:testUrl, //
|
||||
timeout: 5000
|
||||
})
|
||||
var url = ''
|
||||
@@ -42,7 +41,7 @@ service.interceptors.request.use(
|
||||
const data = { // 用于存储加密
|
||||
params: '' // 加密后的密文
|
||||
}
|
||||
console.log('请求路径', config.url, '参数加密前', config.data)
|
||||
// console.log('请求路径', config.url, '参数加密前', config.data)
|
||||
// 要加密
|
||||
data.params = utils.encrypt(JSON.stringify(config.data))
|
||||
config.data = data
|
||||
@@ -76,7 +75,7 @@ service.interceptors.response.use(
|
||||
// 加密的数据,需要解密
|
||||
const dataParam = JSON.parse(utils.decrypt(res.data))
|
||||
res.data = JSON.stringify(dataParam) === '{}' ? null : dataParam
|
||||
console.log('生产环境 请求路径', response.config.url, '解密为', res.data)
|
||||
// console.log('生产环境 请求路径', response.config.url, '解密为', res.data)
|
||||
}
|
||||
} else {
|
||||
console.log('请求路径', response.config.url, '返回结果未加密', res)
|
||||
@@ -90,18 +89,6 @@ service.interceptors.response.use(
|
||||
title: res.msg,
|
||||
icon: "none"
|
||||
})
|
||||
// if (res.code === 42011) {
|
||||
// console.log(res.code)
|
||||
// uni.reLaunch({
|
||||
// url: '/pages/startPage/startPage',
|
||||
// success: () => {
|
||||
// console.log('跳转成功')
|
||||
// },
|
||||
// fail: (err) => {
|
||||
// console.log(err)
|
||||
// }
|
||||
// })
|
||||
// }
|
||||
if (res.msg === '您已被迫下线') {
|
||||
outTimer = setTimeout(() => {
|
||||
uni.showModal({
|
||||
|
||||
Reference in New Issue
Block a user