mirror of
http://112.124.100.131/GFRS/ebiz-h5.git
synced 2025-12-16 02:56:45 +08:00
代码格式化
This commit is contained in:
@@ -2,12 +2,11 @@ import axios from 'axios'
|
||||
import AESTools from '@/assets/js/utils/cryptoJsUtil'
|
||||
import configApp from '@/config'
|
||||
import { Dialog, Toast } from 'vant'
|
||||
import dateUtil from "@/assets/js/utils/date-utils";
|
||||
import MD5 from 'js-md5';
|
||||
import dateUtil from '@/assets/js/utils/date-utils'
|
||||
import MD5 from 'js-md5'
|
||||
import CacheUtils from '@/assets/js/utils/cacheUtils'
|
||||
import BusinessCommon from '@/assets/js/business-common'
|
||||
|
||||
|
||||
let proposal = [
|
||||
'/proposal/proposal/list',
|
||||
'/proposal/proposal/toInsurance',
|
||||
@@ -128,19 +127,19 @@ service.interceptors.request.use(
|
||||
/**
|
||||
* 请求拦截处理(待添加 判断走统一网关处理)
|
||||
*/
|
||||
if(config.url && /api\/$/.test(config.url.split(configApp.API_VERSION)[0]) && configApp.API_VERSION == 'v2'){
|
||||
if(!config.data || config.data == null){
|
||||
if (config.url && /api\/$/.test(config.url.split(configApp.API_VERSION)[0]) && configApp.API_VERSION == 'v2') {
|
||||
if (!config.data || config.data == null) {
|
||||
config.data = {}
|
||||
}
|
||||
if(!!config.data && config.data != null){
|
||||
let encrypt = AESTools.AESEncrypt(JSON.stringify(config.data),configApp.REQ_PWD)
|
||||
config.data = {"data": encrypt }
|
||||
if (!!config.data && config.data != null) {
|
||||
let encrypt = AESTools.AESEncrypt(JSON.stringify(config.data), configApp.REQ_PWD)
|
||||
config.data = { data: encrypt }
|
||||
}
|
||||
}
|
||||
|
||||
// token 不存在初始化处理
|
||||
let token = CacheUtils.getLocItem('token');
|
||||
if (!token){
|
||||
let token = CacheUtils.getLocItem('token')
|
||||
if (!token) {
|
||||
// 设备类型
|
||||
const target = BusinessCommon.device()
|
||||
// 安卓or苹果
|
||||
@@ -153,9 +152,9 @@ service.interceptors.request.use(
|
||||
|
||||
config.headers['token'] = CacheUtils.getLocItem('token')
|
||||
// 添加请时间戳
|
||||
let timeStr = new Date().getTime() + '';
|
||||
config.headers['timeStr'] = timeStr;
|
||||
config.headers['signature'] = MD5(timeStr + CacheUtils.getLocItem('token'));
|
||||
let timeStr = new Date().getTime() + ''
|
||||
config.headers['timeStr'] = timeStr
|
||||
config.headers['signature'] = MD5(timeStr + CacheUtils.getLocItem('token'))
|
||||
return config
|
||||
},
|
||||
error => {
|
||||
@@ -168,9 +167,15 @@ service.interceptors.request.use(
|
||||
service.interceptors.response.use(
|
||||
response => {
|
||||
let res = response.data
|
||||
if( configApp.API_VERSION == 'v2' && response.config.url && response.headers['content-type'].match(/application\/json/) && /api\/$/.test(response.config.url.split(configApp.API_VERSION)[0])){
|
||||
if(res.response){// 正常情況返回必有response 节点
|
||||
res = JSON.parse(AESTools.AESDecrypt(res.response,configApp.REQ_PWD))
|
||||
if (
|
||||
configApp.API_VERSION == 'v2' &&
|
||||
response.config.url &&
|
||||
response.headers['content-type'].match(/application\/json/) &&
|
||||
/api\/$/.test(response.config.url.split(configApp.API_VERSION)[0])
|
||||
) {
|
||||
if (res.response) {
|
||||
// 正常情況返回必有response 节点
|
||||
res = JSON.parse(AESTools.AESDecrypt(res.response, configApp.REQ_PWD))
|
||||
}
|
||||
}
|
||||
Toast.clear()
|
||||
|
||||
Reference in New Issue
Block a user