dt_empty.vue 3.8 KB

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