dt_empty.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. <template>
  2. <view class="empty-wrap" v-if="type != 0" :style="{'height':wrapHeight,'backgroundColor':wrapBgColor}">
  3. <view class="load-content"
  4. :style="{'background-color':_config.bgColor,'z-index':zIndex,'paddingTop':loadingPaddingTop}">
  5. <view class="load-error" :style="_errorStyle">
  6. <template v-if="type === 1">
  7. <image :src="_config.dt_nodata" mode="widthFix"></image>
  8. </template>
  9. <template v-if="type === 2">
  10. <image :src="_config.dt_error" mode="widthFix"></image>
  11. </template>
  12. </view>
  13. <view class="load-tips">
  14. <text>{{ tips }}</text>
  15. <slot></slot>
  16. </view>
  17. </view>
  18. <view
  19. class="load-empty"
  20. v-if="type == -1"
  21. :style="{ top: _config.blankTop + 'px' }"
  22. ></view>
  23. </view>
  24. </template>
  25. <script>
  26. export default {
  27. data() {
  28. return {
  29. config: {
  30. width: '160', // 图片宽度 upx
  31. blankTop: '0', // 空白距离顶部位置 px
  32. icon_nodata: 'https://szsq.nxzhsq.cn/community/miniofile/image/noData.png',
  33. icon_error: 'https://szsq.nxzhsq.cn/community/miniofile/image/noData.png',
  34. is_opt: false
  35. }
  36. }
  37. },
  38. props: {
  39. type: {
  40. type: Number,
  41. default: 0 // -1初始化,0无,1空,2错误
  42. },
  43. tips: {
  44. type: String,
  45. default: '暂无数据'
  46. },
  47. wrapHeight: {
  48. type: String,
  49. default: '100%'
  50. },
  51. wrapBgColor: {
  52. type: String,
  53. default: '#f2f2f2'
  54. },
  55. loadingPaddingTop: {
  56. type: String,
  57. default: '40%'
  58. },
  59. // config:{
  60. // type: Object,
  61. // default: {
  62. // width:'160', // 图片宽度 upx
  63. // blankTop:'0', // 空白距离顶部位置 px
  64. // icon_nodata: 'https://szsq.nxzhsq.cn/community/miniofile/image/noData.png',
  65. // icon_error: 'https://szsq.nxzhsq.cn/community/miniofile/image/noData.png',
  66. // is_opt: false
  67. // }
  68. // },
  69. zIndex: {
  70. type: [String, Number],
  71. default: '500'
  72. },
  73. },
  74. computed: {
  75. _config() {
  76. let _config = this.config || {}
  77. _config = Object.assign(_config, {
  78. bgColor: 'transparent', // 背景色
  79. width: '160', // 图片宽度 upx
  80. blankTop: '0', // 空白距离顶部位置 px
  81. dt_nodata: 'https://szsq.nxzhsq.cn/community/miniofile/image/noData.png',
  82. dt_error: 'https://szsq.nxzhsq.cn/community/miniofile/image/noData.png',
  83. is_opt: false
  84. })
  85. return _config
  86. },
  87. _errorStyle() {
  88. return 'max-width:' + uni.upx2px(this._config.width) + 'px;'
  89. }
  90. },
  91. methods: {
  92. // init(config){
  93. // let _config = config || {}
  94. // _config = Object.assign(_config,{
  95. // zIndex:'500', // 图标层级
  96. // bgColor:'transparent', // 背景色
  97. // width:'160', // 图片宽度 upx
  98. // blankTop:'0', // 空白距离顶部位置 px
  99. // dt_nodata: 'https://szsq.nxzhsq.cn/community/miniofile/image/comps/dt_nodata.png',
  100. // dt_error: 'https://szsq.nxzhsq.cn/community/miniofile/image/comps/dt_nodata.png',
  101. // is_opt: false
  102. // })
  103. // this.errorStyle = 'max-width:'+uni.upx2px(_config.width)+'px'
  104. // this.contentStyle = `
  105. // background-color:${relConfig.bgColor};
  106. // z-index:${relConfig.zIndex};
  107. // `;
  108. // this.relConfig = _config
  109. // },
  110. // onPageLoad(){
  111. // this.init(this.config)
  112. // }
  113. }
  114. }
  115. </script>
  116. <style lang="scss">
  117. .empty-wrap {
  118. width: 100%;
  119. .load-content {
  120. position: relative;
  121. width: 100%;
  122. display: flex;
  123. flex-wrap: wrap;
  124. justify-content: center;
  125. z-index: 500;
  126. }
  127. .load-error {
  128. max-width: 200 upx;
  129. max-height: 204 upx;
  130. image {
  131. max-width: 100%;
  132. max-height: 100%;
  133. }
  134. }
  135. .load-tips {
  136. width: 100%;
  137. text-align: center;
  138. color: #999999;
  139. font-size: 24 upx;
  140. word-break: break-all;
  141. padding: 30 upx;
  142. color: #666;
  143. }
  144. }
  145. .load-empty {
  146. position: fixed;
  147. left: 0;
  148. top: 0;
  149. width: 100%;
  150. height: 100%;
  151. background: $dt-bg-color-grey;
  152. z-index: 1000;
  153. }
  154. </style>