<template>
	<view>
		<!-- 单词区 -->
		<selectWordsVue :active-words="activeWords" :activeWord="activeWord"></selectWordsVue>
		<!-- 显示区 -->
		<selectTypesVue activeSelect="2"></selectTypesVue>
		<!-- 输入区 -->
		<view></view>
		<!-- 解释区 -->
		<view>
			{{activeWord.jianyi.join(';')}}
		</view>
		<!-- 音标区 -->
		<view></view>
		<!-- 浮层输入区 -->
		<view></view>
	</view>
</template>

<script setup>
	import selectWordsVue from './selectWords.vue';
	import selectTypesVue from './selectTypes.vue';
	import {
		reactive,
		computed
	} from 'vue';
	import {
		getUserIdentity,
	} from "@/utils/common.js"
	
	const userCode = getUserIdentity();
	
	const props = defineProps({
		activeWord: { // 单词数据
			type: Object,
		},
		activeWords: {
			type: Array
		},
	})

	const data = reactive({
		answer: '',
		result: false, // 正确性
	})

	// 选择单词
	function handleSelect(word) {
		data.answer+=word;
	}

	function checkIsRight() {
		if (data.answer == props.activeWord.value) {
			data.result = true;
			noticeBackDb()
		} else {
			data.result = false;
		}
	}

	function noticeBackDb() {
		// 通知后台已学完当前单词
		if (userCode == 'Visitor') {
			// 游客不更新后台
			return;
		}
	}
	
	function handleReset() {
		data.answer = '';
	}
</script>

<style>
</style>