z-paging-empty-view.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. <!-- z-paging -->
  2. <!-- github地址:https://github.com/SmileZXLee/uni-z-paging -->
  3. <!-- dcloud地址:https://ext.dcloud.net.cn/plugin?id=3935 -->
  4. <!-- 反馈QQ群:790460711 -->
  5. <!-- 空数据占位view,此组件支持easycom规范,可以在项目中直接引用 -->
  6. <template>
  7. <view class="zp-container" :style="[finalEmptyViewStyle]">
  8. <view class="zp-main">
  9. <image v-if="!emptyViewImg.length" class="zp-main-image" :style="[emptyViewImgStyle]" :src="emptyImg"></image>
  10. <image v-else class="zp-main-image" mode="aspectFit" :style="[emptyViewImgStyle]" :src="emptyViewImg"></image>
  11. <text class="zp-main-title" :style="[emptyViewTitleStyle]">{{emptyViewText}}</text>
  12. <text v-if="showEmptyViewReload" class="zp-main-error-btn" :style="[emptyViewReloadStyle]"
  13. @click="reloadClick">{{emptyViewReloadText}}</text>
  14. </view>
  15. </view>
  16. </template>
  17. <script>
  18. import zStatic from '../z-paging/js/z-paging-static'
  19. export default {
  20. data() {
  21. return {
  22. base64Empty: zStatic.base64Empty,
  23. base64Error: zStatic.base64Error
  24. };
  25. },
  26. props: {
  27. //空数据描述文字
  28. emptyViewText: {
  29. type: String,
  30. default: function() {
  31. return '没有数据哦~'
  32. }
  33. },
  34. //空数据图片
  35. emptyViewImg: {
  36. type: String,
  37. default: function() {
  38. return ''
  39. }
  40. },
  41. //是否显示空数据图重新加载按钮
  42. showEmptyViewReload: {
  43. type: Boolean,
  44. default: function() {
  45. return false
  46. }
  47. },
  48. //空数据点击重新加载文字
  49. emptyViewReloadText: {
  50. type: String,
  51. default: function() {
  52. return '重新加载'
  53. }
  54. },
  55. //是否是加载失败
  56. isLoadFailed: {
  57. type: Boolean,
  58. default: function() {
  59. return false
  60. }
  61. },
  62. //空数据图样式
  63. emptyViewStyle: {
  64. type: Object,
  65. default: function() {
  66. return {}
  67. }
  68. },
  69. //空数据图img样式
  70. emptyViewImgStyle: {
  71. type: Object,
  72. default: function() {
  73. return {}
  74. }
  75. },
  76. //空数据图描述文字样式
  77. emptyViewTitleStyle: {
  78. type: Object,
  79. default: function() {
  80. return {}
  81. }
  82. },
  83. //空数据图重新加载按钮样式
  84. emptyViewReloadStyle: {
  85. type: Object,
  86. default: function() {
  87. return {}
  88. }
  89. },
  90. //空数据图z-index
  91. emptyViewZIndex: {
  92. type: Number,
  93. default: function() {
  94. return 9
  95. }
  96. }
  97. },
  98. computed: {
  99. emptyImg() {
  100. if (this.isLoadFailed) {
  101. return this.base64Error;
  102. } else {
  103. return this.base64Empty;
  104. }
  105. },
  106. finalEmptyViewStyle(){
  107. this.emptyViewStyle['z-index'] = this.emptyViewZIndex;
  108. return this.emptyViewStyle;
  109. }
  110. },
  111. methods: {
  112. reloadClick() {
  113. this.$emit('reload');
  114. }
  115. }
  116. }
  117. </script>
  118. <style scoped>
  119. .zp-container {
  120. /* #ifndef APP-NVUE */
  121. position: absolute;
  122. top: 0;
  123. left: 0;
  124. width: 100%;
  125. height: 100%;
  126. display: flex;
  127. /* #endif */
  128. /* #ifdef APP-NVUE */
  129. flex: 1;
  130. /* #endif */
  131. align-items: center;
  132. justify-content: center;
  133. }
  134. .zp-main {
  135. /* #ifndef APP-NVUE */
  136. display: flex;
  137. margin-top: -150rpx;
  138. /* #endif */
  139. /* #ifdef APP-NVUE */
  140. margin-top: -100rpx;
  141. /* #endif */
  142. flex-direction: column;
  143. align-items: center;
  144. }
  145. .zp-main-image {
  146. width: 200rpx;
  147. height: 200rpx;
  148. }
  149. .zp-main-title {
  150. font-size: 26rpx;
  151. color: #aaaaaa;
  152. text-align: center;
  153. margin-top: 10rpx;
  154. }
  155. .zp-main-error-btn {
  156. font-size: 26rpx;
  157. padding: 8rpx 24rpx;
  158. border: solid 1px #dddddd;
  159. border-radius: 6rpx;
  160. color: #aaaaaa;
  161. margin-top: 50rpx;
  162. }
  163. </style>