phone-code.vue 1.5 KB
Newer Older
芊里 已提交
1
<template>
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
	<view class="content">
		<!-- 顶部文字 -->
		<text class="tit">请输入验证码</text>
		<text class="tip">{{tipText}}</text>
		<!-- 登录框 (选择手机号所属国家和地区需要另行实现) -->
			<uni-easyinput type="number" class="easyinput" :inputBorder="false"
				v-model="code" maxlength="6" placeholder="请输入验证码">
				<template slot="right">
					<uni-send-sms-code :phone="phone" ref="sendSmsCode"></uni-send-sms-code>
				</template>
			</uni-easyinput>
			<button class="send-btn" :disabled="!canSubmit" :type="canSubmit?'primary':'default'"
				@click="submit">登录</button>
		</uni-forms>
		<uni-quick-login></uni-quick-login>
芊里 已提交
17 18
	</view>
</template>
19
<script>
DCloud_JSON's avatar
DCloud_JSON 已提交
20
	import mixin from '../common/login-page.mixin.js';
21
	export default {
芊里 已提交
22
		mixins:[mixin],
芊里 已提交
23 24
		data() {
			return {
25 26
				code:'',
				phone:''
芊里 已提交
27 28 29 30
			}
		},
		computed: {
			tipText() {
DCloud_JSON's avatar
DCloud_JSON 已提交
31
				return `验证码已通过短信发送至${this.phone}。`;
芊里 已提交
32
			},
33 34
			canSubmit(){
				return this.code.length==6;
芊里 已提交
35 36
			}
		},
L
123  
linju 已提交
37
		onLoad({phoneNumber,phoneArea}) {
DCloud_JSON's avatar
clear  
DCloud_JSON 已提交
38
			this.phone = phoneNumber;
芊里 已提交
39
		},
DCloud_JSON's avatar
DCloud_JSON 已提交
40
		onReady() {
DCloud_JSON's avatar
DCloud_JSON 已提交
41
			this.$refs.sendSmsCode.start();
DCloud_JSON's avatar
DCloud_JSON 已提交
42
		},
43 44
		methods: {
			submit(){ //完成并提交
45 46 47 48 49 50 51 52 53 54 55 56 57 58
				uniCloud.callFunction({
					name:'uni-id-cf',
					data:{
						action:'loginBySms',
						params:{
							"mobile":this.phone,
							"code":this.code
						},
					},
					success: ({result}) => {
						this.loginSuccess(result)
					}
				})
				
芊里 已提交
59 60 61 62
			}
		}
	}
</script>
DCloud_JSON's avatar
DCloud_JSON 已提交
63
<style>
DCloud_JSON's avatar
DCloud_JSON 已提交
64
	@import url("../common/login-page.css");
DCloud_JSON's avatar
DCloud_JSON 已提交
65
</style>