z-paging-empty-view.vue 3.5 KB

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