index.vue 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <template>
  2. <div class="empty-container">
  3. <div class="empty-content-position">
  4. <div class="image" :class="stateClass"></div>
  5. <div class="empty-main tip-text">
  6. <slot name="default"></slot>
  7. </div>
  8. </div>
  9. </div>
  10. </template>
  11. <script>
  12. export default {
  13. name: 'AppEmpty',
  14. components: {},
  15. props: {
  16. /**
  17. * 图标名称 back [back cry chagrin sleep smile box]
  18. */
  19. state: {
  20. type: String,
  21. default: 'back'
  22. }
  23. },
  24. computed: {
  25. stateClass() {
  26. const imgType = this.typeSrc[this.state]
  27. const classArr = [imgType]
  28. if (!this.$envs.inH5) {
  29. classArr.push('fixed-position')
  30. }
  31. return classArr
  32. }
  33. },
  34. data: () => ({
  35. typeSrc: {
  36. back: 'empty-back',
  37. cry: 'empty-cry',
  38. chagrin: 'empty-chagrin',
  39. sleep: 'empty-sleep',
  40. smile: 'empty-smile',
  41. box: 'empty-box',
  42. ai: 'empty-ai-empty'
  43. }
  44. })
  45. }
  46. </script>
  47. <style lang="scss" scoped>
  48. .empty-container {
  49. display: flex;
  50. flex-direction: column;
  51. align-items: center;
  52. justify-content: center;
  53. flex: 1;
  54. min-height: 100%;
  55. padding: 16px;
  56. box-sizing: border-box;
  57. .empty-content-position {
  58. display: flex;
  59. align-items: center;
  60. flex-direction: column;
  61. justify-content: center;
  62. }
  63. .empty-main {
  64. @extend .empty-content-position;
  65. text-align: center;
  66. }
  67. .max-width70 {
  68. width: 70%;
  69. }
  70. .max-width80 {
  71. width: 80%;
  72. }
  73. .tip-text {
  74. color: #5f5e64;
  75. font-size: 14px;
  76. line-height: 20px;
  77. text-align: center;
  78. }
  79. .tip-sub-text {
  80. color: #9b9ca3;
  81. font-size: 13px;
  82. line-height: 20px;
  83. margin-top: 6px;
  84. text-align: center;
  85. }
  86. .image {
  87. width: 200px;
  88. height: 200px;
  89. &.empty-box {
  90. margin-top: unset;
  91. width: 160px;
  92. height: 160px;
  93. }
  94. }
  95. .fixed-position {
  96. margin-top: -50px;
  97. }
  98. $empty-types: (back, cry, chagrin, sleep, smile, box, 'ai-empty');
  99. @each $empty in $empty-types {
  100. .empty-#{$empty} {
  101. background: url(@/assets/image/public/jy-#{$empty}.png) no-repeat;
  102. background-size: contain;
  103. }
  104. }
  105. }
  106. </style>