consumer模块完成度95%,准备部署消费者端测试
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
<!-- pages/mall/consumer/chat.uvue -->
|
||||
<!-- pages/mall/consumer/chat.uvue -->
|
||||
<template>
|
||||
<view class="chat-page">
|
||||
<!-- 聊天头部 -->
|
||||
@@ -7,11 +7,15 @@
|
||||
<text class="back-icon">‹</text>
|
||||
</view>
|
||||
<view class="header-info">
|
||||
<text class="chat-title">{{ headerTitle }}</text>
|
||||
<text class="chat-status">在线</text>
|
||||
<view class="header-info-text-wrapper">
|
||||
<text class="chat-title">{{ headerTitle }}</text>
|
||||
<text class="chat-status">在线</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="header-actions">
|
||||
<text class="action-icon" @click="showMoreActions">⋮</text>
|
||||
<view class="action-icon" @click="showMoreActions">
|
||||
<text class="action-icon-text">⋯</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@@ -20,7 +24,7 @@
|
||||
scroll-y="true"
|
||||
class="chat-content"
|
||||
:scroll-into-view="scrollToView"
|
||||
:scroll-with-animation="false"
|
||||
:scroll-with-animation="true"
|
||||
:show-scrollbar="false"
|
||||
upper-threshold="100"
|
||||
@scrolltoupper="onScrollToUpper"
|
||||
@@ -53,7 +57,7 @@
|
||||
/>
|
||||
<view class="message-content-wrapper">
|
||||
<text class="sender-name">{{ headerTitle }}</text>
|
||||
<view class="message-bubble">
|
||||
<view class="message-bubble received-bubble">
|
||||
<text class="message-text">{{ message.content }}</text>
|
||||
<text class="message-time">{{ message.time }}</text>
|
||||
</view>
|
||||
@@ -158,25 +162,34 @@ function scrollToBottom() : void {
|
||||
|
||||
// 获取最后一条消息的 ID
|
||||
const lastMsg = messages.value[messages.value.length - 1]
|
||||
const targetId = 'msg-' + lastMsg.id
|
||||
const targetId = lastMsg.viewId
|
||||
|
||||
// 关键点:在 UVue 安卓端,直接连续赋值可能被合并。
|
||||
// 我们先清除 ID,然后在下一帧赋值,确保 scroll-view 监听到变化。
|
||||
// 我们先清空 ID,然后在下一帧赋值,确保 scroll-view 监听到变化。
|
||||
scrollToView.value = ''
|
||||
|
||||
// 增加多次尝试,确保在 DOM 彻底完成渲染(包含由于高度计算引起的多次排版)后定位。
|
||||
// 延迟更久一点,确保安卓端列表排版彻底完成
|
||||
setTimeout(() => {
|
||||
scrollToView.value = targetId
|
||||
console.log('[scrollToBottom] 发起第一次滚动定位:', targetId)
|
||||
console.log('[scrollToBottom] 发起滚动定位:', targetId)
|
||||
|
||||
// 二次校准:针对长消息或图片导致的高度变化
|
||||
// 分级校准:针对长消息或渲染抖动导致的高度变化
|
||||
setTimeout(() => {
|
||||
scrollToView.value = ''
|
||||
setTimeout(() => {
|
||||
scrollToView.value = targetId
|
||||
console.log('[scrollToBottom] 二次校准完成:', targetId)
|
||||
console.log('[scrollToBottom] 第一阶段校准:', targetId)
|
||||
}, 50)
|
||||
}, 100)
|
||||
}, 500)
|
||||
|
||||
// 最终深度校准(针对首屏数据较多时)
|
||||
setTimeout(() => {
|
||||
scrollToView.value = ''
|
||||
setTimeout(() => {
|
||||
scrollToView.value = targetId
|
||||
console.log('[scrollToBottom] 最终校准:', targetId)
|
||||
}, 50)
|
||||
}, 1200)
|
||||
}, 300)
|
||||
}
|
||||
|
||||
@@ -522,7 +535,7 @@ const goBack = () => {
|
||||
<style>
|
||||
.chat-page {
|
||||
width: 100%;
|
||||
height: 100vh;
|
||||
flex: 1;
|
||||
background-color: #f5f5f5;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
@@ -552,7 +565,12 @@ const goBack = () => {
|
||||
|
||||
.header-info {
|
||||
flex: 1;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.header-info-text-wrapper {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.chat-title {
|
||||
@@ -571,7 +589,11 @@ const goBack = () => {
|
||||
font-size: 20px;
|
||||
color: #333;
|
||||
width: 40px;
|
||||
}
|
||||
|
||||
.action-icon-text {
|
||||
text-align: right;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
/* 聊天内容区 */
|
||||
@@ -591,7 +613,9 @@ const goBack = () => {
|
||||
|
||||
/* 系统消息 */
|
||||
.message-item.system {
|
||||
text-align: center;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: center;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
@@ -601,12 +625,14 @@ const goBack = () => {
|
||||
background-color: #f0f0f0;
|
||||
padding: 5px 15px;
|
||||
border-radius: 15px;
|
||||
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
/* 时间分割线 */
|
||||
.time-divider {
|
||||
text-align: center;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: center;
|
||||
margin: 20px 0;
|
||||
}
|
||||
|
||||
@@ -616,6 +642,7 @@ const goBack = () => {
|
||||
background-color: #f0f0f0;
|
||||
padding: 3px 10px;
|
||||
border-radius: 10px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
/* 消息项 */
|
||||
@@ -644,7 +671,7 @@ const goBack = () => {
|
||||
}
|
||||
|
||||
.message-content-wrapper {
|
||||
max-width: 70%;
|
||||
width: 260px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
@@ -655,9 +682,11 @@ const goBack = () => {
|
||||
border-radius: 12px;
|
||||
position: relative;
|
||||
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
|
||||
align-self: flex-start; /* 关键:根据内容宽度自适应,不撑满 */
|
||||
word-wrap: break-word;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.received-bubble {
|
||||
align-self: flex-start;
|
||||
border-top-left-radius: 2px;
|
||||
}
|
||||
|
||||
.message-bubble.me {
|
||||
@@ -666,10 +695,6 @@ const goBack = () => {
|
||||
border-top-right-radius: 2px;
|
||||
}
|
||||
|
||||
.message-bubble:not(.me) {
|
||||
border-top-left-radius: 2px;
|
||||
}
|
||||
|
||||
.sender-name {
|
||||
font-size: 11px;
|
||||
color: #999;
|
||||
@@ -682,8 +707,6 @@ const goBack = () => {
|
||||
color: #333;
|
||||
line-height: 1.4;
|
||||
margin-bottom: 5px;
|
||||
word-wrap: break-word;
|
||||
word-break: break-all;
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
|
||||
@@ -781,3 +804,4 @@ const goBack = () => {
|
||||
|
||||
/* 响应式适配 removed for strict uv-app-x compliance */
|
||||
</style>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user