FamilyEmptyState.vue 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <template>
  2. <view class="family-empty-state" :class="['family-empty-' + type]">
  3. <view class="empty-icon">{{ iconChar }}</view>
  4. <view class="empty-title">{{ title }}</view>
  5. <view v-if="desc" class="empty-desc">{{ desc }}</view>
  6. <view class="empty-actions">
  7. <button class="empty-btn primary" @click="goCreate">{{ primaryText }}</button>
  8. <button class="empty-btn secondary" @click="goJoin">{{ secondaryText }}</button>
  9. </view>
  10. </view>
  11. </template>
  12. <script>
  13. export default {
  14. name: 'FamilyEmptyState',
  15. props: {
  16. // 形态: 'card'(嵌入卡片,紧凑)/ 'block'(中等块)/ 'list'(列表空态)
  17. type: { type: String, default: 'card' },
  18. title: { type: String, default: '请先创建或加入家庭' },
  19. desc: { type: String, default: '加入家庭后即可解锁本功能' },
  20. primaryText: { type: String, default: '创建家庭' },
  21. secondaryText: { type: String, default: '加入家庭' }
  22. },
  23. computed: {
  24. iconChar: function() {
  25. return this.type === 'card' ? '🏠' : '👨‍👩‍👧'
  26. }
  27. },
  28. methods: {
  29. goCreate: function() {
  30. uni.navigateTo({ url: '/pages/profile-extra/family-members?action=create' })
  31. },
  32. goJoin: function() {
  33. uni.navigateTo({ url: '/pages/profile-extra/family-members' })
  34. }
  35. }
  36. }
  37. </script>
  38. <style lang="scss" scoped>
  39. .family-empty-state {
  40. display: flex;
  41. flex-direction: column;
  42. align-items: center;
  43. padding: 20rpx 16rpx;
  44. }
  45. .family-empty-card { padding: 24rpx 16rpx; }
  46. .family-empty-block { padding: 60rpx 24rpx; }
  47. .family-empty-list { padding: 40rpx 16rpx; }
  48. .empty-icon { font-size: 48rpx; margin-bottom: 12rpx; }
  49. .empty-title { font-size: 28rpx; color: #333; margin-bottom: 8rpx; }
  50. .empty-desc { font-size: 24rpx; color: #999; margin-bottom: 16rpx; }
  51. .empty-actions { display: flex; flex-direction: row; gap: 16rpx; margin-top: 8rpx; }
  52. .empty-btn {
  53. font-size: 26rpx;
  54. padding: 10rpx 28rpx;
  55. border-radius: 32rpx;
  56. }
  57. .empty-btn.primary {
  58. background: #F97316;
  59. color: #fff;
  60. }
  61. .empty-btn.secondary {
  62. background: #FFF7ED;
  63. color: #F97316;
  64. border: 2rpx solid #F97316;
  65. }
  66. </style>