ns-empty.vue 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <template>
  2. <view class="empty" :class="{ fixed: fixed }">
  3. <view class="empty_img"><image :src="$util.img('upload/uniapp/common-empty.png')" mode="aspectFit"></image></view>
  4. <view class="color-tip margin-top margin-bottom">{{ text }}</view>
  5. <button type="primary" size="mini" class="button" @click="goIndex()" v-if="emptyBtn.show">{{ emptyBtn.text }}</button>
  6. </view>
  7. </template>
  8. <script>
  9. export default {
  10. data() {
  11. return {};
  12. },
  13. props: {
  14. text: {
  15. type: String,
  16. default: '暂无数据'
  17. },
  18. emptyBtn: {
  19. type: Object,
  20. default: () => {
  21. return {
  22. url: '',
  23. show: false,
  24. text: ''
  25. };
  26. }
  27. },
  28. fixed: {
  29. type: Boolean,
  30. default: false
  31. }
  32. },
  33. methods: {
  34. goIndex() {
  35. if (this.emptyBtn.url) {
  36. this.$util.redirectTo(this.emptyBtn.url, {}, 'redirectTo');
  37. }
  38. }
  39. }
  40. };
  41. </script>
  42. <style lang="scss">
  43. .empty {
  44. width: 100%;
  45. display: flex;
  46. flex-direction: column;
  47. align-items: center;
  48. padding: $padding;
  49. box-sizing: border-box;
  50. justify-content: center;
  51. .empty_img {
  52. width: 63%;
  53. height: 450rpx;
  54. image {
  55. width: 100%;
  56. height: 100%;
  57. padding-bottom: $padding;
  58. }
  59. }
  60. button {
  61. min-width: 300rpx;
  62. margin-top: 100rpx;
  63. height: 70rpx;
  64. line-height: 70rpx !important;
  65. font-size: $font-size-base;
  66. }
  67. }
  68. .fixed {
  69. position: fixed;
  70. left: 0;
  71. top: 20vh;
  72. }
  73. </style>