Files
xingque/pages/chat/chat.wxml
2026-07-09 00:17:03 +08:00

87 lines
4.8 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<view class="chat-page">
<scroll-view class="chat-msg-list" scroll-y="true"
scroll-into-view="{{scrollToView}}"
refresher-enabled="{{true}}"
refresher-triggered="{{isRefreshing}}"
bindrefresherrefresh="onPullDownRefresh"
style="top: 20rpx; bottom: calc({{bottomSafeHeight}}rpx + {{keyboardHeight}}px + env(safe-area-inset-bottom) + 24rpx);">
<view class="chat-loading-more" wx:if="{{loadingHistory}}">加载更早消息...</view>
<block wx:for="{{messages}}" wx:key="messageId">
<view class="chat-msg-wrapper" data-messageid="{{item.messageId}}" bindlongpress="showAction">
<view class="chat-time-tag" wx:if="{{item.showTime}}">{{item.formattedTime}}</view>
<view class="chat-msg-row {{item.senderId === currentUser.id ? 'chat-msg-row--right' : 'chat-msg-row--left'}}">
<image wx:if="{{item.senderId !== currentUser.id}}" class="chat-avatar" src="{{toAvatar || defaultAvatarUrl}}" mode="aspectFill" binderror="onPeerAvatarError" />
<view class="chat-bubble {{item.senderId === currentUser.id ? 'chat-bubble--right' : 'chat-bubble--left'}}"
data-messageid="{{item.messageId}}"
data-text="{{item.type==='text' ? item.payload.text : ''}}"
bindtap="{{item.type==='text' ? 'onBubbleTap' : (item.type==='image' ? 'previewImage' : '')}}"
data-url="{{item.type==='image' ? item.payload.url : ''}}">
<text wx:if="{{item.type === 'text'}}" class="chat-msg-text">{{item.payload.text}}</text>
<image wx:elif="{{item.type === 'image'}}" class="chat-msg-image" src="{{item.payload.url}}" mode="widthFix" />
<view wx:elif="{{item.type === 'order'}}" class="chat-order-bubble">
<text class="chat-order-label">[订单]</text>
<text class="chat-order-info">ID: {{item.payload.orderId}}</text>
</view>
</view>
<image wx:if="{{item.senderId === currentUser.id}}" class="chat-avatar" src="{{currentUser.avatar || defaultAvatarUrl}}" mode="aspectFill" binderror="onSelfAvatarError" data-index="{{index}}" />
</view>
<view wx:if="{{item.senderId === currentUser.id && item.status === 'success'}}" class="chat-read-tag">
{{item.read ? '已读' : '未读'}}
</view>
</view>
</block>
<view id="msg-bottom" style="height:56rpx;"></view>
</scroll-view>
<view class="chat-input-area" style="bottom: {{keyboardHeight}}px; padding-bottom: calc(10rpx + env(safe-area-inset-bottom));">
<view class="chat-plus-panel {{showPlusPanel ? 'show' : ''}}" catchtap="closePlusPanel">
<view class="chat-plus-grid">
<view class="chat-plus-item" catchtap="openEmojiFromPlus">
<text class="chat-plus-icon">😀</text>
<text class="chat-plus-label">表情</text>
</view>
<view class="chat-plus-item" catchtap="chooseImage">
<text class="chat-plus-icon">📷</text>
<text class="chat-plus-label">图片</text>
</view>
<view class="chat-plus-item" catchtap="openOrderSender">
<text class="chat-plus-icon">📋</text>
<text class="chat-plus-label">订单</text>
</view>
</view>
</view>
<view class="chat-emoji-mask" wx:if="{{showEmojiPanel}}" catchtap="closeEmojiPanel"></view>
<view class="chat-emoji-panel {{showEmojiPanel ? 'show' : ''}}">
<scroll-view scroll-y="true" class="chat-emoji-scroll">
<view class="chat-emoji-grid">
<block wx:for="{{emojiList}}" wx:key="*this">
<view class="chat-emoji-item" data-emoji="{{item}}" catchtap="insertEmoji">{{item}}</view>
</block>
</view>
</scroll-view>
</view>
<view class="chat-pending-image" wx:if="{{pendingImage}}">
<image class="chat-pending-thumb" src="{{pendingImage}}" mode="aspectFill" />
<view class="chat-pending-remove" catchtap="clearPendingImage">✕</view>
</view>
<view class="chat-write-row">
<input class="chat-text-input" placeholder="消息" value="{{inputText}}" bindinput="onInput" adjust-position="{{false}}" bindkeyboardheightchange="onKeyboardHeightChange" cursor-spacing="10"/>
<view class="chat-send-btn" bindtap="sendMessage">发送</view>
<view class="chat-plus-btn" bindtap="togglePlusPanel">
<text class="chat-plus-icon-single"></text>
</view>
</view>
</view>
<view class="chat-detail-modal" wx:if="{{showDetailModal}}" catchtap="hideDetail">
<view class="chat-detail-content" catchtap="noop">
<text class="chat-detail-text" user-select="true">{{detailText}}</text>
<button class="chat-copy-btn" bindtap="copyDetail">复制</button>
</view>
</view>
<order-sender visible="{{showOrderSender}}" bind:send="onSendOrder" bind:close="closeOrderSender" />
</view>