Prechádzať zdrojové kódy

新增修改手机号弹窗

chenxiong 3 rokov pred
rodič
commit
96026f537c

+ 19 - 0
common/httpList/login.js

@@ -61,6 +61,25 @@ export default {
 			noToken: true
 		})
 	},
+	//获取重新绑定手机短信
+	bindNewSms(data) {
+		return myRequest({
+			url: '/app/common/sms/bindNew',
+			method: 'post',
+			data: data,
+			noToken: true
+		})
+	},
+	
+	//重新绑定手机
+	bindNewTel(data) {
+		return myRequest({
+			url: '/app/user/bindNewTel',
+			method: 'post',
+			data: data
+		})
+	},
+
 	//注册用户
 	registerUser(data) {
 		return myRequest({

+ 2 - 2
common/request.js

@@ -5,8 +5,8 @@ import api from './api.js'
 var num = 1
 //接口api   
 // export const BASE_URL = 'https://api.xyyxt.net'   //release
-// export const BASE_URL = 'http://42.192.164.187:19005'  //test
-export const BASE_URL = 'http://192.168.1.222:5055'    //dev
+export const BASE_URL = 'http://42.192.164.187:19005'  //test
+// export const BASE_URL = 'http://192.168.1.222:5055'    //dev
 
  //图片上传api
 // export const BASE_IMG_URL = 'https://file.xyyxt.net/'     //release

+ 0 - 2
pages2/subject/collect.vue

@@ -94,8 +94,6 @@ export default {
 	onPullDownRefresh() {},
 	onLoad(option) {
 		
-		
-		
 		this.listGoodsUserQuestion();
 		this.examaperList();
 		this.getData();

+ 50 - 9
pages2/wd/info.vue

@@ -80,15 +80,15 @@
 			<view class="form">
 				<u-form :model="telForm" ref="telForm">
 					<view class="input-wrap">
-						<u-form-item prop="tel"><u-input ref="tel" placeholder="手机号码" v-model="telForm.tel" /></u-form-item>
+						<u-form-item ref="tel" prop="tel"><u-input placeholder="手机号码" v-model="telForm.tel" /></u-form-item>
 						<u-form-item prop="code">
 							<u-input placeholder="验证码" v-model="telForm.code" />
 							<view  slot="right" @click="getCode" class="getcode">{{codeTips}}</view>
 						</u-form-item>
 					</view>
 					<view class="btns">
-						<view class="cancel" @click="showPhoneModal = false;">取消</view>
-						<view class="submit">确认更换</view>
+						<view class="cancel" @click="showPhoneModal = false">取消</view>
+						<view class="submit" :class="{able:canSubmit()}" @click="bindNewSubmit">确认更换</view>
 					</view>
 				</u-form>
 			</view>
@@ -131,7 +131,7 @@ export default {
 						required: true, 
 						message: '请输入手机号', 
 						// 可以单个或者同时写两个触发验证方式 
-						trigger: ['change','blur'],
+						trigger: ['change']
 					},
 					{
 						validator: (rule, value, callback) => {
@@ -141,7 +141,7 @@ export default {
 						},
 						message: '手机号码格式不正确',
 						// 触发器可以同时用blur和change
-						trigger: ['change','blur'],
+						trigger: ['change'],
 					}
 				],
 				code: [
@@ -161,7 +161,6 @@ export default {
 		console.log(this.form)
 	},
 	onLoad(option) {
-		this.$refs.telForm.setRules(this.rules)
 	},
 	methods: {
 		bindPickerChangeSex(e) {
@@ -341,6 +340,12 @@ export default {
 			this.showPhoneModal = true;
 			this.$refs.telForm.setRules(this.rules)
 		},
+		canSubmit() {
+			if(this.telForm.tel && this.telForm.code) {
+				return true;
+			}
+			return false;
+		},
 		
 		codeChange(text) {
 			this.codeTips = text;
@@ -349,8 +354,8 @@ export default {
 			let that = this
 			if(that.$refs.uCode.canGetCode) {
 				if(that.$refs.tel.validateState == 'success') {
-					let datas = {tel:this.form.tel}
-					that.$api.registerSms(datas).then(
+					let datas = {tel:this.telForm.tel}
+					that.$api.bindNewSms(datas).then(
 						res => {
 							if (res.data.code == 200) {
 								that.$u.toast('验证码已发送');
@@ -365,10 +370,39 @@ export default {
 						}
 					);	
 				} else {
-					console.log(this.$refs.tel)
 					this.$refs.tel.onFieldChange()
 				}
 			}
+		},
+		bindNewSubmit() {
+			let that = this
+			this.$refs.telForm.validate(valid => {
+				if(valid) {
+					let datas = {
+						tel:this.telForm.tel,
+						code:this.telForm.code,
+					}
+					that.$api.bindNewTel(datas).then(
+						res => {
+							if (res.data.code == 200) {
+								uni.showModal({
+									title: '提示',
+									content: '绑定成功',
+									showCancel:false,
+									success: function(resst) {
+										this.showPhoneModal = false;
+									}
+								});
+							} else {
+								that.$u.toast(res.data.msg);
+							}
+						},
+						err => {
+							
+						}
+					);
+				}
+			})
 		}
 	},
 	computed: {...mapGetters(['userInfo'])},
@@ -504,6 +538,7 @@ export default {
 					justify-content: space-between;
 					margin-top:160rpx;
 					.cancel {
+						font-weight: bold;
 						text-align: center;
 						line-height: 80rpx;
 						color:#007AFF;
@@ -515,6 +550,8 @@ export default {
 					}
 					
 					.submit {
+						font-weight: bold;
+						opacity: 0.6;
 						text-align: center;
 						line-height: 80rpx;
 						color:#fff;
@@ -523,6 +560,10 @@ export default {
 						height: 80rpx;
 						background: #007AFF;
 						border-radius: 40rpx 40rpx 40rpx 40rpx;
+						
+						&.able {
+							opacity: 1;
+						}
 					}
 				}
 			}