index.tsx 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. import { defineComponent, PropType } from 'vue'
  2. import styles from './index.module.less'
  3. import empty from '@common/images/icon_nodata.png'
  4. import { Button, Empty, Image } from 'vant'
  5. import { postMessage } from '@/helpers/native-message'
  6. export const getAssetsHomeFile = (fileName: string) => {
  7. const path = `./images/${fileName}`
  8. const modules = import.meta.globEager('./images/*')
  9. return modules[path].default
  10. }
  11. export default defineComponent({
  12. name: 'col-result',
  13. props: {
  14. tips: {
  15. type: String
  16. },
  17. type: {
  18. // 空 | 老师认证 | 音乐人认证 | 直播认证
  19. type: String as PropType<
  20. | 'empty'
  21. | 'teacherCert'
  22. | 'musicCert'
  23. | 'liveCert'
  24. | 'error'
  25. | 'network'
  26. | 'search'
  27. | 'emptyContent'
  28. >,
  29. default: 'empty'
  30. },
  31. classImgSize: {
  32. type: String as PropType<'CERT' | 'SMALL'>,
  33. default: ''
  34. },
  35. btnStatus: {
  36. type: Boolean,
  37. default: true
  38. },
  39. buttonText: {
  40. type: String,
  41. default: '我知道了'
  42. },
  43. onClick: Function
  44. },
  45. methods: {
  46. onResult() {
  47. if (this.onClick) {
  48. this.onClick()
  49. } else {
  50. postMessage({ api: 'back', content: {} })
  51. }
  52. }
  53. },
  54. computed: {
  55. image() {
  56. let image = null as any
  57. switch (this.type) {
  58. case 'teacherCert':
  59. image = getAssetsHomeFile('teacherCert.png')
  60. break
  61. case 'musicCert':
  62. image = getAssetsHomeFile('musicCert.png')
  63. break
  64. case 'liveCert':
  65. image = getAssetsHomeFile('liveCert.png')
  66. break
  67. case 'emptyContent':
  68. image = getAssetsHomeFile('emptyContent.png')
  69. break
  70. case 'error':
  71. image = 'error'
  72. break
  73. case 'network':
  74. image = getAssetsHomeFile('network.png')
  75. break
  76. case 'search':
  77. image = 'search'
  78. break
  79. default:
  80. image = getAssetsHomeFile('empty.png')
  81. break
  82. }
  83. return image
  84. }
  85. },
  86. render() {
  87. return (
  88. <div class={styles['col-result']}>
  89. <Empty
  90. image={this.image}
  91. class={styles[this.classImgSize]}
  92. description={this.tips}
  93. />
  94. {this.btnStatus ? (
  95. <Button
  96. class={styles.btn}
  97. round
  98. block
  99. type="primary"
  100. onClick={this.onResult}
  101. >
  102. {this.buttonText}
  103. </Button>
  104. ) : null}
  105. </div>
  106. )
  107. }
  108. })