index.vue 3.3 KB
Newer Older
芊里 已提交
1
<template>
DCloud_JSON's avatar
DCloud_JSON 已提交
2
	<view class="content">
3
		<!-- 顶部文字 -->
4
		<text class="title">{{$t('login.phoneLogin')}}</text>
DCloud_JSON's avatar
DCloud_JSON 已提交
5 6 7 8 9 10 11
		<!-- 登录框 -->
		<view v-if="['apple','weixin'].includes(type)" class="quickLogin">
			<image @click="quickLogin" :src="imgSrc" mode="widthFix" class="quickLoginBtn"></image>
			<uni-agreements @setAgree="agree = $event"></uni-agreements>
		</view>
		<template v-else>
			<input type="number" class="input-box" :inputBorder="false" v-model="phone" maxlength="11"
12
				:placeholder="$t('common.phonePlaceholder')" />
DCloud_JSON's avatar
DCloud_JSON 已提交
13 14
			<uni-agreements @setAgree="agree = $event"></uni-agreements>
			<button class="get-code" :disabled="!isPhone" :type="isPhone?'primary':'default'"
15 16
				@click="sendShortMsg">{{$t('login.getVerifyCode')}}</button>
			<text class="tip">{{$t('login.phoneLoginTip')}}</text>
17
		</template>
DCloud_JSON's avatar
DCloud_JSON 已提交
18

19
		<!-- 快捷登录按钮弹窗 -->
20
		<uni-quick-login :agree="agree" ref="uniQuickLogin"></uni-quick-login>
芊里 已提交
21 22 23
	</view>
</template>

24
<script>
25
	let currentWebview; //是否一键登录优先
L
123  
linju 已提交
26
	export default {
芊里 已提交
27
		data() {
DCloud_JSON's avatar
DCloud_JSON 已提交
28 29
			return {
				type: "",
DCloud_JSON's avatar
DCloud_JSON 已提交
30
				phone: "",
31
				agree: false
L
linju 已提交
32
			}
L
23  
linju 已提交
33
		},
DCloud_JSON's avatar
DCloud_JSON 已提交
34 35 36
		computed: {
			loginConfig() {
				return getApp().globalData.config.router.login
37
			},
DCloud_JSON's avatar
DCloud_JSON 已提交
38
			isPhone() {
39
				return /^1\d{10}$/.test(this.phone);
DCloud_JSON's avatar
DCloud_JSON 已提交
40 41 42
			},
			imgSrc() {
				return '/static/login-index/' + this.type + '.png'
43
			}
44
		},
DCloud_JSON's avatar
DCloud_JSON 已提交
45 46 47
		onLoad(e) {
			this.type = e.type

DCloud_JSON's avatar
DCloud_JSON 已提交
48
			//是否优先启动一键登录。即:页面一加载就启动一键登录
L
23  
linju 已提交
49
			//#ifdef APP-PLUS
50
			if (this.type == "univerify") {
L
23  
linju 已提交
51 52 53
				const pages = getCurrentPages();
				currentWebview = pages[pages.length - 1].$getAppWebview();
				currentWebview.setStyle({
DCloud_JSON's avatar
DCloud_JSON 已提交
54
					"top": "2000px" //隐藏当前页面窗体
L
23  
linju 已提交
55
				})
L
21  
linju 已提交
56
			}
57 58 59 60 61 62 63
			//#endif
			uni.$on('setLoginType',type=>{
				this.type = type
			})
		},
		onUnload() {
			uni.$off('setLoginType')
L
23  
linju 已提交
64 65 66
		},
		onReady() {
			//#ifdef APP-PLUS
DCloud_JSON's avatar
DCloud_JSON 已提交
67
			if (this.type == "univerify") {
68
				this.type == this.loginConfig[1]
69
				// console.log('开始一键登录');
DCloud_JSON's avatar
DCloud_JSON 已提交
70
				setTimeout(() => {
71
					this.$refs.uniQuickLogin.login_before('univerify')
DCloud_JSON's avatar
DCloud_JSON 已提交
72
				}, 100)
L
23  
linju 已提交
73 74
				setTimeout(() => {
					currentWebview.setStyle({
DCloud_JSON's avatar
DCloud_JSON 已提交
75 76 77
						titleNView: {
							autoBackButton: true,
							backgroundColor: "#FFFFFF"
L
23  
linju 已提交
78 79 80
						}
					})
					currentWebview.setStyle({
DCloud_JSON's avatar
DCloud_JSON 已提交
81
						"top": "0"
L
23  
linju 已提交
82 83 84 85 86
					})
				}, 1500);
			}
			//#endif
		},
DCloud_JSON's avatar
DCloud_JSON 已提交
87 88 89
		methods: {
			quickLogin() {
				this.$refs.uniQuickLogin.login_before(this.type)
90
			},
91
			sendShortMsg() {
DCloud_JSON's avatar
DCloud_JSON 已提交
92
				if (!this.agree) {
93
					return uni.showToast({
94
						title: this.$t('common').noAgree,
95 96 97
						icon: 'none'
					});
				}
DCloud_JSON's avatar
DCloud_JSON 已提交
98
				// 发送验证吗
L
123  
linju 已提交
99
				uni.showLoading();
L
123  
linju 已提交
100
				uni.navigateTo({
DCloud_JSON's avatar
DCloud_JSON 已提交
101
					url: '/pages/ucenter/login-page/phone-code/phone-code?phoneNumber=' + this.phone,
102 103
					complete: () => {
						uni.hideLoading();
DCloud_JSON's avatar
DCloud_JSON 已提交
104
					}
L
123  
linju 已提交
105
				});
L
linju 已提交
106
			},
DCloud_JSON's avatar
DCloud_JSON 已提交
107
			//去密码登录页
L
linju 已提交
108 109
			toPwdLogin() {
				uni.navigateTo({
L
23  
linju 已提交
110
					url: '../pwd-login/pwd-login'
L
linju 已提交
111
				})
芊里 已提交
112 113 114 115 116
			}
		}
	}
</script>

DCloud_JSON's avatar
DCloud_JSON 已提交
117
<style lang="scss" scoped>
118
	/* #ifndef APP-NVUE */
119 120 121 122 123 124 125
	view {
		display: flex;
		box-sizing: border-box;
		flex-direction: column;
	}
	/* #endif */
	
DCloud_JSON's avatar
DCloud_JSON 已提交
126
	@import url("../common/login-page.css");
127

DCloud_JSON's avatar
DCloud_JSON 已提交
128 129 130 131 132 133 134 135 136 137
	.quickLogin {
		width: 650rpx;
		height: 350px;
		align-items: center;
		justify-content: center;
	}

	.quickLoginBtn {
		margin: 20px 0;
		width: 450rpx;
138
	}
139
</style>