|
@@ -2,14 +2,14 @@
|
|
|
<mobile-frame>
|
|
|
<view class="main">
|
|
|
<view class="one">
|
|
|
- <uni-forms ref="form" :modelValue="form" :rules="rules" label-width="auto">
|
|
|
+ <uni-forms ref="form" :rules="rules" :model="form" label-width="auto">
|
|
|
<uni-forms-item label="手机号" name="phone">
|
|
|
<uni-easyinput type="number" v-model="form.phone" placeholder="请输入您的手机号" />
|
|
|
</uni-forms-item>
|
|
|
<uni-forms-item label="手机验证码" name="code">
|
|
|
<view class="yzm">
|
|
|
<view class="l">
|
|
|
- <uni-easyinput type="text" v-model="form.code" placeholder="请输入您的手机验证码" />
|
|
|
+ <uni-easyinput type="number" v-model="form.code" placeholder="请输入您的手机验证码" />
|
|
|
</view>
|
|
|
<view class="r">
|
|
|
<button type="default" size="mini" @tap="sendCount">{{time_count==0?'验证码':time_count}}</button>
|
|
@@ -69,13 +69,22 @@
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
- sendCount() {
|
|
|
+ async sendCount() {
|
|
|
const that = this;
|
|
|
let form = that.form;
|
|
|
+ let user = that.user;
|
|
|
if (form && form.phone) {
|
|
|
- let time_count = 60;
|
|
|
- that.$set(that, `time_count`, time_count);
|
|
|
- that.timeDown();
|
|
|
+ let res = await that.$api(`/user/toBindPhone`, 'POST', {
|
|
|
+ id: user._id,
|
|
|
+ phone: form.phone
|
|
|
+ })
|
|
|
+ if (res.errcode == '0') {
|
|
|
+ uni.showToast({
|
|
|
+ title: '发送成功'
|
|
|
+ })
|
|
|
+ that.$set(that, `time_count`, 60);
|
|
|
+ that.timeDown();
|
|
|
+ }
|
|
|
} else {
|
|
|
uni.showToast({
|
|
|
title: '输入错误,请重新输入!',
|
|
@@ -98,12 +107,13 @@
|
|
|
const that = this;
|
|
|
let user = that.user;
|
|
|
that.$refs[ref].validate().then(async params => {
|
|
|
- let code = '1234';
|
|
|
- if (params.code == code) {
|
|
|
- let res = await that.$api(`/user/${user._id}`, 'POST', params);
|
|
|
- if (res.errcode == '0') {
|
|
|
+ params.id = user._id;
|
|
|
+ const res = await that.$api(`/user/checkBindPhone`, 'POST', params);
|
|
|
+ if (res.errcode == '0') {
|
|
|
+ const arr = await that.$api(`/user/${params.id}`, 'POST', params);
|
|
|
+ if (arr.errcode == '0') {
|
|
|
uni.showToast({
|
|
|
- title: '手机号绑定成功',
|
|
|
+ title: '绑定手机号成功',
|
|
|
icon: 'none'
|
|
|
})
|
|
|
uni.navigateBack({
|
|
@@ -111,13 +121,13 @@
|
|
|
})
|
|
|
} else {
|
|
|
uni.showToast({
|
|
|
- title: res.errms,
|
|
|
+ title: arr.errmsg,
|
|
|
icon: 'none'
|
|
|
})
|
|
|
}
|
|
|
} else {
|
|
|
uni.showToast({
|
|
|
- title: '验证码输入错误!',
|
|
|
+ title: res.errmsg,
|
|
|
icon: 'none'
|
|
|
})
|
|
|
}
|