uni-points.vue 1.9 KB

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