66 lines
2.0 KiB
JavaScript
66 lines
2.0 KiB
JavaScript
|
"use strict";
|
||
|
const common_vendor = require("../../common/vendor.js");
|
||
|
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)
|
||
|
};
|
||
|
};
|
||
|
}
|
||
|
};
|
||
|
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-433c1236"]]);
|
||
|
wx.createPage(MiniProgramPage);
|
||
|
//# sourceMappingURL=chat.js.map
|