index.vue 3.2 KB
Newer Older
芊里 已提交
1
<template>
DCloud_JSON's avatar
DCloud_JSON 已提交
2
	<view class="content">
3
		<!-- 顶部文字 -->
DCloud_JSON's avatar
DCloud_JSON 已提交
4
		<text class="title">登录后即可展示自己</text>
DCloud_JSON's avatar
DCloud_JSON 已提交
5 6 7 8 9 10 11 12 13 14 15 16
		<!-- 登录框 -->
		<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"
				placeholder="请输入手机号" />
			<uni-agreements @setAgree="agree = $event"></uni-agreements>
			<button class="get-code" :disabled="!isPhone" :type="isPhone?'primary':'default'"
				@click="sendShortMsg">获取短信验证码</button>
			<text class="tip">未注册的手机号验证通过后将自动注册</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
			}
L
23  
linju 已提交
57 58 59 60
			//#endif
		},
		onReady() {
			//#ifdef APP-PLUS
DCloud_JSON's avatar
DCloud_JSON 已提交
61
			if (this.type == "univerify") {
62
				this.type == this.loginConfig[1]
63
				// console.log('开始一键登录');
DCloud_JSON's avatar
DCloud_JSON 已提交
64
				setTimeout(() => {
65
					this.$refs.uniQuickLogin.login_before('univerify')
DCloud_JSON's avatar
DCloud_JSON 已提交
66
				}, 100)
L
23  
linju 已提交
67 68
				setTimeout(() => {
					currentWebview.setStyle({
DCloud_JSON's avatar
DCloud_JSON 已提交
69 70 71
						titleNView: {
							autoBackButton: true,
							backgroundColor: "#FFFFFF"
L
23  
linju 已提交
72 73 74
						}
					})
					currentWebview.setStyle({
DCloud_JSON's avatar
DCloud_JSON 已提交
75
						"top": "0"
L
23  
linju 已提交
76 77 78 79 80
					})
				}, 1500);
			}
			//#endif
		},
DCloud_JSON's avatar
DCloud_JSON 已提交
81 82 83
		methods: {
			quickLogin() {
				this.$refs.uniQuickLogin.login_before(this.type)
84
			},
85
			sendShortMsg() {
DCloud_JSON's avatar
DCloud_JSON 已提交
86
				if (!this.agree) {
87 88 89 90 91
					return uni.showToast({
						title: '你未同意隐私政策协议',
						icon: 'none'
					});
				}
DCloud_JSON's avatar
DCloud_JSON 已提交
92
				// 发送验证吗
L
123  
linju 已提交
93
				uni.showLoading();
L
123  
linju 已提交
94
				uni.navigateTo({
DCloud_JSON's avatar
DCloud_JSON 已提交
95
					url: '/pages/ucenter/login-page/phone-code/phone-code?phoneNumber=' + this.phone,
96 97
					complete: () => {
						uni.hideLoading();
DCloud_JSON's avatar
DCloud_JSON 已提交
98
					}
L
123  
linju 已提交
99
				});
L
linju 已提交
100
			},
DCloud_JSON's avatar
DCloud_JSON 已提交
101
			//去密码登录页
L
linju 已提交
102 103
			toPwdLogin() {
				uni.navigateTo({
L
23  
linju 已提交
104
					url: '../pwd-login/pwd-login'
L
linju 已提交
105
				})
芊里 已提交
106 107 108 109 110
			}
		}
	}
</script>

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

DCloud_JSON's avatar
DCloud_JSON 已提交
122 123 124 125 126 127 128 129 130 131
	.quickLogin {
		width: 650rpx;
		height: 350px;
		align-items: center;
		justify-content: center;
	}

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