z-paging-empty-view.vue 3.4 KB

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