用户模块

This commit is contained in:
仲么了
2023-07-10 20:20:00 +08:00
parent 69063cb241
commit 2104bc0c4c
17 changed files with 4764 additions and 381 deletions

View File

@@ -5,15 +5,32 @@
<template v-if="step == 1">
<uni-forms ref="form" :rules="rules" :modelValue="formData">
<uni-forms-item name="phone">
<uni-easyinput disabled type="text" v-model="formData.phoneShow" placeholder="请输入手机号" />
<uni-easyinput
disabled
type="text"
maxlength="11"
v-model="formData.phoneShow"
placeholder="请输入手机号"
/>
</uni-forms-item>
<uni-forms-item name="code">
<view class="login-box-input">
<uni-easyinput type="number" v-model="formData.code" placeholder="请输入验证码" />
<view class="ml40"
style="margin-left:40rpx;font-size: 28rpx; color: #666; width: 200rpx; text-align: center"
v-if="waitTime > 0">{{ waitTime + 's后重新获取' }}</view>
<button class="login-box-input-btn" v-else @click="getCode(5)" size="mini">获取验证码</button>
<view
class="ml40"
style="
margin-left: 40rpx;
font-size: 28rpx;
color: #666;
width: 200rpx;
text-align: center;
"
v-if="waitTime > 0"
>{{ waitTime + 's后重新获取' }}</view
>
<button class="login-box-input-btn" v-else @click="getCode(5)" size="mini">
获取验证码
</button>
</view>
</uni-forms-item>
</uni-forms>
@@ -22,15 +39,31 @@
<template v-else>
<uni-forms ref="form" :rules="rules" :modelValue="formData">
<uni-forms-item name="phone">
<uni-easyinput type="number" v-model="formData.phone2" placeholder="请输入新手机号" />
<uni-easyinput
maxlength="11"
type="number"
v-model="formData.phone2"
placeholder="请输入新手机号"
/>
</uni-forms-item>
<uni-forms-item name="code">
<view class="login-box-input">
<uni-easyinput type="number" v-model="formData.code2" placeholder="请输入验证码" />
<view class="ml40"
style="margin-left:40rpx;font-size: 28rpx; color: #666; width: 200rpx; text-align: center"
v-if="waitTime > 0">{{ waitTime + 's后重新获取' }}</view>
<button class="login-box-input-btn" v-else @click="getCode(4)" size="mini">获取验证码</button>
<view
class="ml40"
style="
margin-left: 40rpx;
font-size: 28rpx;
color: #666;
width: 200rpx;
text-align: center;
"
v-if="waitTime > 0"
>{{ waitTime + 's后重新获取' }}</view
>
<button class="login-box-input-btn" v-else @click="getCode(4)" size="mini">
获取验证码
</button>
</view>
</uni-forms-item>
</uni-forms>
@@ -43,8 +76,8 @@
<script>
import { apiGetYms, apiComfirmCode, apiRebindPhone } from '@/common/api/user'
export default {
name: "jiaban",
data () {
name: 'jiaban',
data() {
return {
step: 1,
loading: false,
@@ -62,102 +95,108 @@ export default {
rules: [
{
required: true,
errorMessage: "请填写手机号"
}
]
errorMessage: '请填写手机号',
},
],
},
code: {
rules: [
{
required: true,
errorMessage: "请填写验证码"
}
]
errorMessage: '请填写验证码',
},
],
},
phone2: {
rules: [
{
required: true,
errorMessage: "请填写新手机号"
}
]
errorMessage: '请填写新手机号',
},
],
},
code2: {
rules: [
{
required: true,
errorMessage: "请填写验证码"
}
]
}
}
};
errorMessage: '请填写验证码',
},
],
},
},
}
},
onLoad () {
onLoad() {
this.init()
},
methods: {
getCode (type) {
getCode(type) {
if (!this.formData.phone) {
return this.$util.toast('请输入手机号!')
}
uni.showLoading({
title: '请稍等'
title: '请稍等',
})
apiGetYms({
phone: type == 5 ? this.formData.phone : this.formData.phone2,
type,
}).then(res => {
uni.hideLoading()
console.log(res);
this.waitTime = 60
this.inter = setInterval(() => {
if (this.waitTime == 0) {
clearInterval(this.inter)
} else {
this.waitTime--
}
}, 1000)
}).catch(err => {
uni.hideLoading()
console.log(err);
})
.then((res) => {
uni.hideLoading()
console.log(res)
this.waitTime = 60
this.inter = setInterval(() => {
if (this.waitTime == 0) {
clearInterval(this.inter)
} else {
this.waitTime--
}
}, 1000)
})
.catch((err) => {
uni.hideLoading()
console.log(err)
})
},
init () {
this.formData.phone = uni.getStorageSync('userInfo').phone
// 150****0083
this.formData.phoneShow = this.formData.phone.substr(0, 3) + '****' + this.formData.phone.substr(7)
init() {
// 手机号中间四位隐藏
this.formData.phone = uni.getStorageSync('userInfo').user_name
this.formData.phoneShow = this.formData.phone.replace(/(\d{3})\d{4}(\d{4})/, '$1****$2')
},
firstSubmit () {
firstSubmit() {
apiComfirmCode({
phone: this.formData.phone,
code: this.formData.code,
}).then(res => {
this.step = 2
clearInterval(this.inter)
this.waitTime = 0
}).catch(err => {
console.log(err);
})
.then((res) => {
this.step = 2
clearInterval(this.inter)
this.waitTime = 0
})
.catch((err) => {
console.log(err)
})
},
secondSubmit () {
secondSubmit() {
apiRebindPhone({
phone: this.formData.phone2,
code: this.formData.code2,
}).then(res => {
this.$util.toast('绑定成功')
uni.clearStorageSync();
setTimeout(() => {
uni.redirectTo({
url: '/pages/user/login'
})
}, 1500);
}).catch(err => {
console.log(err);
})
}
}
};
.then((res) => {
this.$util.toast('绑定成功')
uni.clearStorageSync()
setTimeout(() => {
uni.redirectTo({
url: '/pages/user/login',
})
}, 1500)
})
.catch((err) => {
console.log(err)
})
},
},
}
</script>
<style lang="scss">
.index {