Merge remote-tracking branch 'origin/dev-wdb' into dev-hjf
This commit is contained in:
commit
2fe645a886
@ -1,4 +1,4 @@
|
|||||||
MP_API_BASE_URL=https://patient.youcan365.com
|
MP_API_BASE_URL=https://patient.youcan365.com
|
||||||
MP_CACHE_PREFIX=development
|
MP_CACHE_PREFIX=development
|
||||||
MP_WX_APP_ID=wx6ee11733526b4f04
|
MP_WX_APP_ID=wx6ee11733526b4f04
|
||||||
MP_TIM_SDK_APP_ID=1600123876
|
MP_TIM_SDK_APP_ID=1600126296
|
||||||
@ -1,4 +1,4 @@
|
|||||||
MP_API_BASE_URL=http://localhost:8080
|
MP_API_BASE_URL=http://localhost:8080
|
||||||
MP_CACHE_PREFIX=development
|
MP_CACHE_PREFIX=development
|
||||||
MP_WX_APP_ID=wx6ee11733526b4f04
|
MP_WX_APP_ID=wx6ee11733526b4f04
|
||||||
MP_TIM_SDK_APP_ID=1600123876
|
MP_TIM_SDK_APP_ID=1600126296
|
||||||
|
|||||||
@ -25,7 +25,7 @@ const props = defineProps({
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const list = computed(() => props.avatarList.map(i => i || '/static/default-avatar.png'))
|
const list = computed(() => props.avatarList.map(i => i || '/static/default-avatar.svg'))
|
||||||
|
|
||||||
const size = computed(() => {
|
const size = computed(() => {
|
||||||
const val = Number.isInteger(props.size) && props.size > 0 ? props.size : 144;
|
const val = Number.isInteger(props.size) && props.size > 0 ? props.size : 144;
|
||||||
|
|||||||
81
pages.json
81
pages.json
@ -1,155 +1,181 @@
|
|||||||
{
|
{
|
||||||
"pages": [{
|
"pages": [
|
||||||
|
{
|
||||||
"path": "pages/home/home",
|
"path": "pages/home/home",
|
||||||
"style": {
|
"style": {
|
||||||
"navigationBarTitleText": "首页",
|
"navigationBarTitleText": "首页",
|
||||||
"navigationStyle": "custom"
|
"navigationStyle": "custom",
|
||||||
|
"disableScroll": true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "pages/article/article-list",
|
"path": "pages/article/article-list",
|
||||||
"style": {
|
"style": {
|
||||||
"navigationBarTitleText": "我的宣教"
|
"navigationBarTitleText": "我的宣教",
|
||||||
|
"disableScroll": true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "pages/article/article-cate-list",
|
"path": "pages/article/article-cate-list",
|
||||||
"style": {
|
"style": {
|
||||||
"navigationBarTitleText": "健康宣教"
|
"navigationBarTitleText": "健康宣教",
|
||||||
|
"disableScroll": true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "pages/survey/survey-list",
|
"path": "pages/survey/survey-list",
|
||||||
"style": {
|
"style": {
|
||||||
"navigationBarTitleText": "我的问卷"
|
"navigationBarTitleText": "我的问卷",
|
||||||
|
"disableScroll": true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "pages/message/message",
|
"path": "pages/message/message",
|
||||||
"style": {
|
"style": {
|
||||||
"navigationBarTitleText": "消息"
|
"navigationBarTitleText": "消息",
|
||||||
|
"disableScroll": true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "pages/message/index",
|
"path": "pages/message/index",
|
||||||
"style": {
|
"style": {
|
||||||
"navigationBarTitleText": "聊天",
|
"navigationBarTitleText": "聊天",
|
||||||
"enablePullDownRefresh": false
|
"enablePullDownRefresh": false,
|
||||||
|
"disableScroll": true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "pages/login/login",
|
"path": "pages/login/login",
|
||||||
"style": {
|
"style": {
|
||||||
"navigationBarTitleText": "健康柚",
|
"navigationBarTitleText": "健康柚",
|
||||||
"navigationStyle": "custom"
|
"navigationStyle": "custom",
|
||||||
|
"disableScroll": true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "pages/login/redirect-page",
|
"path": "pages/login/redirect-page",
|
||||||
"style": {
|
"style": {
|
||||||
"navigationBarTitleText": "健康柚"
|
"navigationBarTitleText": "健康柚",
|
||||||
|
"disableScroll": true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "pages/login/agreement",
|
"path": "pages/login/agreement",
|
||||||
"style": {
|
"style": {
|
||||||
"navigationBarTitleText": "健康柚"
|
"navigationBarTitleText": "健康柚",
|
||||||
|
"disableScroll": true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "pages/archive/archive-manage",
|
"path": "pages/archive/archive-manage",
|
||||||
"style": {
|
"style": {
|
||||||
"navigationBarTitleText": "档案管理"
|
"navigationBarTitleText": "档案管理",
|
||||||
|
"disableScroll": true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "pages/archive/edit-archive",
|
"path": "pages/archive/edit-archive",
|
||||||
"style": {
|
"style": {
|
||||||
"navigationBarTitleText": "新增档案"
|
"navigationBarTitleText": "新增档案",
|
||||||
|
"disableScroll": true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "pages/archive/archive-result",
|
"path": "pages/archive/archive-result",
|
||||||
"style": {
|
"style": {
|
||||||
"navigationBarTitleText": "团队服务"
|
"navigationBarTitleText": "团队服务",
|
||||||
|
"disableScroll": true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "pages/health/list",
|
"path": "pages/health/list",
|
||||||
"style": {
|
"style": {
|
||||||
"navigationBarTitleText": "健康信息"
|
"navigationBarTitleText": "健康信息",
|
||||||
|
"disableScroll": true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "pages/health/record",
|
"path": "pages/health/record",
|
||||||
"style": {
|
"style": {
|
||||||
"navigationBarTitleText": "健康信息"
|
"navigationBarTitleText": "健康信息",
|
||||||
|
"disableScroll": true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "pages/library/diagnosis-list",
|
"path": "pages/library/diagnosis-list",
|
||||||
"style": {
|
"style": {
|
||||||
"navigationBarTitleText": "选择诊断"
|
"navigationBarTitleText": "选择诊断",
|
||||||
|
"disableScroll": true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "pages/team/team-detail",
|
"path": "pages/team/team-detail",
|
||||||
"style": {
|
"style": {
|
||||||
"navigationBarTitleText": "团队介绍"
|
"navigationBarTitleText": "团队介绍",
|
||||||
|
"disableScroll": true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "pages/team/homepage",
|
"path": "pages/team/homepage",
|
||||||
"style": {
|
"style": {
|
||||||
"navigationBarTitleText": "个人主页"
|
"navigationBarTitleText": "个人主页",
|
||||||
|
"disableScroll": true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "pages/team/friend",
|
"path": "pages/team/friend",
|
||||||
"style": {
|
"style": {
|
||||||
"navigationBarTitleText": "添加好友"
|
"navigationBarTitleText": "添加好友",
|
||||||
|
"disableScroll": true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "pages/web-view/web-view",
|
"path": "pages/web-view/web-view",
|
||||||
"style": {
|
"style": {
|
||||||
"navigationBarTitleText": ""
|
"navigationBarTitleText": "",
|
||||||
|
"disableScroll": true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "pages/mine/mine",
|
"path": "pages/mine/mine",
|
||||||
"style": {
|
"style": {
|
||||||
"navigationBarTitleText": "我的"
|
"navigationBarTitleText": "我的",
|
||||||
|
"disableScroll": true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "pages/mine/contact",
|
"path": "pages/mine/contact",
|
||||||
"style": {
|
"style": {
|
||||||
"navigationBarTitleText": "联系客服"
|
"navigationBarTitleText": "联系客服",
|
||||||
|
"disableScroll": true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "pages/common/privacy",
|
"path": "pages/common/privacy",
|
||||||
"style": {
|
"style": {
|
||||||
"navigationBarTitleText": "隐私政策"
|
"navigationBarTitleText": "隐私政策",
|
||||||
|
"disableScroll": true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "pages/common/agreement",
|
"path": "pages/common/agreement",
|
||||||
"style": {
|
"style": {
|
||||||
"navigationBarTitleText": "用户协议"
|
"navigationBarTitleText": "用户协议",
|
||||||
|
"disableScroll": true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "pages/article/article-detail",
|
"path": "pages/article/article-detail",
|
||||||
"style": {
|
"style": {
|
||||||
"navigationBarTitleText": "宣教文章"
|
"navigationBarTitleText": "宣教文章",
|
||||||
|
"disableScroll": true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "pages/article/send-article",
|
"path": "pages/article/send-article",
|
||||||
"style": {
|
"style": {
|
||||||
"navigationBarTitleText": "选择宣教文章"
|
"navigationBarTitleText": "选择宣教文章",
|
||||||
|
"disableScroll": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@ -164,7 +190,8 @@
|
|||||||
"selectedColor": "#007aff",
|
"selectedColor": "#007aff",
|
||||||
"backgroundColor": "#ffffff",
|
"backgroundColor": "#ffffff",
|
||||||
"borderStyle": "white",
|
"borderStyle": "white",
|
||||||
"list": [{
|
"list": [
|
||||||
|
{
|
||||||
"pagePath": "pages/home/home",
|
"pagePath": "pages/home/home",
|
||||||
"iconPath": "static/tabbar/home.png",
|
"iconPath": "static/tabbar/home.png",
|
||||||
"selectedIconPath": "static/tabbar/home_selected.png",
|
"selectedIconPath": "static/tabbar/home_selected.png",
|
||||||
|
|||||||
@ -13,7 +13,7 @@
|
|||||||
<view v-for="i in teamates" :key="i.userid"
|
<view v-for="i in teamates" :key="i.userid"
|
||||||
class="member-card flex flex-shrink-0 min-w-120 mr-15 p-15"
|
class="member-card flex flex-shrink-0 min-w-120 mr-15 p-15"
|
||||||
@click="toHomePage(i)">
|
@click="toHomePage(i)">
|
||||||
<image class="flex-shrink-0 avatar mr-10" :src="i.avatar || '/static/default-avatar.png'" />
|
<image class="flex-shrink-0 avatar mr-10" :src="i.avatar || '/static/default-avatar.svg'" />
|
||||||
<view class="flex-grow flex flex-col justify-between">
|
<view class="flex-grow flex flex-col justify-between">
|
||||||
<view>
|
<view>
|
||||||
<view class="member-name leading-normal h-24 text-base font-semibold text-dark whitespace-nowrap">
|
<view class="member-name leading-normal h-24 text-base font-semibold text-dark whitespace-nowrap">
|
||||||
|
|||||||
@ -8,7 +8,7 @@
|
|||||||
<view class="input-area">
|
<view class="input-area">
|
||||||
<textarea v-if="!showVoiceInput" class="text-input" v-model="inputText" placeholder="我来说两句..."
|
<textarea v-if="!showVoiceInput" class="text-input" v-model="inputText" placeholder="我来说两句..."
|
||||||
@confirm="sendTextMessage" @focus="handleInputFocus" @input="handleInput"
|
@confirm="sendTextMessage" @focus="handleInputFocus" @input="handleInput"
|
||||||
:auto-height="true" :show-confirm-bar="false" :adjust-position="true" :cursor-spacing="80" />
|
:auto-height="true" :show-confirm-bar="false" :adjust-position="true" :cursor-spacing="40" />
|
||||||
<input v-else class="voice-input-btn" :class="{ recording: isRecording }" @touchstart="startRecord"
|
<input v-else class="voice-input-btn" :class="{ recording: isRecording }" @touchstart="startRecord"
|
||||||
@touchmove="onRecordTouchMove" @touchend="stopRecord" @touchcancel="cancelRecord" :placeholder="isRecording ? '松开发送' : '按住说话'" disabled>
|
@touchmove="onRecordTouchMove" @touchend="stopRecord" @touchcancel="cancelRecord" :placeholder="isRecording ? '松开发送' : '按住说话'" disabled>
|
||||||
</input>
|
</input>
|
||||||
|
|||||||
@ -10,7 +10,7 @@ export default function useGroupAvatars() {
|
|||||||
const groupAvatarMap = ref({}) // { groupID: [avatarUrl1, avatarUrl2, ...] }
|
const groupAvatarMap = ref({}) // { groupID: [avatarUrl1, avatarUrl2, ...] }
|
||||||
const teamStore = useTeamStore()
|
const teamStore = useTeamStore()
|
||||||
const patientDefaultAvatar = '/static/default-patient-avatar.png'
|
const patientDefaultAvatar = '/static/default-patient-avatar.png'
|
||||||
const teamMemberDefaultAvatar = '/static/default-avatar.png'
|
const teamMemberDefaultAvatar = '/static/default-avatar.svg'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取单个群聊的头像列表
|
* 获取单个群聊的头像列表
|
||||||
@ -28,7 +28,7 @@ export default function useGroupAvatars() {
|
|||||||
|
|
||||||
// 获取团队成员的头像和名称
|
// 获取团队成员的头像和名称
|
||||||
const memberMap = await teamStore.getTeamMemberAvatarsAndName(teamId)
|
const memberMap = await teamStore.getTeamMemberAvatarsAndName(teamId)
|
||||||
|
|
||||||
if (!memberMap || Object.keys(memberMap).length === 0) {
|
if (!memberMap || Object.keys(memberMap).length === 0) {
|
||||||
console.warn(`群聊 ${groupID} 的团队成员为空`)
|
console.warn(`群聊 ${groupID} 的团队成员为空`)
|
||||||
return []
|
return []
|
||||||
@ -38,8 +38,8 @@ export default function useGroupAvatars() {
|
|||||||
const avatarList = Object.values(memberMap)
|
const avatarList = Object.values(memberMap)
|
||||||
.map(member => {
|
.map(member => {
|
||||||
// 如果成员有头像且不为空,使用成员头像;否则使用团队成员默认头像
|
// 如果成员有头像且不为空,使用成员头像;否则使用团队成员默认头像
|
||||||
return (member.avatar && member.avatar.trim() !== '')
|
return (member.avatar && member.avatar.trim() !== '')
|
||||||
? member.avatar
|
? member.avatar
|
||||||
: teamMemberDefaultAvatar
|
: teamMemberDefaultAvatar
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@ -47,31 +47,25 @@ export default function useGroupChat(groupID) {
|
|||||||
const getUserAvatar = (userId) => {
|
const getUserAvatar = (userId) => {
|
||||||
const member = chatMember.value[userId]
|
const member = chatMember.value[userId]
|
||||||
if (!member) {
|
if (!member) {
|
||||||
// 如果找不到成员信息,根据是否为团队成员返回默认头像
|
return userId === openid.value ? '/static/default-patient-avatar.png' : '/static/default-avatar.svg'
|
||||||
// 患者(userId为当前账户openid)使用 default-patient-avatar.png
|
|
||||||
// 其他情况使用 default-avatar.png
|
|
||||||
return userId === openid.value ? '/static/default-patient-avatar.png' : '/static/default-avatar.png'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 如果有头像且不为空字符串,返回头像
|
// 如果有头像且不为空字符串,返回头像
|
||||||
if (member.avatar && member.avatar.trim() !== '') {
|
if (member.avatar && member.avatar.trim() !== '') {
|
||||||
return member.avatar
|
return member.avatar
|
||||||
}
|
}
|
||||||
|
|
||||||
// 否则根据是否为团队成员返回默认头像
|
|
||||||
// 患者使用 default-patient-avatar.png,团队成员使用 default-avatar.png
|
|
||||||
return member.isTeamMember ? '/static/default-avatar.png' : '/static/default-patient-avatar.png'
|
|
||||||
}
|
|
||||||
|
|
||||||
|
return member.isTeamMember ? '/static/default-avatar.svg' : '/static/default-patient-avatar.png'
|
||||||
|
}
|
||||||
// 获取群聊信息和成员头像
|
// 获取群聊信息和成员头像
|
||||||
async function getGroupInfo() {
|
async function getGroupInfo() {
|
||||||
const gid = typeof groupID === 'string' ? groupID : groupID.value
|
const gid = typeof groupID === 'string' ? groupID : groupID.value
|
||||||
if (!gid) return
|
if (!gid) return
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// 1. 获取群聊基本信息
|
// 1. 获取群聊基本信息
|
||||||
const groupResult = await api('getGroupListByGroupId', { groupId: gid })
|
const groupResult = await api('getGroupListByGroupId', { groupId: gid })
|
||||||
|
|
||||||
if (groupResult && groupResult.success && groupResult.data) {
|
if (groupResult && groupResult.success && groupResult.data) {
|
||||||
groupInfo.value = {
|
groupInfo.value = {
|
||||||
groupID: gid,
|
groupID: gid,
|
||||||
@ -79,14 +73,14 @@ export default function useGroupChat(groupID) {
|
|||||||
status: groupResult.data.orderStatus || 'active',
|
status: groupResult.data.orderStatus || 'active',
|
||||||
teamId: groupResult.data.teamId
|
teamId: groupResult.data.teamId
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. 如果有teamId,获取团队成员头像和名称
|
// 2. 如果有teamId,获取团队成员头像和名称
|
||||||
if (groupResult.data.teamId) {
|
if (groupResult.data.teamId) {
|
||||||
const memberMap = await teamStore.getTeamMemberAvatarsAndName(groupResult.data.teamId)
|
const memberMap = await teamStore.getTeamMemberAvatarsAndName(groupResult.data.teamId)
|
||||||
|
|
||||||
// 3. 存储团队成员ID列表
|
// 3. 存储团队成员ID列表
|
||||||
teamMemberIds.value = Object.keys(memberMap)
|
teamMemberIds.value = Object.keys(memberMap)
|
||||||
|
|
||||||
// 4. 构建团队成员列表(从返回的 { userId: { avatar, name } } 中提取)
|
// 4. 构建团队成员列表(从返回的 { userId: { avatar, name } } 中提取)
|
||||||
members.value = teamMemberIds.value.map(userId => {
|
members.value = teamMemberIds.value.map(userId => {
|
||||||
const memberInfo = memberMap[userId] || {}
|
const memberInfo = memberMap[userId] || {}
|
||||||
@ -97,7 +91,7 @@ export default function useGroupChat(groupID) {
|
|||||||
isTeamMember: true
|
isTeamMember: true
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// 5. 添加患者信息(使用默认患者头像)
|
// 5. 添加患者信息(使用默认患者头像)
|
||||||
if (groupResult.data.patient) {
|
if (groupResult.data.patient) {
|
||||||
const pid = groupResult.data.patientId?.toString() || ''
|
const pid = groupResult.data.patientId?.toString() || ''
|
||||||
|
|||||||
@ -9,7 +9,11 @@
|
|||||||
>{{ patientInfo.sex }} · {{ patientInfo.age }}岁</text
|
>{{ patientInfo.sex }} · {{ patientInfo.age }}岁</text
|
||||||
>
|
>
|
||||||
</view>
|
</view>
|
||||||
<view class="status-badge" :class="chatStatusInfo.badgeClass" v-if="chatStatusInfo.badgeText">
|
<view
|
||||||
|
class="status-badge"
|
||||||
|
:class="chatStatusInfo.badgeClass"
|
||||||
|
v-if="chatStatusInfo.badgeText"
|
||||||
|
>
|
||||||
<text class="badge-text">{{ chatStatusInfo.badgeText }}</text>
|
<text class="badge-text">{{ chatStatusInfo.badgeText }}</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
@ -290,11 +294,11 @@ const fetchGroupOrderStatus = async () => {
|
|||||||
if (result.success && result.data) {
|
if (result.success && result.data) {
|
||||||
orderStatus.value = result.data.orderStatus || "";
|
orderStatus.value = result.data.orderStatus || "";
|
||||||
corpId.value = result.data.corpId || "";
|
corpId.value = result.data.corpId || "";
|
||||||
|
|
||||||
// 更新导航栏标题为团队名称
|
// 更新导航栏标题为团队名称
|
||||||
const teamName = result.data.team?.name || "群聊";
|
const teamName = result.data.team?.name || "群聊";
|
||||||
updateNavigationTitle(teamName);
|
updateNavigationTitle(teamName);
|
||||||
|
|
||||||
// 更新患者信息
|
// 更新患者信息
|
||||||
if (result.data.patient) {
|
if (result.data.patient) {
|
||||||
patientInfo.value = {
|
patientInfo.value = {
|
||||||
@ -308,10 +312,10 @@ const fetchGroupOrderStatus = async () => {
|
|||||||
if (result.data.patientId) {
|
if (result.data.patientId) {
|
||||||
patientId.value = result.data.patientId.toString();
|
patientId.value = result.data.patientId.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 更新聊天状态栏信息
|
// 更新聊天状态栏信息
|
||||||
updateChatStatusInfo(result.data);
|
updateChatStatusInfo(result.data);
|
||||||
|
|
||||||
console.log("获取群组订单状态:", {
|
console.log("获取群组订单状态:", {
|
||||||
orderStatus: orderStatus.value,
|
orderStatus: orderStatus.value,
|
||||||
corpId: corpId.value,
|
corpId: corpId.value,
|
||||||
@ -329,7 +333,7 @@ const fetchGroupOrderStatus = async () => {
|
|||||||
// 更新聊天状态栏信息
|
// 更新聊天状态栏信息
|
||||||
const updateChatStatusInfo = (groupData) => {
|
const updateChatStatusInfo = (groupData) => {
|
||||||
const status = groupData.orderStatus || "";
|
const status = groupData.orderStatus || "";
|
||||||
|
|
||||||
let statusConfig = {
|
let statusConfig = {
|
||||||
show: false,
|
show: false,
|
||||||
title: "",
|
title: "",
|
||||||
@ -337,7 +341,7 @@ const updateChatStatusInfo = (groupData) => {
|
|||||||
badgeText: "",
|
badgeText: "",
|
||||||
badgeClass: "",
|
badgeClass: "",
|
||||||
};
|
};
|
||||||
|
|
||||||
switch (status) {
|
switch (status) {
|
||||||
case "pending":
|
case "pending":
|
||||||
statusConfig = {
|
statusConfig = {
|
||||||
@ -387,7 +391,7 @@ const updateChatStatusInfo = (groupData) => {
|
|||||||
default:
|
default:
|
||||||
statusConfig.show = false;
|
statusConfig.show = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
chatStatusInfo.value = statusConfig;
|
chatStatusInfo.value = statusConfig;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -572,7 +576,6 @@ const initTIMCallbacks = async () => {
|
|||||||
uniqueMessages.push(message);
|
uniqueMessages.push(message);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
messageList.value = uniqueMessages;
|
messageList.value = uniqueMessages;
|
||||||
console.log(
|
console.log(
|
||||||
"消息列表已更新,原始",
|
"消息列表已更新,原始",
|
||||||
@ -664,7 +667,7 @@ const loadMessageList = async () => {
|
|||||||
// 获取群组订单状态
|
// 获取群组订单状态
|
||||||
await fetchGroupOrderStatus();
|
await fetchGroupOrderStatus();
|
||||||
|
|
||||||
timChatManager.enterConversation(chatInfo.value.conversationID || "test1");
|
timChatManager.enterConversation(chatInfo.value.conversationID);
|
||||||
|
|
||||||
// 标记会话为已读 - 确保清空未读数
|
// 标记会话为已读 - 确保清空未读数
|
||||||
if (
|
if (
|
||||||
@ -828,15 +831,12 @@ onShow(() => {
|
|||||||
checkLoginAndInitTIM();
|
checkLoginAndInitTIM();
|
||||||
} else if (timChatManager.tim && !timChatManager.isLoggedIn) {
|
} else if (timChatManager.tim && !timChatManager.isLoggedIn) {
|
||||||
timChatManager.ensureIMConnection();
|
timChatManager.ensureIMConnection();
|
||||||
} else if (timChatManager.tim && timChatManager.isLoggedIn && chatInfo.value.conversationID) {
|
} else if (
|
||||||
|
timChatManager.tim &&
|
||||||
messageList.value = [];
|
timChatManager.isLoggedIn &&
|
||||||
isCompleted.value = false;
|
chatInfo.value.conversationID
|
||||||
lastFirstMessageId.value = "";
|
)
|
||||||
loadMessageList();
|
startIMMonitoring(30000);
|
||||||
}
|
|
||||||
|
|
||||||
startIMMonitoring(30000);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// 页面隐藏
|
// 页面隐藏
|
||||||
|
|||||||
@ -1,9 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<view class="message-page">
|
<view class="message-page">
|
||||||
<!-- 标题栏 -->
|
|
||||||
<!-- <view class="message-header">
|
|
||||||
<text class="header-title">咨询</text>
|
|
||||||
</view> -->
|
|
||||||
|
|
||||||
<!-- 消息列表 -->
|
<!-- 消息列表 -->
|
||||||
<scroll-view
|
<scroll-view
|
||||||
@ -332,16 +328,14 @@ const setupConversationListener = () => {
|
|||||||
existing.lastMessageTime !== conversationData.lastMessageTime ||
|
existing.lastMessageTime !== conversationData.lastMessageTime ||
|
||||||
existing.unreadCount !== conversationData.unreadCount
|
existing.unreadCount !== conversationData.unreadCount
|
||||||
) {
|
) {
|
||||||
// 只更新变化的字段,保持头像和未读数稳定
|
// 只更新变化的字段,保持头像稳定
|
||||||
conversationList.value[existingIndex] = {
|
conversationList.value[existingIndex] = {
|
||||||
...conversationData,
|
...conversationData,
|
||||||
// 保持原有头像,避免闪动
|
// 保持原有头像,避免闪动
|
||||||
avatar: existing.avatar || conversationData.avatar,
|
avatar: existing.avatar || conversationData.avatar,
|
||||||
// 保留较大的未读数(避免被后端数据覆盖)
|
// 【修复】直接使用 TIM SDK 返回的未读数,不使用 Math.max
|
||||||
unreadCount: Math.max(
|
// 这样才能正确处理标记已读的情况(unreadCount 从 N 变为 0)
|
||||||
existing.unreadCount || 0,
|
unreadCount: conversationData.unreadCount || 0
|
||||||
conversationData.unreadCount || 0
|
|
||||||
),
|
|
||||||
};
|
};
|
||||||
needSort = true;
|
needSort = true;
|
||||||
console.log(
|
console.log(
|
||||||
@ -369,40 +363,12 @@ const setupConversationListener = () => {
|
|||||||
globalTimChatManager.setCallback("onMessageReceived", (message) => {
|
globalTimChatManager.setCallback("onMessageReceived", (message) => {
|
||||||
console.log("消息列表页面收到新消息:", message);
|
console.log("消息列表页面收到新消息:", message);
|
||||||
|
|
||||||
// 找到对应的会话
|
// 【修复】不再手动更新未读数
|
||||||
const conversationID = message.conversationID;
|
// TIM SDK 会在收到新消息时自动更新会话的未读数,并触发 onConversationListUpdated 事件
|
||||||
const conversationIndex = conversationList.value.findIndex(
|
// 手动 +1 可能导致未读数不准确(重复计数)
|
||||||
(conv) => conv.conversationID === conversationID
|
//
|
||||||
);
|
// 注意:onConversationListUpdated 事件会在消息接收后自动触发,
|
||||||
|
// 其中包含了正确的未读数,因此这里不需要手动处理
|
||||||
if (conversationIndex !== -1) {
|
|
||||||
const conversation = conversationList.value[conversationIndex];
|
|
||||||
|
|
||||||
// 检查当前页面栈,判断用户是否正在查看该会话的聊天详情页
|
|
||||||
const pages = getCurrentPages();
|
|
||||||
const currentPage = pages[pages.length - 1];
|
|
||||||
|
|
||||||
// 获取当前页面的 groupID 参数(如果在聊天详情页)
|
|
||||||
const currentGroupID = currentPage?.options?.groupID;
|
|
||||||
const isViewingThisConversation =
|
|
||||||
currentPage?.route === "pages/message/index" &&
|
|
||||||
currentGroupID === conversation.groupID;
|
|
||||||
|
|
||||||
// 如果用户正在查看这个具体的会话,不增加未读数
|
|
||||||
if (isViewingThisConversation) {
|
|
||||||
console.log("用户正在查看该会话,不增加未读数");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 只在用户不在该会话的聊天页面时才增加未读数
|
|
||||||
conversation.unreadCount = (conversation.unreadCount || 0) + 1;
|
|
||||||
console.log(
|
|
||||||
"已更新会话未读数:",
|
|
||||||
conversation.name,
|
|
||||||
"unreadCount:",
|
|
||||||
conversation.unreadCount
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -487,18 +453,7 @@ const handleRefresh = async () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// 页面加载
|
// 页面加载
|
||||||
onLoad(() => {
|
onLoad( async() => {
|
||||||
console.log("消息列表页面加载");
|
|
||||||
});
|
|
||||||
|
|
||||||
// 清理消息文本(移除换行符)
|
|
||||||
const cleanMessageText = (text) => {
|
|
||||||
if (!text) return "";
|
|
||||||
return text.replace(/[\r\n]+/g, " ").trim();
|
|
||||||
};
|
|
||||||
|
|
||||||
// 页面显示
|
|
||||||
onShow(async () => {
|
|
||||||
try {
|
try {
|
||||||
// 初始化IM
|
// 初始化IM
|
||||||
const imReady = await initIM();
|
const imReady = await initIM();
|
||||||
@ -514,6 +469,17 @@ onShow(async () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 清理消息文本(移除换行符)
|
||||||
|
const cleanMessageText = (text) => {
|
||||||
|
if (!text) return "";
|
||||||
|
return text.replace(/[\r\n]+/g, " ").trim();
|
||||||
|
};
|
||||||
|
|
||||||
|
// 页面显示
|
||||||
|
onShow(async () => {
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
// 页面隐藏
|
// 页面隐藏
|
||||||
onHide(() => {
|
onHide(() => {
|
||||||
// 清除防抖定时器
|
// 清除防抖定时器
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
<view v-if="member" class="flex flex-col h-full items-center justify-center">
|
<view v-if="member" class="flex flex-col h-full items-center justify-center">
|
||||||
<view class="business-card">
|
<view class="business-card">
|
||||||
<view class="flex">
|
<view class="flex">
|
||||||
<image class="mr-10 avatar" :src="member.avatar || '/static/default-avatar.png'"></image>
|
<image class="mr-10 avatar" :src="member.avatar || '/static/default-avatar.svg'"></image>
|
||||||
<view class="w-0 flex-grow leading-normal">
|
<view class="w-0 flex-grow leading-normal">
|
||||||
<view class="flex items-center">
|
<view class="flex items-center">
|
||||||
<view class="mr-5 text-lg font-semibold text-dark">{{ member.anotherName }}</view>
|
<view class="mr-5 text-lg font-semibold text-dark">{{ member.anotherName }}</view>
|
||||||
|
|||||||
@ -25,7 +25,7 @@
|
|||||||
</view>
|
</view>
|
||||||
<view v-for="i in teammate.leaders" :key="i._id" class="mt-12 flex p-10 border-primary rounded-sm"
|
<view v-for="i in teammate.leaders" :key="i._id" class="mt-12 flex p-10 border-primary rounded-sm"
|
||||||
@click="toHomePage(i.userid)">
|
@click="toHomePage(i.userid)">
|
||||||
<image class="flex-shrink-0 mr-10 avatar" :src="i.avatar || '/static/default-avatar.png'"></image>
|
<image class="flex-shrink-0 mr-10 avatar" :src="i.avatar || '/static/default-avatar.svg'"></image>
|
||||||
<view class="w-0 flex-grow leading-normal">
|
<view class="w-0 flex-grow leading-normal">
|
||||||
<view class="flex items-center justify-between">
|
<view class="flex items-center justify-between">
|
||||||
<view class="flex-shrink-0 mr-5 view-lg text-dark font-semibold">{{ i.anotherName }}</view>
|
<view class="flex-shrink-0 mr-5 view-lg text-dark font-semibold">{{ i.anotherName }}</view>
|
||||||
@ -50,7 +50,7 @@
|
|||||||
</view>
|
</view>
|
||||||
<view v-for="i in teammate.members" :key="i._id" class="mt-12 flex p-10 border-primary rounded-sm"
|
<view v-for="i in teammate.members" :key="i._id" class="mt-12 flex p-10 border-primary rounded-sm"
|
||||||
@click="toHomePage(i.userid)">
|
@click="toHomePage(i.userid)">
|
||||||
<image class="flex-shrink-0 mr-10 avatar" :src="i.avatar || '/static/default-avatar.png'"></image>
|
<image class="flex-shrink-0 mr-10 avatar" :src="i.avatar || '/static/default-avatar.svg'"></image>
|
||||||
<view class="w-0 flex-grow leading-normal">
|
<view class="w-0 flex-grow leading-normal">
|
||||||
<view class="flex items-center justify-between">
|
<view class="flex items-center justify-between">
|
||||||
<view class="flex-shrink-0 mr-5 view-lg text-dark font-semibold">{{ i.anotherName }}</view>
|
<view class="flex-shrink-0 mr-5 view-lg text-dark font-semibold">{{ i.anotherName }}</view>
|
||||||
|
|||||||
@ -144,7 +144,10 @@ function mergeConversationData(conversation, groupDetailsMap) {
|
|||||||
name: formatConversationName(groupDetail),
|
name: formatConversationName(groupDetail),
|
||||||
|
|
||||||
// 更新头像(优先使用已有头像,避免闪动)
|
// 更新头像(优先使用已有头像,避免闪动)
|
||||||
avatar: conversation.avatar || groupDetail.patient?.avatar || '/static/default-avatar.png'
|
avatar: conversation.avatar || groupDetail.patient?.avatar || '/static/default-avatar.svg',
|
||||||
|
|
||||||
|
// 【修复】保留未读消息数(确保不被覆盖)
|
||||||
|
unreadCount: conversation.unreadCount || 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1439,15 +1439,15 @@ class TimChatManager {
|
|||||||
// 更新当前会话ID
|
// 更新当前会话ID
|
||||||
this.currentConversationID = conversationID
|
this.currentConversationID = conversationID
|
||||||
|
|
||||||
// 清空当前消息列表
|
// 不清空消息列表,只重置分页状态
|
||||||
this.messageList = []
|
// this.messageList = []
|
||||||
|
|
||||||
// 重置分页状态
|
// 重置分页状态
|
||||||
this.nextReqMessageID = ""
|
this.nextReqMessageID = ""
|
||||||
this.isCompleted = false
|
this.isCompleted = false
|
||||||
this.isLoadingMore = false
|
this.isLoadingMore = false
|
||||||
|
|
||||||
console.log(" 会话ID已更新,消息列表已清空,分页状态已重置")
|
console.log(" 会话ID已更新,分页状态已重置")
|
||||||
|
|
||||||
// 进入群聊会话,默认加载20条消息
|
// 进入群聊会话,默认加载20条消息
|
||||||
this.enterGroupConversation(conversationID, 20)
|
this.enterGroupConversation(conversationID, 20)
|
||||||
@ -1455,6 +1455,7 @@ class TimChatManager {
|
|||||||
|
|
||||||
// 进入群聊会话
|
// 进入群聊会话
|
||||||
async enterGroupConversation(groupID, count = 20) {
|
async enterGroupConversation(groupID, count = 20) {
|
||||||
|
|
||||||
console.log("【enterGroupConversation】进入群聊会话, groupID:", groupID, "count:", count)
|
console.log("【enterGroupConversation】进入群聊会话, groupID:", groupID, "count:", count)
|
||||||
|
|
||||||
let conversationID = groupID
|
let conversationID = groupID
|
||||||
@ -1470,8 +1471,8 @@ class TimChatManager {
|
|||||||
|
|
||||||
console.log(" conversationID:", conversationID, "actualGroupID:", actualGroupID)
|
console.log(" conversationID:", conversationID, "actualGroupID:", actualGroupID)
|
||||||
|
|
||||||
// 清空消息列表,准备加载新会话的消息
|
// 不清空消息列表,只在首次进入时清空
|
||||||
this.messageList = []
|
// this.messageList = []
|
||||||
|
|
||||||
// 确保设置当前会话ID,防止消息混淆
|
// 确保设置当前会话ID,防止消息混淆
|
||||||
this.currentConversationID = conversationID
|
this.currentConversationID = conversationID
|
||||||
@ -2220,8 +2221,8 @@ class TimChatManager {
|
|||||||
// 确保使用当前会话的conversationID
|
// 确保使用当前会话的conversationID
|
||||||
const conversationID = this.conversation.conversationID || this.currentConversationID
|
const conversationID = this.conversation.conversationID || this.currentConversationID
|
||||||
|
|
||||||
// 获取图片尺寸信息
|
// 使用默认尺寸,不调用接口获取图片信息
|
||||||
const imageInfo = await this.getImageInfo(imageFile);
|
const defaultImageInfo = { width: 400, height: 300 }
|
||||||
|
|
||||||
const localMessage = {
|
const localMessage = {
|
||||||
ID: `local_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`,
|
ID: `local_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`,
|
||||||
@ -2230,8 +2231,8 @@ class TimChatManager {
|
|||||||
payload: {
|
payload: {
|
||||||
imageInfoArray: [{
|
imageInfoArray: [{
|
||||||
url: this.getImageUrl(imageFile),
|
url: this.getImageUrl(imageFile),
|
||||||
width: imageInfo.width,
|
width: defaultImageInfo.width,
|
||||||
height: imageInfo.height
|
height: defaultImageInfo.height
|
||||||
}]
|
}]
|
||||||
},
|
},
|
||||||
lastTime: Date.now(),
|
lastTime: Date.now(),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user