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>
5 6
		<uni-agreements @setAgree="agree = $event"></uni-agreements>
		<!-- 登录框 -->
DCloud_JSON's avatar
DCloud_JSON 已提交
7 8
		<input type="number" class="input-box" :inputBorder="false" v-model="phone" maxlength="11"
			placeholder="请输入手机号" />
9 10
		<button class="get-code" :class="{isPhone}" :disabled="!isPhone" :type="isPhone?'primary':'default'"
			@click="sendShortMsg">获取短信验证码</button>
DCloud_JSON's avatar
DCloud_JSON 已提交
11
		<text class="tip">未注册的手机号验证通过后将自动注册</text>
L
linju 已提交
12
		<!-- 登录按钮弹窗 -->
DCloud_JSON's avatar
DCloud_JSON 已提交
13
		<uni-quick-login :univerifyStyle="univerifyStyle" :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 23 24 25 26 27 28 29
				phone: "",
				agree: false,
				univerifyStyle: {
					"fullScreen": true, // 是否全屏显示,true表示全屏模式,false表示非全屏模式,默认值为false。
					"backgroundColor": "#ffffff", // 授权页面背景颜色,默认值:#ffffff
					"buttons": { // 自定义登陆按钮
						"iconWidth": "45px", // 图标宽度(高度等比例缩放) 默认值:45px
						"list": [{
30
								"iconPath": "/static/uni-quick-login/wechat.png" // 图标路径仅支持本地图片
DCloud_JSON's avatar
DCloud_JSON 已提交
31 32 33 34
							}
						]
					}
				}
L
linju 已提交
35
			}
L
23  
linju 已提交
36
		},
37
		computed: {
DCloud_JSON's avatar
DCloud_JSON 已提交
38
			isPhone() {
39 40 41
				return /^1\d{10}$/.test(this.phone);
			}
		},
42 43 44 45 46 47 48 49 50 51 52 53 54
		onLoad(e) {
			uni.getProvider({
			    service: 'oauth',
			    success:res=>{
			        if (~res.provider.indexOf('apple')) {
						this.univerifyStyle.buttons.list.push({
							"iconPath": "/static/uni-quick-login/apple.png" // 图标路径仅支持本地图片
						})
			        }
			    }
			});
			
			
DCloud_JSON's avatar
DCloud_JSON 已提交
55
			//是否优先启动一键登录。即:页面一加载就启动一键登录
L
23  
linju 已提交
56 57
			univerify_first = e.univerify_first
			//#ifdef APP-PLUS
DCloud_JSON's avatar
DCloud_JSON 已提交
58
			if (univerify_first) {
L
23  
linju 已提交
59 60 61
				const pages = getCurrentPages();
				currentWebview = pages[pages.length - 1].$getAppWebview();
				currentWebview.setStyle({
DCloud_JSON's avatar
DCloud_JSON 已提交
62
					"top": "2000px" //隐藏当前页面窗体
L
23  
linju 已提交
63
				})
L
21  
linju 已提交
64
			}
L
23  
linju 已提交
65 66 67 68
			//#endif
		},
		onReady() {
			//#ifdef APP-PLUS
DCloud_JSON's avatar
DCloud_JSON 已提交
69
			if (univerify_first) {
70 71
				console.log('开始一键登录');
				this.agree = true
DCloud_JSON's avatar
DCloud_JSON 已提交
72
				setTimeout(() => {
73
					this.$refs.uniQuickLogin.login_before('univerify')
DCloud_JSON's avatar
DCloud_JSON 已提交
74
				}, 100)
L
23  
linju 已提交
75 76
				setTimeout(() => {
					currentWebview.setStyle({
DCloud_JSON's avatar
DCloud_JSON 已提交
77 78 79
						titleNView: {
							autoBackButton: true,
							backgroundColor: "#FFFFFF"
L
23  
linju 已提交
80 81 82
						}
					})
					currentWebview.setStyle({
DCloud_JSON's avatar
DCloud_JSON 已提交
83
						"top": "0"
L
23  
linju 已提交
84 85 86 87 88
					})
				}, 1500);
			}
			//#endif
		},
L
linju 已提交
89
		methods: {
90
			sendShortMsg() {
DCloud_JSON's avatar
DCloud_JSON 已提交
91
				if (!this.agree) {
92 93 94 95 96
					return uni.showToast({
						title: '你未同意隐私政策协议',
						icon: 'none'
					});
				}
DCloud_JSON's avatar
DCloud_JSON 已提交
97
				// 发送验证吗
L
123  
linju 已提交
98
				uni.showLoading();
L
123  
linju 已提交
99
				uni.navigateTo({
DCloud_JSON's avatar
DCloud_JSON 已提交
100
					url: '/pages/ucenter/login-page/phone-code/phone-code?phoneNumber=' + this.phone,
101 102
					complete: () => {
						uni.hideLoading();
DCloud_JSON's avatar
DCloud_JSON 已提交
103
					}
L
123  
linju 已提交
104
				});
L
linju 已提交
105
			},
DCloud_JSON's avatar
DCloud_JSON 已提交
106
			//去密码登录页
L
linju 已提交
107 108
			toPwdLogin() {
				uni.navigateTo({
L
23  
linju 已提交
109
					url: '../pwd-login/pwd-login'
L
linju 已提交
110
				})
芊里 已提交
111 112 113 114 115
			}
		}
	}
</script>

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