jiuyiUniapp/jiuyi2/pages/news/group-chat-list/index.vue

34 lines
916 B
Vue

<!-- 群聊列表 -->
<template>
<view class="group-chat-list" v-if="groupList.length > 0">
<view class="p25" v-for="(item, index) in groupList" :key="index"
@click="notificationChat(item, msgType.chatType.GROUP_CHAT)">
{{ item.groupname }}
</view>
</view>
</template>
<script setup>
import { ref, inject } from 'vue';
const groupList = ref([]);
const { notificationChat } = inject('util')
const msgType = {}
const fetchGroupList = () => {
try {
uni.WebIM.conn.getGroup({
limit: 100,
success: function (res) {
groupList.value = res.data
getApp().globalData.groupList = res.data || [];
},
error: function () { }
});
} catch (error) {
console.error('获取群聊列表失败:', error);
}
}
fetchGroupList()
</script>
<style scoped lang="scss"></style>