z-paging-empty-view.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  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':true,'zp-main-fixed':emptyViewFixed}">
  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. //空数据图片是否使用fixed布局并铺满z-paging
  98. emptyViewFixed: {
  99. type: Boolean,
  100. default: function() {
  101. return true
  102. }
  103. }
  104. },
  105. computed: {
  106. emptyImg() {
  107. if (this.isLoadFailed) {
  108. return this.base64Error;
  109. } else {
  110. return this.base64Empty;
  111. }
  112. },
  113. finalEmptyViewStyle(){
  114. this.emptyViewStyle['z-index'] = this.emptyViewZIndex;
  115. return this.emptyViewStyle;
  116. }
  117. },
  118. methods: {
  119. reloadClick() {
  120. this.$emit('reload');
  121. }
  122. }
  123. }
  124. </script>
  125. <style scoped>
  126. .zp-container{
  127. /* #ifndef APP-NVUE */
  128. display: flex;
  129. /* #endif */
  130. align-items: center;
  131. justify-content: center;
  132. }
  133. .zp-container-fixed {
  134. /* #ifndef APP-NVUE */
  135. position: absolute;
  136. top: 0;
  137. left: 0;
  138. width: 100%;
  139. height: 100%;
  140. /* #endif */
  141. /* #ifdef APP-NVUE */
  142. flex: 1;
  143. /* #endif */
  144. }
  145. .zp-main{
  146. /* #ifndef APP-NVUE */
  147. display: flex;
  148. /* #endif */
  149. flex-direction: column;
  150. align-items: center;
  151. }
  152. .zp-main-fixed {
  153. /* #ifndef APP-NVUE */
  154. margin-top: -150rpx;
  155. /* #endif */
  156. /* #ifdef APP-NVUE */
  157. margin-top: -100rpx;
  158. /* #endif */
  159. }
  160. .zp-main-image {
  161. width: 200rpx;
  162. height: 200rpx;
  163. }
  164. .zp-main-title {
  165. font-size: 26rpx;
  166. color: #aaaaaa;
  167. text-align: center;
  168. margin-top: 10rpx;
  169. }
  170. .zp-main-error-btn {
  171. font-size: 26rpx;
  172. padding: 8rpx 24rpx;
  173. border: solid 1px #dddddd;
  174. border-radius: 6rpx;
  175. color: #aaaaaa;
  176. margin-top: 50rpx;
  177. }
  178. </style>