uni-points.vue 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <template>
  2. <uni-popup ref="popupRef" :animation="false" :is-mask-click="false"
  3. mask-background-color="rgba(51, 137, 217, 0.65);">
  4. <view class="exam-score-dialog" :class="getDialogClass()">
  5. <view class="score-content-box">
  6. <view class="right-error-row">
  7. <icon class="right-icon"></icon><text class="text-red">{{data.right}}</text>题
  8. <icon class="error-icon"></icon><text class="text-red">{{data.wrong}}</text>题
  9. </view>
  10. <view class="text-score" v-if="!studyFlag">{{data.jifen}}</view>
  11. </view>
  12. <view class="score-btn-box">
  13. <view @click="checkAnswer" class="ckst-btn"></view>
  14. <view @click="goStudyContinue" class="jxxx-btn" v-if="isLastZhang"></view>
  15. </view>
  16. </view>
  17. </uni-popup>
  18. </template>
  19. <script setup>
  20. import {
  21. ref,
  22. reactive
  23. } from "vue"
  24. const props = defineProps({
  25. isLastZhang: {
  26. type: Boolean,
  27. default: true
  28. },
  29. // 当前是否已答过试题 0未答,1已答
  30. studyFlag: {
  31. type: Number,
  32. default: 0
  33. }
  34. })
  35. const popupRef = ref(null)
  36. const popup_background_color = `rgba(0,0,0,0.2)`; // 【弹出框模态层背景颜色】
  37. const emits = defineEmits(['checkAnswer', 'goStudy']);
  38. const data = reactive({
  39. right: 0,
  40. wrong: 0,
  41. jifen: 0
  42. })
  43. // 切换成绩
  44. function showPopup({
  45. right,
  46. wrong,
  47. jifen
  48. }) {
  49. data.right = right;
  50. data.wrong = wrong;
  51. data.jifen = jifen;
  52. popupRef.value.open()
  53. }
  54. function getDialogClass(){
  55. console.log('333',props.studyFlag === 0)
  56. if(props.studyFlag === 0){
  57. return 'score-study-dialog';
  58. }else{
  59. return 'score-finish-dialog';
  60. }
  61. }
  62. function closePopup() {
  63. popupRef.value.close()
  64. }
  65. // 查看答案
  66. function checkAnswer() {
  67. emits('checkAnswer');
  68. closePopup();
  69. }
  70. // 继续学习
  71. function goStudyContinue() {
  72. emits('goStudy');
  73. closePopup();
  74. }
  75. defineExpose({
  76. showPopup
  77. })
  78. </script>
  79. <style>
  80. </style>