渣渣宝 4 yıl önce
ebeveyn
işleme
45c4a850a0
2 değiştirilmiş dosya ile 44 ekleme ve 72 silme
  1. 41 63
      pages/login/login.vue
  2. 3 9
      pages/login/reg.vue

+ 41 - 63
pages/login/login.vue

@@ -210,7 +210,6 @@
 
 
 			//点击登录(验证码/密码)
 			//点击登录(验证码/密码)
 			startReg: async function() {
 			startReg: async function() {
-				//注册
 				if (this.isRotate) {
 				if (this.isRotate) {
 					//判断是否加载中,避免重复点击请求
 					//判断是否加载中,避免重复点击请求
 					return false;
 					return false;
@@ -239,7 +238,7 @@
 						'password': this.password
 						'password': this.password
 					});
 					});
 					if (res.status == 0) {
 					if (res.status == 0) {
-						
+
 						store.commit('setJwt', res.data.token);
 						store.commit('setJwt', res.data.token);
 						store.commit('setUser', res.data);
 						store.commit('setUser', res.data);
 						store.commit('login');
 						store.commit('login');
@@ -279,83 +278,62 @@
 						});
 						});
 						return false;
 						return false;
 					}
 					}
-
-
-
-
 				} else {
 				} else {
-					if (this.verCode.length != 4) {
+					if (this.verCode.length == 0) {
 						uni.showToast({
 						uni.showToast({
 							icon: 'none',
 							icon: 'none',
 							position: 'bottom',
 							position: 'bottom',
-							title: '验证码不正确'
+							title: '请输入验证码'
 						});
 						});
 						return false;
 						return false;
 					}
 					}
-					let code = uni.getStorageSync('verfiyCode')
+					// 发送登陆
+					let res = await this.$request.post('common/phoneLogin', {
+						'phone': this.phoneData,
+						'verify': this.verCode
+					});
 
 
-					if (code == null || code == '') {
+					if (res.status == 0) {
 						uni.showToast({
 						uni.showToast({
 							icon: 'none',
 							icon: 'none',
 							position: 'bottom',
 							position: 'bottom',
-							title: '验证码错误'
+							title: '登陆成功'
 						});
 						});
+						uni.removeStorage('verfiyCode')
+						store.commit('setJwt', res.data.token);
+						store.commit('setUser', res.data);
+						store.commit('login');
+
+						getApp().globalData.imService = new IMService();
+						let loginResult = getApp().globalData.imService.login({
+							uuid: res.data.data.flag,
+							name: res.data.data.name,
+							avatar: res.data.data.avatar
+						});
+						if (loginResult) {
+							//连接IM
+							getApp().globalData.imService.connectIM();
+						}
+						// 写一个跳转到首页
+						setTimeout(function() {
+							uni.navigateBack({
+								delta: 1
+							})
+							uni.switchTab({
+								url: "../index/index"
+							})
+						}, 2000)
 						return false;
 						return false;
 					} else {
 					} else {
-						if (this.verCode == code) {
-							// 发送登陆
-							let res = await this.$request.post('common/phoneLogin', {
-								'phone': this.phoneData
-							});
+						uni.showToast({
+							icon: 'none',
+							position: 'bottom',
+							title: res.message
+						});
+						return false;
+					}
 
 
-							if (res.status == 0) {
-								uni.showToast({
-									icon: 'none',
-									position: 'bottom',
-									title: '登陆成功'
-								});
-								uni.removeStorage('verfiyCode')
-								store.commit('setJwt', res.data.token);
-								store.commit('setUser', res.data);
-								store.commit('login');
 
 
-								getApp().globalData.imService = new IMService();
-								let loginResult = getApp().globalData.imService.login({
-									uuid: res.data.data.flag,
-									name: res.data.data.name,
-									avatar: res.data.data.avatar
-								});
-								if (loginResult) {
-									//连接IM
-									getApp().globalData.imService.connectIM();
-								}
-								// 写一个跳转到首页
-								setTimeout(function() {
-								uni.navigateBack({
-									delta: 1
-								})
-								uni.switchTab({
-									url: "../index/index"
-								})
-								}, 2000)
-								return false;
-							} else {
-								uni.showToast({
-									icon: 'none',
-									position: 'bottom',
-									title: res.message
-								});
-								return false;
-							}
-						} else {
-							uni.showToast({
-								icon: 'none',
-								position: 'bottom',
-								title: '验证码错误'
-							});
-							return false;
-						}
-					}
 				}
 				}
 
 
 
 

+ 3 - 9
pages/login/reg.vue

@@ -175,14 +175,7 @@
 					});
 					});
 					return false;
 					return false;
 				}
 				}
-				if (this.verCode != this.sourceVerCode) {
-					uni.showToast({
-						icon: 'none',
-						position: 'bottom',
-						title: '验证码不正确'
-					});
-					return false;
-				}
+				
 				if (this.password.length < 6) {
 				if (this.password.length < 6) {
 					uni.showToast({
 					uni.showToast({
 						icon: 'none',
 						icon: 'none',
@@ -204,7 +197,8 @@
 
 
 				let res = await this.$request.post('common/phoneRegister', {
 				let res = await this.$request.post('common/phoneRegister', {
 					'phone': this.phoneData,
 					'phone': this.phoneData,
-					'password': this.password
+					'password': this.password,
+					'verify': this.verCode
 				});
 				});
 				if (res.status == 0) {
 				if (res.status == 0) {
 					uni.showToast({
 					uni.showToast({