<template>
  <view>
    <uni-popup ref="popupRef" type="dialog" :animation="false" :is-mask-click="false"
               mask-background-color="rgba(0, 0, 0, 0.4);">
      <uni-popup-dialog mode="input"
                        class="phone-ksxz-dialog"
                        title="提示"
                        :duration="2000"
                        :before-close="true"
                        :showClose="true"
                        @close="handleClose"
                        @confirm="handleConfirm">
        <text>
          您已经回答了{{data.answercartsCount}}题（共{{data.answercartsTotal}}题），确认交卷？
        </text>
      </uni-popup-dialog>
    </uni-popup>
  </view>
</template>

<script setup>
import {
  ref,reactive
} from "vue";
const popupRef = ref(null)
const data = reactive({
  answercartsCount: '',
  answercartsTotal: '',

})

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

function showDialog(options) {
  data.answercartsCount = options.answercartsCount;
  data.answercartsTotal = options.answercartsTotal;
  popupRef.value.open()
}

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

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

defineExpose({
  showDialog
})

</script>

<style>
</style>