Explorar el Código

fix:登录防抖

zhanghui hace 1 año
padre
commit
bbf85e1f54
Se han modificado 2 ficheros con 12 adiciones y 3 borrados
  1. 10 1
      pages/login/login.vue
  2. 2 2
      pages/register/register.vue

+ 10 - 1
pages/login/login.vue

@@ -35,7 +35,7 @@
 					</view>
 				</view>
 
-				<view class="loginButton" @click="login">
+				<view class="loginButton" @click="debounce(login,500)">
 					<text>登录</text>
 				</view>
 
@@ -194,7 +194,16 @@
 				}).catch(err=>{
 					this.requestStatus=false
 				})
+			},
+
+			debounce(fn, delay) {
+				console.log(delay)
+				clearTimeout(this.timer);
+				this.timer = setTimeout(() => {
+					fn.apply();
+				}, delay);
 			}
+
 		}
 	}
 </script>

+ 2 - 2
pages/register/register.vue

@@ -15,7 +15,7 @@
                     <u--input v-model="form.name" placeholder="请输入姓名" border="none"></u--input>
                 </u-form-item>
                 <u-form-item :labelWidth="80" label="身份证号:" borderBottom prop="idCard" ref="item1">
-                    <u--input v-model="form.idCard" placeholder="请输入姓名" border="none"></u--input>
+                    <u--input v-model="form.idCard" placeholder="请输入身份证号" border="none"></u--input>
                 </u-form-item>
                 <u-form-item :labelWidth="80" label="密码:" borderBottom prop="newPassword" ref="item1">
                     <u--input v-model="form.newPassword" placeholder="请输入密码" type="password" border="none"></u--input>
@@ -41,7 +41,7 @@
 
             <view :style="{'marginTop':'100rpx'}">
 <!--                <button class="customStyle" @click="expandRegister">提交</button>-->
-                <button class="customStyle" @click="debounce(expandRegister,600)">提交</button>
+                <button class="customStyle" @click="debounce(expandRegister,500)">提交</button>
             </view>
 
             <view class="flex-row justify-center  register">