This commit is contained in:
pengxiaolong
2025-07-21 22:10:59 +08:00
parent 31527ba8a6
commit 7116e57fc3
157 changed files with 2793 additions and 405 deletions

View File

@@ -10,45 +10,74 @@
<view class="title">消息</view>
</view>
<view class="content">
<scroll-view show-scrollbar="false" scroll-y="true" class="scroll">
<scroll-view
show-scrollbar="false"
scroll-y="true"
class="scroll"
v-if="Conversationobj.conversations.length > 0"
refresher-enabled="true"
refresher-threshold="40"
@refresherrefresh="onRefresherRefresh"
:refresher-triggered="triggered"
>
<view class="card" v-for="item in Conversationobj.conversations" :key="item.userId">
<uni-swipe-action>
<uni-swipe-action-item>
<view class="cardContent" @click="goChat(item.userId,item.data.nickname,item.data.avatar)">
<image
class="cardImg"
:src="item.data.avatar"
mode="scaleToFill"
/>
<view class="cardUnread" v-if="item.unread>0">{{ item.unread > 99 ? '99+':item.unread }}</view>
<view class="cardnameandtimeandNews">
<uni-swipe-action-item>
<view
class="cardContent"
@click="goChat(item.userId, item.data.nickname, item.data.avatar)"
>
<image class="cardImg" :src="item.data.avatar" mode="scaleToFill" />
<view class="cardUnread" v-if="item.unread > 0">{{
item.unread > 99 ? "99+" : item.unread
}}</view>
<view class="cardnameandtimeandNews">
<view class="cardnameandtime">
<view class="cardname">{{ item.data.nickname }}</view>
<view class="cardtime">{{TimeFormatting(item.lastMessage.timestamp)}}</view>
<view class="cardname">{{ item.data.nickname }}</view>
<view class="cardtime">{{
TimeFormatting(item.lastMessage.timestamp)
}}</view>
</view>
<view class="cardNews">
{{ item.lastMessage.payload.text }}
{{ item.lastMessage.payload.text }}
</view>
</view>
</view>
</view>
<template v-slot:right>
<view class="rightPosition">
<view class="topPosition">置顶</view>
<view class="Delete">删除</view>
</view>
</template>
</uni-swipe-action-item>
</uni-swipe-action>
<template v-slot:right>
<view class="rightPosition">
<view v-if="!item.top" class="topPosition" @click="goTop(item, true)"
>置顶</view
>
<view v-if="item.top" class="topPosition" @click="goTop(item, false)"
>取消置顶</view
>
<view class="Delete" @click="deleteConversation(item)">删除</view>
</view>
</template>
</uni-swipe-action-item>
</uni-swipe-action>
</view>
</scroll-view>
<view class="scroll" v-if="Conversationobj.conversations.length == 0">
<view class="nodata">
<view class="nodatatext">您还没有跟其他人的聊天快去聊天吧</view>
</view>
</view>
</view>
<!-- tanber -->
<view class="tabBar">
<tabBar :tabIndex="3"></tabBar>
</view>
<uni-popup ref="Refusepopup" type="center" border-radius="10px 10px 0 0">
<view class="popup-Hintcontent">
<view class="popup-text">提示</view>
<view class="popup-texts">您确定要删除这个会话吗</view>
<view class="popup-btn">
<button class="invite" type="primary" @click="operation()">确认</button>
<button class="cancel" type="default" @click="RefuseHintcloseHint()">取消</button>
</view>
</view>
</uni-popup>
</template>
<script>
@@ -56,12 +85,16 @@ import tabBar from "../../components/tabBar/tabBar";
import TimeFormatting from "../../components/TimeFormatting.js";
import {
getConversationList,
conversationTop,
conversationDelete,
} from "../../components/goEasyTool/tool.js";
import GoEasy from 'goeasy'
import GoEasy from "goeasy";
export default {
data() {
return {
Conversationobj: {},
Conversationobj: { conversations: [] },
DeleteSession: {},
triggered: false,
};
},
onLoad() {
@@ -75,13 +108,50 @@ export default {
im.on(GoEasy.IM_EVENT.CONVERSATIONS_UPDATED, this.onConversationsUpdated);
},
methods: {
//下拉刷新
onRefresherRefresh() {
this.triggered = true;
getConversationList(this.$goeasy).then((res) => {
this.Conversationobj = res;
this.triggered = false;
});
},
//删除会话
operation() {
conversationDelete(this.$goeasy, this.DeleteSession).then((res) => {
uni.showToast({
title: "删除成功",
icon: "none",
});
this.$refs.Refusepopup.close();
});
},
//关闭提示框
RefuseHintcloseHint() {
this.$refs.Refusepopup.close();
this.DeleteSession = {};
},
//删除会话
deleteConversation(item) {
this.DeleteSession = item;
this.$refs.Refusepopup.open("center");
},
//置顶会话
goTop(item, top) {
conversationTop(this.$goeasy, item, top).then((res) => {
uni.showToast({
title: top ? "置顶成功" : "取消置顶成功",
icon: "none",
});
});
},
//监听会话列表变化
onConversationsUpdated(conversations){
onConversationsUpdated(conversations) {
this.Conversationobj = conversations;
},
TimeFormatting:TimeFormatting,
TimeFormatting: TimeFormatting,
//跳转聊天页面
goChat(userId,nickname,avatar) {
goChat(userId, nickname, avatar) {
wx.navigateTo({
url: `/pages/index/chat/chat?userId=${userId}&nickname=${nickname}&avatar=${avatar}`,
});
@@ -126,6 +196,29 @@ export default {
height: 100%;
padding: 0% 5% 0% 5%;
}
.scroll ::-webkit-scrollbar {
width: 0;
height: 0;
color: transparent;
display: none;
}
.nodata {
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
}
.nodatatext {
font-size: 30rpx;
color: #999;
}
.scroll ::-webkit-scrollbar {
width: 0;
height: 0;
color: transparent;
display: none;
}
.card {
width: 100%;
height: 150rpx;
@@ -133,19 +226,19 @@ export default {
border-radius: 20rpx;
margin-top: 20rpx;
}
.cardContent{
height: 150rpx;
width: 100%;
display: flex;
align-items: center;
.cardContent {
height: 150rpx;
width: 100%;
display: flex;
align-items: center;
}
.cardImg{
height: 110rpx;
width: 110rpx;
border-radius: 20rpx;
margin-left: 20rpx;
.cardImg {
height: 110rpx;
width: 110rpx;
border-radius: 20rpx;
margin-left: 20rpx;
}
.cardUnread{
.cardUnread {
width: 30rpx;
height: 30rpx;
border-radius: 15rpx;
@@ -157,56 +250,109 @@ export default {
margin-top: -100rpx;
margin-left: -15rpx;
}
.cardnameandtimeandNews{
width: 500rpx;
height: 110rpx;
margin-left: 20rpx;
display: flex;
flex-direction: column;
justify-content: space-between;
.cardnameandtimeandNews {
width: 500rpx;
height: 110rpx;
margin-left: 20rpx;
display: flex;
flex-direction: column;
justify-content: space-between;
}
.cardnameandtime{
width: 100%;
display: flex;
justify-content: space-between;
.cardnameandtime {
width: 100%;
display: flex;
justify-content: space-between;
}
.cardNews{
width: 500rpx;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
margin-bottom: 10rpx;
font-size: 28rpx;
color: #333;
.cardNews {
width: 500rpx;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
margin-bottom: 10rpx;
font-size: 28rpx;
color: #333;
}
.cardname{
font-size: 30rpx;
color: #100e0f;
font-weight: bold;
.cardname {
font-size: 30rpx;
color: #100e0f;
font-weight: bold;
}
.cardtime{
font-size: 24rpx;
color: #999;
.cardtime {
font-size: 24rpx;
color: #999;
}
.rightPosition{
height: 150rpx;
width: 300rpx;
display: flex;
.rightPosition {
height: 150rpx;
width: 300rpx;
display: flex;
}
.topPosition{
height: 150rpx;
width: 150rpx;
background-color: #f5a623;
text-align: center;
line-height: 150rpx;
.topPosition {
height: 150rpx;
width: 150rpx;
background-color: #f5a623;
text-align: center;
line-height: 150rpx;
}
.Delete{
height: 150rpx;
width: 150rpx;
background-color: #f54323;
text-align: center;
line-height: 150rpx;
border-top-right-radius: 20rpx;
border-bottom-right-radius: 20rpx;
.Delete {
height: 150rpx;
width: 150rpx;
background-color: #f54323;
text-align: center;
line-height: 150rpx;
border-top-right-radius: 20rpx;
border-bottom-right-radius: 20rpx;
}
.popup-Hintcontent {
width: 600rpx;
height: 500rpx;
background-repeat: no-repeat;
border-radius: 10px;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
background-image: url(https://vv-1317974657.cos.ap-shanghai.myqcloud.com/util/chard1.png);
background-position: center;
}
.popup-text {
color: #161616;
font-size: 36.26rpx;
font-weight: bold;
margin-bottom: 30rpx;
}
.popup-texts {
margin-left: 50rpx;
color: #7e7e7e;
font-size: 26rpx;
margin-right: 50rpx;
margin-top: 70rpx;
margin-bottom: 70rpx;
}
.popup-btn {
display: flex;
justify-content: space-around;
margin-top: 50rpx;
}
.invite {
width: 225.19rpx;
height: 78.24rpx;
font-size: 28.63rpx;
line-height: 80rpx;
border-top-left-radius: 50rpx;
border-bottom-left-radius: 50rpx;
border-bottom-right-radius: 50rpx;
background-image: linear-gradient(135deg, #4fcacd, #5fdbde);
}
.cancel {
width: 225.19rpx;
height: 78.24rpx;
font-size: 28.63rpx;
line-height: 80rpx;
margin-left: 30rpx;
color: #03aba8;
border-top-left-radius: 50rpx;
border-bottom-left-radius: 50rpx;
border-bottom-right-radius: 50rpx;
border: 1rpx solid #03aba8;
}
</style>