From c27827a337477c6eaba028292e2259e5303746dc Mon Sep 17 00:00:00 2001 From: sx <2427911852@qq.com> Date: Mon, 10 Mar 2025 17:24:53 +0800 Subject: [PATCH] =?UTF-8?q?2025.03.10=20=E5=B7=A5=E4=BD=9C=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- jiuyi2/common/js/util.js | 27 +- jiuyi2/manifest.json | 4 +- jiuyi2/pages.json | 14 + jiuyi2/pages/index/index.nvue | 1 - jiuyi2/pages/index/report.vue | 442 +++++------ jiuyi2/pages/news/chat/chat - 副本.vue | 748 ++++++++++++++++++ jiuyi2/pages/news/chat/chat.vue | 207 ++--- .../news/chat/components/news-temp/index.vue | 18 +- jiuyi2/pages/news/chat/fn.js | 2 +- jiuyi2/pages/news/chat/index.scss | 3 +- jiuyi2/pages/news/detail/group.vue | 175 +++- jiuyi2/pages/news/detail/user.vue | 12 + jiuyi2/pages/news/group/chatList.vue | 20 +- jiuyi2/pages/news/group/create.vue | 2 + jiuyi2/pages/news/group/invite.vue | 58 +- jiuyi2/pages/news/group/remove.vue | 123 +++ 16 files changed, 1491 insertions(+), 365 deletions(-) create mode 100644 jiuyi2/pages/news/chat/chat - 副本.vue create mode 100644 jiuyi2/pages/news/detail/user.vue create mode 100644 jiuyi2/pages/news/group/remove.vue diff --git a/jiuyi2/common/js/util.js b/jiuyi2/common/js/util.js index 4f512616..f9a91a5d 100644 --- a/jiuyi2/common/js/util.js +++ b/jiuyi2/common/js/util.js @@ -1522,13 +1522,28 @@ const util = { * @param {Object} option.type 聊天类型 C2C单聊 GROUP群聊 */ toChat(option) { - uni.navigateTo({ - url: util.setUrl('/pages/news/chat/chat', { - name: option.name, - msgId: option.msgId, - type: option.type, - num: option.num, + // 跳转目标页面路由 + let target = 'pages/news/chat/chat' + // 跳转路径 + let url = util.setUrl(`/${target}`, { + name: option.name, + msgId: option.msgId, + type: option.type, + num: option.num, + }) + // 获取当前页面栈 + let pages = getCurrentPages(); + let find_index = pages.findIndex(node => node.route == target) + + if (find_index > -1) { + uni.navigateBack({ + delta: find_index, }) + uni.redirectTo({ + url, + }) + } else uni.navigateTo({ + url, }) }, diff --git a/jiuyi2/manifest.json b/jiuyi2/manifest.json index f0e0b21e..ecec5357 100644 --- a/jiuyi2/manifest.json +++ b/jiuyi2/manifest.json @@ -2,8 +2,8 @@ "name" : "九亿", "appid" : "__UNI__08B31BC", "description" : "", - "versionName" : "1.0.13", - "versionCode" : 1013, + "versionName" : "1.0.14", + "versionCode" : 1014, "transformPx" : false, /* 5+App特有相关 */ "app-plus" : { diff --git a/jiuyi2/pages.json b/jiuyi2/pages.json index 56971c7d..781ae621 100644 --- a/jiuyi2/pages.json +++ b/jiuyi2/pages.json @@ -776,6 +776,20 @@ { "navigationBarTitleText" : "邀请加群" } + }, + { + "path" : "pages/news/group/remove", + "style" : + { + "navigationBarTitleText" : "移除群成员" + } + }, + { + "path" : "pages/news/detail/user", + "style" : + { + "navigationBarTitleText" : "聊天信息" + } } ], diff --git a/jiuyi2/pages/index/index.nvue b/jiuyi2/pages/index/index.nvue index 573054ad..e4d60480 100644 --- a/jiuyi2/pages/index/index.nvue +++ b/jiuyi2/pages/index/index.nvue @@ -461,7 +461,6 @@ dom.scrollToElement(element, { animated: true }) - console.log('current', current[tab_index]) // 如果视频切换 if (current[tab_index] != currentLast[tab_index]) { diff --git a/jiuyi2/pages/index/report.vue b/jiuyi2/pages/index/report.vue index 396f48d1..211583b4 100644 --- a/jiuyi2/pages/index/report.vue +++ b/jiuyi2/pages/index/report.vue @@ -1,192 +1,192 @@ \ No newline at end of file diff --git a/jiuyi2/pages/news/chat/chat - 副本.vue b/jiuyi2/pages/news/chat/chat - 副本.vue new file mode 100644 index 00000000..b9c4cbf5 --- /dev/null +++ b/jiuyi2/pages/news/chat/chat - 副本.vue @@ -0,0 +1,748 @@ + + + + + + \ No newline at end of file diff --git a/jiuyi2/pages/news/chat/chat.vue b/jiuyi2/pages/news/chat/chat.vue index b2906a02..8040fe60 100644 --- a/jiuyi2/pages/news/chat/chat.vue +++ b/jiuyi2/pages/news/chat/chat.vue @@ -24,6 +24,9 @@ onPageScroll, onUnload } from "@dcloudio/uni-app" + import { + getHistoryMsg + } from './fn.js' // 单条消息 import newsTemplate from './components/news-temp' @@ -66,12 +69,12 @@ }) // 列表数据 const list = reactive({ - // 列表条数 - limit: 20, - //显示的数据 - data: [], - // - total: 0, + // 消息列表 + messageList: [], + // 用于续拉,分页续拉时需传入该字段 + nextReqMessageID: undefined, + // 表示是否已经拉完所有消息 + isCompleted: false, }) // 页面标题 const pageTitle = ref('') @@ -89,6 +92,8 @@ const videoContext = ref(null) // 红包对象 const redPacket = reactive({}) + // 输入框聚焦 + const inputFocus = ref(false) onLoad(option => { // 标题 @@ -172,6 +177,8 @@ // 点击发送 function handleSend() { + inputFocus.value = false + // 发送消息 sendMsg({ query: { @@ -185,6 +192,7 @@ success: () => { // 清空已发送的消息 content.value = '' + inputFocus.value = true } }) } @@ -315,54 +323,35 @@ */ function getHistory(param = {}) { // 验证sdk是否准备完毕 - // #ifdef APP - let isReady = uni.$chat.isReady(); - if (!isReady && userinfo.value.id) { - setTimeout(function() { - getHistory() - }, 200); - return - } - // #endif + // let isReady = uni.$chat.isReady(); + // if (!isReady && userinfo.value.id) { + // setTimeout(function() { + // getHistory() + // }, 200); + // return + // } loading.value = true - - // 获取单聊聊天记录 - let request = api.news.getUserMsgHistory - // 如果是群聊 获取群聊聊天记录 - if (msg.type == 'GROUP') request = api.news.getGroupMsgHistory + console.log('getHistory', msg, `${msg.type}${msg.id}`) // 获取历史记录 - request({ - query: { - msgId: param.msgId || '', - fromId: userinfo.value.id, - toId: msg.id, - groupId: msg.id, - limit: param.limit || list.limit, - }, + getHistoryMsg({ + conversationID: `${msg.type}${msg.id}`, }).then(res => { - if (res.code === 200) { + console.log('getHistoryMsg', res) + if (res.code === 0) { // 结果 const result = res.data - // 头像路径 - list.faceUrl = result.faceUrl + if (!list.nextReqMessageID) list.messageList.length = 0 + // 下次拉取的消息id + list.nextReqMessageID = result.nextReqMessageID + // 是否拉取完毕 + list.isCompleted = result.isCompleted + // 消息体 + list.messageList = result.messageList.map(item => { + console.log('msg item', item) + return item + }) - // 如果是最新消息 - if (param.limit == 1) { - list.data.push(...result.list.map(item => { - item.callbackData = JSON.parse(item.callbackJson) - return item - })) - } else { - // 追加 - list.data.unshift(...result.list.map(item => { - item.callbackData = JSON.parse(item.callbackJson) - return item - })) - } - console.log('getHostory', list.data) - // 总数 - list.total = result.total nextTick(() => { param.callback && param.callback() }) @@ -459,35 +448,18 @@ function handleMore(ev) { // 配置 const url = { - 'GROUP': util.setUrl('/pages/news/detail/group',{ + 'GROUP': util.setUrl('/pages/news/detail/group', { groupId: msg.id, }), - 'C2C': util.setUrl('/') + 'C2C': util.setUrl('/pages/index/videoHome', { + userId: msg.id, + }) } [msg.type] // 跳转详情 uni.navigateTo({ url, }) - return - const config = [{ - name: '举报', - callback: rs => { - uni.navigateTo({ - url: util.setUrl('/pages/index/report', { - userId: msg.id, - }) - }) - } - }] - - // - uni.showActionSheet({ - itemList: config.map(node => node.name), - success: rs => { - config[rs.tapIndex].callback() - } - }) } @@ -504,33 +476,78 @@ - - - -