pwd-login.vue 2.3 KB
Newer Older
DCloud_JSON's avatar
DCloud_JSON 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14
<template>
	<view class="content">
		<!-- 顶部文字 -->
		<text class="title">用户名密码登录</text>
		<uni-agreements></uni-agreements>
		<input type="number" class="input-box" :inputBorder="false" v-model="username" maxlength="11" placeholder="请输入手机号/用户名"></input>
		<input type="password" class="input-box" :inputBorder="false" v-model="password" placeholder="请输入密码"></input>
		<button class="send-btn" :disabled="!canLogin" :type="canLogin?'primary':'default'" @click="pwdLogin">登录</button>
		<!-- 忘记密码 -->
		<view class="auth-box">
			<text class="link" @click="toRetrievePwd">忘记密码</text>
			<text class="link" @click="toRegister">注册账号</text>
		</view>
		<uni-quick-login ref="uniQuickLogin"></uni-quick-login>
芊里 已提交
15 16 17
	</view>
</template>

L
123  
linju 已提交
18
<script>
DCloud_JSON's avatar
DCloud_JSON 已提交
19
	import mixin from '../common/login-page.mixin.js';
L
123  
linju 已提交
20
	export default {
芊里 已提交
21
		mixins:[mixin],
芊里 已提交
22
		data() {
DCloud_JSON's avatar
DCloud_JSON 已提交
23 24 25
			return {
				"password":"",
				"username":""
芊里 已提交
26 27 28 29
			}
		},
		computed: {
			canLogin() {
DCloud_JSON's avatar
DCloud_JSON 已提交
30 31 32 33 34 35 36 37
				return  this.username.length && this.isPwd;
			},
			isPwd(){
				return /^.{6,20}$/.test(this.password);
			},
			isPhone(){
				return /^1\d{10}$/.test(this.phone);
			},
芊里 已提交
38 39
		},
		methods: {
DCloud_JSON's avatar
DCloud_JSON 已提交
40
			// 页面跳转,找回密码
芊里 已提交
41 42
			toRetrievePwd() {
				uni.navigateTo({
DCloud_JSON's avatar
DCloud_JSON 已提交
43
					url: '../pwd-retrieve/pwd-retrieve?phoneNumber=' + (this.isPhone?this.username:'') + '&phoneArea=' + this.currenPhoneArea
芊里 已提交
44 45 46 47 48 49
				})
			},
			/**
			 * 密码登录
			 */
			pwdLogin() {
DCloud_JSON's avatar
DCloud_JSON 已提交
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
				// 下边是可以登录
				this.request('user-center/login',
					{
						"username":this.username,
						"password":this.password
					},result=>{
						console.log(result);
						if(result.code === 0){
							this.loginSuccess(result)
						}else{
							uni.showModal({
								title: '错误',
								content: result.msg,
								showCancel: false,
								confirmText: '知道了'
							});
						}
					}
				)
69 70 71 72 73
			},
			/* 前往注册 */
			toRegister(e){
				console.log(e);
				uni.navigateTo({
74
					url:'/pages/ucenter/login-page/register/register'
75
				})
76
			}
芊里 已提交
77 78 79 80 81
		}
	}
</script>

<style>
DCloud_JSON's avatar
DCloud_JSON 已提交
82 83 84
	@import url("../common/login-page.css");
	.auth-box {
		flex-direction: row;
DCloud_JSON's avatar
DCloud_JSON 已提交
85
		justify-content: space-between;
DCloud_JSON's avatar
DCloud_JSON 已提交
86 87 88 89 90
		margin-top: 20px;
	}
	.auth-box .link{
		font-size: 26rpx;
	}
芊里 已提交
91 92
	.login-text-sub {
		color: #8a8f8b;
93 94 95 96
	}
	.toRegister{
		margin-top: 80px;
		width: 600rpx;
芊里 已提交
97
	}
L
123  
linju 已提交
98
</style>