WXL
21 小时以前 05c363fdd7ab04e3bd9a753e2c5d5bfff04d681c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
"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