community.wxml 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <!-- pages/community/community.wxml -->
  2. <view class="container" style="{{containerStyle}}">
  3. <!-- 签到区域 -->
  4. <view class="checkin-section" style="background-color: {{theme.bgColor}}">
  5. <view class="checkin-info">
  6. <text>连续签到:{{continuousDays}}天</text>
  7. <text>累计专注:{{totalDuration}}分钟</text>
  8. </view>
  9. <button
  10. class="checkin-btn"
  11. bindtap="checkIn"
  12. style="background-color: {{isChecked ? '#ccc' : theme.primaryColor}}; color: {{theme.textColor}}"
  13. >{{isChecked ? '今日已签到' : '立即签到'}}</button>
  14. </view>
  15. <!-- 发布区域 -->
  16. <view class="post-creator" style="background-color: {{theme.bgColor}}">
  17. <textarea
  18. placeholder="分享您的专注成果..."
  19. placeholder-class="placeholder"
  20. bindinput="onInputContent"
  21. value="{{postContent}}"
  22. style="color: {{theme.textColor}}"
  23. ></textarea>
  24. <view class="post-meta">
  25. <text class="duration-text">今日专注: {{todayDuration}}分钟</text>
  26. <button
  27. class="post-button"
  28. bindtap="createPost"
  29. style="background-color: {{theme.primaryColor}}; color: {{theme.textColor}}"
  30. >发布</button>
  31. </view>
  32. </view>
  33. <!-- 帖子列表 -->
  34. <view class="posts-list">
  35. <block wx:for="{{posts}}" wx:key="id">
  36. <view class="post-card" style="background-color: {{theme.bgColor}}">
  37. <!-- 用户信息 -->
  38. <view class="post-header">
  39. <image class="avatar" src="{{item.user.avatar}}"></image>
  40. <view class="user-info">
  41. <text class="username" style="color: {{theme.textColor}}">{{item.user.name}}</text>
  42. <text class="post-time" style="color: {{theme.textColor}}">{{item.time}}</text>
  43. </view>
  44. </view>
  45. <!-- 帖子内容 -->
  46. <view class="post-content" style="color: {{theme.textColor}}">
  47. {{item.content}}
  48. </view>
  49. <!-- 专注数据 -->
  50. <view class="focus-data" style="background-color: {{theme.primaryColor}}; opacity: 0.5">
  51. <text>专注时长: {{item.duration}}分钟</text>
  52. <text>完成于: {{item.focusTime}}</text>
  53. </view>
  54. <!-- 互动区域 -->
  55. <view class="post-actions">
  56. <view
  57. class="action like"
  58. bindtap="toggleLike"
  59. data-id="{{item.id}}"
  60. >
  61. <image src="{{item.isLiked ? '../../images/liked.png' : '../../images/like.png'}}"></image>
  62. <text style="color: {{item.isLiked ? theme.primaryColor : theme.textColor}}">{{item.likes}}</text>
  63. </view>
  64. <view
  65. class="action comment"
  66. bindtap="showComments"
  67. data-id="{{item.id}}"
  68. >
  69. <image src="../../images/comment.png"></image>
  70. <text style="color: {{theme.textColor}}">{{item.comments.length}}</text>
  71. </view>
  72. </view>
  73. <!-- 评论区域 -->
  74. <view class="comments-section" wx:if="{{showCommentId === item.id}}">
  75. <view class="comments-list">
  76. <block wx:for="{{item.comments}}" wx:key="id">
  77. <view class="comment-item">
  78. <text class="comment-user" style="color: {{theme.primaryColor}}">{{item.user}}:</text>
  79. <text class="comment-content" style="color: {{theme.textColor}}">{{item.content}}</text>
  80. </view>
  81. </block>
  82. </view>
  83. <view class="comment-input">
  84. <input
  85. placeholder="写评论..."
  86. placeholder-class="placeholder"
  87. bindinput="onCommentInput"
  88. data-id="{{item.id}}"
  89. style="color: {{theme.textColor}}"
  90. />
  91. <button
  92. class="send-button"
  93. bindtap="addComment"
  94. data-id="{{item.id}}"
  95. style="background-color: {{theme.primaryColor}}; color: {{theme.textColor}}"
  96. >发送</button>
  97. </view>
  98. </view>
  99. </view>
  100. </block>
  101. </view>
  102. </view>