Quellcode durchsuchen

fix:发送验证码

DESKTOP-1OI7FFK\WZTX vor 8 Monaten
Ursprung
Commit
4fabacfc7e
3 geänderte Dateien mit 19 neuen und 1 gelöschten Zeilen
  1. 1 0
      frontend/package.json
  2. 12 1
      frontend/src/components/login/index.vue
  3. 6 0
      frontend/src/utils/publickey.js

+ 1 - 0
frontend/package.json

@@ -14,6 +14,7 @@
     "axios": "1.8.3",
     "crypto-js": "4.1.1",
     "element-plus": "2.1.7",
+    "jsencrypt": "^3.3.2",
     "pinia": "3.0.1",
     "pinia-plugin-persistedstate": "4.2.0",
     "vue": "3.5.13",

+ 12 - 1
frontend/src/components/login/index.vue

@@ -150,6 +150,8 @@ import { ref, reactive, computed } from 'vue'
 import { ElMessage } from 'element-plus'
 import { getAccountCompany, selectCompany, sendCode } from '@/apis/user';
 import useUserInfo from "@/stores/modules/user";
+import JSEncrypt from 'jsencrypt/bin/jsencrypt.min'
+import { publicKey } from '@/utils/publickey'
 const showDialog = computed(() => props.dialogVisible)
 
 const props = defineProps({
@@ -254,8 +256,17 @@ const sendVerificationCode = () => {
     return
   }
 
+  const encryptor = new JSEncrypt()
+    encryptor.setPublicKey(publicKey)
+    let _params = encryptor.encrypt(
+      JSON.stringify({
+        phone: loginForm.username,
+        time:new Date().getTime(),
+        device: 'h5'
+      })
+    )
   sendCode({
-    phone: loginForm.username
+    _params_: _params
   }).then(() => {
     isCodeSending.value = true
     countdown.value = 60

+ 6 - 0
frontend/src/utils/publickey.js

@@ -0,0 +1,6 @@
+export const publicKey = `-----BEGIN PUBLIC KEY-----
+MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDElMhAUOwyo78M97jDGlYvl1FZ
+JZV+/EKZ3G7VDO1T5uUNnXWqgxSSwobbd384/npxvfFznoeJ+PaM/fXFNeOGKL9N
+GrswS/jTmSdIUdoMQVbGuzrGUK1liK+L9VGxxCmbvJ1f+6iiOHUwZAx6AXA2Mk2s
+8LVtXFCoM5cZWG4GiQIDAQAB
+-----END PUBLIC KEY-----`