phone-code.vue 2.3 KB
Newer Older
芊里 已提交
1
<template>
2 3
	<view class="content">
		<!-- 顶部文字 -->
4
		<text class="tit">{{$t('common.verifyCodePlaceholder')}}</text>
DCloud_JSON's avatar
DCloud_JSON 已提交
5
		<text class="tip">{{tipText}}</text>
6
		<uni-forms>
7 8
		<!-- 登录框 (选择手机号所属国家和地区需要另行实现) -->
			<uni-easyinput type="number" class="easyinput" :inputBorder="false"
9
				v-model="code" maxlength="6" :placeholder="$t('common.verifyCodePlaceholder')">
10
				<template v-slot:right>
11 12 13 14
					<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'"
15
				@click="submit">{{$t('common.login')}}</button>
16 17
		</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() {
32
				return this.$t('common.verifyCodeSend')+ `${this.phone}。`;
芊里 已提交
33
			},
34 35
			canSubmit(){
				return this.code.length==6;
DCloud_JSON's avatar
DCloud_JSON 已提交
36
			}
芊里 已提交
37
		},
L
123  
linju 已提交
38
		onLoad({phoneNumber,phoneArea}) {
DCloud_JSON's avatar
clear  
DCloud_JSON 已提交
39
			this.phone = phoneNumber;
芊里 已提交
40
		},
DCloud_JSON's avatar
DCloud_JSON 已提交
41
		onReady() {
DCloud_JSON's avatar
-...  
DCloud_JSON 已提交
42 43 44
			if(this.phone.length==11){
				this.$refs.sendSmsCode.start();
			}
DCloud_JSON's avatar
DCloud_JSON 已提交
45
		},
46
		methods: {
study夏羽's avatar
study夏羽 已提交
47 48 49 50 51 52
			async submit(){ //完成并提交
				return await uniCloud.callFunction({
					name:'uni-id-cf',
					data:{
						action:'loginBySms',
						params:{
53
							"mobile":this.phone,
study夏羽's avatar
study夏羽 已提交
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
							"code":this.code
						},
					}
				}).then(({result})=>{
					if(result.code === 0){
						this.loginSuccess(result)
					}else{
						uni.showModal({
							content: result.msg,
							showCancel: false
						});
					}
					return result
				})
			
DCloud_JSON's avatar
DCloud_JSON 已提交
69 70 71 72 73
				// uniCloud.callFunction({
				// 	name:'uni-id-cf',
				// 	data:{
				// 		action:'loginBySms',
				// 		params:{
study夏羽's avatar
study夏羽 已提交
74
				// 			"mobile":this.phone,
DCloud_JSON's avatar
DCloud_JSON 已提交
75 76 77 78 79 80 81 82 83 84 85 86 87
				// 			"code":this.code
				// 		},
				// 	},
				// 	success: ({result}) => {
				// 		if(result.code === 0){
				// 			this.loginSuccess(result)
				// 		}else{
				// 			uni.showModal({
				// 				content: result.msg,
				// 				showCancel: false
				// 			});
				// 		}
				// 	}
study夏羽's avatar
study夏羽 已提交
88
				// })
芊里 已提交
89 90 91 92
			}
		}
	}
</script>
DCloud_JSON's avatar
DCloud_JSON 已提交
93
<style>
DCloud_JSON's avatar
DCloud_JSON 已提交
94
	@import url("../common/login-page.css");
DCloud_JSON's avatar
DCloud_JSON 已提交
95
</style>