调整自定义插件、代码风格化

This commit is contained in:
sfmind
2022-04-16 22:04:02 +08:00
parent cfcc0aa6dd
commit 9e69f6e6c2
12 changed files with 528 additions and 563 deletions

View File

@ -1,6 +1,5 @@
<template>
<view class="container">
<view class="unp-header">
<view class="unp-logo">
<u-avatar size="80" icon="github-circle-fill" fontSize="80"></u-avatar>
@ -36,21 +35,12 @@
<!-- 占位 -->
</view>
<u-button
type="error"
text="重置密码"
customStyle="margin-top: 50px"
@click="handleSubmit"
></u-button>
<u-button type="error" text="重置密码" customStyle="margin-top: 50px" @click="handleSubmit"></u-button>
<u-gap height="20"></u-gap>
<u-button type="info" text="返回" @click="navigateBack()"></u-button>
</u--form>
</view>
</view>
</template>
@ -64,24 +54,24 @@ export default {
formData: {
username: '',
code: '',
password: '',
password: ''
},
rules: {
'username': {
username: {
type: 'string',
max: 20,
required: true,
message: '请输入您的账号',
trigger: ['blur', 'change']
},
'code': {
code: {
type: 'number',
max: 6,
required: true,
message: '请输入验证码',
trigger: ['blur', 'change']
},
'password': {
password: {
type: 'string',
max: 20,
required: true,
@ -91,24 +81,22 @@ export default {
}
}
},
onLoad() {
},
onLoad() {},
methods: {
handleUsernameChange(e){
let str = uni.$u.trim(e, 'all');
handleUsernameChange(e) {
let str = uni.$u.trim(e, 'all')
this.$nextTick(() => {
this.formData.username = str
})
},
handlePasswordChange(e){
let str = uni.$u.trim(e, 'all');
handlePasswordChange(e) {
let str = uni.$u.trim(e, 'all')
this.$nextTick(() => {
this.formData.password = str
})
},
codeChange(text) {
this.tips = text;
this.tips = text
},
getCode() {
if (this.$refs.uCode.canGetCode) {
@ -117,22 +105,23 @@ export default {
title: '正在获取验证码'
})
setTimeout(() => {
uni.hideLoading();
uni.hideLoading()
// 这里此提示会被this.start()方法中的提示覆盖
uni.$u.toast('验证码已发送');
uni.$u.toast('验证码已发送')
// 通知验证码组件内部开始倒计时
this.$refs.uCode.start();
}, 2000);
this.$refs.uCode.start()
}, 2000)
} else {
uni.$u.toast('倒计时结束后再发送');
uni.$u.toast('倒计时结束后再发送')
}
},
handleSubmit() {
this.$refs.form.validate().then(res => {
uni.$u.toast('点击了重置密码')
}).catch(err => {
})
this.$refs.form
.validate()
.then(res => {
uni.$u.toast('点击了重置密码')
})
.catch(err => {})
},
navigateBack() {
uni.navigateBack()
@ -142,26 +131,17 @@ export default {
</script>
<style lang="scss" scoped>
.unp-header {
height: 400rpx;
display: flex;
align-items: center;
justify-content: center;
@include flex-center;
.unp-logo {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
@include flex-center;
}
}
.unp-box {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
.unp-form{
@include flex-center(column);
.unp-form {
width: 560rpx;
}
}
@ -169,14 +149,10 @@ export default {
.lk-group {
height: 40rpx;
margin-top: 40rpx;
display: flex;
align-items: center;
justify-content: space-between;
@include flex-space-between;
font-size: 12rpx;
color: $u-primary;
text-decoration: $u-primary;
}
</style>