或然中台小程序
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.

62 lines
1.3 KiB

2 years ago
<template>
<view class="page">
<view class="input">
<uni-easyinput v-model.trim="account" placeholder="请输入账号" @input="accountChange"></uni-easyinput>
</view>
<button type="primary" @click="submit">确认</button>
</view>
</template>
<script>
import { checkIfAnAccountExists, changeAccount } from '@/apis/modules/user.js'
export default {
data() {
return {
timer: null,
account: '',
repeat: false
}
},
onShow() {
},
methods: {
// 账号判重
accountChange() {
clearTimeout(this.timer)
this.timer = setTimeout(() => {
checkIfAnAccountExists(this.account).then(() => {
this.repeat = false
}).catch(e => {
this.repeat = true
})
}, 500)
},
submit() {
const { account } = this
if(!account) return this.$util.errMsg('请输入账号')
if (this.repeat) return this.$util.errMsg('账号已存在!')
changeAccount(account).then(res => {
this.$util.sucMsg('修改成功!')
setTimeout(() => {
uni.navigateBack()
}, 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>