登录对接
This commit is contained in:
@@ -5,21 +5,24 @@
|
||||
<template v-if="step == 1">
|
||||
<uni-forms ref="form" :rules="rules" :modelValue="formData">
|
||||
<uni-forms-item name="phone">
|
||||
<uni-easyinput type="number" v-model="formData.phone" placeholder="请输入手机号" />
|
||||
<uni-easyinput type="number" v-model="formData.phone" maxlength="11" 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>
|
||||
<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" size="mini">获取验证码</button>
|
||||
</view>
|
||||
</uni-forms-item>
|
||||
</uni-forms>
|
||||
<button type="default" class="submit-btn" @click="firstSubmit">下一步</button>
|
||||
<view class="login-box-tips">
|
||||
<view style="color:#999">点击提交即表示同意</view>
|
||||
<view style="color: #999">点击提交即表示同意</view>
|
||||
<navigator url="/pages/mine/agreement" hover-class="none">《用户协议》</navigator>
|
||||
<navigator url="/pages/mine/policy" hover-class="none">《个人信息保护政策》</navigator>
|
||||
</view>
|
||||
@@ -35,7 +38,7 @@
|
||||
</uni-forms>
|
||||
<button type="default" class="submit-btn" @click="secondSubmit">提交</button>
|
||||
<view class="login-box-tips">
|
||||
<view style="color:#999">说明:密码长度为6-18位</view>
|
||||
<view style="color: #999">说明:密码长度为6-18位</view>
|
||||
</view>
|
||||
</template>
|
||||
</view>
|
||||
@@ -43,10 +46,11 @@
|
||||
</Cn-page>
|
||||
</template>
|
||||
<script>
|
||||
import { apiRegister, apiGetYms, apiSetPsd } from '@/common/api/user'
|
||||
import { apiRegister, apiGetYms, apiSetPsd, autoLogin } from '@/common/api/user'
|
||||
|
||||
export default {
|
||||
name: "jiaban",
|
||||
data () {
|
||||
name: 'jiaban',
|
||||
data() {
|
||||
return {
|
||||
step: 1,
|
||||
loading: false,
|
||||
@@ -56,89 +60,94 @@ export default {
|
||||
phone: '',
|
||||
code: '',
|
||||
password: '',
|
||||
password2: ''
|
||||
password2: '',
|
||||
},
|
||||
rules: {
|
||||
phone: {
|
||||
rules: [
|
||||
{
|
||||
required: true,
|
||||
errorMessage: "请填写手机号"
|
||||
}
|
||||
]
|
||||
errorMessage: '请填写手机号',
|
||||
},
|
||||
],
|
||||
},
|
||||
code: {
|
||||
rules: [
|
||||
{
|
||||
required: true,
|
||||
errorMessage: "请填写验证码"
|
||||
}
|
||||
]
|
||||
errorMessage: '请填写验证码',
|
||||
},
|
||||
],
|
||||
},
|
||||
password: {
|
||||
rules: [
|
||||
{
|
||||
required: true,
|
||||
errorMessage: "请填写新密码"
|
||||
}
|
||||
]
|
||||
errorMessage: '请填写新密码',
|
||||
},
|
||||
],
|
||||
},
|
||||
password2: {
|
||||
rules: [
|
||||
{
|
||||
required: true,
|
||||
errorMessage: "请填写确认密码"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
};
|
||||
},
|
||||
onLoad () {
|
||||
errorMessage: '请填写确认密码',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
}
|
||||
},
|
||||
onLoad() {},
|
||||
methods: {
|
||||
getCode () {
|
||||
getCode() {
|
||||
if (!this.formData.phone) {
|
||||
return this.$util.toast('请输入手机号!')
|
||||
}
|
||||
uni.showLoading({
|
||||
title: '请稍等'
|
||||
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);
|
||||
})
|
||||
.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 () {
|
||||
firstSubmit() {
|
||||
this.$refs.form.validate().then((valid, errors) => {
|
||||
apiRegister({
|
||||
phone: this.formData.phone,
|
||||
code: this.formData.code
|
||||
}).then(res => {
|
||||
console.log(res);
|
||||
code: this.formData.code,
|
||||
}).then((res) => {
|
||||
console.log(res)
|
||||
this.$util.toast(res.msg)
|
||||
uni.setStorageSync('userInfo', res.data)
|
||||
this.step = 2
|
||||
// this.step = 2
|
||||
// 直接登录
|
||||
autoLogin(this.formData.phone).then((res) => {
|
||||
this.loginSuccess(res.data)
|
||||
})
|
||||
})
|
||||
})
|
||||
},
|
||||
secondSubmit () {
|
||||
secondSubmit() {
|
||||
this.$refs.form.validate().then((valid, errors) => {
|
||||
console.log(this.formData.password.length);
|
||||
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) {
|
||||
@@ -147,18 +156,18 @@ export default {
|
||||
apiSetPsd({
|
||||
phone: this.formData.phone,
|
||||
password: this.formData.password,
|
||||
}).then(res => {
|
||||
console.log(res);
|
||||
}).then((res) => {
|
||||
console.log(res)
|
||||
this.$util.toast(res.msg)
|
||||
uni.setStorageSync('userInfo', res.data)
|
||||
uni.reLaunch({
|
||||
url: '/pages/user/login'
|
||||
url: '/pages/user/login',
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
};
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
<style lang="scss">
|
||||
.index {
|
||||
|
||||
Reference in New Issue
Block a user