加入加密框架
Showing
10 changed files
with
135 additions
and
45 deletions
| ... | @@ -5,3 +5,6 @@ VUE_APP_RSA_PUBLIC_KEY = 'B5FE03847F02046C47292AF0FF2DE88977241483DD40C123046EB3 | ... | @@ -5,3 +5,6 @@ VUE_APP_RSA_PUBLIC_KEY = 'B5FE03847F02046C47292AF0FF2DE88977241483DD40C123046EB3 |
| 5 | VUE_APP_RSA_KEY_INDEX = '10001' | 5 | VUE_APP_RSA_KEY_INDEX = '10001' |
| 6 | VUE_APP_VHIS_INDEX= 'https://icpois.pingan.com/vhis/insurIndex' | 6 | VUE_APP_VHIS_INDEX= 'https://icpois.pingan.com/vhis/insurIndex' |
| 7 | VUE_APP_INDEX_VIDEO = 'https://ow.go.qudone.com/jyesupload/ee516bb327484197b7ca72f3dc4be9e6.mp4' | 7 | VUE_APP_INDEX_VIDEO = 'https://ow.go.qudone.com/jyesupload/ee516bb327484197b7ca72f3dc4be9e6.mp4' |
| 8 | |||
| 9 | |||
| 10 | VUE_APP_CONTENT_ENCRYPT_KEY = 'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDA1SNj4qiOEmvTkZfp+Gt0UOLTCdxuEqRE+k0fROhgZdN2GmtDg6jcZV/CXKdwQGGdwOYdxEngRQb2K/SXd5Rnu4MkuAoHopDNrBRVqoJNQi6VOv6fvAEzeYivtS9aMM7IvdZuN1QlASCz2vxfUKJ3BaijMQqQE9m0pVm+0BDEfwIDAQAB' | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| ... | @@ -6,3 +6,6 @@ VUE_APP_RSA_PUBLIC_KEY = 'B5FE03847F02046C47292AF0FF2DE88977241483DD40C123046EB3 | ... | @@ -6,3 +6,6 @@ VUE_APP_RSA_PUBLIC_KEY = 'B5FE03847F02046C47292AF0FF2DE88977241483DD40C123046EB3 |
| 6 | VUE_APP_RSA_KEY_INDEX = '10001' | 6 | VUE_APP_RSA_KEY_INDEX = '10001' |
| 7 | VUE_APP_VHIS_INDEX= 'https://icpois.pingan.com/vhis/insurIndex' | 7 | VUE_APP_VHIS_INDEX= 'https://icpois.pingan.com/vhis/insurIndex' |
| 8 | VUE_APP_INDEX_VIDEO = 'https://ow.go.qudone.com/jyesupload/ee516bb327484197b7ca72f3dc4be9e6.mp4' | 8 | VUE_APP_INDEX_VIDEO = 'https://ow.go.qudone.com/jyesupload/ee516bb327484197b7ca72f3dc4be9e6.mp4' |
| 9 | |||
| 10 | |||
| 11 | VUE_APP_CONTENT_ENCRYPT_KEY = 'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDA1SNj4qiOEmvTkZfp+Gt0UOLTCdxuEqRE+k0fROhgZdN2GmtDg6jcZV/CXKdwQGGdwOYdxEngRQb2K/SXd5Rnu4MkuAoHopDNrBRVqoJNQi6VOv6fvAEzeYivtS9aMM7IvdZuN1QlASCz2vxfUKJ3BaijMQqQE9m0pVm+0BDEfwIDAQAB' | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| ... | @@ -5,3 +5,5 @@ VUE_APP_RSA_PUBLIC_KEY = 'B5FE03847F02046C47292AF0FF2DE88977241483DD40C123046EB3 | ... | @@ -5,3 +5,5 @@ VUE_APP_RSA_PUBLIC_KEY = 'B5FE03847F02046C47292AF0FF2DE88977241483DD40C123046EB3 |
| 5 | VUE_APP_RSA_KEY_INDEX = '10001' | 5 | VUE_APP_RSA_KEY_INDEX = '10001' |
| 6 | VUE_APP_VHIS_INDEX= 'https://icpois.pingan.com/vhis/insurIndex' | 6 | VUE_APP_VHIS_INDEX= 'https://icpois.pingan.com/vhis/insurIndex' |
| 7 | VUE_APP_INDEX_VIDEO = 'https://ow.go.qudone.com/jyesupload/ee516bb327484197b7ca72f3dc4be9e6.mp4' | 7 | VUE_APP_INDEX_VIDEO = 'https://ow.go.qudone.com/jyesupload/ee516bb327484197b7ca72f3dc4be9e6.mp4' |
| 8 | |||
| 9 | VUE_APP_CONTENT_ENCRYPT_KEY = 'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDA1SNj4qiOEmvTkZfp+Gt0UOLTCdxuEqRE+k0fROhgZdN2GmtDg6jcZV/CXKdwQGGdwOYdxEngRQb2K/SXd5Rnu4MkuAoHopDNrBRVqoJNQi6VOv6fvAEzeYivtS9aMM7IvdZuN1QlASCz2vxfUKJ3BaijMQqQE9m0pVm+0BDEfwIDAQAB' | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| ... | @@ -18,7 +18,9 @@ | ... | @@ -18,7 +18,9 @@ |
| 18 | "axios-mock-adapter": "^1.16.0", | 18 | "axios-mock-adapter": "^1.16.0", |
| 19 | "co": "^4.6.0", | 19 | "co": "^4.6.0", |
| 20 | "core-js": "^2.6.5", | 20 | "core-js": "^2.6.5", |
| 21 | "crypto-js": "^3.1.9-1", | ||
| 21 | "glob": "^7.1.4", | 22 | "glob": "^7.1.4", |
| 23 | "jsencrypt": "^3.0.0-rc.1", | ||
| 22 | "mockjs": "^1.0.1-beta3", | 24 | "mockjs": "^1.0.1-beta3", |
| 23 | "postcss-pxtorem": "^4.0.1", | 25 | "postcss-pxtorem": "^4.0.1", |
| 24 | "purecss": "^1.0.1", | 26 | "purecss": "^1.0.1", | ... | ... |
| 1 | import axiosIns from 'axios'; | 1 | import axiosIns from 'axios'; |
| 2 | import state from '@/store/state.js'; | 2 | import state from '@/store/state.js'; |
| 3 | import CryptoJS from "crypto-js"; | ||
| 4 | import JsEncrypt from "jsencrypt"; | ||
| 5 | let key = process.env.VUE_APP_CONTENT_ENCRYPT_KEY; | ||
| 6 | let rsa = new JsEncrypt(); | ||
| 7 | rsa.setPublicKey(key); | ||
| 8 | 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(","); | ||
| 9 | |||
| 10 | function randomAesKey() { | ||
| 11 | let res = ""; | ||
| 12 | for (let i = 0; i < 16; i++) { | ||
| 13 | let id = Math.ceil(Math.random() * (chars.length - 1)); | ||
| 14 | res += chars[id]; | ||
| 15 | } | ||
| 16 | return res; | ||
| 17 | }; | ||
| 18 | |||
| 19 | function encryptContent(obj) { | ||
| 20 | let aesKey = randomAesKey(); | ||
| 21 | let key = CryptoJS.enc.Utf8.parse(aesKey); | ||
| 22 | var encrypted = CryptoJS.AES.encrypt(JSON.stringify(obj), key, { | ||
| 23 | mode: CryptoJS.mode.ECB, | ||
| 24 | padding: CryptoJS.pad.Pkcs7 | ||
| 25 | }); | ||
| 26 | let content = encrypted.toString(); //返回的是base64格式的密文 | ||
| 27 | let securityKey = rsa.encrypt(aesKey); | ||
| 28 | |||
| 29 | let result = { | ||
| 30 | k: securityKey, | ||
| 31 | v: content | ||
| 32 | }; | ||
| 33 | return result; | ||
| 34 | }; | ||
| 35 | |||
| 3 | // import { | 36 | // import { |
| 4 | // Toast | 37 | // Toast |
| 5 | // } from 'vant'; | 38 | // } from 'vant'; |
| ... | @@ -21,18 +54,40 @@ const axios = axiosIns.create({ | ... | @@ -21,18 +54,40 @@ const axios = axiosIns.create({ |
| 21 | timeout: 5000 | 54 | timeout: 5000 |
| 22 | }) | 55 | }) |
| 23 | 56 | ||
| 57 | let encryptPattern = [ | ||
| 58 | /^\/pingan_hklife_webapi\/policy.*/, | ||
| 59 | /^\/pingan_hklife_webapi\/user.*/, | ||
| 60 | /^\/pingan_hklife_webapi\/auth.*/, | ||
| 61 | /^\/pingan_hklife_webapi\/customService.*/, | ||
| 62 | ] | ||
| 63 | |||
| 64 | let encryptWhileList = [ | ||
| 65 | "/pingan_hklife_webapi/policy/idPicUpload" | ||
| 66 | ] | ||
| 67 | |||
| 24 | // 请求拦截器 | 68 | // 请求拦截器 |
| 25 | // axios.interceptors.request.use( | 69 | axios.interceptors.request.use( |
| 26 | // config => { | 70 | config => { |
| 27 | // // 每次发送请求之前判断是否存在token,如果存在,则统一在http请求的header都加上token,不用每次请求都手动添加了 | 71 | for (let index = 0; index < encryptPattern.length; index++) { |
| 28 | // // 即使本地存在token,也有可能token是过期的,所以在响应拦截器中要对返回状态进行判断 | 72 | let element = encryptPattern[index]; |
| 29 | // const token = "token"; //这里写入token | 73 | if (element.test(config.url)) { |
| 30 | // token && (config.headers.Authorization = token); | 74 | if (encryptWhileList.indexOf(config.url) >= 0) { |
| 31 | // return config; | 75 | break; |
| 32 | // }, | 76 | } |
| 33 | // error => { | 77 | let data = config.data; |
| 34 | // return Promise.error(error); | 78 | try { |
| 35 | // }) | 79 | config.data = encryptContent(data); |
| 80 | } catch (e) { | ||
| 81 | console.error(e); | ||
| 82 | } | ||
| 83 | break; | ||
| 84 | } | ||
| 85 | } | ||
| 86 | return config; | ||
| 87 | }, | ||
| 88 | error => { | ||
| 89 | return Promise.error(error); | ||
| 90 | }) | ||
| 36 | 91 | ||
| 37 | // 响应拦截器 | 92 | // 响应拦截器 |
| 38 | axios.interceptors.response.use( | 93 | axios.interceptors.response.use( |
| ... | @@ -147,7 +202,7 @@ export const httpPost = params => { | ... | @@ -147,7 +202,7 @@ export const httpPost = params => { |
| 147 | url, | 202 | url, |
| 148 | data, | 203 | data, |
| 149 | sid, | 204 | sid, |
| 150 | sidStr | 205 | sidStr, |
| 151 | } = params; | 206 | } = params; |
| 152 | let headers = {}; | 207 | let headers = {}; |
| 153 | if (sid) { | 208 | if (sid) { |
| ... | @@ -185,7 +240,7 @@ export const formdata = params => { | ... | @@ -185,7 +240,7 @@ export const formdata = params => { |
| 185 | sid, | 240 | sid, |
| 186 | } = params; | 241 | } = params; |
| 187 | let headers = { | 242 | let headers = { |
| 188 | headers : { | 243 | headers: { |
| 189 | "Content-Type": "multipart/form-data" | 244 | "Content-Type": "multipart/form-data" |
| 190 | } | 245 | } |
| 191 | } | 246 | } | ... | ... |
| ... | @@ -242,30 +242,35 @@ export default { | ... | @@ -242,30 +242,35 @@ export default { |
| 242 | }, | 242 | }, |
| 243 | _showAgreeProtocalTips() { | 243 | _showAgreeProtocalTips() { |
| 244 | let message = this.i18n.login.tips.e4; | 244 | let message = this.i18n.login.tips.e4; |
| 245 | this.showModal(message, "info"); | 245 | // this.showModal(message, "info"); |
| 246 | }, | 246 | }, |
| 247 | _showLoginErrorMessage(response) { | 247 | _showLoginErrorMessage(response) { |
| 248 | // response.returnCode = "GS_RESETPWD_ERROR_NOUSERINFO"; | 248 | // response.returnCode = "GS_RESETPWD_ERROR_NOUSERINFO"; |
| 249 | switch (response.returnCode) { | 249 | switch (response.returnCode) { |
| 250 | case "SMS_ERROR_006": | 250 | case "SMS_ERROR_006": |
| 251 | // 短信验证码不正确 | 251 | // 短信验证码不正确 |
| 252 | this.showModal(this.i18n.login.tips.oe4, "info"); | 252 | // this.showModal(this.i18n.login.tips.oe4, "info"); |
| 253 | this.errorTips.oe2 = this.i18n.login.tips.oe4; | ||
| 253 | break; | 254 | break; |
| 254 | case "BIZ_ERROR_018": | 255 | case "BIZ_ERROR_018": |
| 255 | // 账号或密码不正确 | 256 | // 账号或密码不正确 |
| 256 | this.showModal(this.i18n.login.tips.e5, "info"); | 257 | this.errorTips.e2 = this.i18n.login.tips.e5; |
| 258 | // this.showModal(this.i18n.login.tips.e5, "info"); | ||
| 257 | break; | 259 | break; |
| 258 | case "BIZ_ERROR_011": | 260 | case "BIZ_ERROR_011": |
| 259 | case "BIZ_ERROR_012": | 261 | case "BIZ_ERROR_012": |
| 260 | // 登录错误4次、5次 | 262 | // 登录错误4次、5次 |
| 261 | this.showModal(response.returnMsg, "info"); | 263 | this.errorTips.e2 = response.returnMsg; |
| 264 | // this.showModal(response.returnMsg, "info"); | ||
| 262 | return; | 265 | return; |
| 263 | case "GS_RESETPWD_ERROR_NOUSERINFO": | 266 | case "GS_RESETPWD_ERROR_NOUSERINFO": |
| 264 | // 这个是用户OTP验证成功后没有账号导致 | 267 | // 这个是用户OTP验证成功后没有账号导致 |
| 265 | this.type = 3; | 268 | this.type = 3; |
| 266 | break; | 269 | break; |
| 267 | default: | 270 | default: |
| 268 | this.showModal(this.i18n.login.tips.e5, "info"); | 271 | this.errorTips.e2 = this.i18n.login.tips.e5; |
| 272 | this.errorTips.oe2 = this.i18n.login.tips.e5; | ||
| 273 | // this.showModal(this.i18n.login.tips.e5, "info"); | ||
| 269 | break; | 274 | break; |
| 270 | } | 275 | } |
| 271 | }, | 276 | }, | ... | ... |
| ... | @@ -298,7 +298,7 @@ export default { | ... | @@ -298,7 +298,7 @@ export default { |
| 298 | 298 | ||
| 299 | _showAgreeProtocolTip() { | 299 | _showAgreeProtocolTip() { |
| 300 | let message = this.i18n.register.tips.e2; | 300 | let message = this.i18n.register.tips.e2; |
| 301 | this.showModal(message, "info"); | 301 | // this.showModal(message, "info"); |
| 302 | 302 | ||
| 303 | // alert("请同意协议") | 303 | // alert("请同意协议") |
| 304 | }, | 304 | }, |
| ... | @@ -314,13 +314,13 @@ export default { | ... | @@ -314,13 +314,13 @@ export default { |
| 314 | }, | 314 | }, |
| 315 | _showDuplicateRegistrationTip() { | 315 | _showDuplicateRegistrationTip() { |
| 316 | let message = this.i18n.register.tips.e5; | 316 | let message = this.i18n.register.tips.e5; |
| 317 | this.showModal(message, "info"); | 317 | // this.showModal(message, "info"); |
| 318 | this.errorTips.p1 = message; | ||
| 318 | // alert("手机号已经被注册,请使用其他手机号重新注册") | 319 | // alert("手机号已经被注册,请使用其他手机号重新注册") |
| 319 | }, | 320 | }, |
| 320 | _showImageValueTip() { | 321 | _showImageValueTip() { |
| 321 | let message = this.i18n.register.tips.e5; | 322 | let message = this.i18n.register.tips.e5; |
| 322 | this.errorTips.p3 = message; | 323 | this.errorTips.p3 = message; |
| 323 | |||
| 324 | // alert("请输入图片验证码") | 324 | // alert("请输入图片验证码") |
| 325 | }, | 325 | }, |
| 326 | _showCheckOTPErrTip(msg) { | 326 | _showCheckOTPErrTip(msg) { |
| ... | @@ -389,12 +389,14 @@ export default { | ... | @@ -389,12 +389,14 @@ export default { |
| 389 | this.handlerRefreshImageVcode(); | 389 | this.handlerRefreshImageVcode(); |
| 390 | let message = this.i18n.register.tips.e10; | 390 | let message = this.i18n.register.tips.e10; |
| 391 | // alert("验证码过期,请重新申请验证码"); | 391 | // alert("验证码过期,请重新申请验证码"); |
| 392 | this.showModal(message, "info"); | 392 | // this.showModal(message, "info"); |
| 393 | this.errorTips.p2 = message; | ||
| 393 | } else { | 394 | } else { |
| 394 | this._resetAllParams(); | 395 | this._resetAllParams(); |
| 395 | let message = this.i18n.register.tips.e11; | 396 | let message = this.i18n.register.tips.e11; |
| 396 | // alert("注册失败,请联系工作人员"); | 397 | // alert("注册失败,请联系工作人员"); |
| 397 | this.showModal(message, "info"); | 398 | // this.showModal(message, "info"); |
| 399 | this.errorTips.p5 = message; | ||
| 398 | } | 400 | } |
| 399 | }, | 401 | }, |
| 400 | _resetAllParams() { | 402 | _resetAllParams() { | ... | ... |
| ... | @@ -31,7 +31,7 @@ const routes = [ | ... | @@ -31,7 +31,7 @@ const routes = [ |
| 31 | name: 'login', | 31 | name: 'login', |
| 32 | component: () => import('./pages/login/login.vue'), | 32 | component: () => import('./pages/login/login.vue'), |
| 33 | meta: { | 33 | meta: { |
| 34 | title: '' | 34 | title: '平安人寿保险官网' |
| 35 | } | 35 | } |
| 36 | }, | 36 | }, |
| 37 | { | 37 | { |
| ... | @@ -39,7 +39,7 @@ const routes = [ | ... | @@ -39,7 +39,7 @@ const routes = [ |
| 39 | name: 'register', | 39 | name: 'register', |
| 40 | component: () => import('./pages/register/register.vue'), | 40 | component: () => import('./pages/register/register.vue'), |
| 41 | meta: { | 41 | meta: { |
| 42 | title: '' | 42 | title: '平安人寿保险官网' |
| 43 | } | 43 | } |
| 44 | }, | 44 | }, |
| 45 | { | 45 | { |
| ... | @@ -47,7 +47,7 @@ const routes = [ | ... | @@ -47,7 +47,7 @@ const routes = [ |
| 47 | name: 'passwordFind', | 47 | name: 'passwordFind', |
| 48 | component: () => import('./pages/password-find/password-find.vue'), | 48 | component: () => import('./pages/password-find/password-find.vue'), |
| 49 | meta: { | 49 | meta: { |
| 50 | title: '' | 50 | title: '平安人寿保险官网' |
| 51 | } | 51 | } |
| 52 | }, | 52 | }, |
| 53 | { | 53 | { |
| ... | @@ -55,7 +55,7 @@ const routes = [ | ... | @@ -55,7 +55,7 @@ const routes = [ |
| 55 | name: 'passwordReset', | 55 | name: 'passwordReset', |
| 56 | component: () => import('./pages/password-reset/password-reset.vue'), | 56 | component: () => import('./pages/password-reset/password-reset.vue'), |
| 57 | meta: { | 57 | meta: { |
| 58 | title: '' | 58 | title: '平安人寿保险官网' |
| 59 | } | 59 | } |
| 60 | }, | 60 | }, |
| 61 | { | 61 | { |
| ... | @@ -63,7 +63,7 @@ const routes = [ | ... | @@ -63,7 +63,7 @@ const routes = [ |
| 63 | name: 'infomationImprove', | 63 | name: 'infomationImprove', |
| 64 | component: () => import('./pages/infomation-improve/infomation-improve.vue'), | 64 | component: () => import('./pages/infomation-improve/infomation-improve.vue'), |
| 65 | meta: { | 65 | meta: { |
| 66 | title: '' | 66 | title: '平安人寿保险官网' |
| 67 | } | 67 | } |
| 68 | }, | 68 | }, |
| 69 | { | 69 | { |
| ... | @@ -71,7 +71,7 @@ const routes = [ | ... | @@ -71,7 +71,7 @@ const routes = [ |
| 71 | name: 'profile', | 71 | name: 'profile', |
| 72 | component: () => import('./pages/profile/profile.vue'), | 72 | component: () => import('./pages/profile/profile.vue'), |
| 73 | meta: { | 73 | meta: { |
| 74 | title: '公司简介' | 74 | title: '平安人寿保险官网' |
| 75 | } | 75 | } |
| 76 | }, | 76 | }, |
| 77 | { | 77 | { |
| ... | @@ -79,7 +79,7 @@ const routes = [ | ... | @@ -79,7 +79,7 @@ const routes = [ |
| 79 | name: 'terms', | 79 | name: 'terms', |
| 80 | component: () => import('./pages/terms/terms.vue'), | 80 | component: () => import('./pages/terms/terms.vue'), |
| 81 | meta: { | 81 | meta: { |
| 82 | title: '使用条款' | 82 | title: '平安人寿保险官网' |
| 83 | } | 83 | } |
| 84 | }, | 84 | }, |
| 85 | { | 85 | { |
| ... | @@ -87,7 +87,7 @@ const routes = [ | ... | @@ -87,7 +87,7 @@ const routes = [ |
| 87 | name: 'privacy', | 87 | name: 'privacy', |
| 88 | component: () => import('./pages/privacy/privacy.vue'), | 88 | component: () => import('./pages/privacy/privacy.vue'), |
| 89 | meta: { | 89 | meta: { |
| 90 | title: '隐私政策' | 90 | title: '平安人寿保险官网' |
| 91 | } | 91 | } |
| 92 | }, | 92 | }, |
| 93 | { | 93 | { |
| ... | @@ -95,7 +95,7 @@ const routes = [ | ... | @@ -95,7 +95,7 @@ const routes = [ |
| 95 | name: 'personalDataCollection', | 95 | name: 'personalDataCollection', |
| 96 | component: () => import('./pages/personal-data-collection/personal-data-collection.vue'), | 96 | component: () => import('./pages/personal-data-collection/personal-data-collection.vue'), |
| 97 | meta: { | 97 | meta: { |
| 98 | title: '' | 98 | title: '平安人寿保险官网' |
| 99 | } | 99 | } |
| 100 | }, | 100 | }, |
| 101 | { | 101 | { |
| ... | @@ -103,7 +103,7 @@ const routes = [ | ... | @@ -103,7 +103,7 @@ const routes = [ |
| 103 | name: 'protocol', | 103 | name: 'protocol', |
| 104 | component: () => import('./pages/protocol/protocol.vue'), | 104 | component: () => import('./pages/protocol/protocol.vue'), |
| 105 | meta: { | 105 | meta: { |
| 106 | title: '平安一賬通會員服務協議' | 106 | title: '平安人寿保险官网' |
| 107 | } | 107 | } |
| 108 | }, | 108 | }, |
| 109 | { | 109 | { |
| ... | @@ -111,7 +111,7 @@ const routes = [ | ... | @@ -111,7 +111,7 @@ const routes = [ |
| 111 | name: 'newsList', | 111 | name: 'newsList', |
| 112 | component: () => import('./pages/news-list/news-list.vue'), | 112 | component: () => import('./pages/news-list/news-list.vue'), |
| 113 | meta: { | 113 | meta: { |
| 114 | title: '' | 114 | title: '平安人寿保险官网' |
| 115 | } | 115 | } |
| 116 | }, | 116 | }, |
| 117 | { | 117 | { |
| ... | @@ -119,7 +119,7 @@ const routes = [ | ... | @@ -119,7 +119,7 @@ const routes = [ |
| 119 | name: 'newsDetail', | 119 | name: 'newsDetail', |
| 120 | component: () => import('./pages/news-detail/news-detail.vue'), | 120 | component: () => import('./pages/news-detail/news-detail.vue'), |
| 121 | meta: { | 121 | meta: { |
| 122 | title: '' | 122 | title: '平安人寿保险官网' |
| 123 | } | 123 | } |
| 124 | }, | 124 | }, |
| 125 | 125 | ||
| ... | @@ -128,7 +128,7 @@ const routes = [ | ... | @@ -128,7 +128,7 @@ const routes = [ |
| 128 | name: 'product', | 128 | name: 'product', |
| 129 | component: () => import('./pages/product/product.vue'), | 129 | component: () => import('./pages/product/product.vue'), |
| 130 | meta: { | 130 | meta: { |
| 131 | title: '' | 131 | title: '平安人寿保险官网' |
| 132 | } | 132 | } |
| 133 | }, | 133 | }, |
| 134 | { | 134 | { |
| ... | @@ -136,7 +136,7 @@ const routes = [ | ... | @@ -136,7 +136,7 @@ const routes = [ |
| 136 | name: 'customService', | 136 | name: 'customService', |
| 137 | component: () => import('./pages/custom-service/custom-service.vue'), | 137 | component: () => import('./pages/custom-service/custom-service.vue'), |
| 138 | meta: { | 138 | meta: { |
| 139 | title: '保单查询' | 139 | title: '平安人寿保险官网' |
| 140 | } | 140 | } |
| 141 | }, | 141 | }, |
| 142 | { | 142 | { |
| ... | @@ -144,7 +144,7 @@ const routes = [ | ... | @@ -144,7 +144,7 @@ const routes = [ |
| 144 | name: 'customProduct', | 144 | name: 'customProduct', |
| 145 | component: () => import('./pages/custom-product/custom-product.vue'), | 145 | component: () => import('./pages/custom-product/custom-product.vue'), |
| 146 | meta: { | 146 | meta: { |
| 147 | title: '' | 147 | title: '平安人寿保险官网' |
| 148 | } | 148 | } |
| 149 | }, | 149 | }, |
| 150 | 150 | ||
| ... | @@ -153,7 +153,7 @@ const routes = [ | ... | @@ -153,7 +153,7 @@ const routes = [ |
| 153 | name: 'demo', | 153 | name: 'demo', |
| 154 | component: () => import('./pages/demo/index.vue'), | 154 | component: () => import('./pages/demo/index.vue'), |
| 155 | meta: { | 155 | meta: { |
| 156 | title: '' | 156 | title: '平安人寿保险官网' |
| 157 | } | 157 | } |
| 158 | }, | 158 | }, |
| 159 | { | 159 | { |
| ... | @@ -161,7 +161,7 @@ const routes = [ | ... | @@ -161,7 +161,7 @@ const routes = [ |
| 161 | name: 'about', | 161 | name: 'about', |
| 162 | component: () => import('./pages/About.vue'), | 162 | component: () => import('./pages/About.vue'), |
| 163 | meta: { | 163 | meta: { |
| 164 | title: '' | 164 | title: '平安人寿保险官网' |
| 165 | } | 165 | } |
| 166 | }, | 166 | }, |
| 167 | { | 167 | { |
| ... | @@ -169,7 +169,7 @@ const routes = [ | ... | @@ -169,7 +169,7 @@ const routes = [ |
| 169 | name: 'empty', | 169 | name: 'empty', |
| 170 | component: () => import('./pages/empty/empty.vue'), | 170 | component: () => import('./pages/empty/empty.vue'), |
| 171 | meta: { | 171 | meta: { |
| 172 | title: '' | 172 | title: '平安人寿保险官网' |
| 173 | } | 173 | } |
| 174 | }, | 174 | }, |
| 175 | // 404页面 | 175 | // 404页面 |
| ... | @@ -190,6 +190,7 @@ const router = new Router({ | ... | @@ -190,6 +190,7 @@ const router = new Router({ |
| 190 | // mode: 'history', | 190 | // mode: 'history', |
| 191 | }); | 191 | }); |
| 192 | 192 | ||
| 193 | |||
| 193 | router.beforeEach((to, from, next) => { | 194 | router.beforeEach((to, from, next) => { |
| 194 | let langStr = localStorage.getItem("lang") || 'tc'; | 195 | let langStr = localStorage.getItem("lang") || 'tc'; |
| 195 | let lang; | 196 | let lang; |
| ... | @@ -212,11 +213,22 @@ router.beforeEach((to, from, next) => { | ... | @@ -212,11 +213,22 @@ router.beforeEach((to, from, next) => { |
| 212 | } | 213 | } |
| 213 | 214 | ||
| 214 | // lang对象为当前语言配置 见 en.js,tc.js,zh.js | 215 | // lang对象为当前语言配置 见 en.js,tc.js,zh.js |
| 215 | console.log("lang:", lang); | 216 | let title = ""; |
| 217 | lang.nav.navList.forEach(e1 => { | ||
| 218 | if (e1.list && e1.list.length > 0) { | ||
| 219 | e1.list.forEach(e2 => { | ||
| 220 | if(e2.path == to.fullPath){ | ||
| 221 | title = e2.name; | ||
| 222 | } | ||
| 223 | }); | ||
| 224 | } else { | ||
| 225 | if(e1.path == to.fullPath){ | ||
| 226 | title = e1.name; | ||
| 227 | } | ||
| 228 | } | ||
| 229 | }); | ||
| 216 | // to参数可以获取要前往页面的信息,包括参数 | 230 | // to参数可以获取要前往页面的信息,包括参数 |
| 217 | console.log("to:", to); | 231 | title = title || to.meta && to.meta.title; |
| 218 | |||
| 219 | const title = to.meta && to.meta.title; | ||
| 220 | if (title) { | 232 | if (title) { |
| 221 | document.title = title; | 233 | document.title = title; |
| 222 | } | 234 | } | ... | ... |
-
Please register or sign in to post a comment