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

@@ -2,8 +2,12 @@
const common_vendor = require("../../../common/vendor.js");
const components_ChatId = require("../../../components/ChatId.js");
const components_TimeFormatting = require("../../../components/TimeFormatting.js");
require("../../../components/picturesVideosMessages.js");
require("../../../components/audioMessages.js");
const components_request = require("../../../components/request.js");
const components_goEasyTool_tool = require("../../../components/goEasyTool/tool.js");
const textmessage = () => "./messageComponent/textmessage.js";
const customPKMessage = () => "./messageComponent/customPKMessage.js";
const InvitationComponents = () => "./moreMessageComponents/InvitationComponents.js";
const _sfc_main = {
data() {
@@ -12,8 +16,6 @@ const _sfc_main = {
// 对方用户id
nickname: "",
// 对方用户昵称
triggered: false,
// 下拉刷新状态
avatar: "",
// 对方用户头像
chatList: [],
@@ -50,7 +52,23 @@ const _sfc_main = {
// 定时器
lastTimestamp: null,
// 上一次刷新时间戳
LastTime: null,
// 最后聊天记录的时间戳
MoreMessageList: [],
Record: null,
// 定位记录
myitem: null,
//直接发送自定义消息的我的选中主播
youritem: null,
//直接发送自定义消息的对方选中主播
type: null,
//直接发送自定义消息的消息类型
popUpList: [
{
name: "相册",
icon: "https://vv-1317974657.cos.ap-shanghai.myqcloud.com/util/Album.png",
type: "Album"
},
{
name: "邀请",
icon: "https://vv-1317974657.cos.ap-shanghai.myqcloud.com/util/chat_invite.png",
@@ -62,6 +80,9 @@ const _sfc_main = {
},
onShow() {
this.onPage = true;
common_vendor.index.onKeyboardHeightChange((res) => {
this.KeyboardHeight = res.height * 2 - this.ioshide;
});
},
onHide() {
this.onPage = false;
@@ -70,20 +91,40 @@ const _sfc_main = {
common_vendor.index.getStorage({
key: "userinfo",
success: (res) => {
this.userinfo = res;
this.userinfo = res.data;
}
});
this.userId = options.userId;
this.nickname = options.nickname;
this.avatar = options.avatar;
this.type = options.type;
try {
this.myitem = JSON.parse(options.myitem);
this.youritem = JSON.parse(options.youritem);
} catch (e) {
}
if (this.type == "pk") {
setTimeout(() => {
this.sendCustomMessage();
}, 500);
}
components_goEasyTool_tool.getConversationMessages(this.$goeasy, this.userId, null).then((res) => {
this.chatList = res.map((item) => {
item.id = components_ChatId.generateId();
item.timestampStatus = this.checkInterval(item.timestamp);
return item;
});
common_vendor.index.__f__("log", "at pages/index/chat/chat.vue:209", "获取和对方用户的聊天记录", this.chatList);
setTimeout(() => {
this.ElementPositioning = this.chatList[this.chatList.length - 1].id;
if (this.chatList.length > 0) {
this.ElementPositioning = this.chatList[this.chatList.length - 1].id;
this.LastTime = this.chatList[0].timestamp;
} else {
common_vendor.index.showToast({
title: "您和对方暂无聊天记录,快去聊天吧",
icon: "none",
duration: 2e3
});
}
}, 300);
const query = common_vendor.index.createSelectorQuery().in(this);
query.select(".inputComponent").boundingClientRect((res2) => {
@@ -91,7 +132,7 @@ const _sfc_main = {
}).exec();
});
components_goEasyTool_tool.messageRead(this.$goeasy, this.userId).then((res) => {
common_vendor.index.__f__("log", "at pages/index/chat/chat.vue:223", "已读对方的消息");
common_vendor.index.__f__("log", "at pages/index/chat/chat.vue:300", "已读对方的消息");
});
this.getIOSDeviceType();
var im = this.$goeasy.im;
@@ -100,6 +141,62 @@ const _sfc_main = {
this.getscrollviewheight();
},
methods: {
//直接发送自定义消息
sendCustomMessage() {
components_request.request({
url: "pk/createPkRecord",
method: "POST",
data: {
pkIdA: this.youritem.id,
pkIdB: this.myitem.id,
userIdA: this.userId,
userIdB: this.userinfo.id,
pkTime: this.youritem.pkTime,
pkNumber: this.youritem.pkNumber,
anchorIdA: this.youritem.anchorId,
anchorIdB: this.myitem.anchorId,
anchorIconA: this.youritem.anchorIcon,
anchorIconB: this.myitem.anchorIcon,
piIdA: this.youritem.id,
piIdB: this.myitem.id
},
userInfo: true
}).then((res) => {
if (res.code == 200) {
const customData = {
id: res.data.id,
pkIdA: this.youritem.id,
pkIdB: this.myitem.id
};
let order = {
customData,
link: "https://vv-1317974657.cos.ap-shanghai.myqcloud.com/util/pk.png",
text: "PK邀请消息"
};
components_goEasyTool_tool.sendCustomMessage(
this.$goeasy,
this.type,
this.userId,
order,
this.avatar,
this.nickname
).then((res2) => {
this.ElementPositioning = res2.id = components_ChatId.generateId();
res2.timestampStatus = this.checkInterval(res2.timestamp);
this.chatList.push(res2);
common_vendor.index.showToast({
title: "发送成功",
icon: "none"
});
});
} else {
common_vendor.index.showToast({
title: res.msg,
icon: "none"
});
}
});
},
//时间显示
checkInterval(timestamp) {
if (!this.lastTimestamp) {
@@ -133,22 +230,42 @@ const _sfc_main = {
this.Scrolling = false;
}
},
//获取更多聊天记录
onScrollToUpper() {
this.lastTimestamp = null;
components_goEasyTool_tool.getConversationMessages(this.$goeasy, this.userId, this.LastTime).then((res) => {
this.Record = this.chatList[0].id;
this.MoreMessageList = res.map((item) => {
item.id = components_ChatId.generateId();
item.timestampStatus = this.checkInterval(item.timestamp);
return item;
});
});
setTimeout(() => {
this.chatList = [...this.MoreMessageList, ...this.chatList];
common_vendor.index.__f__("log", "at pages/index/chat/chat.vue:418", "获取更多聊天记录", this.chatList);
this.LastTime = this.chatList[0].timestamp;
this.ElementPositioning = this.Record;
}, 300);
},
//监听已读消息
onMessageRead(message) {
common_vendor.index.__f__("log", "at pages/index/chat/chat.vue:275", "已读消息", message);
common_vendor.index.__f__("log", "at pages/index/chat/chat.vue:425", "1已读消息", message);
},
//监听接受消息
onPrivateMessageReceived(message) {
if (!this.Scrolling) {
this.ElementPositioning = message.id = components_ChatId.generateId();
message.timestampStatus = this.checkInterval(message.timestamp);
this.judgescrollTop = false;
} else {
message.id = components_ChatId.generateId();
message.timestampStatus = this.checkInterval(message.timestamp);
}
this.chatList.push(message);
if (this.onPage) {
components_goEasyTool_tool.messageRead(this.$goeasy, this.userId).then((res) => {
common_vendor.index.__f__("log", "at pages/index/chat/chat.vue:288", "已读对方的消息");
common_vendor.index.__f__("log", "at pages/index/chat/chat.vue:440", "已读对方的消息");
});
}
},
@@ -162,8 +279,9 @@ const _sfc_main = {
this.avatar,
this.nickname
).then((res) => {
common_vendor.index.__f__("log", "at pages/index/chat/chat.vue:302", "发送成功", res);
common_vendor.index.__f__("log", "at pages/index/chat/chat.vue:454", "发送成功", res);
this.ElementPositioning = res.id = components_ChatId.generateId();
res.timestampStatus = this.checkInterval(res.timestamp);
this.chatList.push(res);
this.judgescrollTop = false;
});
@@ -171,6 +289,15 @@ const _sfc_main = {
this.ButtonStatus = false;
}
},
//自定义消息发送返回处理
refreshMessage(message) {
this.MoreItemStatus = null;
this.ElementPositioning = message.message.id = components_ChatId.generateId();
message.timestampStatus = this.checkInterval(message.message.timestamp);
this.chatList.push(message.message);
this.judgescrollTop = false;
this.MoreStatus = false;
},
//ios兼容
getIOSDeviceType() {
const systemInfo = common_vendor.index.getSystemInfoSync();
@@ -201,7 +328,31 @@ const _sfc_main = {
},
//更多消息类型弹窗点击事件
onMoreItem(type) {
this.MoreItemStatus = type;
if (type == "Album") {
this.onSendMedia();
} else {
this.MoreItemStatus = type;
}
},
//发送图片,视频消息
onSendMedia() {
common_vendor.index.chooseMedia({
count: 9,
mediaType: ["image", "video"],
sourceType: ["album", "camera"],
maxDuration: 60,
camera: "front",
success(res) {
common_vendor.index.__f__("log", "at pages/index/chat/chat.vue:523", res.tempFiles);
if (res.tempFiles.fileType == "image")
;
else if (res.tempFiles.fileType == "video")
;
}
});
},
//发送音频消息
onSendAudio() {
},
// 获取键盘高度
onFocus(event) {
@@ -213,7 +364,6 @@ const _sfc_main = {
this.judgescrollTop = false;
}
this.getscrollviewheight();
this.KeyboardHeight = event.detail.height * 2 - this.ioshide;
const query = common_vendor.index.createSelectorQuery().in(this);
query.select(".inputComponent").boundingClientRect((res) => {
this.Elementheight = res.height * 2;
@@ -221,7 +371,6 @@ const _sfc_main = {
},
//键盘消失
onBlur(event) {
this.KeyboardHeight = 0;
const query = common_vendor.index.createSelectorQuery().in(this);
query.select(".inputComponent").boundingClientRect((res) => {
this.Elementheight = res.height * 2;
@@ -250,12 +399,15 @@ const _sfc_main = {
},
components: {
textmessage,
InvitationComponents
InvitationComponents,
customPKMessage
}
};
if (!Array) {
const _component_textmessage = common_vendor.resolveComponent("textmessage");
const _component_customPKMessage = common_vendor.resolveComponent("customPKMessage");
const _component_InvitationComponents = common_vendor.resolveComponent("InvitationComponents");
_component_InvitationComponents();
(_component_textmessage + _component_customPKMessage + _component_InvitationComponents)();
}
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
return common_vendor.e({
@@ -265,35 +417,67 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
d: common_vendor.o(($event) => $options.onMore(false)),
e: common_vendor.f($data.chatList, (item, index, i0) => {
return common_vendor.e({
a: $options.checkInterval(item.timestamp)
}, $options.checkInterval(item.timestamp) ? {
a: item.timestampStatus
}, item.timestampStatus ? {
b: common_vendor.t($options.TimeFormatting(item.timestamp))
} : {}, {
c: item.id,
d: item.id
c: item.senderId == $data.userId
}, item.senderId == $data.userId ? common_vendor.e({
d: $data.avatar,
e: item.type == "text"
}, item.type == "text" ? {
f: "f4b42ac4-0-" + i0,
g: common_vendor.p({
messagetext: item.payload.text
})
} : {}, {
h: item.type == "pk"
}, item.type == "pk" ? {
i: "f4b42ac4-1-" + i0,
j: common_vendor.p({
message: item.payload
})
} : {}) : {}, {
k: item.senderId == $data.userinfo.id
}, item.senderId == $data.userinfo.id ? common_vendor.e({
l: $data.userinfo.headerIcon,
m: item.type == "text"
}, item.type == "text" ? {
n: "f4b42ac4-2-" + i0,
o: common_vendor.p({
messagetext: item.payload.text
})
} : {}, {
p: item.type == "pk"
}, item.type == "pk" ? {
q: "f4b42ac4-3-" + i0,
r: common_vendor.p({
message: item.payload
})
} : {}) : {}, {
s: item.id,
t: item.id
});
}),
f: common_vendor.o((...args) => _ctx.onRefresherRefresh && _ctx.onRefresherRefresh(...args)),
g: common_vendor.o((...args) => _ctx.onScrollToLower && _ctx.onScrollToLower(...args)),
h: $data.triggered,
i: $data.ElementPositioning,
j: common_vendor.o((...args) => $options.onScroll && $options.onScroll(...args)),
k: common_vendor.o(($event) => $options.onMore(false)),
l: $data.MoreStatus || $data.KeyboardHeight != 0 || $data.Elementheight != 0 ? $data.MoreStatus ? 650 + $data.Elementheight + "rpx" : $data.KeyboardHeight != 0 ? $data.KeyboardHeight + $data.Elementheight + "rpx" : $data.Elementheight + "rpx" : $data.Elementheight + "rpx",
m: common_vendor.o([($event) => $data.content = $event.detail.value, (...args) => $options.SendInput && $options.SendInput(...args)]),
n: common_vendor.o((...args) => $options.onFocus && $options.onFocus(...args)),
o: common_vendor.o((...args) => $options.onBlur && $options.onBlur(...args)),
p: $data.content,
q: !$data.ButtonStatus
f: common_vendor.o((...args) => $options.onScrollToUpper && $options.onScrollToUpper(...args)),
g: $data.ElementPositioning,
h: common_vendor.o((...args) => $options.onScroll && $options.onScroll(...args)),
i: common_vendor.o(($event) => $options.onMore(false)),
j: $data.MoreStatus || $data.KeyboardHeight != 0 || $data.Elementheight != 0 ? $data.MoreStatus ? 650 + $data.Elementheight + "rpx" : $data.KeyboardHeight != 0 ? $data.KeyboardHeight + $data.Elementheight + "rpx" : $data.Elementheight + "rpx" : $data.Elementheight + "rpx",
k: common_vendor.o([($event) => $data.content = $event.detail.value, (...args) => $options.SendInput && $options.SendInput(...args)]),
l: common_vendor.o((...args) => $options.onFocus && $options.onFocus(...args)),
m: common_vendor.o((...args) => $options.onBlur && $options.onBlur(...args)),
n: $data.content,
o: !$data.ButtonStatus
}, !$data.ButtonStatus ? {
r: common_vendor.o(($event) => $options.onMore(!$data.MoreStatus))
p: common_vendor.o(($event) => $options.onMore(!$data.MoreStatus))
} : {}, {
s: $data.ButtonStatus
q: $data.ButtonStatus
}, $data.ButtonStatus ? {
t: common_vendor.o((...args) => $options.onSend && $options.onSend(...args))
r: common_vendor.o((...args) => $options.onSend && $options.onSend(...args))
} : {}, {
v: $data.MoreStatus || $data.KeyboardHeight != 0 ? $data.MoreStatus ? "650rpx" : $data.KeyboardHeight != 0 ? $data.KeyboardHeight + "rpx" : "0" : "0",
w: common_vendor.f($data.popUpList, (item, index, i0) => {
s: $data.MoreStatus || $data.KeyboardHeight > 300 ? $data.MoreStatus ? "650rpx" : $data.KeyboardHeight > 300 ? $data.KeyboardHeight + "rpx" : "0" : "0",
t: common_vendor.f($data.popUpList, (item, index, i0) => {
return {
a: item.icon,
b: common_vendor.t(item.name),
@@ -301,9 +485,17 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
d: index
};
}),
x: $data.MoreStatus || $data.KeyboardHeight != 0 ? $data.MoreStatus ? "0" : $data.KeyboardHeight != 0 ? "0" : $data.KeyboardHeight + "rpx" : "-650rpx",
y: $data.MoreItemStatus == "Invitation"
}, $data.MoreItemStatus == "Invitation" ? {} : {}, {
v: $data.MoreStatus || $data.KeyboardHeight > 300 ? $data.MoreStatus ? "0" : $data.KeyboardHeight > 300 ? "0" : $data.KeyboardHeight + "rpx" : "-650rpx",
w: $data.MoreItemStatus == "Invitation"
}, $data.MoreItemStatus == "Invitation" ? {
x: common_vendor.o($options.refreshMessage),
y: common_vendor.p({
oppositeId: $data.userId,
myId: $data.userinfo.id,
avatar: $data.avatar,
nickname: $data.nickname
})
} : {}, {
z: common_vendor.o(() => {
}),
A: $data.MoreItemStatus == null ? "-1000rpx" : "0",