z-paging-empty-view.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  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. 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. }
  105. }
  106. </script>
  107. <style scoped>
  108. .zp-container{
  109. /* #ifndef APP-NVUE */
  110. display: flex;
  111. /* #endif */
  112. align-items: center;
  113. justify-content: center;
  114. }
  115. .zp-container-fixed {
  116. /* #ifndef APP-NVUE */
  117. position: absolute;
  118. top: 0;
  119. left: 0;
  120. width: 100%;
  121. height: 100%;
  122. /* #endif */
  123. /* #ifdef APP-NVUE */
  124. flex: 1;
  125. /* #endif */
  126. }
  127. .zp-main{
  128. /* #ifndef APP-NVUE */
  129. display: flex;
  130. /* #endif */
  131. flex-direction: column;
  132. align-items: center;
  133. padding: 50rpx 0rpx;
  134. }
  135. .zp-main-image {
  136. width: 200rpx;
  137. height: 200rpx;
  138. }
  139. .zp-main-title {
  140. font-size: 26rpx;
  141. color: #aaaaaa;
  142. text-align: center;
  143. margin-top: 10rpx;
  144. }
  145. .zp-main-error-btn {
  146. font-size: 26rpx;
  147. padding: 8rpx 24rpx;
  148. border: solid 1px #dddddd;
  149. border-radius: 6rpx;
  150. color: #aaaaaa;
  151. margin-top: 50rpx;
  152. }
  153. </style>