ソースを参照

1. 调整短信验证码登录

MONSTER-ygh 1 年間 前
コミット
1a07d84247
3 ファイル変更7 行追加2 行削除
  1. 2 1
      src/api/login.js
  2. 3 1
      src/store/modules/user.js
  3. 2 0
      src/views/login.vue

+ 2 - 1
src/api/login.js

@@ -71,9 +71,10 @@ export function getCodeNum(data) {
   })
 }
 
-export function loginCode(username, code) {
+export function loginCode(username, smsToken,code) {
   const data = {
     username,
+    smsToken,
     code
   }
   return request({

+ 3 - 1
src/store/modules/user.js

@@ -35,6 +35,8 @@ const user = {
       const password = userInfo.password
       const code = userInfo.code
       const uuid = userInfo.uuid
+      const smsToken = userInfo.smsToken
+      const phone = userInfo.phone
       return new Promise((resolve, reject) => {
         if(userInfo.loginType == 1){ // 密码登录
           login(username, password, code, uuid).then(res => {
@@ -45,7 +47,7 @@ const user = {
             reject(error)
           })
         }else { // 验证码登录
-          loginCode(username,  code).then(res => {
+          loginCode(phone, smsToken, code).then(res => {
             setToken(res.data.access_token)
             commit('SET_TOKEN', res.data.access_token)
             resolve()

+ 2 - 0
src/views/login.vue

@@ -147,6 +147,7 @@ export default {
 
         loginType: 1,
         phone: null,
+        smsToken: null, // 短信验证token,由短信发送接口获取
       },
       loginRules: {
         username: [
@@ -233,6 +234,7 @@ export default {
         getCodeNum({
           "mobile": this.loginForm.phone
         }).then(res => {
+          this.loginForm.smsToken = res.data.smsToken
           this.codeType = 1
           this.codeLoading = false
           this.codeEffectiveTime = 60