7a55ee0f2e
前端: - 新增 pages/comments 独立评论页(列表 + 底部输入条 + 回复),社区卡片点评论改为 navigateTo - 输入条用普通流式布局 + 原生 adjust-position 做键盘避让,聚焦期间不 setData 碰输入框 - 评论只能配 1 张图;底部常驻「审核后公开」提示;发送按钮在途「审核中…」防连点 - 发布结果按状态区分:过审即时展示,其余提示「已提交,审核通过后展示」 - 评论页把已发布评论数回传社区列表,卡片数字实时更新 后端: - CreateComment 文本判为违规时直接拒收(ErrContentRejected),不入库 - 社区列表/用户帖子列表用「已发布评论实时条数」覆盖 comment_count, 修正异步过审/删待审/后台改状态导致的计数漂移 - IDCard 手机号返回完整号码(上一批遗留) Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
83 lines
4.4 KiB
Plaintext
83 lines
4.4 KiB
Plaintext
<nav-bar title="评论" show-back="{{true}}"></nav-bar>
|
|
|
|
<scroll-view class="cm-scroll" scroll-y="{{true}}" enhanced="{{true}}" show-scrollbar="{{false}}">
|
|
<view class="cm-count-head">共 {{total}} 条评论</view>
|
|
|
|
<view wx:for="{{comments}}" wx:key="id" class="cm"
|
|
bindtap="onReplyTo" data-id="{{item.id}}" data-name="{{item.author_name}}">
|
|
<view class="cm-av">{{item.initial}}</view>
|
|
<view class="cm-body">
|
|
<view class="cm-name">{{item.author_name}}<text wx:if="{{item.is_self}}" class="mine-tag">我</text></view>
|
|
<view class="cm-text">{{item.content}}</view>
|
|
<view wx:if="{{item.imgs.length}}" class="cm-imgs">
|
|
<image wx:for="{{item.imgs}}" wx:for-item="u" wx:key="*this" class="cm-img"
|
|
src="{{u}}" mode="aspectFill" catchtap="onPreviewCommentImage"
|
|
data-urls="{{item.imgs}}" data-cur="{{u}}"></image>
|
|
</view>
|
|
<view class="cm-meta">
|
|
<text>{{item.timeText}}</text>
|
|
<text class="cm-reply-btn">回复</text>
|
|
<text wx:if="{{item.is_self}}" class="cm-del" catchtap="onDeleteComment"
|
|
data-id="{{item.id}}" data-self="{{true}}">删除</text>
|
|
</view>
|
|
|
|
<view wx:if="{{item.replies.length}}" class="cm-replies">
|
|
<view wx:for="{{item.replies}}" wx:for-item="r" wx:key="id" class="cm-reply"
|
|
catchtap="onReplyTo" data-id="{{r.id}}" data-name="{{r.author_name}}">
|
|
<view class="cm-av cm-av-sm">{{r.initial}}</view>
|
|
<view class="cm-body">
|
|
<view class="cm-name">
|
|
{{r.author_name}}<text wx:if="{{r.is_self}}" class="mine-tag">我</text>
|
|
<text wx:if="{{r.reply_to_name}}" class="cm-at"> 回复 {{r.reply_to_name}}</text>
|
|
</view>
|
|
<view class="cm-text">{{r.content}}</view>
|
|
<view class="cm-meta">
|
|
<text>{{r.timeText}}</text>
|
|
<text class="cm-reply-btn">回复</text>
|
|
<text wx:if="{{r.is_self}}" class="cm-del" catchtap="onDeleteComment"
|
|
data-id="{{r.id}}" data-self="{{true}}">删除</text>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
<view wx:if="{{item.reply_n > item.replies.length}}" class="cm-more"
|
|
catchtap="onExpandReplies" data-id="{{item.id}}" data-index="{{index}}">
|
|
— 展开全部 {{item.reply_n}} 条回复
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
|
|
<view wx:if="{{!comments.length}}" class="cmp-empty">
|
|
<view class="cmp-empty-ic"><pt-icon name="comment" size="{{72}}"></pt-icon></view>
|
|
<view class="cmp-empty-t">还没有评论</view>
|
|
<view class="cmp-empty-p">来抢个沙发,说点什么吧~</view>
|
|
</view>
|
|
|
|
</scroll-view>
|
|
|
|
<!-- 底部输入条:普通流式排在 flex 列最底部(不 fixed)。页面整体 overflow:hidden 不能滚,
|
|
聚焦时原生 adjust-position 会把整屏均匀上移让输入条避开键盘 —— 不会像 fixed 那样把
|
|
页面过度上滚出大片空白,也不需要任何 JS 碰输入条(碰了就抖失焦)。 -->
|
|
<view class="cm-bar">
|
|
<view wx:if="{{replyTo.name}}" class="cm-replying">
|
|
回复 {{replyTo.name}}
|
|
<view class="cm-cancel" catchtap="onCancelReply"><pt-icon name="close" size="{{24}}"></pt-icon></view>
|
|
</view>
|
|
<view wx:if="{{commentImages.length}}" class="img-picker">
|
|
<view wx:for="{{commentImages}}" wx:key="id" class="img-thumb">
|
|
<image src="{{item.url}}" mode="aspectFill"></image>
|
|
<view class="img-del" catchtap="onRemoveCommentImage" data-index="{{index}}"><pt-icon name="close" size="{{24}}"></pt-icon></view>
|
|
</view>
|
|
</view>
|
|
<view class="cm-bar-row">
|
|
<textarea class="cm-ta" placeholder="{{replyTo.name ? '回复 @' + replyTo.name + '…' : '说点什么…'}}"
|
|
placeholder-class="placeholder" value="{{commentText}}" bindinput="onCommentInput"
|
|
focus="{{cmFocus}}" bindblur="onCommentBlur"
|
|
maxlength="500" auto-height="{{true}}" show-confirm-bar="{{false}}"
|
|
adjust-position="{{true}}" cursor-spacing="16"></textarea>
|
|
<view class="cm-pic {{commentImages.length ? 'disabled' : ''}}" catchtap="onPickCommentImages"><pt-icon name="photo" size="{{44}}"></pt-icon></view>
|
|
<view class="cm-send {{commentText && !sendingComment ? 'on' : ''}}" catchtap="onSendComment">{{sendingComment ? '审核中…' : '发送'}}</view>
|
|
</view>
|
|
<view class="cm-tip">评论通过安全审核后才会公开显示,配图最多 1 张</view>
|
|
</view>
|