z-paging-empty-view.vue 3.5 KB

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