From f53ec45c51350d41b132006466818a45e1490f47 Mon Sep 17 00:00:00 2001 From: Sun_sun <469361609@qq.com> Date: Fri, 10 Oct 2025 14:16:01 +0800 Subject: [PATCH] =?UTF-8?q?2025-10-10=20=E9=A1=B9=E7=9B=AE=E6=94=B6?= =?UTF-8?q?=E8=97=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/message.js | 2 +- api/program.js | 9 ++- pages/message/message.vue | 69 ++++++++++++++------- pages/program/program.vue | 2 +- pages/program/programDetail.vue | 106 +++++++++++++++++++++++++++++--- static/icon/Bookmark-active.png | Bin 0 -> 591 bytes 6 files changed, 153 insertions(+), 35 deletions(-) create mode 100644 static/icon/Bookmark-active.png diff --git a/api/message.js b/api/message.js index 13513ba..7dd4a45 100644 --- a/api/message.js +++ b/api/message.js @@ -2,7 +2,7 @@ import { http } from "../util/api" -const baseURL = "http://192.168.0.15:3007" +const baseURL = "http://192.168.0.12:3005/chat" // 项目相关API export const messageAPI = { diff --git a/api/program.js b/api/program.js index 4c48056..0598079 100644 --- a/api/program.js +++ b/api/program.js @@ -2,14 +2,19 @@ import { http } from "../util/api" -const baseURL = "http://192.168.0.15:3006" +const baseURL = "http://192.168.0.12:3005/term" // 项目相关API export const programAPI = { // 列表 getList: (params) => http.get(baseURL + '/program/list', params), isChat: (params) => http.get(baseURL + "/program/isChat", params), - getProgram: (id) => http.get(baseURL + "/program/" + id) + getProgram: (id) => http.get(baseURL + "/program/" + id), + collect: (data) => http.post(baseURL + '/program/collect', data), // 收藏 + unCollect: (data) => http.post(baseURL + '/program/uncollect', data), // 取消收藏 + collectList: (params) => http.get(baseURL + '/program/collectList', params), // 收藏列表 + isCollect: (params) => http.get(baseURL + '/program/isCollect', params), // 是否收藏 + randomNext: (params) => http.get(baseURL + '/program/random',params) } export default { diff --git a/pages/message/message.vue b/pages/message/message.vue index 434136a..e00afda 100644 --- a/pages/message/message.vue +++ b/pages/message/message.vue @@ -4,7 +4,7 @@ - + 容讯聊天室 @@ -49,7 +49,8 @@ - + + - - + + @@ -75,7 +77,7 @@ {{ item.program.startDate + "至" + item.program.endDate }} --> - 未读: {{item.userUnread.length}} + 消息未读: {{item.userUnread.length}} - 未读: {{item.chargeUnread.length}} + 消息未读: {{item.chargeUnread.length}} + @@ -128,11 +131,11 @@ // 搜索 const keyword = ref('') - + // 系统消息 const handleNavigateTo = () => { uni.navigateTo({ - url:'/pages/message/systemMessage' + url: '/pages/message/systemMessage' }) } @@ -157,6 +160,13 @@ currentMenu.value = val } + // 进入聊天 + const handleChat = (item) => { + uni.navigateTo({ + url: '/pages/message/chat?groupId=' + item.groupId + }) + } + // 消息 const messageList = ref([]) const user = ref() @@ -167,6 +177,8 @@ userId: '', customerId: '', }) + const pages = ref(0) + const status = ref('loadmore') const options = [ { text: '收藏', @@ -182,21 +194,24 @@ } ] - const handleChat = (item) => { - uni.navigateTo({ - url: '/pages/message/chat?groupId=' + item.groupId - }) - } - const loadData = () => { + if (status.value == 'nomore') return groupAPI.getList(params.value).then((res) => { - messageList.value = res.data.list - console.log(messageList.value); + pages.value = res.data.pages + messageList.value = messageList.value.concat(res.data.list) + params.value.page++ + if (params.value.page > pages.value) { + status.value = 'nomore' + } }) } onPullDownRefresh(async () => { - await loadData() + // 重新刷新,将参数初始化 + params.value.page = 1 + messageList.value = [] + status.value = 'loadmore' + loadData() uni.stopPullDownRefresh() }) @@ -319,26 +334,34 @@ } .message-list { - margin-top: 10rpx; + margin-top: 20rpx; .message-item { // border: 1px solid #000; - .other-message { + .other-program { padding: 20rpx 0rpx 20rpx 20rpx; background-color: #F8FBFF; - ; + border-bottom: 2rpx solid #f1f4ff; + + .item-unread{ + color: red; + } } .my-program { padding: 20rpx 0rpx 20rpx 20rpx; background-color: #F8FBFF; border-bottom: 2rpx solid #f1f4ff; + + .item-unread{ + color: red; + } } } - - .placeholder-box{ + + .placeholder-box { width: 100%; height: 50rpx; } diff --git a/pages/program/program.vue b/pages/program/program.vue index e53c256..eb1f796 100644 --- a/pages/program/program.vue +++ b/pages/program/program.vue @@ -42,7 +42,7 @@ - + diff --git a/pages/program/programDetail.vue b/pages/program/programDetail.vue index f25f940..2ceb554 100644 --- a/pages/program/programDetail.vue +++ b/pages/program/programDetail.vue @@ -3,7 +3,8 @@ @@ -101,6 +102,8 @@ 立刻融 + 不感兴趣?换一个 + @@ -174,7 +177,7 @@ import { programAPI } from '../../api/program'; import { onLoad } from '@dcloudio/uni-app' import { groupAPI } from '../../api/group'; - + const pdMsgRef = ref() const userId = ref() @@ -193,6 +196,64 @@ createDate: '', user: {} }) + const isCollect = ref(false) + + // 是否收藏项目 + const isCollectMethod = () => { + let params = { + programId: programId.value, + userId: userId.value + } + programAPI.isCollect(params).then(res => { + if (res.code == 200) { + isCollect.value = res.data.isCollect + } else { + pdMsgRef.value.show({ + title: res.msg, + type: 'error' + }) + } + }) + } + + // 收藏项目 + const handleCollect = () => { + let data = { + programId: programId.value, + userId: userId.value + } + if (isCollect.value) { + programAPI.unCollect(data).then(res => { + if (res.code == 200) { + isCollect.value = false + pdMsgRef.value.show({ + title: "取消收藏", + type: 'success' + }) + } else { + pdMsgRef.value.show({ + title: res.msg, + type: 'error' + }) + } + }) + } else { + programAPI.collect(data).then(res => { + if (res.code == 200) { + isCollect.value = true + pdMsgRef.value.show({ + title: "收藏成功", + type: 'success' + }) + } else { + pdMsgRef.value.show({ + title: res.msg, + type: 'error' + }) + } + }) + } + } const loadData = () => { programAPI.isChat({ @@ -215,14 +276,15 @@ }) onMounted(() => { + isCollectMethod() loadData() }) const handleChat = () => { if (isChat.value) { // 继续聊 - groupAPI.getOne({programId: programId.value, userId: userId.value}).then(res=>{ - if(res.code==200){ + groupAPI.getOne({ programId: programId.value, userId: userId.value }).then(res => { + if (res.code == 200) { // 进入聊天 uni.redirectTo({ url: '/pages/message/chat?groupId=' + res.data.groupId @@ -232,13 +294,12 @@ } else { // 开启群组聊天 groupAPI.add({ programId: programId.value, userId: userId.value }).then(res => { - console.log(res); - if(res.code==200){ + if (res.code == 200) { // 创建成功,进入聊天 uni.redirectTo({ url: '/pages/message/chat?groupId=' + res.data.groupId }) - }else{ + } else { pdMsgRef.value.show({ title: res.msg, type: 'error' @@ -271,7 +332,6 @@ // 立刻融 确认选择 const handleChose = () => { if (!is_agree.value) { - console.log("change"); showErrMsg.value = true return } @@ -299,6 +359,27 @@ showFile.value = false showWarning.value = true } + + // 不感兴趣,换一个 + const handleChange = () => { + const params = { + userId: userId.value, + programId: programId.value + } + programAPI.randomNext(params).then(res => { + if (res.code == 200) { + const nextPid = res.data.id + uni.redirectTo({ + url: '/pages/program/programDetail?programId=' + nextPid + }) + } else { + pdMsgRef.value.show({ + title: res.msg, + type: 'error' + }) + } + }) + }