<template>
	<uni-popup ref="popupRef" :animation="false" :is-mask-click="false" type="top"
		mask-background-color="rgba(0, 0, 0, 0.4);">
		<view class="exam-score-dialog">
			<customNavbarVue :title="title" :show-back-btn="true" @back="handleClose"></customNavbarVue>

			<view class="score-content-box">
          <view class="score-content-name">{{data[nameKey]}}</view>
          <view class="content-score-box">
					<view>
						<view class="score-content-text">正确数量：{{data.rightCount}}</view>
						<view class="score-content-text">试题总数：{{data.shitiTotal}}</view>
						<view class="score-content-text">及格分数：{{data.okScore}}</view>
						<view class="score-content-text">{{labelName}}：{{data.ksScore}}</view>
					</view>
					<view class="score-content-text"><text>{{data.userScore}}</text>分</view>
				</view>
			</view>

			<view class="progress-text-btn-box">
				<text class="progress-text">正确率</text>
				<c-progress-circle :progress='data.userAccuracy/100' color='#3fd2a1' size='240rpx'
					boderWidth="240rpx" class="progress-circle-box"></c-progress-circle>
				<button type="default" class="phone-green-btn score-dialog-btn" @click="handleCheckSj">查看成绩</button>
			</view>
		</view>
	</uni-popup>
</template>

<script setup>
	import {ref,reactive} from "vue";
	import customNavbarVue from "@/components/custom-navbar/custom-navbar.vue";
	const popupRef = ref(null)
	const data = reactive({
		ksName: '',
    lxName: '',
		ksScore: '',
		okScore: '',
		rightCount: '',
		shitiTotal: '',
		userScore: '',
	})

	defineProps({
		title: {
			type: String,
			default: '考试得分'
		},
		labelName: {
			type: String,
			default: '考试总分'
		},
    nameKey: {
      type: String,
      default: 'ksName'
    }
	})

	const emits = defineEmits(['confirm', 'close'])

	function handleClose() {
		emits('close');
		popupRef.value.close()
	}

	function handleCheckSj() {
		emits('confirm', data);
		popupRef.value.close()
	}

	function showDialog(options) {
		data.ksName = options.ksName;
    data.lxName = options.lxName;
		data.ksScore = options.ksScore;
		data.okScore = options.okScore;
		data.rightCount = options.rightCount;
		data.shitiTotal = options.shitiTotal;
		data.userScore = options.userScore;
		data.userAccuracy = options.userAccuracy;
		popupRef.value.open()
	}

	defineExpose({
		showDialog
	})
</script>

<style lang="scss">
	 .content{
	        display: flex;
	        flex-direction: column;
	        align-items: center;
	        padding-top: 20rpx;
	        font-size: 28rpx;
	    }
	    .btnBox{
	        width: 100%;
	        display: flex;
	        align-items: center;
	        margin-top:30rpx;
	    }
</style>