index.tsx 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. import { defineComponent, PropType } from 'vue'
  2. import { Image, Button } from 'vant'
  3. import iconError from '../../images/icon-error.png'
  4. import styles from './index.module.less'
  5. export default defineComponent({
  6. name: 'result-mode',
  7. props: {
  8. confirmButtonText: {
  9. type: String,
  10. default: '去练习'
  11. },
  12. cancelButtonText: {
  13. type: String,
  14. default: '我知道了'
  15. },
  16. status: {
  17. type: String as PropType<'SUCCESS' | 'FAIL' | 'PRACTICE'>,
  18. default: 'SUCCESS'
  19. },
  20. result: {
  21. type: Object,
  22. default: () => ({
  23. tips: '恭喜你,测验通过!',
  24. score: 0,
  25. examName: ''
  26. })
  27. }
  28. },
  29. emits: ['close', 'conform'],
  30. setup(props, { slots, emit }) {
  31. return () => (
  32. <div
  33. class={[
  34. styles.finishResult,
  35. props.status === 'FAIL' && styles.finishFail,
  36. props.status === 'PRACTICE' && styles.finishPractice
  37. ]}
  38. >
  39. <div class={styles.finishContainer}>
  40. <div class={styles.finishContent}>
  41. {slots.content ? (
  42. slots.content()
  43. ) : (
  44. <>
  45. <div class={styles.scoreNums}>
  46. {props.result.score}
  47. <span>分</span>
  48. </div>
  49. <div class={styles.scoreName}>{props.result.examName}</div>
  50. <div class={styles.scoreResult}>{props.result.tips}</div>
  51. </>
  52. )}
  53. </div>
  54. </div>
  55. <div class={styles.finishBtnGroup}>
  56. <div class={styles.finishLeft} onClick={() => emit('close')}>
  57. {props.cancelButtonText}
  58. </div>
  59. <div class={styles.finishRight} onClick={() => emit('conform')}>
  60. {props.confirmButtonText}
  61. </div>
  62. </div>
  63. </div>
  64. )
  65. }
  66. })