app-wrapper-empty.vue 3.4 KB

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