index.vue 2.4 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>
5
		<!-- 登录框 -->
DCloud_JSON's avatar
DCloud_JSON 已提交
6
		<input type="number" class="input-box" :inputBorder="false" v-model="phone" maxlength="11"
7 8 9
			placeholder="请输入手机号" />
		<uni-agreements @setAgree="agree = $event"></uni-agreements>
		<button class="get-code" :disabled="!isPhone" :type="isPhone?'primary':'default'"
10
			@click="sendShortMsg">获取短信验证码</button>
DCloud_JSON's avatar
DCloud_JSON 已提交
11
		<text class="tip">未注册的手机号验证通过后将自动注册</text>
L
linju 已提交
12
		<!-- 登录按钮弹窗 -->
13
		<uni-quick-login :agree="agree" ref="uniQuickLogin"></uni-quick-login>
芊里 已提交
14 15 16
	</view>
</template>

17
<script>
DCloud_JSON's avatar
DCloud_JSON 已提交
18
	var univerify_first, currentWebview; //是否一键登录优先
L
123  
linju 已提交
19
	export default {
芊里 已提交
20
		data() {
21
			return {
DCloud_JSON's avatar
DCloud_JSON 已提交
22
				phone: "",
23
				agree: false
L
linju 已提交
24
			}
L
23  
linju 已提交
25
		},
26
		computed: {
DCloud_JSON's avatar
DCloud_JSON 已提交
27
			isPhone() {
28 29 30
				return /^1\d{10}$/.test(this.phone);
			}
		},
31
		onLoad(e) {
DCloud_JSON's avatar
DCloud_JSON 已提交
32
			//是否优先启动一键登录。即:页面一加载就启动一键登录
L
23  
linju 已提交
33 34
			univerify_first = e.univerify_first
			//#ifdef APP-PLUS
DCloud_JSON's avatar
DCloud_JSON 已提交
35
			if (univerify_first) {
L
23  
linju 已提交
36 37 38
				const pages = getCurrentPages();
				currentWebview = pages[pages.length - 1].$getAppWebview();
				currentWebview.setStyle({
DCloud_JSON's avatar
DCloud_JSON 已提交
39
					"top": "2000px" //隐藏当前页面窗体
L
23  
linju 已提交
40
				})
L
21  
linju 已提交
41
			}
L
23  
linju 已提交
42 43 44 45
			//#endif
		},
		onReady() {
			//#ifdef APP-PLUS
DCloud_JSON's avatar
DCloud_JSON 已提交
46
			if (univerify_first) {
47
				// console.log('开始一键登录');
DCloud_JSON's avatar
DCloud_JSON 已提交
48
				setTimeout(() => {
49
					this.$refs.uniQuickLogin.login_before('univerify')
DCloud_JSON's avatar
DCloud_JSON 已提交
50
				}, 100)
L
23  
linju 已提交
51 52
				setTimeout(() => {
					currentWebview.setStyle({
DCloud_JSON's avatar
DCloud_JSON 已提交
53 54 55
						titleNView: {
							autoBackButton: true,
							backgroundColor: "#FFFFFF"
L
23  
linju 已提交
56 57 58
						}
					})
					currentWebview.setStyle({
DCloud_JSON's avatar
DCloud_JSON 已提交
59
						"top": "0"
L
23  
linju 已提交
60 61 62 63 64
					})
				}, 1500);
			}
			//#endif
		},
L
linju 已提交
65
		methods: {
66
			sendShortMsg() {
DCloud_JSON's avatar
DCloud_JSON 已提交
67
				if (!this.agree) {
68 69 70 71 72
					return uni.showToast({
						title: '你未同意隐私政策协议',
						icon: 'none'
					});
				}
DCloud_JSON's avatar
DCloud_JSON 已提交
73
				// 发送验证吗
L
123  
linju 已提交
74
				uni.showLoading();
L
123  
linju 已提交
75
				uni.navigateTo({
DCloud_JSON's avatar
DCloud_JSON 已提交
76
					url: '/pages/ucenter/login-page/phone-code/phone-code?phoneNumber=' + this.phone,
77 78
					complete: () => {
						uni.hideLoading();
DCloud_JSON's avatar
DCloud_JSON 已提交
79
					}
L
123  
linju 已提交
80
				});
L
linju 已提交
81
			},
DCloud_JSON's avatar
DCloud_JSON 已提交
82
			//去密码登录页
L
linju 已提交
83 84
			toPwdLogin() {
				uni.navigateTo({
L
23  
linju 已提交
85
					url: '../pwd-login/pwd-login'
L
linju 已提交
86
				})
芊里 已提交
87 88 89 90 91
			}
		}
	}
</script>

92
<style lang="scss">
DCloud_JSON's avatar
DCloud_JSON 已提交
93
	@import url("../common/login-page.css");
DCloud_JSON's avatar
DCloud_JSON 已提交
94
</style>