app-wrapper-empty.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  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: '200rpx'
  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 {
  95. return `${this.$constant.imgUrl}/retail/common/img_nodata.png`
  96. }
  97. }
  98. },
  99. data() {
  100. return {}
  101. }
  102. }
  103. </script>
  104. <style lang="scss" scoped>
  105. .app-empty {
  106. width: 100%;
  107. display: flex;
  108. align-items: center;
  109. & .app-empty-center {
  110. width: 100%;
  111. margin-bottom: 80px;
  112. }
  113. & .app-empty__img {
  114. width: 100%;
  115. text-align: center;
  116. margin: 116px auto 50px;
  117. & image {
  118. width: 500px;
  119. max-width: 100%;
  120. height: auto;
  121. }
  122. }
  123. & .app-empty__title {
  124. display: flex;
  125. flex-direction: column;
  126. align-items: center;
  127. font-size: 32px;
  128. color: #666666;
  129. & span {
  130. font-weight: 400;
  131. & + span {
  132. font-weight: initial;
  133. margin-top: 10px;
  134. font-size: 26px;
  135. }
  136. }
  137. & .empty_noData {
  138. font-size: 26px;
  139. }
  140. }
  141. }
  142. .foot-divider {
  143. height: 1px;
  144. background-color: #dcdada;
  145. width: 63px;
  146. margin: 0 22px;
  147. }
  148. .foot-text {
  149. font-size: 26px;
  150. color: #a1a1a1;
  151. display: flex;
  152. justify-content: center;
  153. align-items: center;
  154. }
  155. .foot-layout {
  156. display: flex;
  157. flex-direction: row;
  158. justify-content: center;
  159. align-items: center;
  160. height: 115px;
  161. }
  162. .loading {
  163. display: inline-block;
  164. margin-right: 12px;
  165. vertical-align: middle;
  166. width: 14px;
  167. height: 14px;
  168. background: 0 0;
  169. border-radius: 50%;
  170. border: 2px solid #e9eaec;
  171. border-color: #e9eaec #e9eaec #e9eaec #f4a738;
  172. animation: btn-spin 0.6s linear;
  173. animation-iteration-count: infinite;
  174. }
  175. @keyframes btn-spin {
  176. 0% {
  177. transform: rotate(0);
  178. }
  179. 100% {
  180. transform: rotate(360deg);
  181. }
  182. }
  183. </style>