app-wrapper-empty.vue 3.3 KB

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