phone-code.vue 2.2 KB
Newer Older
芊里 已提交
1
<template>
2 3
	<view class="content">
		<!-- 顶部文字 -->
4
		<text class="tit">{{$t('common.verifyCodePlaceholder')}}</text>
5 6
		<text class="tip">{{tipText}}</text>
		<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;
36
			}
芊里 已提交
37
		},
L
123  
linju 已提交
38
		onLoad({phoneNumber,phoneArea}) {
DCloud_JSON's avatar
clear  
DCloud_JSON 已提交
39
			this.phone = phoneNumber;
芊里 已提交
40
		},
41
		onReady() {
42
			// this.$refs.sendSmsCode.start();
DCloud_JSON's avatar
DCloud_JSON 已提交
43
		},
44
		methods: {
study夏羽's avatar
study夏羽 已提交
45 46 47 48 49 50
			async submit(){ //完成并提交
				return await uniCloud.callFunction({
					name:'uni-id-cf',
					data:{
						action:'loginBySms',
						params:{
51
							"mobile":this.phone,
study夏羽's avatar
study夏羽 已提交
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
							"code":this.code
						},
					}
				}).then(({result})=>{
					if(result.code === 0){
						this.loginSuccess(result)
					}else{
						uni.showModal({
							content: result.msg,
							showCancel: false
						});
					}
					return result
				})
			
				// uniCloud.callFunction({
				// 	name:'uni-id-cf',
				// 	data:{
				// 		action:'loginBySms',
				// 		params:{
				// 			"mobile":this.phone,
				// 			"code":this.code
				// 		},
				// 	},
				// 	success: ({result}) => {
				// 		if(result.code === 0){
				// 			this.loginSuccess(result)
				// 		}else{
				// 			uni.showModal({
				// 				content: result.msg,
				// 				showCancel: false
				// 			});
				// 		}
				// 	}
				// })
				
芊里 已提交
88 89 90 91
			}
		}
	}
</script>
DCloud_JSON's avatar
DCloud_JSON 已提交
92
<style>
DCloud_JSON's avatar
DCloud_JSON 已提交
93
	@import url("../common/login-page.css");
DCloud_JSON's avatar
DCloud_JSON 已提交
94
</style>