uni-points.vue 2.2 KB

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