yujialong 2 weeks ago
parent 9811ac3bbd
commit d6babd4c52
  1. 28
      src/components/upload/config.js
  2. 34
      src/pages/account/redirect/index.vue

@ -1,32 +1,12 @@
/** /**
* 阿里云oss配置 * 阿里云oss配置
* */ * */
import { get } from '@/plugins/requests/index.js'
import api from '@/api'
import CryptoJS from 'crypto-js'
import JSEncrypt from 'jsencrypt'
const A = (key, encryptedData) => {
const keyHex = CryptoJS.enc.Base64.parse(key)
const decrypted = CryptoJS.AES.decrypt(encryptedData, keyHex, {
mode: CryptoJS.mode.ECB,
padding: CryptoJS.pad.Pkcs7
})
return decrypted.toString(CryptoJS.enc.Utf8)
}
const R = (encryptedKey, privateKey) => {
const decrypt = new JSEncrypt()
decrypt.setPrivateKey(privateKey)
const decryptedKey = decrypt.decrypt(encryptedKey)
return decryptedKey
}
export default async function () { export default async function () {
try { try {
const res = await get(api.encrypt) let RE = localStorage.getItem('osc')
const RE = A(R(res.encryptedKey, res.privateKey), res.encryptedData).split('/') if (RE) RE = JSON.parse(RE)
return { return RE ? {
// oss账号信息 // oss账号信息
config: { config: {
region: 'oss-cn-shenzhen', region: 'oss-cn-shenzhen',
@ -36,6 +16,6 @@ export default async function () {
}, },
// 上传成功url前置部分(成功回调没有返回url) // 上传成功url前置部分(成功回调没有返回url)
preUrl: 'https://huoran.oss-cn-shenzhen.aliyuncs.com/' preUrl: 'https://huoran.oss-cn-shenzhen.aliyuncs.com/'
} } : {}
} catch (e) { } } catch (e) { }
} }

@ -1,9 +1,11 @@
<template></template> <template></template>
<script> <script>
import { mapActions, mapMutations } from "vuex"; import { mapActions, mapMutations } from 'vuex'
import Util from '@/libs/util' import Util from '@/libs/util'
import Setting from "@/setting"; import Setting from '@/setting'
import CryptoJS from 'crypto-js'
import JSEncrypt from 'jsencrypt'
export default { export default {
data: function () { data: function () {
return { return {
@ -12,6 +14,8 @@ export default {
}, },
mounted () { mounted () {
localStorage.removeItem('opened') localStorage.removeItem('opened')
localStorage.removeItem('review_token')
localStorage.removeItem('reviewPath')
this.token ? this.setLogin() : this.$router.replace('/login') this.token ? this.setLogin() : this.$router.replace('/login')
}, },
methods: { methods: {
@ -22,10 +26,9 @@ export default {
"setCustomerName" "setCustomerName"
]), ]),
setLogin () { setLogin () {
localStorage.removeItem('review_token')
localStorage.removeItem('reviewPath')
this.SET_FROM(true) this.SET_FROM(true)
Util.local.set(Setting.tokenKey, window.atob(decodeURI(this.token)), Setting.tokenExpires); Util.local.set(Setting.tokenKey, window.atob(decodeURI(this.token)), Setting.tokenExpires);
this.getOss()
this.getRole() this.getRole()
this.queryCustomer() this.queryCustomer()
}, },
@ -43,7 +46,28 @@ export default {
const list = res.permissionMenu[0].children const list = res.permissionMenu[0].children
this.$router.push(list.find(e => e.path === path) ? path : list[0].path) this.$router.push(list.find(e => e.path === path) ? path : list[0].path)
}).catch(err => { }) }).catch(err => { })
} },
async getOss () {
const A = (key, encryptedData) => {
const keyHex = CryptoJS.enc.Base64.parse(key)
const decrypted = CryptoJS.AES.decrypt(encryptedData, keyHex, {
mode: CryptoJS.mode.ECB,
padding: CryptoJS.pad.Pkcs7
})
return decrypted.toString(CryptoJS.enc.Utf8)
}
const R = (encryptedKey, privateKey) => {
const decrypt = new JSEncrypt()
decrypt.setPrivateKey(privateKey)
const decryptedKey = decrypt.decrypt(encryptedKey)
return decryptedKey
}
const res = await this.$get(this.api.encrypt)
const RE = A(R(res.encryptedKey, res.privateKey), res.encryptedData).split('/')
localStorage.setItem('osc', JSON.stringify(RE))
},
} }
}; };
</script> </script>

Loading…
Cancel
Save