uni-points.vue 1.7 KB

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