调用登录接口、注册接口、找回密码接口、短信验证码接口、退出登录接口
							parent
							
								
									f9330094a1
								
							
						
					
					
						commit
						4ea5a4223c
					
				|  | @ -72,22 +72,20 @@ const request = (method, url, options) => { | |||
|             } | ||||
|             break; | ||||
|     } | ||||
| 	let params = {}; | ||||
| 	if(options!=undefined) params = options; | ||||
| 	params.token = uni.getStorageSync('token'); | ||||
| 	return new Promise((resolve, reject) => { | ||||
| 		uni.request({ | ||||
| 			url: `${uni.getStorageSync('hostapi')}${url}`, | ||||
| 			method: methods, | ||||
| 			data: options, | ||||
| 			data: params, | ||||
| 			header: headers, | ||||
| 			success: res => { | ||||
| 				console.log(`${url}返的结果===>`,res); | ||||
| 				if (res.statusCode == 200) { | ||||
| 					if (res.data.code == 0) { | ||||
| 						// 接口调用成功
 | ||||
| 						resolve(res.data); | ||||
| 					} else { | ||||
| 						// 接口返回错误信息
 | ||||
| 						checkError(res); | ||||
| 					} | ||||
| 					// 接口调用成功
 | ||||
| 					resolve(res.data); | ||||
| 				} else { | ||||
| 					// 接口返回错误信息
 | ||||
| 					checkError(res); | ||||
|  |  | |||
|  | @ -1,41 +1,46 @@ | |||
| <template> | ||||
| 	<view class="pad-zy30"> | ||||
| 		<view class="fon52 bold mar-sx50">忘记密码?</view> | ||||
| 		<view class="fon28"> | ||||
| 			<view class="forget-title mar-x10">手机号码</view> | ||||
| 			<view class="forget-input-box posir"> | ||||
| 				<input @blur="inputBlurEv(0)" @focus="inputFocusEv(0)" @input="inputFocusEv(0)" class="fon24" type="number" maxlength="11" v-model="forget_phone" placeholder="请输入您的手机号码" placeholder-style="color:#c8c8c8;" /> | ||||
| 				<!-- 清除按钮 --> | ||||
| 				<view class="clear-box" v-show="ifPhone" @tap="clearInput(0)"><view class="clear-close"><span></span><span></span></view></view> | ||||
| 		<status-nav navBarTitle="找回密码" returnColor="#c2c2c2"></status-nav> | ||||
| 		<container-subgroup> | ||||
| 			<view slot="content" style="margin: 0 -30rpx;"> | ||||
| 				<view class="fon52 bold mar-sx50">忘记密码 ?</view> | ||||
| 				<view class="fon28"> | ||||
| 					<view class="forget-title mar-x10">手机号码</view> | ||||
| 					<view class="forget-input-box posir"> | ||||
| 						<input @blur="inputBlurEv(0)" @focus="inputFocusEv(0)" @input="inputFocusEv(0)" class="fon24" type="number" maxlength="11" v-model="forget_phone" placeholder="请输入您的手机号码" placeholder-style="color:#c8c8c8;" /> | ||||
| 						<!-- 清除按钮 --> | ||||
| 						<view class="clear-box" v-show="ifPhone" @tap="clearInput(0)"><view class="clear-close"><span></span><span></span></view></view> | ||||
| 					</view> | ||||
| 					<view class="forget-title mar-x10">手机验证码</view> | ||||
| 					<view class="forget-input-box posir"> | ||||
| 						<input @blur="inputBlurEv(1)" @focus="inputFocusEv(1)" @input="inputFocusEv(1)" class="fon24" type="number" maxlength="6" v-model="forget_code" placeholder="请输入手机验证码" placeholder-style="color:#c8c8c8;" /> | ||||
| 						<view class="forget-obtain-code" @tap="getCode">{{codeText}}</view> | ||||
| 						<!-- 清除按钮 --> | ||||
| 						<view class="clear-box" v-show="ifCode" @tap="clearInput(1)" style="right: 260rpx;"><view class="clear-close"><span></span><span></span></view></view> | ||||
| 					</view> | ||||
| 					<view class="forget-title mar-x10">新密码</view> | ||||
| 					<view class="forget-input-box posir"> | ||||
| 						<input @blur="inputBlurEv(2)" @focus="inputFocusEv(2)" @input="inputFocusEv(2)" class="fon24" type="text" password v-model="forget_password" placeholder="请输入新密码" placeholder-style="color:#c8c8c8;" /> | ||||
| 						<!-- 清除按钮 --> | ||||
| 						<view class="clear-box" v-show="ifPassword" @tap="clearInput(2)"><view class="clear-close"><span></span><span></span></view></view> | ||||
| 					</view> | ||||
| 					<view class="forget-title mar-x10">确认密码</view> | ||||
| 					<view class="forget-input-box posir"> | ||||
| 						<input @blur="inputBlurEv(3)" @focus="inputFocusEv(3)" @input="inputFocusEv(3)" class="fon24" type="text" password v-model="forget_qpassword" placeholder="请再次确认密码" placeholder-style="color:#c8c8c8;" /> | ||||
| 						<!-- 清除按钮 --> | ||||
| 						<view class="clear-box" v-show="ifqpassword" @tap="clearInput(3)"><view class="clear-close"><span></span><span></span></view></view> | ||||
| 					</view> | ||||
| 					<view class="forget-title mar-x10">单位名称</view> | ||||
| 					<view class="forget-input-box posir"> | ||||
| 						<input @blur="inputBlurEv(4)" @focus="inputFocusEv(4)" @input="inputFocusEv(4)" class="fon24" type="text" v-model="forget_unitname" placeholder="请输入单位名称" placeholder-style="color:#c8c8c8;" /> | ||||
| 						<!-- 清除按钮 --> | ||||
| 						<view class="clear-box" v-show="ifUnitname" @tap="clearInput(4)"><view class="clear-close"><span></span><span></span></view></view> | ||||
| 					</view> | ||||
| 				</view> | ||||
| 				<!-- 立即修改 --> | ||||
| 				<view class="forget-btn" @tap="submitEv">立即修改</view> | ||||
| 			</view> | ||||
| 			<view class="forget-title mar-x10">手机验证码</view> | ||||
| 			<view class="forget-input-box posir"> | ||||
| 				<input @blur="inputBlurEv(1)" @focus="inputFocusEv(1)" @input="inputFocusEv(1)" class="fon24" type="number" maxlength="6" v-model="forget_code" placeholder="请输入手机验证码" placeholder-style="color:#c8c8c8;" /> | ||||
| 				<view class="forget-obtain-code" @tap="getCode">{{codeText}}</view> | ||||
| 				<!-- 清除按钮 --> | ||||
| 				<view class="clear-box" v-show="ifCode" @tap="clearInput(1)" style="right: 260rpx;"><view class="clear-close"><span></span><span></span></view></view> | ||||
| 			</view> | ||||
| 			<view class="forget-title mar-x10">新密码</view> | ||||
| 			<view class="forget-input-box posir"> | ||||
| 				<input @blur="inputBlurEv(2)" @focus="inputFocusEv(2)" @input="inputFocusEv(2)" class="fon24" type="text" password v-model="forget_password" placeholder="请输入新密码" placeholder-style="color:#c8c8c8;" /> | ||||
| 				<!-- 清除按钮 --> | ||||
| 				<view class="clear-box" v-show="ifPassword" @tap="clearInput(2)"><view class="clear-close"><span></span><span></span></view></view> | ||||
| 			</view> | ||||
| 			<view class="forget-title mar-x10">确认密码</view> | ||||
| 			<view class="forget-input-box posir"> | ||||
| 				<input @blur="inputBlurEv(3)" @focus="inputFocusEv(3)" @input="inputFocusEv(3)" class="fon24" type="text" password v-model="forget_qpassword" placeholder="请再次确认密码" placeholder-style="color:#c8c8c8;" /> | ||||
| 				<!-- 清除按钮 --> | ||||
| 				<view class="clear-box" v-show="ifqpassword" @tap="clearInput(3)"><view class="clear-close"><span></span><span></span></view></view> | ||||
| 			</view> | ||||
| 			<view class="forget-title mar-x10">单位名称</view> | ||||
| 			<view class="forget-input-box posir"> | ||||
| 				<input @blur="inputBlurEv(4)" @focus="inputFocusEv(4)" @input="inputFocusEv(4)" class="fon24" type="text" v-model="forget_unitname" placeholder="请输入单位名称" placeholder-style="color:#c8c8c8;" /> | ||||
| 				<!-- 清除按钮 --> | ||||
| 				<view class="clear-box" v-show="ifUnitname" @tap="clearInput(4)"><view class="clear-close"><span></span><span></span></view></view> | ||||
| 			</view> | ||||
| 		</view> | ||||
| 		<!-- 立即修改 --> | ||||
| 		<view class="forget-btn" @tap="submitEv">立即修改</view> | ||||
| 		</container-subgroup> | ||||
| 	</view> | ||||
| </template> | ||||
| 
 | ||||
|  | @ -54,7 +59,8 @@ | |||
| 				ifUnitname:false, | ||||
| 				forget_unitname:'', | ||||
| 				codeText:'获取验证码' ,// 获取验证码按钮文字 | ||||
| 				flagCode:true // 允许点击获取验证码 | ||||
| 				flagCode:true ,// 允许点击获取验证码 | ||||
| 				countDown:null//验证码倒计时事件 | ||||
| 			} | ||||
| 		}, | ||||
| 		methods: { | ||||
|  | @ -69,7 +75,12 @@ | |||
| 						affiliation: this.forget_unitname ,//单位名称   | ||||
| 					} | ||||
| 					this.$requst.post('/universal/api.login/password_find',params).then(res=>{ | ||||
| 						this.$toolAll.tools.showToast('找回成功'); | ||||
| 						if(res.code==1) { | ||||
| 							this.$toolAll.tools.showToast('找回成功'); | ||||
| 							setTimeout(()=>{uni.navigateBack({delta:1})},1000) | ||||
| 						} else { | ||||
| 							this.$toolAll.tools.showToast(res.msg); | ||||
| 						} | ||||
| 					}) | ||||
| 				} | ||||
| 			}, | ||||
|  | @ -82,12 +93,12 @@ | |||
| 						this.flagCode = false; | ||||
| 						let count = 60; | ||||
| 						this.codeText = `${count}S重新获取` | ||||
| 						let countDown = setInterval(()=>{ | ||||
| 						this.countDown = setInterval(()=>{ | ||||
| 							count--; | ||||
| 							count < 10 ? this.codeText = `0${count}S重新获取` : this.codeText = `${count}S重新获取`; | ||||
| 							if(count==0) { | ||||
| 								this.codeText = `重新获取`; | ||||
| 								clearInterval(countDown); | ||||
| 								clearInterval(this.countDown); | ||||
| 								this.flagCode = true; | ||||
| 							} | ||||
| 						},1000) | ||||
|  | @ -100,6 +111,10 @@ | |||
| 			getMessage(phone){ | ||||
| 				this.$requst.post('/universal/api.login/send_sms',{phone}).then(res=>{ | ||||
| 					this.$toolAll.tools.showToast(res.msg); | ||||
| 					if(res.code==0) { | ||||
| 						clearInterval(this.countDown); | ||||
| 						this.codeText = `获取验证码` | ||||
| 					} | ||||
| 				}) | ||||
| 			}, | ||||
| 			// 检测是否某个输入框为空 | ||||
|  | @ -202,5 +217,5 @@ | |||
| </script> | ||||
| 
 | ||||
| <style> | ||||
| 
 | ||||
| page{background-color: #FFFFFF;} | ||||
| </style> | ||||
|  |  | |||
|  | @ -82,22 +82,32 @@ | |||
| 		methods: { | ||||
| 			// 提交事件 | ||||
| 			submitEv(){ | ||||
| 				// if(this.checkEmpty()){ | ||||
| 				// 	let params = { | ||||
| 				// 		login_type: this.login_type, // 登陆手机类型: mobile:手机登陆、account:账号密码登陆   | ||||
| 				// 		phone: this.login_type == 'mobile' ? this.login_phone : '', // 手机号码,login_type 为 mobile 时必填   | ||||
| 				// 		password: this.login_password, // 密码,login_type 为 account 时必填   | ||||
| 				// 		sms_code: this.login_code, // 短信验证码,login_type 为 mobile 时必填   | ||||
| 				// 		username: this.login_type == 'account' ? this.login_phone : '', //账号,login_type 为 account 时必填   | ||||
| 				// 		affiliation: this.login_unitName // 单位名称   | ||||
| 				// 	} | ||||
| 				// 	this.$requst.post('/universal/api.login/login',params).then(res=>{ | ||||
| 				// 		this.$toolAll.tools.showToast('登录成功'); | ||||
| 				// 	}) | ||||
| 				// } | ||||
| 				uni.reLaunch({ | ||||
| 					url:'/pages/tabbar/pagehome/pagehome' | ||||
| 				}) | ||||
| 				if(this.checkEmpty()){ | ||||
| 					let params = { | ||||
| 						login_type: this.login_type, // 登陆手机类型: mobile:手机登陆、account:账号密码登陆   | ||||
| 						phone: this.login_type == 'mobile' ? this.login_phone : '', // 手机号码,login_type 为 mobile 时必填   | ||||
| 						password: this.login_password, // 密码,login_type 为 account 时必填   | ||||
| 						sms_code: this.login_code, // 短信验证码,login_type 为 mobile 时必填   | ||||
| 						username: this.login_type == 'account' ? this.login_phone : '', //账号,login_type 为 account 时必填   | ||||
| 						affiliation: this.login_unitName // 单位名称   | ||||
| 					} | ||||
| 					this.$requst.post('/universal/api.login/login',params).then(res=>{ | ||||
| 						console.log(res,95); | ||||
| 						if(res.code==1) { | ||||
| 							this.$toolAll.tools.showToast('登录成功'); | ||||
| 							// 缓存token和角色类型 | ||||
| 							uni.setStorageSync('token',res.data.token); | ||||
| 							uni.setStorageSync('type_id',res.data.type_id); | ||||
| 							setTimeout(()=>{ | ||||
| 								uni.reLaunch({ | ||||
| 									url:'/pages/tabbar/pagehome/pagehome' | ||||
| 								}) | ||||
| 							},2000) | ||||
| 						} else { | ||||
| 							this.$toolAll.tools.showToast(res.msg); | ||||
| 						} | ||||
| 					}) | ||||
| 				} | ||||
| 			}, | ||||
| 			// 获取验证码 | ||||
| 			getCode(){ | ||||
|  | @ -126,7 +136,7 @@ | |||
| 			getMessage(phone){ | ||||
| 				this.$requst.post('/universal/api.login/send_sms',{phone}).then(res=>{ | ||||
| 					this.$toolAll.tools.showToast(res.msg); | ||||
| 					if(res.data.length==0) { | ||||
| 					if(res.code==0) { | ||||
| 						this.codeText = '获取验证码'; | ||||
| 						clearInterval(this.countDown); | ||||
| 					} | ||||
|  |  | |||
|  | @ -93,7 +93,8 @@ | |||
| 				register_unitName:'', // 注册时的单位名称 | ||||
| 				ifAgreen:false ,// 注册时是否勾选协议与政策 | ||||
| 				codeText:'获取验证码' ,// 获取验证码按钮文字 | ||||
| 				flagCode:true // 允许点击获取验证码 | ||||
| 				flagCode:true ,// 允许点击获取验证码 | ||||
| 				countDown:null//验证码倒计时事件 | ||||
| 			} | ||||
| 		}, | ||||
| 		methods: { | ||||
|  | @ -108,9 +109,15 @@ | |||
| 						affiliation: this.register_unitName //单位名称   | ||||
| 					} | ||||
| 					this.$requst.post('/universal/api.login/register',params).then(res=>{ | ||||
| 						this.$toolAll.tools.showToast('注册成功'); | ||||
| 						// 调用前往登录页 | ||||
| 						this.goLogin(); | ||||
| 						if(res.code==1) { | ||||
| 							this.$toolAll.tools.showToast('注册成功'); | ||||
| 							setTimeout(()=>{ | ||||
| 								// 调用前往登录页 | ||||
| 								this.goLogin(); | ||||
| 							},1000) | ||||
| 						} else { | ||||
| 							this.$toolAll.tools.showToast(res.msg); | ||||
| 						} | ||||
| 					}) | ||||
| 				} | ||||
| 			}, | ||||
|  | @ -123,12 +130,12 @@ | |||
| 						this.flagCode = false; | ||||
| 						let count = 60; | ||||
| 						this.codeText = `${count}S重新获取` | ||||
| 						let countDown = setInterval(()=>{ | ||||
| 						this.countDown = setInterval(()=>{ | ||||
| 							count--; | ||||
| 							count < 10 ? this.codeText = `0${count}S重新获取` : this.codeText = `${count}S重新获取`; | ||||
| 							if(count==0) { | ||||
| 								this.codeText = `重新获取`; | ||||
| 								clearInterval(countDown); | ||||
| 								clearInterval(this.countDown); | ||||
| 								this.flagCode = true; | ||||
| 							} | ||||
| 						},1000) | ||||
|  | @ -141,6 +148,11 @@ | |||
| 			getMessage(phone){ | ||||
| 				this.$requst.post('/universal/api.login/send_sms',{phone}).then(res=>{ | ||||
| 					this.$toolAll.tools.showToast(res.msg); | ||||
| 					if(res.code==0) { | ||||
| 						clearInterval(this.countDown); | ||||
| 						this.codeText = `获取验证码` | ||||
| 						this.flagCode = true; | ||||
| 					} | ||||
| 				}) | ||||
| 			}, | ||||
| 			// 检测是否某个输入框为空 | ||||
|  |  | |||
|  | @ -45,7 +45,7 @@ | |||
| 					</view> | ||||
| 				</view> | ||||
| 				<!-- 退出登录 --> | ||||
| 				<view class="my-exit-btn">退出登录</view> | ||||
| 				<view class="my-exit-btn" @tap="logOutEv">退出登录</view> | ||||
| 			</view> | ||||
| 		</view> | ||||
| 		<!-- 底部tab --> | ||||
|  | @ -103,6 +103,21 @@ | |||
| 			this.$toolAll.tools.disableShareEv(); | ||||
| 		}, | ||||
| 		methods: { | ||||
| 			// 退出登录 | ||||
| 			logOutEv(){ | ||||
| 				this.$requst.post('/universal/api.login/signout').then(res=>{ | ||||
| 					if(res.code==1) { | ||||
| 						this.$toolAll.tools.showToast('退出成功'); | ||||
| 						// 清除所有缓存 | ||||
| 						uni.clearStorageSync(); | ||||
| 						setTimeout(()=>{ | ||||
| 							uni.reLaunch({ | ||||
| 								url:'/pages/login/login' | ||||
| 							}) | ||||
| 						},1000) | ||||
| 					} | ||||
| 				}) | ||||
| 			}, | ||||
| 			checkInfo(){ | ||||
| 				this.$requst.post('/api/user/info').then(res=>{ | ||||
| 					// console.log('用户信息:',res); | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue