Browse Source

订座-登录页接口对接

panyong 3 years ago
parent
commit
4ec95cfa26
2 changed files with 12 additions and 12 deletions
  1. 1 1
      htmldev/dashboard/src/api/request.js
  2. 11 11
      htmldev/dashboard/src/login/index.vue

+ 1 - 1
htmldev/dashboard/src/api/request.js

@@ -16,7 +16,7 @@ const request = axios.create({
 
 // Add a request interceptor
 request.interceptors.request.use(request => {
-  request.headers.token = getCookieValue('token')
+  request.headers.token = getCookieValue('afhousetoken')
   return request
 }, error => {
   // Do something with request error

+ 11 - 11
htmldev/dashboard/src/login/index.vue

@@ -148,8 +148,8 @@ export default {
       }
       return this.arrErrorList.length <= 0
     },
-    funSubmit () {
-      const { phone, code } = this.postData
+    async funSubmit () {
+      const { phone, code, msg } = this.postData
       if (!this.verifyData()) {
         Toast({
           message: this.arrErrorList[0],
@@ -161,17 +161,18 @@ export default {
         duration: 1000 * 100,
         forbidClick: true
       })
-      login(phone, code).then(res => {
+      try {
+        const { status, data } = await login(phone, code)
         myToast.clear()
-        if (res.status) {
-          const { token } = res.data
+        if (status) {
+          const { token } = data
           clearLoginInfo()
           this.$nextTick(() => {
             this.$store.commit('common/UPDATE_PHONE', phone)
             this.$store.commit('common/UPDATE_TOKEN', token)
 
-            this.$cookie.set('phone', phone, '30d')
-            this.$cookie.set('token', token, '30d')
+            this.$cookie.set('afhousephone', phone, '30d')
+            this.$cookie.set('afhousetoken', token, '30d')
           })
 
           Toast({
@@ -184,11 +185,10 @@ export default {
           })
           return
         }
-        Toast(res.msg)
-      }).catch(err => {
+        Toast(msg)
+      } catch (err) {
         myToast.clear()
-        Toast(err.msg)
-      })
+      }
     }
   }
 }