10.9提交
This commit is contained in:
+134
-136
@@ -25,7 +25,7 @@
|
||||
<view class="header-right" @click="goMessage">
|
||||
<view class="message-icon">
|
||||
<uni-icons type="email" size="32" color="#fff"></uni-icons>
|
||||
<view v-if="hasUnread" class="red-dot"></view>
|
||||
<view v-if="hasTip" class="red-dot"></view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -172,6 +172,7 @@
|
||||
class="course-item"
|
||||
v-for="(item, index) in courseList"
|
||||
:key="index"
|
||||
@click="goCourseDetail(item)"
|
||||
>
|
||||
<view class="course-card">
|
||||
<up-image
|
||||
@@ -281,7 +282,7 @@
|
||||
</view>
|
||||
|
||||
<!-- 自定义Tabbar -->
|
||||
<custom-tabbar ref="tabbarRef" @tabChange="onTabChange"></custom-tabbar>
|
||||
<custom-tabbar ref="tabbarRef" ></custom-tabbar>
|
||||
</view>
|
||||
<unidialog
|
||||
:visible="visible"
|
||||
@@ -319,11 +320,19 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive, watch, onMounted, nextTick, computed,onUnmounted} from "vue";
|
||||
import {
|
||||
ref,
|
||||
reactive,
|
||||
watch,
|
||||
onMounted,
|
||||
nextTick,
|
||||
computed,
|
||||
onUnmounted,
|
||||
} from "vue";
|
||||
import { onShow, onLoad, onPageScroll } from "@dcloudio/uni-app";
|
||||
import CustomTabbar from "@/components/tabBar/tabBar.vue";
|
||||
import unidialog from "@/components/dialog/dialog.vue";
|
||||
import { autorun } from 'mobx'
|
||||
import { autorun } from "mobx";
|
||||
import api from "@/api/api.js";
|
||||
import navTo from "@/utils/navTo.js";
|
||||
import docUrl from "@/utils/docUrl.js";
|
||||
@@ -340,9 +349,12 @@ import bo_bg from "@/static/bo_bg.png";
|
||||
import nosign from "@/static/home_no_qiandao_icon.png";
|
||||
import sign from "@/static/home_qiandao_icon.png";
|
||||
import signImg from "@/static/sign_in_bng_big.png";
|
||||
import dayjs from "dayjs"
|
||||
import dayjs from "dayjs";
|
||||
import { V2NIMConst } from "@/utils/im/nim";
|
||||
import { V2NIMConversationForUI, V2NIMLocalConversationForUI } from "@/utils/im/nim";
|
||||
import {
|
||||
V2NIMConversationForUI,
|
||||
V2NIMLocalConversationForUI,
|
||||
} from "@/utils/im/nim";
|
||||
import { setTabUnread } from "@/utils/im/msg";
|
||||
const expertDetail = reactive({});
|
||||
const hasConsult = ref(false);
|
||||
@@ -362,46 +374,52 @@ const hasSign = ref(false);
|
||||
// 滚动相关状态
|
||||
const scrollTop = ref(0);
|
||||
const bannerHeight = 400; // 轮播图高度,单位rpx
|
||||
const hasQeqPatient = ref(false);
|
||||
const hasQeqPatient = ref(false);
|
||||
const patientList = ref([]);
|
||||
const patientListByGBK = async () => {
|
||||
const res = await api.patientListByGBK();
|
||||
if(res.code == 1){
|
||||
patientList.value = res.data;
|
||||
hasQeqPatient.value = true;
|
||||
comparePatient();
|
||||
}
|
||||
|
||||
const res = await api.patientListByGBK();
|
||||
if (res.code == 1) {
|
||||
patientList.value = res.data;
|
||||
hasQeqPatient.value = true;
|
||||
comparePatient();
|
||||
}
|
||||
};
|
||||
const handleReadMsg = () => {
|
||||
if(!hasQeqPatient.value){
|
||||
patientListByGBK();
|
||||
}else{
|
||||
comparePatient();
|
||||
}
|
||||
if (!hasQeqPatient.value) {
|
||||
patientListByGBK();
|
||||
} else {
|
||||
comparePatient();
|
||||
}
|
||||
};
|
||||
const goCourseDetail=(item)=>{
|
||||
navTo({
|
||||
url: "/pages_course/course_detail/course_detail?id="+item.id,
|
||||
});
|
||||
}
|
||||
|
||||
const comparePatient = () => {
|
||||
let count = 0;
|
||||
for(let i = 0; i < patientList.value.length; i++){
|
||||
for(let j = 0; j < conversationList.value.length; j++){
|
||||
if(conversationList.value[j].conversationId.indexOf(patientList.value[i].uuid.toLowerCase()) > -1){
|
||||
count += conversationList.value[j].unreadCount;
|
||||
|
||||
}
|
||||
}
|
||||
};
|
||||
console.log(count);
|
||||
if(count > 0){
|
||||
hasMsg.value = true;
|
||||
}else{
|
||||
hasMsg.value = false;
|
||||
}
|
||||
}
|
||||
let count = 0;
|
||||
for (let i = 0; i < patientList.value.length; i++) {
|
||||
for (let j = 0; j < conversationList.value.length; j++) {
|
||||
if (
|
||||
conversationList.value[j].conversationId.indexOf(
|
||||
patientList.value[i].uuid.toLowerCase()
|
||||
) > -1
|
||||
) {
|
||||
count += conversationList.value[j].unreadCount;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (count > 0) {
|
||||
hasMsg.value = true;
|
||||
} else {
|
||||
hasMsg.value = false;
|
||||
}
|
||||
};
|
||||
const subscribeUserStatus = (
|
||||
conversations: (V2NIMConversationForUI | V2NIMLocalConversationForUI)[]
|
||||
) => {
|
||||
const loginStateVisible = uni.$UIKitStore.localOptions.loginStateVisible
|
||||
const loginStateVisible = uni.$UIKitStore.localOptions.loginStateVisible;
|
||||
if (loginStateVisible) {
|
||||
// 订阅会话列表中 单聊的在线离线状态
|
||||
const accounts = conversations
|
||||
@@ -413,22 +431,22 @@ const subscribeUserStatus = (
|
||||
.map((item) => {
|
||||
return uni.$UIKitNIM?.V2NIMConversationIdUtil.parseConversationTargetId(
|
||||
item.conversationId
|
||||
)
|
||||
})
|
||||
);
|
||||
});
|
||||
// 将 accounts 拆分成多个长度不超过 100 的子数组
|
||||
const chunkSize = 100
|
||||
const chunkSize = 100;
|
||||
|
||||
const length = accounts.length
|
||||
const length = accounts.length;
|
||||
|
||||
for (let i = 0; i < length; i += chunkSize) {
|
||||
const chunk = accounts.slice(i, i + chunkSize)
|
||||
const chunk = accounts.slice(i, i + chunkSize);
|
||||
|
||||
if (chunk.length > 0) {
|
||||
uni.$UIKitStore.subscriptionStore.subscribeUserStatusActive(chunk)
|
||||
uni.$UIKitStore.subscriptionStore.subscribeUserStatusActive(chunk);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**会话列表 */
|
||||
const conversationList = ref<
|
||||
@@ -436,17 +454,16 @@ const conversationList = ref<
|
||||
| (V2NIMConversationForUI & { renderKey: string })
|
||||
| (V2NIMLocalConversationForUI & { renderKey: string })
|
||||
)[]
|
||||
>([])
|
||||
>([]);
|
||||
/**是否是云端会话 */
|
||||
const enableV2CloudConversation =
|
||||
uni.$UIKitStore?.sdkOptions?.enableV2CloudConversation
|
||||
|
||||
uni.$UIKitStore?.sdkOptions?.enableV2CloudConversation;
|
||||
|
||||
/** 监听会话列表数据变更,实时更新 conversationList */
|
||||
const conversationListWatch = autorun(() => {
|
||||
const _conversationList = enableV2CloudConversation
|
||||
? uni.$UIKitStore?.uiStore?.conversations
|
||||
: uni.$UIKitStore?.uiStore?.localConversations
|
||||
: uni.$UIKitStore?.uiStore?.localConversations;
|
||||
|
||||
conversationList.value = _conversationList
|
||||
?.map(
|
||||
@@ -456,7 +473,7 @@ const conversationListWatch = autorun(() => {
|
||||
// 为什么要加一个renderKey 直接在渲染的时候写 :key = conversation.conversationId 不就行了吗?
|
||||
// 如果不加,在渲染的时候,就会出现会话列表显示undefined,uniapp 很奇怪的问题
|
||||
renderKey: conversation.conversationId,
|
||||
}
|
||||
};
|
||||
}
|
||||
)
|
||||
.sort(
|
||||
@@ -464,21 +481,19 @@ const conversationListWatch = autorun(() => {
|
||||
a: V2NIMConversationForUI | V2NIMLocalConversationForUI,
|
||||
b: V2NIMConversationForUI | V2NIMLocalConversationForUI
|
||||
) => b.sortOrder - a.sortOrder
|
||||
)
|
||||
console.log(222);
|
||||
console.log(conversationList?.value);
|
||||
handleReadMsg();
|
||||
);
|
||||
|
||||
handleReadMsg();
|
||||
//setTabUnread()
|
||||
})
|
||||
});
|
||||
// 监听数组长度变化
|
||||
watch(
|
||||
() => conversationList?.value?.length, // 监听 length 属性
|
||||
() => {
|
||||
subscribeUserStatus(conversationList?.value);
|
||||
console.log(11111);
|
||||
console.log(conversationList?.value);
|
||||
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
/** 连接状态监听 断网重连后重新订阅 */
|
||||
const connectWatch = autorun(() => {
|
||||
@@ -488,10 +503,9 @@ const connectWatch = autorun(() => {
|
||||
uni.$UIKitStore?.connectStore.connectStatus ===
|
||||
V2NIMConst.V2NIMConnectStatus.V2NIM_CONNECT_STATUS_CONNECTED
|
||||
) {
|
||||
subscribeUserStatus(conversationList?.value)
|
||||
subscribeUserStatus(conversationList?.value);
|
||||
}
|
||||
})
|
||||
|
||||
});
|
||||
|
||||
// 获取设备像素比
|
||||
const getPixelRatio = () => {
|
||||
@@ -613,7 +627,7 @@ const change = (e) => {
|
||||
|
||||
// 消息通知切换事件
|
||||
const onNoticeChange = (e) => {
|
||||
console.log("消息通知切换:", e.detail.current);
|
||||
|
||||
};
|
||||
|
||||
// 使用 dayjs 格式化为 月日(如 8月6日)
|
||||
@@ -626,7 +640,7 @@ const formatToMonthDay = (val) => {
|
||||
|
||||
// 消息通知点击事件
|
||||
const onNoticeClick = (item) => {
|
||||
console.log("点击消息通知:", item);
|
||||
|
||||
uni.showToast({
|
||||
title: `查看${item.content}`,
|
||||
icon: "none",
|
||||
@@ -658,7 +672,6 @@ const onNoticeClick = (item) => {
|
||||
|
||||
// 查看更多消息
|
||||
const onNoticeMore = () => {
|
||||
console.log("查看更多消息");
|
||||
uni.navigateTo({
|
||||
url: "/pages/notice/list",
|
||||
});
|
||||
@@ -666,7 +679,6 @@ const onNoticeMore = () => {
|
||||
|
||||
// 精彩回放点击事件
|
||||
const onReplayClick = (item) => {
|
||||
console.log("点击精彩回放:", item);
|
||||
navTo({
|
||||
url: "/pages_app/videoDetail/videoDetail?id=" + item.id,
|
||||
});
|
||||
@@ -674,8 +686,6 @@ const onReplayClick = (item) => {
|
||||
|
||||
// 网格点击事件
|
||||
const onClick = (index, name) => {
|
||||
console.log(name);
|
||||
console.log("点击了第" + index + "个");
|
||||
let url = "";
|
||||
if (name == "我的患者") {
|
||||
url = "/pages_app/patientMsg/patientMsg";
|
||||
@@ -759,36 +769,10 @@ const onBannerClick = (item, index) => {
|
||||
} else {
|
||||
// 如果存在外链path,优先按平台打开
|
||||
if (item.path) {
|
||||
// #ifdef H5
|
||||
window.open(item.path, "_blank");
|
||||
// #endif
|
||||
|
||||
// #ifdef APP-PLUS
|
||||
plus.runtime.openURL(item.path);
|
||||
// #endif
|
||||
|
||||
// #ifdef MP
|
||||
const encoded = encodeURIComponent(item.path);
|
||||
uni.navigateTo({
|
||||
url: `/pages_app/webview/webview?url=${encoded}`,
|
||||
});
|
||||
// #endif
|
||||
return;
|
||||
}
|
||||
|
||||
// 如果是新闻类型且有uuid,可跳转新闻详情H5
|
||||
if (item.uuid) {
|
||||
const url = `https://dev-doc.igandan.com/app/html/news/${item.uuid}.html`;
|
||||
// #ifdef H5
|
||||
window.open(url, "_blank");
|
||||
// #endif
|
||||
// #ifdef APP-PLUS
|
||||
plus.runtime.openURL(url);
|
||||
// #endif
|
||||
// #ifdef MP
|
||||
const encoded = encodeURIComponent(url);
|
||||
uni.navigateTo({ url: `/pages_app/webview/webview?url=${encoded}` });
|
||||
// #endif
|
||||
navTo({
|
||||
url: `/pages_app/webview/webview?url=${encoded}`,
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -816,50 +800,69 @@ const onEsiteClick = (item) => {
|
||||
});
|
||||
// #endif
|
||||
};
|
||||
const hasTip = ref(false);
|
||||
const goMessage = () => {
|
||||
navTo({
|
||||
url: "/pages_app/msg/msg",
|
||||
});
|
||||
};
|
||||
|
||||
const getUnReadList = () => {
|
||||
api.unReadList({}).then(res => {
|
||||
if (res.code === 200 && res.data) {
|
||||
let count=0;
|
||||
for (const key in res.data) {
|
||||
count+= Number(res.data[key]);
|
||||
}
|
||||
if(count>0){
|
||||
hasTip.value=true;
|
||||
}else{
|
||||
hasTip.value=false;
|
||||
}
|
||||
// 更新角标数据
|
||||
|
||||
}
|
||||
}).catch(err => {
|
||||
console.error('获取未读消息列表失败:', err);
|
||||
});
|
||||
};
|
||||
const downAndSave = (url) => {
|
||||
uni.downloadFile({
|
||||
url: url,
|
||||
success: (res) => {
|
||||
if (res.statusCode === 200) {
|
||||
uni.saveFile({
|
||||
tempFilePath: res.tempFilePath,
|
||||
success: (saveRes) => {
|
||||
console.log(saveRes);
|
||||
console.log("文件保存成功:", saveRes.savedFilePath);
|
||||
uni.getSavedFileList({
|
||||
success: function (res) {
|
||||
console.log("保存的文件列表");
|
||||
console.log(res.fileList);
|
||||
},
|
||||
});
|
||||
},
|
||||
fail: (err) => {
|
||||
console.error("文件保存失败:", err);
|
||||
},
|
||||
});
|
||||
}
|
||||
},
|
||||
});
|
||||
};
|
||||
// 实用指南点击事件
|
||||
const onGuideClick = (item) => {
|
||||
// 如果有PDF链接,直接打开
|
||||
if (item.path) {
|
||||
const pdfUrl = docUrl + item.path;
|
||||
console.log(pdfUrl);
|
||||
if (pdfUrl) {
|
||||
// H5 端
|
||||
// #ifdef H5
|
||||
window.open(pdfUrl, "_blank");
|
||||
// #endif
|
||||
|
||||
// App 端
|
||||
// #ifdef APP-PLUS
|
||||
plus.runtime.openURL(pdfUrl);
|
||||
// #endif
|
||||
|
||||
// 小程序端:使用内嵌 webview 页面打开
|
||||
// #ifdef MP-WEIXIN
|
||||
const encoded = encodeURIComponent(pdfUrl);
|
||||
uni.navigateTo({
|
||||
url: `/pages_app/webview/webview?url=${encoded}`,
|
||||
});
|
||||
// #endif
|
||||
return;
|
||||
}
|
||||
downAndSave(pdfUrl);
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: "暂无下载链接",
|
||||
icon: "none",
|
||||
});
|
||||
}
|
||||
|
||||
// 没有PDF链接时,根据类型跳转到不同页面
|
||||
// if (item.type === 'guide') {
|
||||
// uni.navigateTo({
|
||||
// url: '/pages/guide/detail?id=' + item.id
|
||||
// });
|
||||
// } else if (item.type === 'courseware') {
|
||||
// uni.navigateTo({
|
||||
// url: '/pages/courseware/list'
|
||||
// });
|
||||
// }
|
||||
};
|
||||
|
||||
//测试tabbar功能的方法
|
||||
@@ -894,7 +897,6 @@ const getHomeData = async () => {
|
||||
uni.showLoading({ title: "加载中..." });
|
||||
|
||||
const res = await api.getHomeData();
|
||||
console.log("首页数据:", res);
|
||||
|
||||
if (res && res.data) {
|
||||
const data = res.data;
|
||||
@@ -983,6 +985,7 @@ const getHomeData = async () => {
|
||||
title: item.title || "",
|
||||
status: item.video_num != null ? `共${item.video_num}讲` : "",
|
||||
avatar: item.index_img || "",
|
||||
id: item.id || "",
|
||||
}))
|
||||
);
|
||||
}
|
||||
@@ -1045,7 +1048,6 @@ const getHomeData = async () => {
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("获取首页数据失败:", error);
|
||||
uni.showToast({
|
||||
title: "数据加载失败",
|
||||
icon: "none",
|
||||
@@ -1058,16 +1060,12 @@ const getHomeData = async () => {
|
||||
// 页面滚动监听
|
||||
onPageScroll((e) => {
|
||||
scrollTop.value = e.scrollTop;
|
||||
// 调试信息
|
||||
if (scrollTop.value % 50 === 0) {
|
||||
// 每滚动50px打印一次
|
||||
console.log("滚动位置:", scrollTop.value, "背景色:", headerBgColor.value);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
// 页面加载
|
||||
onLoad(() => {
|
||||
console.log("首页加载完成");
|
||||
|
||||
// 获取首页数据
|
||||
getHomeData();
|
||||
// 页面加载完成后测试tabbar功能
|
||||
@@ -1078,10 +1076,10 @@ onLoad(() => {
|
||||
onShow(() => {
|
||||
//imLogin();
|
||||
if (conversationList.value?.length) {
|
||||
subscribeUserStatus(conversationList?.value)
|
||||
subscribeUserStatus(conversationList?.value);
|
||||
}
|
||||
handleReadMsg();
|
||||
|
||||
getUnReadList();
|
||||
});
|
||||
|
||||
// 跳转到精品课首页
|
||||
|
||||
Reference in New Issue
Block a user