This commit is contained in:
pengxiaolong
2025-07-18 13:06:06 +08:00
parent 6dec463705
commit 31527ba8a6
1853 changed files with 65500 additions and 98288 deletions

View File

@@ -0,0 +1,316 @@
"use strict";
const common_vendor = require("../../../common/vendor.js");
const components_ChatId = require("../../../components/ChatId.js");
const components_TimeFormatting = require("../../../components/TimeFormatting.js");
const components_goEasyTool_tool = require("../../../components/goEasyTool/tool.js");
const textmessage = () => "./messageComponent/textmessage.js";
const InvitationComponents = () => "./moreMessageComponents/InvitationComponents.js";
const _sfc_main = {
data() {
return {
userId: "",
// 对方用户id
nickname: "",
// 对方用户昵称
triggered: false,
// 下拉刷新状态
avatar: "",
// 对方用户头像
chatList: [],
// 聊天记录
userinfo: {},
// 自己用户信息
ButtonStatus: false,
// 发送按钮状态
MoreStatus: false,
// 更多消息类型弹窗状态
KeyboardHeight: 0,
// 键盘高度
content: "",
// 输入框内容
MoreItemStatus: null,
// 更多消息类型弹窗点击属性
ioshide: 0,
// 隐藏ios键盘
ElementPositioning: null,
// 元素定位
scrollviewheight: 0,
// 滚动视图高度
Elementheight: 0,
// 元素高度
Scrolling: false,
// 滚动状态
scrollTop: 0,
// 滚动高度
judgescrollTop: false,
// 判断滚动高度
onPage: false,
// 是否在页面
timer: null,
// 定时器
lastTimestamp: null,
// 上一次刷新时间戳
popUpList: [
{
name: "邀请",
icon: "https://vv-1317974657.cos.ap-shanghai.myqcloud.com/util/chat_invite.png",
type: "Invitation"
}
]
/// 更多消息类型弹窗列表
};
},
onShow() {
this.onPage = true;
},
onHide() {
this.onPage = false;
},
onLoad(options) {
common_vendor.index.getStorage({
key: "userinfo",
success: (res) => {
this.userinfo = res;
}
});
this.userId = options.userId;
this.nickname = options.nickname;
this.avatar = options.avatar;
components_goEasyTool_tool.getConversationMessages(this.$goeasy, this.userId, null).then((res) => {
this.chatList = res.map((item) => {
item.id = components_ChatId.generateId();
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;
}, 300);
const query = common_vendor.index.createSelectorQuery().in(this);
query.select(".inputComponent").boundingClientRect((res2) => {
this.Elementheight = res2.height * 2;
}).exec();
});
components_goEasyTool_tool.messageRead(this.$goeasy, this.userId).then((res) => {
common_vendor.index.__f__("log", "at pages/index/chat/chat.vue:223", "已读对方的消息");
});
this.getIOSDeviceType();
var im = this.$goeasy.im;
im.on(common_vendor.jo.IM_EVENT.PRIVATE_MESSAGE_RECEIVED, this.onPrivateMessageReceived);
im.on(common_vendor.jo.IM_EVENT.MESSAGE_READ, this.onMessageRead);
this.getscrollviewheight();
},
methods: {
//时间显示
checkInterval(timestamp) {
if (!this.lastTimestamp) {
this.lastTimestamp = timestamp;
return true;
}
const timeDiff = timestamp - this.lastTimestamp;
if (timeDiff >= 3e5) {
this.lastTimestamp = timestamp;
return true;
}
return false;
},
//时间格式化
TimeFormatting: components_TimeFormatting.TimeFormatting,
//获取容器高度
getscrollviewheight() {
const queryheight = common_vendor.index.createSelectorQuery().in(this);
queryheight.select(".scroll").boundingClientRect((res) => {
this.scrollviewheight = res.height;
}).exec();
},
//滚动事件
onScroll(event) {
if (!this.judgescrollTop) {
this.scrollTop = event.detail.scrollTop;
this.judgescrollTop = true;
} else if (this.scrollTop - event.detail.scrollTop > this.scrollviewheight) {
this.Scrolling = true;
} else if (this.scrollTop - event.detail.scrollTop < this.scrollviewheight) {
this.Scrolling = false;
}
},
//监听已读消息
onMessageRead(message) {
common_vendor.index.__f__("log", "at pages/index/chat/chat.vue:275", "已读消息", message);
},
//监听接受消息
onPrivateMessageReceived(message) {
if (!this.Scrolling) {
this.ElementPositioning = message.id = components_ChatId.generateId();
this.judgescrollTop = false;
} else {
message.id = components_ChatId.generateId();
}
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", "已读对方的消息");
});
}
},
//发送消息
onSend() {
if (this.content != "") {
components_goEasyTool_tool.sendMessage(
this.$goeasy,
this.userId,
this.content,
this.avatar,
this.nickname
).then((res) => {
common_vendor.index.__f__("log", "at pages/index/chat/chat.vue:302", "发送成功", res);
this.ElementPositioning = res.id = components_ChatId.generateId();
this.chatList.push(res);
this.judgescrollTop = false;
});
this.content = "";
this.ButtonStatus = false;
}
},
//ios兼容
getIOSDeviceType() {
const systemInfo = common_vendor.index.getSystemInfoSync();
const model = systemInfo.model;
if (/iPhone X|iPhone11|iPhone12|iPhone13|iPhone14/i.test(model)) {
if (/iPhone X|iPhone XS|iPhone 11 Pro/i.test(model)) {
this.ioshide = 88;
} else if (/iPhone 12|iPhone 13|iPhone 14/i.test(model)) {
this.ioshide = 94;
}
}
},
//更多消息类型弹窗事件
onMore(Status) {
if (!this.Scrolling) {
this.ElementPositioning = null;
setTimeout(() => {
this.ElementPositioning = this.chatList[this.chatList.length - 1].id;
}, 100);
this.judgescrollTop = false;
}
this.getscrollviewheight();
this.MoreStatus = Status;
const query = common_vendor.index.createSelectorQuery().in(this);
query.select(".inputComponent").boundingClientRect((res) => {
this.Elementheight = res.height * 2;
}).exec();
},
//更多消息类型弹窗点击事件
onMoreItem(type) {
this.MoreItemStatus = type;
},
// 获取键盘高度
onFocus(event) {
if (!this.Scrolling) {
this.ElementPositioning = null;
setTimeout(() => {
this.ElementPositioning = this.chatList[this.chatList.length - 1].id;
}, 100);
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;
}).exec();
},
//键盘消失
onBlur(event) {
this.KeyboardHeight = 0;
const query = common_vendor.index.createSelectorQuery().in(this);
query.select(".inputComponent").boundingClientRect((res) => {
this.Elementheight = res.height * 2;
}).exec();
this.getscrollviewheight();
},
//按钮切换
SendInput(event) {
const query = common_vendor.index.createSelectorQuery().in(this);
query.select(".inputComponent").boundingClientRect((res) => {
this.Elementheight = res.height * 2;
}).exec();
if (event.target.value != "") {
this.ButtonStatus = true;
} else {
this.ButtonStatus = false;
}
},
// 返回上一页
onBack() {
this.onPage = false;
common_vendor.wx$1.navigateBack({
delta: 1
});
}
},
components: {
textmessage,
InvitationComponents
}
};
if (!Array) {
const _component_InvitationComponents = common_vendor.resolveComponent("InvitationComponents");
_component_InvitationComponents();
}
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
return common_vendor.e({
a: common_vendor.o(($event) => $options.onMore(false)),
b: common_vendor.o((...args) => $options.onBack && $options.onBack(...args)),
c: common_vendor.t($data.nickname),
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) ? {
b: common_vendor.t($options.TimeFormatting(item.timestamp))
} : {}, {
c: item.id,
d: 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
}, !$data.ButtonStatus ? {
r: common_vendor.o(($event) => $options.onMore(!$data.MoreStatus))
} : {}, {
s: $data.ButtonStatus
}, $data.ButtonStatus ? {
t: 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) => {
return {
a: item.icon,
b: common_vendor.t(item.name),
c: common_vendor.o(($event) => $options.onMoreItem(item.type), index),
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" ? {} : {}, {
z: common_vendor.o(() => {
}),
A: $data.MoreItemStatus == null ? "-1000rpx" : "0",
B: common_vendor.o(($event) => $options.onMoreItem(null)),
C: $data.MoreItemStatus == null ? "100vh" : "0"
});
}
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-f4b42ac4"]]);
wx.createPage(MiniProgramPage);
//# sourceMappingURL=../../../../.sourcemap/mp-weixin/pages/index/chat/chat.js.map