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