app-wrapper-empty.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. <template>
  2. <div class="app-empty" :style="{'height: 100%;': !!isEmpty }">
  3. <div class="app-empty-center" :style="{'text-align: center;': !!isEmpty}">
  4. <slot v-if="!isEmpty" name="empty_body" />
  5. <slot v-if="isEmpty && !isLoading" name="empty_content">
  6. <!-- :style="`width:${pictureWidth};`" -->
  7. <div class="app-empty__img" :style="{width: pictureWidth}">
  8. <img :src="src" mode="widthFix" />
  9. </div>
  10. <div class="app-empty__title">
  11. <template v-if="isTitle">
  12. <span :class="[type==='noData'?'empty_noData':'']">{{ title }}</span>
  13. <span>{{ content }}</span>
  14. </template>
  15. <slot v-else name="empty_title"></slot>
  16. </div>
  17. </slot>
  18. <slot v-else>
  19. <div>
  20. <div class="foot-layout" v-if="finished">
  21. <!-- <div class='foot-divider'></div> -->
  22. <div class="foot-text">{{finishedText}}</div>
  23. <!-- <div class='foot-divider'></div> -->
  24. </div>
  25. <div class="foot-layout" v-if="isLoading">
  26. <div class="foot-text">
  27. <div class="loading"></div>加载中
  28. </div>
  29. </div>
  30. </div>
  31. </slot>
  32. <slot name="footer" />
  33. </div>
  34. </div>
  35. </template>
  36. <script>
  37. export default {
  38. name: 'AppWrapperEmpty',
  39. props: {
  40. /**
  41. * type()
  42. * search (搜索)
  43. * noData (无数据)
  44. */
  45. type: {
  46. type: String,
  47. default: 'noData'
  48. },
  49. // 图片宽度
  50. pictureWidth: {
  51. type: String,
  52. default: '400rpx'
  53. },
  54. pictureHeight: {
  55. type: String,
  56. default: ''
  57. },
  58. title: {
  59. type: String,
  60. default: ''
  61. },
  62. // 是否垂直居中
  63. content: {
  64. type: String,
  65. default: ''
  66. },
  67. isEmpty: {
  68. type: Boolean,
  69. default: false
  70. },
  71. isLoading: {
  72. type: Boolean,
  73. default: false
  74. },
  75. finished: {
  76. type: Boolean,
  77. default: false
  78. },
  79. finishedText: {
  80. type: String,
  81. default: '没有更多了'
  82. },
  83. isTitle: {
  84. type: Boolean,
  85. default: true
  86. }
  87. },
  88. computed: {
  89. src() {
  90. if (this.img) {
  91. return this.img
  92. } else if (this.type == 'search') {
  93. return `${this.$constant.imgUrl}/retail/common/img_noorder.png`
  94. } else if (this.type == 'billing') {
  95. return `${this.$constant.imgUrl}/ghs/common/img_nodata.png`
  96. } else {
  97. return `${this.$constant.imgUrl}/retail/common/img_nodata.png`
  98. }
  99. }
  100. },
  101. data() {
  102. return {}
  103. }
  104. }
  105. </script>
  106. <style lang="scss" scoped>
  107. .app-empty {
  108. width: 100%;
  109. display: flex;
  110. align-items: center;
  111. & .app-empty-center {
  112. width: 100%;
  113. margin-bottom: 80px;
  114. }
  115. & .app-empty__img {
  116. width: 100%;
  117. text-align: center;
  118. margin: 116px auto 50px;
  119. & image {
  120. width: 500px;
  121. max-width: 100%;
  122. height: auto;
  123. }
  124. }
  125. & .app-empty__title {
  126. display: flex;
  127. flex-direction: column;
  128. align-items: center;
  129. font-size: 32px;
  130. color: #666666;
  131. & span {
  132. font-weight: 400;
  133. & + span {
  134. font-weight: initial;
  135. margin-top: 10px;
  136. font-size: 26px;
  137. }
  138. }
  139. & .empty_noData {
  140. font-size: 26px;
  141. }
  142. }
  143. }
  144. .foot-divider {
  145. height: 1px;
  146. background-color: #dcdada;
  147. width: 63px;
  148. margin: 0 22px;
  149. }
  150. .foot-text {
  151. font-size: 26px;
  152. color: #a1a1a1;
  153. display: flex;
  154. justify-content: center;
  155. align-items: center;
  156. }
  157. .foot-layout {
  158. display: flex;
  159. flex-direction: row;
  160. justify-content: center;
  161. align-items: center;
  162. height: 115px;
  163. }
  164. .loading {
  165. display: inline-block;
  166. margin-right: 12px;
  167. vertical-align: middle;
  168. width: 14px;
  169. height: 14px;
  170. background: 0 0;
  171. border-radius: 50%;
  172. border: 2px solid #e9eaec;
  173. border-color: #e9eaec #e9eaec #e9eaec #f4a738;
  174. animation: btn-spin 0.6s linear;
  175. animation-iteration-count: infinite;
  176. }
  177. @keyframes btn-spin {
  178. 0% {
  179. transform: rotate(0);
  180. }
  181. 100% {
  182. transform: rotate(360deg);
  183. }
  184. }
  185. </style>