You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

64 lines
1.3 KiB

<template>
<view class="page">
<view class="input">
2 years ago
<uni-easyinput v-model.trim="account" placeholder="请输入账号" @input="accountChange"></uni-easyinput>
</view>
<button type="primary" @click="submit">确认</button>
</view>
</template>
<script>
2 years ago
import { checkIfAnAccountExists, changeAccount } from '@/apis/modules/user.js'
export default {
data() {
return {
2 years ago
timer: null,
account: '',
2 years ago
repeat: false
}
},
onShow() {
2 years ago
},
methods: {
2 years ago
// 账号判重
accountChange() {
clearTimeout(this.timer)
this.timer = setTimeout(() => {
checkIfAnAccountExists(this.account).then(() => {
this.repeat = false
}).catch(e => {
this.repeat = true
})
}, 500)
},
submit() {
2 years ago
const { account } = this
if(!account) return this.$util.errMsg('请输入账号')
2 years ago
if (this.repeat) return this.$util.errMsg('账号已存在!')
changeAccount(account).then(res => {
this.$util.sucMsg('修改成功!')
setTimeout(() => {
uni.reLaunch({
url: '../person/person'
})
}, 1000)
}).catch(e => {})
}
}
}
</script>
<style scoped lang="scss">
.page {
padding: 20px;
background-color: #fff;
}
/deep/.input {
margin-bottom: 15px;
.is-input-border {
border-color: #dedede !important;
}
}
</style>