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

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

100
<style lang="scss">
101 102 103 104 105
	@import url("../common/login-page.css");
	.quickLoginBtn{
		width: 500rpx;
		margin: 100rpx;
	}
DCloud_JSON's avatar
DCloud_JSON 已提交
106
</style>