uni-points.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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. const rate = Number(data.right)/(Number(data.right)+Number(data.wrong))
  58. if(props.studyFlag === 0){
  59. if (rate>0.5) {
  60. // 高兴鹅
  61. return 'score-happy-study-dialog'
  62. } else {
  63. // 沮丧鹅
  64. return 'score-unhappy-study-dialog'
  65. }
  66. // return 'score-study-dialog';
  67. }else{
  68. if (rate>0.5) {
  69. // 高兴鹅
  70. return 'score-finish-happy-study-dialog'
  71. } else {
  72. // 沮丧鹅
  73. return 'score-finish-unhappy-study-dialog'
  74. }
  75. // return 'score-finish-dialog';
  76. }
  77. }
  78. function closePopup() {
  79. popupRef.value.close()
  80. }
  81. // 查看答案
  82. function checkAnswer() {
  83. emits('checkAnswer');
  84. closePopup();
  85. }
  86. // 继续学习
  87. function goStudyContinue() {
  88. emits('goStudy');
  89. closePopup();
  90. }
  91. defineExpose({
  92. showPopup
  93. })
  94. </script>
  95. <style>
  96. </style>