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 @@
@@ -290,66 +290,66 @@ function videoInfo(param) {
\ 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 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{ item.callbackData.from_name }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 发送
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{ redPacket.fromName }}的红包
+
+ {{ redPacket.blessing }}
+
+ 红包已过期
+ 来晚啦,红包已被抢完
+
+
+
+ 已领取
+ {{ redPacket.amount }}
+ 余额
+ 积分
+
+
+
+
+ 已
+ 开
+
+
+
+
+
+
+
+
+
+
+
\ 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 @@
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+ {{item.payload.operatorInfo.nick}} 邀请
+ {{user.nick}}
+ 加入群聊
+
-
+ {{item.payload.operatorInfo.nick}} 加入了群聊
-
-
+
+ {{item.payload.operatorInfo.nick}} 退出了群聊
-
-
-
-
- {{ item.callbackData.from_name }}
+
+
+ {{item.payload.operatorInfo.nick}} 已将
+ {{user.nick}}
+ 移出群聊
+
+
+
+ 有群成员被设为管理员
+
+
+ 有群成员被撤销管理员
+
+
+
+ {{item.payload.operatorInfo.nick}} 修改了群
+
+ 头像
+
+
+ 名称为 {{item.payload.newGroupProfile.groupName}}
+
+
+ 资料
+
+
+
+
+
+ 群成员禁言
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{ item.nick }}
+
+
+
-
-
-
+
@@ -539,8 +556,8 @@
-
-
+
+
@@ -551,7 +568,7 @@
+ confirmType="发送" :focus="inputFocus" />
@@ -625,6 +642,14 @@
left: 0;
}
+ // 系统消息
+ .systemMsg {
+ margin: 30rpx 0;
+ text-align: center;
+ color: #999;
+ font-size: 22rpx;
+ }
+
//
.red-bag {
position: relative;
diff --git a/jiuyi2/pages/news/chat/components/news-temp/index.vue b/jiuyi2/pages/news/chat/components/news-temp/index.vue
index 45e3898a..7b72d1f7 100644
--- a/jiuyi2/pages/news/chat/components/news-temp/index.vue
+++ b/jiuyi2/pages/news/chat/components/news-temp/index.vue
@@ -30,7 +30,7 @@
const store = useStore()
const emit = defineEmits(['openRedBag', 'viewVideo'])
// 格式化
- const formatData = computed(() => props.item.callbackData.callback_json[0])
+ const formatData = computed(() => props.item)
//音频
const innerAudioContext = uni.createInnerAudioContext();
// 播放语音
@@ -70,17 +70,17 @@
-
+
-
+
- {{ formatData.MsgContent.Text }}
+ {{ item.payload.text }}
-
+
@@ -153,7 +153,7 @@
-
+
{{ item.payload.downloadFlag }}''
@@ -161,7 +161,7 @@
-
+
@@ -169,11 +169,11 @@
-
+
-
+
diff --git a/jiuyi2/pages/news/chat/fn.js b/jiuyi2/pages/news/chat/fn.js
index 56a46624..7db1660d 100644
--- a/jiuyi2/pages/news/chat/fn.js
+++ b/jiuyi2/pages/news/chat/fn.js
@@ -14,7 +14,7 @@
export const getHistoryMsg = async (option) => {
let options = {
// 对方的用户 ID 或者群组 ID 或聊天室 ID。
- conversationID: `${option.chatType}${option.msgId}`,
+ conversationID: option.conversationID,
nextReqMessageID: option.nextReqMessageID,
}
diff --git a/jiuyi2/pages/news/chat/index.scss b/jiuyi2/pages/news/chat/index.scss
index 432323ab..4e16c8fb 100644
--- a/jiuyi2/pages/news/chat/index.scss
+++ b/jiuyi2/pages/news/chat/index.scss
@@ -1,5 +1,4 @@
-
.scroll-view {
box-sizing: border-box;
flex: 1;
@@ -54,6 +53,7 @@
}
}
+// 工具
.tool {
position: fixed;
width: 100%;
@@ -62,6 +62,7 @@
padding-bottom: constant(safe-area-inset-bottom);
padding-bottom: calc(0 + env(safe-area-inset-bottom));
z-index: 1;
+ box-shadow: 0 0 30rpx rgba(0,0,0,.05);
.tool-group {
display: flex;
diff --git a/jiuyi2/pages/news/detail/group.vue b/jiuyi2/pages/news/detail/group.vue
index eedd3ccb..889fe17b 100644
--- a/jiuyi2/pages/news/detail/group.vue
+++ b/jiuyi2/pages/news/detail/group.vue
@@ -17,11 +17,14 @@
import util from '@/common/js/util.js'
import {
onLoad,
- onReady,
+ onShow,
onPageScroll,
onUnload
} from "@dcloudio/uni-app"
+ const {
+ proxy
+ } = getCurrentInstance()
// 群聊id
const groupId = ref('')
// 群聊详情
@@ -34,9 +37,30 @@
const memberList = reactive([])
// 当前成员在群聊中的身份
const role = computed(() => detail?.selfInfo?.role)
+ // 群邀请菜单
+ const inviteMenu = reactive([{
+ id: 'FreeAccess',
+ name: '邀请无需审批',
+ },
+ // {
+ // id: 'NeedPermission',
+ // name: '需要验证',
+ // },
+ {
+ id: 'DisableInvite',
+ name: '禁止邀请',
+ },
+ ])
+ // 邀请下标
+ const inviteIndex = ref('')
+ // 新群聊名称
+ const newGroupName = ref('')
onLoad((option) => {
if (option.groupId) groupId.value = option.groupId
+ })
+
+ onShow(() => {
// 获取详情
getDetail()
// 获取群成员列表
@@ -53,6 +77,7 @@
}).then((rs) => {
if (rs.code == 0) {
Object.assign(detail, rs.data.group)
+ inviteIndex.value = inviteMenu.findIndex(item => item.id == detail.inviteOption)
}
}).catch(function(imError) {
console.warn('getGroupProfile error:', imError); // 获取群详细资料失败的相关信息
@@ -82,6 +107,92 @@
url,
})
}
+
+ /**
+ * 修改群资料
+ * @param {Object} param 需要修改的群资料
+ * https://web.sdk.qcloud.com/im/doc/v3/zh-cn/SDK.html#updateGroupProfile
+ */
+ function updateGroupProfile(param) {
+ uni.$chat.updateGroupProfile({
+ groupID: groupId.value,
+ ...param,
+ }).then((rs) => {
+ console.log('updateGroupProfile then', rs)
+ Object.assign(detail, rs.data.group)
+ }).catch((imError) => {
+ console.log('updateGroupProfile fail', imError)
+ });
+ }
+
+ /**
+ * 设置群邀请方式
+ * @param {Object} event
+ */
+ function handleInvite(event) {
+ const index = event.detail.value
+ if (inviteIndex.value === index) return
+ inviteIndex.value = index
+
+ //
+ updateGroupProfile({
+ inviteOption: inviteMenu[inviteIndex.value].id,
+ })
+ }
+
+ // 上传群头像
+ function handleGroupAvatar() {
+ if(role.value !== 'Owner') return
+ //
+ util.upload_image({
+ type: 1,
+ success: (res) => {
+ //
+ updateGroupProfile({
+ avatar: res.value
+ })
+ }
+ })
+ }
+
+ // 点击群聊名称
+ function handleGroupName() {
+ if(role.value !== 'Owner') return
+ //
+ newGroupName.value = detail.name
+ //
+ proxy.$refs.groupName.open()
+ }
+
+ // 修改群聊名称
+ function handleGroupNameConfim() {
+ // 新群名是否为空
+ if (newGroupName.value === '') return
+ //
+ updateGroupProfile({
+ name: newGroupName.value
+ })
+ proxy.$refs.groupName.close()
+ }
+
+ /**
+ * 退出群聊
+ * https://web.sdk.qcloud.com/im/doc/v3/zh-cn/SDK.html#quitGroup
+ */
+ function handleExit() {
+ util.alert({
+ content: '确认退出群聊?',
+ }).then(rs => {
+ if (!rs.confirm) return
+ uni.$chat.quitGroup(groupId.value).then((imResponse) => {
+ uni.navigateBack({
+ delta: 2,
+ })
+ }).catch(function(imError) {
+ console.warn('quitGroup error:', imError); // 退出群组失败的相关信息
+ });
+ })
+ }
@@ -106,7 +217,8 @@
邀请
-
+
@@ -118,29 +230,41 @@
-
+
群聊头像
-
+
-
+
群聊名称
{{detail.name}}
-
- 群聊公告
- {{detail.notification}}
+
+
+ 群聊公告
+ {{detail.notification}}
+
+
+
+ 群聊介绍
+ {{detail.introduction}}
+
+
+
+
+
+
+ 群邀请
+ {{inviteMenu[inviteIndex].name}}
+
+
-
- 群聊介绍
- {{detail.introduction}}
-
-
-
+
举报
@@ -149,7 +273,21 @@
- 退出群聊
+ 退出群聊
+
+
+
+
+
+
+
+
+ 确认
+
+
@@ -176,4 +314,11 @@
border-top: 1rpx solid #eee;
}
}
+
+ // 编辑群名称
+ .groupNameAlt {
+ .editBox {
+ background-color: #eee;
+ }
+ }
\ No newline at end of file
diff --git a/jiuyi2/pages/news/detail/user.vue b/jiuyi2/pages/news/detail/user.vue
new file mode 100644
index 00000000..82c33282
--- /dev/null
+++ b/jiuyi2/pages/news/detail/user.vue
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
diff --git a/jiuyi2/pages/news/group/chatList.vue b/jiuyi2/pages/news/group/chatList.vue
index 0ab363d6..09ff18b3 100644
--- a/jiuyi2/pages/news/group/chatList.vue
+++ b/jiuyi2/pages/news/group/chatList.vue
@@ -62,19 +62,17 @@
uni.$chat.off(TencentCloudChat.EVENT.GROUP_LIST_UPDATED,()=>{});
}
- // 获取群组列表
+ /**
+ * 获取群组列表
+ * https://web.sdk.qcloud.com/im/doc/v3/zh-cn/SDK.html#getGroupList
+ */
function getGroupList() {
- api.news.myGroups().then(rs => {
- if (rs.code == 200) {
+ uni.$chat.getGroupList().then(rs => {
+ if (rs.code == 0) {
list.length = 0
- list.push(...rs.data)
- console.log('group list', list)
+ list.push(...rs.data.groupList)
return
}
- util.alert({
- content: rs.msg,
- showCancel: false
- })
})
}
@@ -86,7 +84,7 @@
console.log('group item', item)
util.toChat({
name: `${item.name}`,
- msgId: item.groupId,
+ msgId: item.groupID,
type: 'GROUP',
num: item.memberCount,
})
@@ -127,7 +125,7 @@
-
+
{{item.name}}
diff --git a/jiuyi2/pages/news/group/create.vue b/jiuyi2/pages/news/group/create.vue
index 8db27136..07df3ab5 100644
--- a/jiuyi2/pages/news/group/create.vue
+++ b/jiuyi2/pages/news/group/create.vue
@@ -120,6 +120,8 @@
groupID: data.groupId,
// 群头像
avatar: data.groupFaceUrl,
+ // 邀请进群处理方式
+ inviteOption: TencentCloudChat.TYPES.INVITE_OPTIONS_FREE_ACCESS,
}).then(function(rs) {
// 创建后的群聊信息
const group = rs.data.group
diff --git a/jiuyi2/pages/news/group/invite.vue b/jiuyi2/pages/news/group/invite.vue
index 87d73709..0b45399f 100644
--- a/jiuyi2/pages/news/group/invite.vue
+++ b/jiuyi2/pages/news/group/invite.vue
@@ -27,15 +27,17 @@
const groupId = ref('')
// 好友列表
const friendList = reactive([])
- // 群聊成员列表
- const groupMember = reactive([])
// 群成员列表
const memberList = reactive([])
+ // 新增成员
+ const newMemberIds = reactive([])
onLoad((option) => {
if (option.groupId) groupId.value = option.groupId
// 获取好友列表
getFriendList()
+ // 获取群成员列表
+ getGroupMemberList()
})
// 获取好友列表
@@ -66,16 +68,59 @@
}).then(function(rs) {
memberList.length = 0
memberList.push(...rs.data.memberList)
+ console.log('memberList', memberList)
})
}
+
+ /**
+ * 是否群成员
+ * @param {Object} userId 用户id
+ */
+ function hasMamber(userId) {
+ let result = memberList.find(node => node.userID == userId)
+ return Boolean(result)
+ }
+
+ /**
+ * 选择人员
+ * @param {Object} item 人员信息
+ */
+ function handleUser(item) {
+ if (hasMamber(item.userId)) return
+ let find_index = newMemberIds.findIndex(node => node === item.userId)
+ if (find_index >= 0) newMemberIds.splice(find_index, 1)
+ else newMemberIds.push(item.userId)
+ }
+
+ /**
+ * 添加群成员
+ * https://web.sdk.qcloud.com/im/doc/v3/zh-cn/SDK.html#addGroupMember
+ */
+ function handleSubmit() {
+ uni.$chat.addGroupMember({
+ groupID: groupId.value,
+ userIDList: newMemberIds,
+ }).then((rs) => {
+ uni.navigateBack()
+ }).catch((imError) => {
+ console.warn('addGroupMember error:', imError); // 错误信息
+ });
+ }
-
+
-
+
+
+
+
+
+
+
@@ -92,11 +137,10 @@
-
\ No newline at end of file
diff --git a/jiuyi2/pages/news/group/remove.vue b/jiuyi2/pages/news/group/remove.vue
new file mode 100644
index 00000000..30b653ec
--- /dev/null
+++ b/jiuyi2/pages/news/group/remove.vue
@@ -0,0 +1,123 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{ item.nameCard || item.nick }}
+
+
+
+
+ 到底啦~
+
+
+
+
+
+
+
\ No newline at end of file