220da92c by joe

加入加密框架

1 parent c8aaefc3
......@@ -5,3 +5,6 @@ VUE_APP_RSA_PUBLIC_KEY = 'B5FE03847F02046C47292AF0FF2DE88977241483DD40C123046EB3
VUE_APP_RSA_KEY_INDEX = '10001'
VUE_APP_VHIS_INDEX= 'https://icpois.pingan.com/vhis/insurIndex'
VUE_APP_INDEX_VIDEO = 'https://ow.go.qudone.com/jyesupload/ee516bb327484197b7ca72f3dc4be9e6.mp4'
VUE_APP_CONTENT_ENCRYPT_KEY = 'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDA1SNj4qiOEmvTkZfp+Gt0UOLTCdxuEqRE+k0fROhgZdN2GmtDg6jcZV/CXKdwQGGdwOYdxEngRQb2K/SXd5Rnu4MkuAoHopDNrBRVqoJNQi6VOv6fvAEzeYivtS9aMM7IvdZuN1QlASCz2vxfUKJ3BaijMQqQE9m0pVm+0BDEfwIDAQAB'
\ No newline at end of file
......
......@@ -6,3 +6,6 @@ VUE_APP_RSA_PUBLIC_KEY = 'B5FE03847F02046C47292AF0FF2DE88977241483DD40C123046EB3
VUE_APP_RSA_KEY_INDEX = '10001'
VUE_APP_VHIS_INDEX= 'https://icpois.pingan.com/vhis/insurIndex'
VUE_APP_INDEX_VIDEO = 'https://ow.go.qudone.com/jyesupload/ee516bb327484197b7ca72f3dc4be9e6.mp4'
VUE_APP_CONTENT_ENCRYPT_KEY = 'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDA1SNj4qiOEmvTkZfp+Gt0UOLTCdxuEqRE+k0fROhgZdN2GmtDg6jcZV/CXKdwQGGdwOYdxEngRQb2K/SXd5Rnu4MkuAoHopDNrBRVqoJNQi6VOv6fvAEzeYivtS9aMM7IvdZuN1QlASCz2vxfUKJ3BaijMQqQE9m0pVm+0BDEfwIDAQAB'
\ No newline at end of file
......
......@@ -5,3 +5,5 @@ VUE_APP_RSA_PUBLIC_KEY = 'B5FE03847F02046C47292AF0FF2DE88977241483DD40C123046EB3
VUE_APP_RSA_KEY_INDEX = '10001'
VUE_APP_VHIS_INDEX= 'https://icpois.pingan.com/vhis/insurIndex'
VUE_APP_INDEX_VIDEO = 'https://ow.go.qudone.com/jyesupload/ee516bb327484197b7ca72f3dc4be9e6.mp4'
VUE_APP_CONTENT_ENCRYPT_KEY = 'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDA1SNj4qiOEmvTkZfp+Gt0UOLTCdxuEqRE+k0fROhgZdN2GmtDg6jcZV/CXKdwQGGdwOYdxEngRQb2K/SXd5Rnu4MkuAoHopDNrBRVqoJNQi6VOv6fvAEzeYivtS9aMM7IvdZuN1QlASCz2vxfUKJ3BaijMQqQE9m0pVm+0BDEfwIDAQAB'
\ No newline at end of file
......
......@@ -18,7 +18,9 @@
"axios-mock-adapter": "^1.16.0",
"co": "^4.6.0",
"core-js": "^2.6.5",
"crypto-js": "^3.1.9-1",
"glob": "^7.1.4",
"jsencrypt": "^3.0.0-rc.1",
"mockjs": "^1.0.1-beta3",
"postcss-pxtorem": "^4.0.1",
"purecss": "^1.0.1",
......
import axiosIns from 'axios';
import state from '@/store/state.js';
import CryptoJS from "crypto-js";
import JsEncrypt from "jsencrypt";
let key = process.env.VUE_APP_CONTENT_ENCRYPT_KEY;
let rsa = new JsEncrypt();
rsa.setPublicKey(key);
let chars = "0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z".split(",");
function randomAesKey() {
let res = "";
for (let i = 0; i < 16; i++) {
let id = Math.ceil(Math.random() * (chars.length - 1));
res += chars[id];
}
return res;
};
function encryptContent(obj) {
let aesKey = randomAesKey();
let key = CryptoJS.enc.Utf8.parse(aesKey);
var encrypted = CryptoJS.AES.encrypt(JSON.stringify(obj), key, {
mode: CryptoJS.mode.ECB,
padding: CryptoJS.pad.Pkcs7
});
let content = encrypted.toString(); //返回的是base64格式的密文
let securityKey = rsa.encrypt(aesKey);
let result = {
k: securityKey,
v: content
};
return result;
};
// import {
// Toast
// } from 'vant';
......@@ -21,18 +54,40 @@ const axios = axiosIns.create({
timeout: 5000
})
let encryptPattern = [
/^\/pingan_hklife_webapi\/policy.*/,
/^\/pingan_hklife_webapi\/user.*/,
/^\/pingan_hklife_webapi\/auth.*/,
/^\/pingan_hklife_webapi\/customService.*/,
]
let encryptWhileList = [
"/pingan_hklife_webapi/policy/idPicUpload"
]
// 请求拦截器
// axios.interceptors.request.use(
// config => {
// // 每次发送请求之前判断是否存在token,如果存在,则统一在http请求的header都加上token,不用每次请求都手动添加了
// // 即使本地存在token,也有可能token是过期的,所以在响应拦截器中要对返回状态进行判断
// const token = "token"; //这里写入token
// token && (config.headers.Authorization = token);
// return config;
// },
// error => {
// return Promise.error(error);
// })
axios.interceptors.request.use(
config => {
for (let index = 0; index < encryptPattern.length; index++) {
let element = encryptPattern[index];
if (element.test(config.url)) {
if (encryptWhileList.indexOf(config.url) >= 0) {
break;
}
let data = config.data;
try {
config.data = encryptContent(data);
} catch (e) {
console.error(e);
}
break;
}
}
return config;
},
error => {
return Promise.error(error);
})
// 响应拦截器
axios.interceptors.response.use(
......@@ -147,7 +202,7 @@ export const httpPost = params => {
url,
data,
sid,
sidStr
sidStr,
} = params;
let headers = {};
if (sid) {
......@@ -185,7 +240,7 @@ export const formdata = params => {
sid,
} = params;
let headers = {
headers : {
headers: {
"Content-Type": "multipart/form-data"
}
}
......
......@@ -11,3 +11,9 @@
height: 500px;
}
</style>
<script>
export default {};
</script>
\ No newline at end of file
......
......@@ -242,30 +242,35 @@ export default {
},
_showAgreeProtocalTips() {
let message = this.i18n.login.tips.e4;
this.showModal(message, "info");
// this.showModal(message, "info");
},
_showLoginErrorMessage(response) {
// response.returnCode = "GS_RESETPWD_ERROR_NOUSERINFO";
switch (response.returnCode) {
case "SMS_ERROR_006":
// 短信验证码不正确
this.showModal(this.i18n.login.tips.oe4, "info");
// this.showModal(this.i18n.login.tips.oe4, "info");
this.errorTips.oe2 = this.i18n.login.tips.oe4;
break;
case "BIZ_ERROR_018":
// 账号或密码不正确
this.showModal(this.i18n.login.tips.e5, "info");
this.errorTips.e2 = this.i18n.login.tips.e5;
// this.showModal(this.i18n.login.tips.e5, "info");
break;
case "BIZ_ERROR_011":
case "BIZ_ERROR_012":
// 登录错误4次、5次
this.showModal(response.returnMsg, "info");
this.errorTips.e2 = response.returnMsg;
// this.showModal(response.returnMsg, "info");
return;
case "GS_RESETPWD_ERROR_NOUSERINFO":
// 这个是用户OTP验证成功后没有账号导致
this.type = 3;
break;
default:
this.showModal(this.i18n.login.tips.e5, "info");
this.errorTips.e2 = this.i18n.login.tips.e5;
this.errorTips.oe2 = this.i18n.login.tips.e5;
// this.showModal(this.i18n.login.tips.e5, "info");
break;
}
},
......
......@@ -298,7 +298,7 @@ export default {
_showAgreeProtocolTip() {
let message = this.i18n.register.tips.e2;
this.showModal(message, "info");
// this.showModal(message, "info");
// alert("请同意协议")
},
......@@ -314,13 +314,13 @@ export default {
},
_showDuplicateRegistrationTip() {
let message = this.i18n.register.tips.e5;
this.showModal(message, "info");
// this.showModal(message, "info");
this.errorTips.p1 = message;
// alert("手机号已经被注册,请使用其他手机号重新注册")
},
_showImageValueTip() {
let message = this.i18n.register.tips.e5;
this.errorTips.p3 = message;
// alert("请输入图片验证码")
},
_showCheckOTPErrTip(msg) {
......@@ -389,12 +389,14 @@ export default {
this.handlerRefreshImageVcode();
let message = this.i18n.register.tips.e10;
// alert("验证码过期,请重新申请验证码");
this.showModal(message, "info");
// this.showModal(message, "info");
this.errorTips.p2 = message;
} else {
this._resetAllParams();
let message = this.i18n.register.tips.e11;
// alert("注册失败,请联系工作人员");
this.showModal(message, "info");
// this.showModal(message, "info");
this.errorTips.p5 = message;
}
},
_resetAllParams() {
......
......@@ -31,7 +31,7 @@ const routes = [
name: 'login',
component: () => import('./pages/login/login.vue'),
meta: {
title: ''
title: '平安人寿保险官网'
}
},
{
......@@ -39,7 +39,7 @@ const routes = [
name: 'register',
component: () => import('./pages/register/register.vue'),
meta: {
title: ''
title: '平安人寿保险官网'
}
},
{
......@@ -47,7 +47,7 @@ const routes = [
name: 'passwordFind',
component: () => import('./pages/password-find/password-find.vue'),
meta: {
title: ''
title: '平安人寿保险官网'
}
},
{
......@@ -55,7 +55,7 @@ const routes = [
name: 'passwordReset',
component: () => import('./pages/password-reset/password-reset.vue'),
meta: {
title: ''
title: '平安人寿保险官网'
}
},
{
......@@ -63,7 +63,7 @@ const routes = [
name: 'infomationImprove',
component: () => import('./pages/infomation-improve/infomation-improve.vue'),
meta: {
title: ''
title: '平安人寿保险官网'
}
},
{
......@@ -71,7 +71,7 @@ const routes = [
name: 'profile',
component: () => import('./pages/profile/profile.vue'),
meta: {
title: '公司简介'
title: '平安人寿保险官网'
}
},
{
......@@ -79,7 +79,7 @@ const routes = [
name: 'terms',
component: () => import('./pages/terms/terms.vue'),
meta: {
title: '使用条款'
title: '平安人寿保险官网'
}
},
{
......@@ -87,7 +87,7 @@ const routes = [
name: 'privacy',
component: () => import('./pages/privacy/privacy.vue'),
meta: {
title: '隐私政策'
title: '平安人寿保险官网'
}
},
{
......@@ -95,7 +95,7 @@ const routes = [
name: 'personalDataCollection',
component: () => import('./pages/personal-data-collection/personal-data-collection.vue'),
meta: {
title: ''
title: '平安人寿保险官网'
}
},
{
......@@ -103,7 +103,7 @@ const routes = [
name: 'protocol',
component: () => import('./pages/protocol/protocol.vue'),
meta: {
title: '平安一賬通會員服務協議'
title: '平安人寿保险官网'
}
},
{
......@@ -111,7 +111,7 @@ const routes = [
name: 'newsList',
component: () => import('./pages/news-list/news-list.vue'),
meta: {
title: ''
title: '平安人寿保险官网'
}
},
{
......@@ -119,7 +119,7 @@ const routes = [
name: 'newsDetail',
component: () => import('./pages/news-detail/news-detail.vue'),
meta: {
title: ''
title: '平安人寿保险官网'
}
},
......@@ -128,7 +128,7 @@ const routes = [
name: 'product',
component: () => import('./pages/product/product.vue'),
meta: {
title: ''
title: '平安人寿保险官网'
}
},
{
......@@ -136,7 +136,7 @@ const routes = [
name: 'customService',
component: () => import('./pages/custom-service/custom-service.vue'),
meta: {
title: '保单查询'
title: '平安人寿保险官网'
}
},
{
......@@ -144,7 +144,7 @@ const routes = [
name: 'customProduct',
component: () => import('./pages/custom-product/custom-product.vue'),
meta: {
title: ''
title: '平安人寿保险官网'
}
},
......@@ -153,7 +153,7 @@ const routes = [
name: 'demo',
component: () => import('./pages/demo/index.vue'),
meta: {
title: ''
title: '平安人寿保险官网'
}
},
{
......@@ -161,7 +161,7 @@ const routes = [
name: 'about',
component: () => import('./pages/About.vue'),
meta: {
title: ''
title: '平安人寿保险官网'
}
},
{
......@@ -169,7 +169,7 @@ const routes = [
name: 'empty',
component: () => import('./pages/empty/empty.vue'),
meta: {
title: ''
title: '平安人寿保险官网'
}
},
// 404页面
......@@ -190,6 +190,7 @@ const router = new Router({
// mode: 'history',
});
router.beforeEach((to, from, next) => {
let langStr = localStorage.getItem("lang") || 'tc';
let lang;
......@@ -212,11 +213,22 @@ router.beforeEach((to, from, next) => {
}
// lang对象为当前语言配置 见 en.js,tc.js,zh.js
console.log("lang:", lang);
let title = "";
lang.nav.navList.forEach(e1 => {
if (e1.list && e1.list.length > 0) {
e1.list.forEach(e2 => {
if(e2.path == to.fullPath){
title = e2.name;
}
});
} else {
if(e1.path == to.fullPath){
title = e1.name;
}
}
});
// to参数可以获取要前往页面的信息,包括参数
console.log("to:", to);
const title = to.meta && to.meta.title;
title = title || to.meta && to.meta.title;
if (title) {
document.title = title;
}
......