"use strict";
|
const common_vendor = require("../../common/vendor.js");
|
const common_assets = require("../../common/assets.js");
|
if (!Array) {
|
const _easycom_uni_popup2 = common_vendor.resolveComponent("uni-popup");
|
_easycom_uni_popup2();
|
}
|
const _easycom_uni_popup = () => "../../node-modules/@dcloudio/uni-ui/lib/uni-popup/uni-popup.js";
|
if (!Math) {
|
_easycom_uni_popup();
|
}
|
const _sfc_main = {
|
__name: "chat",
|
setup(__props) {
|
const doctor = common_vendor.ref({
|
avatar: "/static/doctor/avatar.jpg",
|
name: "张医生",
|
title: "主任医师",
|
hospital: "青岛镜湖医院",
|
specialty: "擅长:呼吸系统疾病、慢性病管理",
|
price: 50
|
});
|
const userAvatar = common_vendor.ref("/static/avatar/default.jpg");
|
const messages = common_vendor.ref([]);
|
const scrollTop = common_vendor.ref(0);
|
const inputContent = common_vendor.ref("");
|
const isRecording = common_vendor.ref(false);
|
const sendMessage = async () => {
|
if (!inputContent.value.trim())
|
return;
|
messages.value.push({
|
type: "user",
|
content: inputContent.value
|
});
|
inputContent.value = "";
|
await common_vendor.nextTick$1();
|
scrollToBottom();
|
setTimeout(() => {
|
messages.value.push({
|
type: "doctor",
|
content: "您好,根据您描述的症状...",
|
prescription: {
|
time: "2024-03-25 10:30",
|
medicines: [
|
{ name: "阿莫西林胶囊", usage: "一次1粒,一日3次" },
|
{ name: "布洛芬缓释胶囊", usage: "一次1粒,必要时服用" }
|
]
|
}
|
});
|
scrollToBottom();
|
}, 1e3);
|
};
|
const scrollToBottom = () => {
|
common_vendor.nextTick$1(() => {
|
const query = common_vendor.index.createSelectorQuery();
|
query.select(".message-list").boundingClientRect();
|
query.exec((res) => {
|
if (res[0]) {
|
scrollTop.value = res[0].height;
|
}
|
});
|
});
|
};
|
const formatMessage = (content) => {
|
return content.replace(/\n/g, "<br>");
|
};
|
return (_ctx, _cache) => {
|
return {
|
a: doctor.value.avatar,
|
b: common_vendor.t(doctor.value.name),
|
c: common_vendor.t(doctor.value.title),
|
d: common_vendor.t(doctor.value.hospital),
|
e: common_vendor.t(doctor.value.specialty),
|
f: common_vendor.t(doctor.value.price),
|
g: common_vendor.f(messages.value, (msg, index, i0) => {
|
var _a, _b;
|
return common_vendor.e({
|
a: msg.type === "user"
|
}, msg.type === "user" ? common_vendor.e({
|
b: common_vendor.t(msg.content),
|
c: (_a = msg.images) == null ? void 0 : _a.length
|
}, ((_b = msg.images) == null ? void 0 : _b.length) ? {
|
d: common_vendor.f(msg.images, (img, idx, i1) => {
|
return {
|
a: idx,
|
b: img,
|
c: common_vendor.o(($event) => _ctx.previewImage(msg.images, idx), idx)
|
};
|
})
|
} : {}, {
|
e: msg.report
|
}, msg.report ? {
|
f: msg.report.icon,
|
g: common_vendor.t(msg.report.name),
|
h: common_vendor.t(msg.report.time)
|
} : {}, {
|
i: userAvatar.value
|
}) : common_vendor.e({
|
j: doctor.value.avatar,
|
k: formatMessage(msg.content),
|
l: msg.prescription
|
}, msg.prescription ? {
|
m: common_assets._imports_0$14,
|
n: common_vendor.f(msg.prescription.medicines, (med, idx, i1) => {
|
return {
|
a: common_vendor.t(med.name),
|
b: common_vendor.t(med.usage),
|
c: idx
|
};
|
}),
|
o: common_vendor.t(msg.prescription.time),
|
p: common_vendor.o(($event) => _ctx.viewPrescription(msg.prescription), index)
|
} : {}), {
|
q: index,
|
r: common_vendor.n(msg.type)
|
});
|
}),
|
h: scrollTop.value,
|
i: common_vendor.o((...args) => _ctx.loadMoreHistory && _ctx.loadMoreHistory(...args)),
|
j: common_vendor.o((...args) => _ctx.chooseImage && _ctx.chooseImage(...args)),
|
k: common_vendor.o((...args) => _ctx.chooseReport && _ctx.chooseReport(...args)),
|
l: common_vendor.o((...args) => _ctx.recordVoice && _ctx.recordVoice(...args)),
|
m: common_vendor.o((...args) => _ctx.onFocus && _ctx.onFocus(...args)),
|
n: common_vendor.o((...args) => _ctx.onBlur && _ctx.onBlur(...args)),
|
o: inputContent.value,
|
p: common_vendor.o(($event) => inputContent.value = $event.detail.value),
|
q: inputContent.value ? 1 : "",
|
r: common_vendor.o(sendMessage),
|
s: isRecording.value ? 1 : "",
|
t: common_vendor.o((...args) => _ctx.startRecord && _ctx.startRecord(...args)),
|
v: common_vendor.o((...args) => _ctx.stopRecord && _ctx.stopRecord(...args)),
|
w: common_vendor.t(isRecording.value ? "松开结束" : "按住开始"),
|
x: common_vendor.sr("voicePopup", "75937719-0"),
|
y: common_vendor.p({
|
type: "bottom"
|
}),
|
z: common_vendor.gei(_ctx, "")
|
};
|
};
|
}
|
};
|
wx.createPage(_sfc_main);
|
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/consultation/chat.js.map
|