用户接口对接

This commit is contained in:
仲么了
2023-03-20 08:51:21 +08:00
parent c5ed54924b
commit c308a7131b
10 changed files with 284 additions and 110 deletions

View File

@@ -3,12 +3,12 @@
<view slot="body">
<view class="index">
<template v-if="step == 1">
<uni-forms ref="form">
<uni-forms ref="form" :rules="rules" :modelValue="formData">
<uni-forms-item name="phone">
<uni-easyinput type="number" v-model="formData.phone" placeholder="请输入手机号" />
</uni-forms-item>
<uni-forms-item name="code">
<view class="login-box-input mt40">
<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"
@@ -25,7 +25,7 @@
</view>
</template>
<template v-else>
<uni-forms ref="form">
<uni-forms ref="form" :rules="rules" :modelValue="formData">
<uni-forms-item name="password">
<uni-easyinput type="text" v-model="formData.password" placeholder="请输入登录密码" />
</uni-forms-item>
@@ -43,6 +43,7 @@
</Cn-page>
</template>
<script>
import { apiRegister, apiGetYms, apiSetPsd } from '@/common/api/user'
export default {
name: "jiaban",
data () {
@@ -97,21 +98,64 @@ export default {
},
methods: {
getCode () {
this.waitTime = 60
this.inter = setInterval(() => {
if (this.waitTime == 0) {
clearInterval(this.inter)
} else {
this.waitTime--
}
}, 1000)
if (!this.formData.phone) {
return this.$util.toast('请输入手机号!')
}
uni.showLoading({
title: '请稍等'
})
apiGetYms({
phone: this.formData.phone,
type: 1,
}).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);
})
},
firstSubmit () {
this.step = 2
this.$refs.form.validate().then((valid, errors) => {
apiRegister({
phone: this.formData.phone,
code: this.formData.code
}).then(res => {
console.log(res);
this.$util.toast(res.msg)
uni.setStorageSync('userInfo', res.data)
this.step = 2
})
})
},
secondSubmit () {
this.$refs.form.validate().then((valid, errors) => {
console.log(this.formData.password.length);
if (this.formData.password.length < 6 || this.formData.password.length > 18) {
return this.$util.toast('密码长度为6-18位')
} else if (this.formData.password != this.formData.password2) {
return this.$util.toast('两次密码不一致')
}
apiSetPsd({
phone: this.formData.phone,
password: this.formData.password,
}).then(res => {
console.log(res);
this.$util.toast(res.msg)
uni.setStorageSync('userInfo', res.data)
uni.reLaunch({
url: '/pages/user/login'
})
})
})
}
}
};