UserQuickEntry.vue 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <template>
  2. <view class="user-quick-entry">
  3. <view class="user-info">
  4. <text class="user-info-text">
  5. 👤 当前用户:{{ userName }}({{ roleName }})
  6. </text>
  7. <view class="child-switcher" v-if="children && children.length > 0" @click="showChildPicker">
  8. <text class="child-switcher-text">
  9. 切换孩子:{{ currentChildName || '选择' }} ▼
  10. </text>
  11. </view>
  12. </view>
  13. <view class="quick-actions">
  14. <view class="quick-btn" @click="$emit('scrollTo', 'tasks')">
  15. <text class="quick-btn-icon">📋</text>
  16. <text class="quick-btn-label">今日任务</text>
  17. </view>
  18. <view class="quick-btn" @click="$emit('scrollTo', 'activities')">
  19. <text class="quick-btn-icon">🔥</text>
  20. <text class="quick-btn-label">相关活动</text>
  21. </view>
  22. <view class="quick-btn" @click="$emit('scrollTo', 'products')">
  23. <text class="quick-btn-icon">🛍️</text>
  24. <text class="quick-btn-label">推荐商品</text>
  25. </view>
  26. </view>
  27. </view>
  28. </template>
  29. <script>
  30. export default {
  31. props: {
  32. userName: { type: String, default: '' },
  33. roleName: { type: String, default: '' },
  34. currentChildName: { type: String, default: '' },
  35. children: { type: Array, default: function() { return [] } }
  36. },
  37. methods: {
  38. showChildPicker: function() {
  39. var self = this
  40. var items = this.children.map(function(c) { return c.childName })
  41. uni.showActionSheet({
  42. itemList: items,
  43. success: function(res) {
  44. var child = self.children[res.tapIndex]
  45. if (child) {
  46. uni.setStorageSync('currentChildId', child.childId)
  47. self.$emit('childChanged', child)
  48. }
  49. }
  50. })
  51. }
  52. }
  53. }
  54. </script>
  55. <style scoped>
  56. .user-quick-entry {
  57. margin: 0 30rpx 20rpx;
  58. background: #fff;
  59. border-radius: 20rpx;
  60. padding: 20rpx 24rpx;
  61. box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.04);
  62. }
  63. .user-info {
  64. display: flex;
  65. flex-direction: row;
  66. justify-content: space-between;
  67. align-items: center;
  68. margin-bottom: 16rpx;
  69. }
  70. .user-info-text { font-size: 26rpx; color: #666; }
  71. .child-switcher-text { font-size: 24rpx; color: #F97316; }
  72. .quick-actions {
  73. display: flex;
  74. flex-direction: row;
  75. }
  76. .quick-btn {
  77. flex: 1;
  78. display: flex;
  79. flex-direction: column;
  80. align-items: center;
  81. padding: 16rpx 0;
  82. background: #FFF7ED;
  83. border-radius: 16rpx;
  84. margin-right: 16rpx;
  85. }
  86. .quick-btn:last-child { margin-right: 0; }
  87. .quick-btn:active { opacity: 0.7; }
  88. .quick-btn-icon { font-size: 36rpx; margin-bottom: 6rpx; }
  89. .quick-btn-label { font-size: 22rpx; color: #666; }
  90. </style>