Преглед на файлове

feat(profile): length limit of mobile phone number and email

Casper Dai преди 3 години
родител
ревизия
7d2dfb5c76
променени са 1 файла, в които са добавени 16 реда и са изтрити 7 реда
  1. 16 7
      src/views/platform/profile/index.vue

+ 16 - 7
src/views/platform/profile/index.vue

@@ -25,7 +25,10 @@
       </div>
       <div class="u-bold">{{ name }}</div>
     </div>
-    <div class="l-flex__fill l-flex--col center">
+    <div
+      v-loading="loading"
+      class="l-flex__fill l-flex--col center"
+    >
       <warning
         v-if="error"
         @click="getUserInfo"
@@ -38,6 +41,7 @@
         <div>
           <el-input
             v-model="phone"
+            maxlength="11"
             @change="onPhoneChange"
             @keydown.enter="$event.target.blur()"
           />
@@ -46,6 +50,7 @@
         <div>
           <el-input
             v-model="email"
+            maxlength="50"
             @change="onEmailChange"
             @keydown.enter="$event.target.blur()"
           />
@@ -75,7 +80,7 @@
           <span class="c-sibling-item u-color--black u-bold">请使用微信扫一扫</span>
         </div>
         <div
-          v-loading="loading"
+          v-loading="loadingQr"
           class="c-wechat__wrapper"
           :class="{ retry }"
           @click="getQr"
@@ -106,6 +111,7 @@ export default {
   name: 'Profile',
   data () {
     return {
+      loading: true,
       error: false,
       user: null,
       avatar: '',
@@ -114,7 +120,7 @@ export default {
       wechat: '',
       showQr: false,
       qr: null,
-      loading: false,
+      loadingQr: false,
       retry: false
     }
   },
@@ -163,13 +169,16 @@ export default {
       reader.readAsDataURL(file)
     },
     getUserInfo () {
+      this.loading = true
       this.error = false
       userinfo().then(
         this.setUserInfo,
         () => {
           this.error = true
         }
-      )
+      ).finally(() => {
+        this.loading = false
+      })
     },
     setUserInfo (data) {
       this.avatar = this.getOrCreateAttribute(data, 'avatar', '')
@@ -276,7 +285,7 @@ export default {
       clearTimeout(this.$timer)
     },
     getQr () {
-      if (this.loading || this.qr && !this.retry) {
+      if (this.loadingQr || this.qr && !this.retry) {
         return
       }
       this.fetchQr()
@@ -293,7 +302,7 @@ export default {
         return
       }
       if (!this.qr || this.retry) {
-        this.loading = true
+        this.loadingQr = true
       }
       this.retry = false
       clearTimeout(this.$timer)
@@ -318,7 +327,7 @@ export default {
           }
         }
       ).finally(() => {
-        this.loading = false
+        this.loadingQr = false
       })
     },
     checkBind () {