yizai 3 роки тому
батько
коміт
529e8ab679

+ 31 - 1
src/utils/crypto.js

@@ -1,6 +1,7 @@
 import { JSEncrypt } from 'jsencrypt'
 import CryptoJS from 'crypto-js'
-
+const secretKey = CryptoJS.enc.Base64.parse('cMHVV61tASOzMkNYUe/pOPiPoWJoL8e1') // 将Base64编码字符串解码为原始二进制byte
+const iv = CryptoJS.enc.Utf8.parse('99999999')// 得到偏移量的二进制byte字节;
 export function encryptRSA(data, publicKey) {
   // 新建JSEncrypt对象
   const encryptor = new JSEncrypt()
@@ -53,3 +54,32 @@ function cryptToHex(str) {
   }
   return val
 }
+
+export function decryptTkyAES(word) {
+  var key = CryptoJS.enc.Utf8.parse('r93535.com/.!!!!')
+  var iv = CryptoJS.enc.Utf8.parse('0987654321234567')
+  var decrypt = CryptoJS.AES.decrypt(word, key, {
+    iv: iv,
+    mode: CryptoJS.mode.CBC,
+    padding: CryptoJS.pad.Pkcs7
+  })
+  return CryptoJS.enc.Utf8.stringify(decrypt).toString()
+}
+
+export function EncryptTkyAes(word) {
+  var key = CryptoJS.enc.Utf8.parse('r93535.com/.!!!!')
+  var iv = CryptoJS.enc.Utf8.parse('0987654321234567')
+  const srcs = CryptoJS.enc.Utf8.parse(word)
+  const encrypted = CryptoJS.AES.encrypt(srcs, key, { iv: iv, mode: CryptoJS.mode.CBC, padding: CryptoJS.pad.Pkcs7 })
+  return CryptoJS.enc.Base64.stringify(encrypted.ciphertext)
+}
+
+export function des_decrypt(str) {
+  const decrypt_str = CryptoJS.TripleDES.decrypt(str, secretKey, {
+    iv: iv,
+    mode: CryptoJS.mode.CBC,
+    padding: CryptoJS.pad.Pkcs7
+  })
+  console.log(CryptoJS.pad.Pkcs7, 'des3')
+  return decrypt_str.toString(CryptoJS.enc.Utf8)
+}

+ 7 - 2
src/views/bridge/device-manage/device-work.vue

@@ -45,6 +45,7 @@ import waves from '@/directive/waves' // waves directive
 import Pagination from '@/components/Pagination' // secondary package based on el-pagination
 import InnerSidebar from '@/components/InnerSidebar'
 import tkyIndex from '@/views/bridge/device-manage/tky-manage.vue'
+import * as Crypto from '@/utils/crypto'
 
 export default {
   name: 'DeviceMng',
@@ -71,7 +72,7 @@ export default {
         label: 'name',
         isLeaf: 'isDevice'
       },
-      tkySectionId: this.$route.query.token,
+      tkySectionId: undefined,
       formLoading: false
     }
   },
@@ -81,6 +82,10 @@ export default {
     }
   },
   created() {
+    if (this.$route.query.token) {
+      this.tkySectionId = Crypto.des_decrypt(this.$route.query.token)
+      console.log('asdsadsd', this.tkySectionId)
+    }
     try {
       this.$store.dispatch('user/clientCredentials')
         .then(res => {
@@ -96,7 +101,7 @@ export default {
       if (!value) return true
       return data.name.indexOf(value) !== -1
     },
-    loadTreeNode(node, resolve) {
+    loadTreeNode() {
       griderApi.getDeviceList(this.tkySectionId)
         .then(res => {
           res.forEach(t => {

+ 9 - 6
src/views/bridge/device-manage/index.vue

@@ -228,7 +228,6 @@
 
 <script>
 import * as interfaceApi from '@/api/device-manage.js'
-import * as tkyApi from '@/api/tky-api'
 import * as areaApi from '@/api/backbone/section-area'
 // import ProjectSectionTree from '@/views/projects/components/ProjectSectionTree'
 
@@ -287,11 +286,15 @@ export default {
     }
   },
   mounted() {
-    tkyApi.getAuthSectionInfo()
-      .then(res => {
-        this.authSection = res.data
-      })
-    this.getList()
+    try {
+      this.$store.dispatch('user/clientCredentials')
+        .then(res => {
+          this.getList()
+        })
+      this.loading = false
+    } catch (ex) {
+      console.log(ex)
+    }
   },
   methods: {
     // 树形事件