index.vue 4.3 KB
Newer Older
芊里 已提交
1
<template>
L
12  
linju 已提交
2
	<view class="wrap">
L
213  
linju 已提交
3
		<view class="wrap-content">
芊里 已提交
4
			<view class="content">
L
linju 已提交
5
				<!-- 顶部文字 -->
芊里 已提交
6
				<text class="content-top-title">登陆后即可展示自己</text>
芊里 已提交
7
				<login-ikonw class="login-iknow" :link="link" text="登录即表示同意用户协议和隐私政策"></login-ikonw>
L
linju 已提交
8
				<!-- 登录框 (选择手机号所属国家和地区需要另行实现) -->
芊里 已提交
9 10 11 12
				<uni-forms ref="form" :value="formData" :rules="rules">
					<uni-forms-item name="phone">
						<uni-easyinput type="number" class="phone-input-box" :inputBorder="false"
							v-model="formData.phone" maxlength="11" placeholder="请输入手机号">
芊里 已提交
13 14 15 16 17
							<template slot="left">
								<!-- 当前仅支持中国大陆手机号 -->
								<!-- <picker mode="selector" :range="phoneArea" @change="selectPhoneArea"> -->
									<text class="phone-area" @click="selectPhoneArea">{{currenPhoneArea}}</text>
								<!-- </picker> -->
芊里 已提交
18 19 20 21 22
							</template>
						</uni-easyinput>
					</uni-forms-item>
					<button class="send-btn-box" :disabled="!canGetShortMsg" :type="canGetShortMsg?'primary':'default'"
						@click="sendShortMsg">获取短信验证码</button>
L
123  
linju 已提交
23 24 25
				</uni-forms>

				<!-- tip -->
芊里 已提交
26
				<text class="tip-text">未注册的手机号验证通过后将自动注册</text>
L
linju 已提交
27 28

				<!-- 其他登录方式 -->
芊里 已提交
29 30
				<view class="auth-box">
					<text class="login-text" hover-class="hover" @click="toPwdLogin">密码登录</text>
芊里 已提交
31
					<!-- <text class="login-text" hover-class="hover" @click="openLoginList">其他登录方式</text> -->
L
linju 已提交
32 33
				</view>
			</view>
芊里 已提交
34
		</view>
L
linju 已提交
35
		<!-- 登录按钮弹窗 -->
芊里 已提交
36
		<login-action-sheet ref="loginActionSheet"></login-action-sheet>
L
123  
linju 已提交
37
		<uni-quick-login ref="uniQuickLogin"></uni-quick-login>
芊里 已提交
38 39 40
	</view>
</template>

L
12  
linju 已提交
41
<script>
芊里 已提交
42
	import mixin from '../../common/loginPage.mixin.js';
L
12  
linju 已提交
43
	var currentPage;
芊里 已提交
44 45
	export default {
		mixins:[mixin],
芊里 已提交
46
		data() {
芊里 已提交
47
			return {
L
linju 已提交
48 49
				link: [{
					text: '用户协议',
芊里 已提交
50
					to: '/pages/ucenter/agree-list/service/service'
L
linju 已提交
51 52
				}, {
					text: '隐私政策',
芊里 已提交
53
					to: '/pages/ucenter/agree-list/privacy/privacy'
L
linju 已提交
54
				}],
芊里 已提交
55
				phoneArea: ['+86'],
L
linju 已提交
56
				currenPhoneArea: '+86',
芊里 已提交
57 58

				formData: {
L
123  
linju 已提交
59
					phone: '17777777777'
芊里 已提交
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
				},
				rules: {
					// 对phone字段进行必填验证
					phone: {
						rules: [{
								required: true,
								errorMessage: '请输入手机号',
							},
							{
								pattern: /^1\d{10}$/,
								errorMessage: '手机号格式不正确',
							}
						]
					}
				}
L
linju 已提交
75
			}
芊里 已提交
76
		},
L
12  
linju 已提交
77 78 79 80 81
		onLoad() {
			let pages = getCurrentPages();
			currentPage = pages[pages.length - 1];
			currentPage.$getAppWebview().setStyle({
				top:"1000px"
L
123  
linju 已提交
82
			})
L
12  
linju 已提交
83 84
		},
		onReady() {
L
123  
linju 已提交
85
			this.$refs.uniQuickLogin.login('univerify')
L
12  
linju 已提交
86 87 88 89 90
			setTimeout(() => {
				currentPage.$getAppWebview().setStyle({
					top:"0"
				})
			}, 1500);
芊里 已提交
91 92
		},
		
L
linju 已提交
93 94 95
		computed: {
			canGetShortMsg() {
				let reg = /^1\d{10}$/;
芊里 已提交
96
				return reg.test(this.formData.phone);
芊里 已提交
97 98
			}
		},
L
linju 已提交
99
		methods: {
芊里 已提交
100 101 102 103 104 105 106 107
			// 触发提交表单
			submit() {
				this.$refs.form.submit().then(res => {
					console.log('表单数据信息:', res);
				}).catch(err => {
					console.log('表单错误信息:', err);
				})
			},
芊里 已提交
108 109 110 111 112 113
			selectPhoneArea(event) {
				uni.showToast({
					title: '当前仅支持中国大陆手机号',
					icon: 'none'
				});
				// this.currenPhoneArea = this.phoneArea[event.detail.value];
L
linju 已提交
114 115 116 117 118
			},
			sendShortMsg() {
				if (!this.canGetShortMsg) return;
				/**
				 * 发送验证吗
119
				 */
L
123  
linju 已提交
120
				uni.showLoading();
L
123  
linju 已提交
121 122 123 124 125 126 127
				uni.navigateTo({
					url: './phone-code?phoneNumber=' + this.formData.phone + '&phoneArea=' +
						this.currenPhoneArea,
					success: res => {},
					fail: () => {},
					complete: () => {}
				});
L
linju 已提交
128 129 130
			},
			/**
			 * 去密码登录页
芊里 已提交
131
			 */
L
linju 已提交
132 133 134 135 136 137 138
			toPwdLogin() {
				uni.navigateTo({
					url: './pwd-login'
				})
			},
			openLoginList() {
				this.$refs.loginActionSheet.open();
L
12  
linju 已提交
139 140 141
			},
			back() {
				uni.navigateBack()
芊里 已提交
142 143 144 145 146
			}
		}
	}
</script>

芊里 已提交
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165
<style>
	@import url("../../common/loginPage.css");

	.content-top-title {
		text-align: center;
	}

	.login-iknow {
		justify-content: center;
	}

	.phone-area {
		/* #ifdef APP-NVUE */
		border-right-width: 1rpx;
		border-right-color: #d7d9d8;
		/* #endif */
		/* #ifndef APP-NVUE */
		border-right: 1rpx solid #d7d9d8;
		/* #endif */
芊里 已提交
166
	}
L
12  
linju 已提交
167
</style>