kevy-empty.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. <template>
  2. <view class="t-content">
  3. <view :class="['t-wh',{'full-screen':fullScreen}]">
  4. <view class="t-empty" v-if="show">
  5. <image class="t-icon" :src="icon" :style="{width:imageSize+'rpx',height:imageSize+'rpx'}"></image>
  6. <view class="t-text" v-if="description" :style="{color:textColor,'font-size':textSize+'rpx'}">
  7. {{description}}
  8. </view>
  9. </view>
  10. <slot></slot>
  11. </view>
  12. </view>
  13. </template>
  14. <script>
  15. const typeMap = {
  16. "address": "无地址哦~",
  17. "car": "购物车空空如也~",
  18. "comment": "无评论哦~",
  19. "coupon": "无优惠券哦~",
  20. "data": "无数据哦~",
  21. "equipment": "无设备哦~",
  22. "error": "出错了~",
  23. "goods": "无商品哦~",
  24. "history": "无历史记录哦~",
  25. "list": "无列表哦~",
  26. "loading": "努力加载中...",
  27. "maintain": "正在维护中...",
  28. "money": "无余额哦~",
  29. "network": "无网络哦~",
  30. "news": "无新闻哦~",
  31. "notice": "无通知哦~",
  32. "order": "无订单哦~",
  33. "permission": "无权限哦~",
  34. "points": "无积分哦~",
  35. "search": "无搜索结果哦~",
  36. "task": "无任务哦~",
  37. "404": "页面走丢了~",
  38. "500": "服务器出错了~",
  39. };
  40. export default {
  41. name: "KevyEmpty",
  42. props: {
  43. /**
  44. * 类型:支持address、car、comment、coupon、data、equipment、error、favor、goods、history、list、loading、maintain、message、money、network、news、notice、order、permission、points、search、task、404、500
  45. */
  46. type: {
  47. type: String,
  48. default: "data"
  49. },
  50. /**
  51. * 自定义图标链接,传此参数则优先级高于type显示图片,图标为正方形1:1大小
  52. */
  53. image: {
  54. type: String,
  55. default: undefined
  56. },
  57. /**
  58. * 描述文字
  59. */
  60. text: {
  61. type: String,
  62. default: ''
  63. },
  64. /**
  65. * 描述文字颜色
  66. */
  67. textColor: {
  68. type: String,
  69. default: '#969799'
  70. },
  71. /**
  72. * 描述文字大小,单位rpx
  73. */
  74. textSize: {
  75. type: [String, Number],
  76. default: '28'
  77. },
  78. /**
  79. * 图标大小,单位rpx
  80. */
  81. imageSize: {
  82. type: [String, Number],
  83. default: '320'
  84. },
  85. /**
  86. * 是否显示
  87. */
  88. show: {
  89. type: Boolean,
  90. default: false
  91. },
  92. /**
  93. * 是否全屏展示
  94. */
  95. fullScreen: {
  96. type: [Boolean, String],
  97. default: false
  98. },
  99. },
  100. data() {
  101. return {}
  102. },
  103. computed: {
  104. //计算图标链接
  105. icon: function() {
  106. return this.image ? this.image : ('/uni_modules/kevy-empty/static/empty/' + this.type + '.png');
  107. },
  108. //技术描述文字
  109. description: function() {
  110. return this.text ? this.text : typeMap[this.type];
  111. },
  112. },
  113. methods: {
  114. }
  115. }
  116. </script>
  117. <style lang="scss" scoped>
  118. .t-content {
  119. width: 100%;
  120. box-sizing: border-box;
  121. background: #ffffff;
  122. padding: 20rpx 0rpx 30rpx;
  123. position: relative;
  124. }
  125. .t-wh {
  126. width: 100%;
  127. height: 100%;
  128. box-sizing: border-box;
  129. }
  130. .t-empty {
  131. display: flex;
  132. flex-direction: column;
  133. justify-content: center;
  134. align-items: center;
  135. .t-text {
  136. margin-top: 16rpx;
  137. }
  138. }
  139. .full-screen {
  140. display: flex;
  141. flex-direction: column;
  142. justify-content: flex-start;
  143. align-items: center;
  144. padding-top: 100rpx;
  145. background: #ffffff;
  146. position: fixed;
  147. top: 0rpx;
  148. left: 0rpx;
  149. bottom: 0rpx;
  150. right: 0rpx;
  151. box-sizing: border-box;
  152. width: 100%;
  153. height: 100vh;
  154. overflow: hidden;
  155. }
  156. </style>