app-wrapper-empty.vue 3.5 KB

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