no-data.vue 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <template>
  2. <!-- 无数据展示 -->
  3. <view class="no-data-box">
  4. <slot v-if="custom"></slot>
  5. <view v-else class="text-center">
  6. <view class="flex jcc">
  7. <image class="status-img" mode="widthFix" v-if="statusImgUrl" :src="statusImgUrl"></image>
  8. </view>
  9. <view class="no-data-tips">{{tipsTextCOM}}</view>
  10. </view>
  11. </view>
  12. </template>
  13. <script>
  14. import defaultConfig from '@/config/default.js'
  15. export default {
  16. props: {
  17. statusType: { // 空状态类型
  18. type: Number,
  19. default: 1
  20. },
  21. custom: Boolean, // 是否自定义插槽
  22. tipsText: String, // 文案
  23. },
  24. data() {
  25. return {}
  26. },
  27. computed: {
  28. statusImgUrl() {
  29. let url = ''
  30. const maps = this.$store.state.emptyStatus.status
  31. const index = maps.findIndex(item => item.type === this.statusType)
  32. url = index !== -1 ? defaultConfig.ossImgUrl + maps[index].url : ''
  33. return url
  34. },
  35. tipsTextCOM() {
  36. let text = ''
  37. const maps = this.$store.state.emptyStatus.status
  38. const item = maps.find(item => item.type === this.statusType)
  39. text = this.tipsText ? this.tipsText : item.name
  40. return text
  41. }
  42. },
  43. methods: {}
  44. }
  45. </script>
  46. <style lang="scss" scoped>
  47. .no-data-box {
  48. width: 100%;
  49. height: 100%;
  50. z-index: 996;
  51. padding-top: 160rpx;
  52. }
  53. .status-img {
  54. width: 50%;
  55. margin-bottom: 26rpx;
  56. }
  57. .no-data-tips {
  58. color: #707476;
  59. font-size: 28rpx;
  60. line-height: 40rpx;
  61. // margin-bottom: 34rpx;
  62. text-align: center;
  63. padding: 0 50rpx;
  64. }
  65. </style>