fix(login): 修复登录时按钮状态及错误处理

- 添加 btnDisabled 属性,用于控制登录按钮的状态
- 在登录请求前禁用按钮,请求完成后重新启用- 优化登录失败时的错误处理逻辑
- 修复登录成功后页面跳转方式
main
Tuzki 7 months ago
parent 51bde71959
commit f4399dd3e7
  1. 13
      pages/login.vue

@ -19,7 +19,7 @@
<input v-model="loginForm.password" type="password" class="input" placeholder="请输入密码" maxlength="20" />
</view>
<view class="action-btn">
<button @click="handleLogin" class="login-btn cu-btn block bg-blue lg round">登录</button>
<button :disabled="btnDisabled" :loading="btnDisabled" @click="handleLogin" class="login-btn cu-btn block bg-blue lg round">登录</button>
</view>
</view>
@ -51,7 +51,8 @@
loginname: "laobaigan",
password: "LBGxcx@2023!",
},
tentId: null
tentId: null,
btnDisabled:false
}
},
onShow() {
@ -93,16 +94,22 @@
this.$modal.msgError("请输入您的密码")
} else {
this.$modal.loading("登录中,请耐心等待...")
this.btnDisabled = true
this.$Request.post(this.$config.handheldDevicedoLogin, this.loginForm).then(res => {
if (res.status == 200) {
uni.setStorageSync('sname', res.data.sname);
this.$modal.closeLoading()
uni.navigateTo({
this.btnDisabled = false
uni.redirectTo({
url: '/pages/index'
});
}
}).catch(err => {
this.$modal.closeLoading()
console.log(err, '错误信息')
this.btnDisabled = false;
this.loginForm.loginname="laobaigan";
this.loginForm.password="LBGxcx@2023!";
})
}
},

Loading…
Cancel
Save