no-data.vue 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <template>
  2. <view>
  3. <!-- 1 加载中 -->
  4. <view v-if="propStatus == 1" class="no-data-box no-data-loading loading-animation">
  5. <text>{{title}}</text>
  6. </view>
  7. <!-- 2 处理错误 -->
  8. <view v-else-if="propStatus == 2" class="no-data-box">
  9. <image :src="static_dir+'error.png'" mode="widthFix"></image>
  10. <view class="no-data-tips">{{propMsg || '处理错误'}}</view>
  11. </view>
  12. <!-- 0 默认没有数据 -->
  13. <view v-else-if="propStatus == 0" class="no-data-box">
  14. <image :src="static_dir+'empty.png'" mode="widthFix"></image>
  15. <view class="no-data-tips">{{propMsg || '没有相关数据'}}</view>
  16. </view>
  17. </view>
  18. </template>
  19. <script>
  20. const app = getApp();
  21. export default {
  22. data() {
  23. return {
  24. static_dir: '/static/images/common/',
  25. title: app.globalData.get_application_title(),
  26. };
  27. },
  28. components: {},
  29. props: {
  30. propStatus: {
  31. type: [Number,String],
  32. default: 0
  33. },
  34. propMsg: {
  35. type: String,
  36. default: '没有相关数据'
  37. }
  38. },
  39. methods: {}
  40. };
  41. </script>
  42. <style>
  43. .no-data-box {
  44. padding-top: 17%;
  45. text-align: center;
  46. }
  47. .no-data-box image {
  48. width: 160rpx;
  49. margin-bottom: 30rpx;
  50. }
  51. .no-data-box .no-data-tips {
  52. font-size: 28rpx;
  53. color: #a6a6a6;
  54. }
  55. .no-data-loading text {
  56. color: #999;
  57. }
  58. .loading-animation {
  59. background: #e7e7e7 -webkit-linear-gradient(left,#c6c6c6 0%, #c6c6c6 90%) no-repeat 0 0;
  60. background-size: 20% 100%;
  61. -webkit-background-clip: text;
  62. -webkit-text-fill-color: transparent;
  63. font-size: 60rpx;
  64. font-weight: bold;
  65. padding-top: 20%;
  66. }
  67. .loading-animation {
  68. -webkit-animation: loading-animation 2s linear infinite;
  69. animation: loading-animation 2s linear infinite;
  70. }
  71. @-webkit-keyframes loading-animation {
  72. 0% {
  73. background-position: 0 0;
  74. }
  75. 100% {
  76. background-position: 100% 100%;
  77. }
  78. }
  79. @keyframes loading-animation {
  80. 0% {
  81. background-position: 0 0;
  82. }
  83. 100% {
  84. background-position: 100% 100%;
  85. }
  86. }
  87. </style>