acdr-ui/dist/dev/mp-weixin/modules/pet/message/chat.js

65 lines
2.0 KiB
JavaScript
Raw Normal View History

2024-09-19 07:20:14 +08:00
"use strict";
2024-10-01 09:15:35 +08:00
const common_vendor = require("../../../common/vendor.js");
2024-09-19 07:20:14 +08:00
if (!Array) {
const _component_layout_default_uni = common_vendor.resolveComponent("layout-default-uni");
_component_layout_default_uni();
}
const _sfc_main = {
__name: "chat",
setup(__props) {
const messages = common_vendor.ref([
{
id: 1,
text: "今天天气不错",
time: "15:24",
isMine: false,
type: "support",
avatar: "/acdr/src/static/my/avatar.jpg"
},
{
id: 2,
text: "是啊,阳光明媚",
time: "15:25",
isMine: true,
type: "customer",
avatar: "/acdr/src/static/my/avatar.jpg"
}
]);
const newMessage = common_vendor.ref("");
const sendMessage = () => {
if (newMessage.value.trim() !== "") {
messages.value.push({
id: messages.value.length + 1,
text: newMessage.value,
time: (/* @__PURE__ */ new Date()).toLocaleTimeString().slice(0, 5),
isMine: true,
// Assume the new message is always from the customer
type: "customer",
avatar: "/acdr/static/customer/avatar.png"
});
newMessage.value = "";
}
};
return (_ctx, _cache) => {
return {
a: common_vendor.f(messages.value, (message, k0, i0) => {
return {
a: message.avatar,
b: common_vendor.t(message.text),
c: common_vendor.t(message.time),
d: message.id,
e: message.isMine ? 1 : "",
f: message.type === "customer" ? 1 : "",
g: message.type === "support" ? 1 : ""
};
}),
b: newMessage.value,
c: common_vendor.o(($event) => newMessage.value = $event.detail.value),
d: common_vendor.o(sendMessage)
};
};
}
};
2024-10-01 09:15:35 +08:00
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-5639213b"]]);
2024-09-19 07:20:14 +08:00
wx.createPage(MiniProgramPage);