guhongwei 2 年之前
父節點
當前提交
504ba3014f
共有 2 個文件被更改,包括 24 次插入14 次删除
  1. 1 1
      pagesMy/account/bindEmail.vue
  2. 23 13
      pagesMy/account/bindPhone.vue

+ 1 - 1
pagesMy/account/bindEmail.vue

@@ -9,7 +9,7 @@
 					<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>

+ 23 - 13
pagesMy/account/bindPhone.vue

@@ -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'
 						})
 					}