158 lines
5.8 KiB
JavaScript
158 lines
5.8 KiB
JavaScript
"use strict";
|
|
const common_vendor = require("../../common/vendor.js");
|
|
const common_assets = require("../../common/assets.js");
|
|
const model_ChatModel = require("../../model/ChatModel.js");
|
|
if (!Math) {
|
|
(ChatTopBgImg + ChatTopNavBar + ChatTopBanner + OneFeelMK001 + ChatCardAI + ChatCardMine + ChatMoreTips + ChatQuickAccess)();
|
|
}
|
|
const ChatTopBanner = () => "./ChatTopBanner.js";
|
|
const ChatTopBgImg = () => "./ChatTopBgImg.js";
|
|
const ChatTopNavBar = () => "./ChatTopNavBar.js";
|
|
const ChatCardAI = () => "./ChatCardAI.js";
|
|
const ChatCardMine = () => "./ChatCardMine.js";
|
|
const ChatQuickAccess = () => "./ChatQuickAccess2.js";
|
|
const ChatMoreTips = () => "./ChatMoreTips.js";
|
|
const OneFeelMK001 = () => "../module/OneFeelMK001.js";
|
|
const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
|
|
__name: "ChatMainList",
|
|
emits: ["openDrawer"],
|
|
setup(__props, { emit: __emit }) {
|
|
const statusBarHeight = common_vendor.ref(20);
|
|
const navBgColor = common_vendor.ref("rgba(66, 173, 249, 0)");
|
|
common_vendor.ref(0);
|
|
const timer = common_vendor.ref(null);
|
|
const holdKeyboard = common_vendor.ref(false);
|
|
const holdKeyboardFlag = common_vendor.ref(true);
|
|
const chatMsgList = common_vendor.ref([]);
|
|
const inputMessage = common_vendor.ref("");
|
|
const lastMsgId = common_vendor.ref("anchor-bottom");
|
|
holdKeyboard.value = true;
|
|
const emits = __emit;
|
|
const openDrawer = () => {
|
|
emits("openDrawer");
|
|
common_vendor.index.__f__("log", "at pages/chat/ChatMainList.vue:152", "=============打开抽屉");
|
|
};
|
|
const handleReply = (text) => {
|
|
loadMessage(text);
|
|
scrollToBottom();
|
|
};
|
|
common_vendor.onLoad(() => {
|
|
common_vendor.index.getSystemInfo({
|
|
success: (res) => {
|
|
statusBarHeight.value = res.statusBarHeight || 20;
|
|
}
|
|
});
|
|
});
|
|
common_vendor.onMounted(() => {
|
|
initData();
|
|
});
|
|
const initData = () => {
|
|
const msg = {
|
|
msgId: `msg_${0}`,
|
|
msgType: model_ChatModel.MessageRole.AI,
|
|
msg: "查信息、预定下单、探索玩法、呼叫服务、我通通可以满足,快试试问我问题吧!"
|
|
};
|
|
chatMsgList.value.push(msg);
|
|
};
|
|
const handleTouchEnd = () => {
|
|
clearTimeout(timer.value);
|
|
timer.value = setTimeout(() => {
|
|
if (handleNoHideKeyboard) {
|
|
common_vendor.index.hideKeyboard();
|
|
}
|
|
holdKeyboardFlag.value = true;
|
|
}, 50);
|
|
};
|
|
const handleNoHideKeyboard = () => {
|
|
holdKeyboardFlag.value = false;
|
|
};
|
|
const sendMessage = () => {
|
|
if (!inputMessage.value.trim())
|
|
return;
|
|
handleNoHideKeyboard();
|
|
loadMessage(inputMessage.value);
|
|
inputMessage.value = "";
|
|
scrollToBottom();
|
|
};
|
|
const loadMessage = (text) => {
|
|
const newMsg = {
|
|
msgId: `msg_${chatMsgList.value.length}`,
|
|
msgType: model_ChatModel.MessageRole.ME,
|
|
msg: text,
|
|
msgContent: {
|
|
type: model_ChatModel.MessageType.TEXT,
|
|
text
|
|
}
|
|
};
|
|
chatMsgList.value.push(newMsg);
|
|
let type = chatMsgList.value.length % 3 === 0;
|
|
const newMsgAI = {
|
|
msgId: `msg_${chatMsgList.value.length}`,
|
|
msgType: model_ChatModel.MessageRole.AI,
|
|
msg: `我是ai,你输入的内容是:${text}`,
|
|
msgContent: {
|
|
type: type ? model_ChatModel.MessageType.IMAGE : model_ChatModel.MessageType.TEXT,
|
|
url: ""
|
|
}
|
|
};
|
|
chatMsgList.value.push(newMsgAI);
|
|
common_vendor.index.__f__("log", "at pages/chat/ChatMainList.vue:239", "发送的新消息:", JSON.stringify(newMsg));
|
|
};
|
|
const scrollToBottom = () => {
|
|
lastMsgId.value = `${chatMsgList.value[chatMsgList.value.length - 1].msgId}`;
|
|
common_vendor.nextTick$1(() => {
|
|
lastMsgId.value = "anchor-bottom";
|
|
});
|
|
};
|
|
return (_ctx, _cache) => {
|
|
return {
|
|
a: common_vendor.o(openDrawer),
|
|
b: statusBarHeight.value + "px",
|
|
c: navBgColor.value,
|
|
d: common_vendor.f(chatMsgList.value, (item, k0, i0) => {
|
|
return common_vendor.e({
|
|
a: item.msgType === common_vendor.unref(model_ChatModel.MessageRole).AI
|
|
}, item.msgType === common_vendor.unref(model_ChatModel.MessageRole).AI ? common_vendor.e({
|
|
b: item.msgContent && item.msgContent.type === common_vendor.unref(model_ChatModel.MessageType).IMAGE
|
|
}, item.msgContent && item.msgContent.type === common_vendor.unref(model_ChatModel.MessageType).IMAGE ? {
|
|
c: common_assets._imports_0$1
|
|
} : {}, {
|
|
d: "d7316ec5-7-" + i0 + "," + ("d7316ec5-6-" + i0),
|
|
e: "d7316ec5-6-" + i0,
|
|
f: common_vendor.p({
|
|
text: item.msg
|
|
})
|
|
}) : item.msgType === common_vendor.unref(model_ChatModel.MessageRole).ME ? {
|
|
h: "d7316ec5-8-" + i0,
|
|
i: common_vendor.p({
|
|
text: item.msg
|
|
})
|
|
} : {
|
|
j: common_vendor.t(item.msg)
|
|
}, {
|
|
g: item.msgType === common_vendor.unref(model_ChatModel.MessageRole).ME,
|
|
k: item.msgId,
|
|
l: item.msgId
|
|
});
|
|
}),
|
|
e: lastMsgId.value,
|
|
f: lastMsgId.value,
|
|
g: common_vendor.o(handleReply),
|
|
h: common_vendor.o(handleReply),
|
|
i: common_assets._imports_1,
|
|
j: common_vendor.o(sendMessage),
|
|
k: common_vendor.o(handleNoHideKeyboard),
|
|
l: holdKeyboard.value,
|
|
m: inputMessage.value,
|
|
n: common_vendor.o(($event) => inputMessage.value = $event.detail.value),
|
|
o: common_assets._imports_2,
|
|
p: common_vendor.o(sendMessage),
|
|
q: common_vendor.o(handleTouchEnd)
|
|
};
|
|
};
|
|
}
|
|
});
|
|
const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-d7316ec5"]]);
|
|
wx.createComponent(Component);
|
|
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/chat/ChatMainList.js.map
|