mirror of
http://112.124.100.131/GFRS/ebiz-h5.git
synced 2025-12-11 08:36:44 +08:00
205 lines
5.9 KiB
JavaScript
205 lines
5.9 KiB
JavaScript
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 CacheUtils from '@/assets/js/utils/cacheUtils'
|
|
import BusinessCommon from '@/assets/js/business-common'
|
|
|
|
|
|
let proposal = [
|
|
'/proposal/proposal/list',
|
|
'/proposal/proposal/toInsurance',
|
|
'/proposal/proposal/info',
|
|
'/proposal/proposal/demo',
|
|
'/proposal/proposal/saveOrUpdateProposal',
|
|
'/proposal/proposal/updateInsured',
|
|
'/proposal/file/getFile',
|
|
'/proposal/proposal/deleteProposal'
|
|
] //建议书
|
|
let sale = [
|
|
'/sale/order/orderList',
|
|
'/sale/order/saveOrUpdateOrderInfo',
|
|
'/sale/order/orderList',
|
|
'/sale/order/deleteOrderInfo',
|
|
'/sale/product/getDetail',
|
|
'/sale/order/saveOrUpdateOrderInfo',
|
|
'/sale/order/orderDetail',
|
|
'/customer/authcode/loginedSend',
|
|
'/uploadImage',
|
|
// '/customer/recognition',
|
|
'/sale/insure/underWrite',
|
|
'/sale/insure/acceptInsurance',
|
|
'/app/code/getCodeValue',
|
|
'/customer/token',
|
|
'/media/ebizSignInfo/sign',
|
|
'/sale/receiptSign/submit',
|
|
'/sale/order/orderDetail',
|
|
'/sale/record/check',
|
|
'/ppf/sign',
|
|
'/ppf/check',
|
|
'/sale/insure/selfToHuman',
|
|
'/sale/insure/orderPayStatusQuery'
|
|
] //在线投保
|
|
let agentEnter = [
|
|
'/agent/enter/share',
|
|
'/agent/enter/query',
|
|
'/agent/enter/saveOrUpdateInfo',
|
|
'/agent/enter/queryAll',
|
|
'/agent/enter/getImpart',
|
|
'/agent/agreement/query',
|
|
'/agent/agreement/signAgreement',
|
|
'/agent/enter/query',
|
|
'/agent/examineApprove/dispose' //入司增员审批
|
|
] //入司
|
|
let claims = [
|
|
`/claim/claimApply/progress`,
|
|
`/claim/claimApply/progressDetail`,
|
|
`/claim/claimReport/history`,
|
|
`/claim/claimApply/apply`,
|
|
`/edor/customer/customerList`,
|
|
`/edor/customer/customerInfo`,
|
|
`/claim/claimApply/query`,
|
|
`/claim/claimApply/delete`
|
|
]
|
|
let survey = [
|
|
//'/customer/question/getQuestionnaire', // 代理人下问卷查询 --ok
|
|
'/customer/question/getQuestion', // 问卷题库查询
|
|
'/customer/question/submit', // 问卷提交
|
|
//'/customer/question/shareSubmit', //问卷分享 --ok
|
|
//'/customer/question/getTableId', // id 查询 -- ok
|
|
'/customer/question/getAgentInfo' // 代理人详情
|
|
]
|
|
let manpower = [
|
|
'/customer/answer/queryList' //DISC性格分析
|
|
]
|
|
|
|
//保全
|
|
let preserve = [
|
|
'/edor/customer/customerList', //客户搜索
|
|
'/edor/policy/policyList', //保单列表
|
|
'/edor/edor/queryEdorList' //保全进度查询
|
|
]
|
|
|
|
let productStore = [
|
|
'/customer/shop/getShopList', //获取商城列表/详情
|
|
'/customer/shop/getShareList' //查询分享轨迹(转发记录)
|
|
]
|
|
|
|
// 卡单
|
|
let cardList = []
|
|
|
|
// 续期
|
|
let renewalManage = [
|
|
'/renewal/getRenewalList' //续期列表查询
|
|
]
|
|
|
|
let whiteList = [
|
|
'/customer/agent/getCustomersList',
|
|
...proposal,
|
|
...sale,
|
|
...agentEnter,
|
|
...claims,
|
|
...survey,
|
|
...manpower,
|
|
...productStore,
|
|
...preserve,
|
|
...renewalManage
|
|
]
|
|
|
|
// 创建axios实例
|
|
const service = axios.create({
|
|
timeout: 66666666 // 请求超时时间
|
|
})
|
|
|
|
// request拦截器
|
|
service.interceptors.request.use(
|
|
async config => {
|
|
let relativePath = config.url && config.url.split(configApp.API_VERSION)[1]
|
|
if (whiteList.includes(relativePath)) {
|
|
Toast.loading({
|
|
duration: 0, // 持续展示 toast
|
|
forbidClick: true, // 禁用背景点击
|
|
loadingType: 'spinner',
|
|
message: '加载中……'
|
|
})
|
|
}
|
|
/**
|
|
* 请求拦截处理(待添加 判断走统一网关处理)
|
|
*/
|
|
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 }
|
|
}
|
|
}
|
|
|
|
// token 不存在初始化处理
|
|
let token = CacheUtils.getLocItem('token');
|
|
if (!token){
|
|
// 设备类型
|
|
const target = BusinessCommon.device()
|
|
// 安卓or苹果
|
|
if (target.isAndroid || target.isIphone) {
|
|
// eslint-disable-next-line no-undef
|
|
const res = await EWebBridge.webCallAppInJs('getToken')
|
|
CacheUtils.setLocItem('token', JSON.parse(res).token)
|
|
}
|
|
}
|
|
|
|
config.headers['token'] = CacheUtils.getLocItem('token')
|
|
// 添加请时间戳
|
|
let timeStr = new Date().getTime() + '';
|
|
config.headers['timeStr'] = timeStr;
|
|
config.headers['signature'] = MD5(timeStr + CacheUtils.getLocItem('token'));
|
|
return config
|
|
},
|
|
error => {
|
|
// Do something with request error
|
|
Promise.reject(error)
|
|
}
|
|
)
|
|
|
|
// respone拦截器
|
|
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))
|
|
}
|
|
}
|
|
Toast.clear()
|
|
if (res.code != 0) {
|
|
if (res.code == 10001 || res.code == 10002) {
|
|
Dialog.confirm({
|
|
confirmButtonText: '重新登录',
|
|
message: '你已被登出,可以取消继续留在该页面,或者重新登录'
|
|
}).then(() => {
|
|
//eslint-disable-next-line
|
|
EWebBridge.webCallAppInJs('bridge', {
|
|
flag: 'login'
|
|
})
|
|
})
|
|
} else {
|
|
//Toast.fail(res.msg)
|
|
}
|
|
return Promise.reject(res)
|
|
} else {
|
|
return res.content
|
|
}
|
|
},
|
|
error => {
|
|
Toast.clear()
|
|
console.log('err' + error) // for debug
|
|
//Toast.fail(error.message)
|
|
return Promise.reject(error)
|
|
}
|
|
)
|
|
|
|
export default service
|