suerprisePlus
2024-06-12 0b7865733542931c7c3fcf74febd30fe145af957
src/views/chartView/index.vue
@@ -18,6 +18,7 @@
import store from "../../store";
import bus from "./../../assets/js/bus.js";
import { getAIMessage } from "../../api/api.js";
import mapInfo from "../../assets/js/map/mapInfo.js";
export default {
  name: "jwChat",
@@ -67,8 +68,9 @@
      clearInterval(window.timer);
      window.timer = null;
    }
    // this.setLoading();
    setTimeout(() => {
      this.setMsgStart("您好");
      // this.setMsgStart("您好");
    }, config.loadTime);
    bus.$on("mapInfo", (res) => {
      if (res) {
@@ -81,28 +83,22 @@
      const msg = this.inputMsg;
      if (!msg) return;
      this.getMsg("role", msg);
      this.setLoading();
      setTimeout(() => {
        // this.loading = true;
        this.setMsgStart(msg);
        // const loader = msgData.getLoader();
        // this.list.push(loader);
      }, 200);
    },
    async setMsgStart(res) {
      const data = await getAIMessage(res);
      // var msg = aiData.aiMsg[0]
      this.getMsg("ai", data);
      if (res == "hi") {
        this.$nextTick(() => {
          setTimeout(() => {
            this.$store.state.erroInfoMessage = {
              title: "警告:菲律宾苏比克湾区域检测出异常军事目标!",
              val: "异常代号:4r5as5s001"
            };
          }, 5000);
        });
      const message = data.order;
      if (data.order.args && data.order.args.place) {
        message = data.order.args.place;
      }
      this.getMsg("ai", message);
      if (data.order.name) {
        mapInfo.init(data.order.name);
      }
    },
    setMapInfo(res) {
      var msg = "";
@@ -110,10 +106,17 @@
        msg = "<div>异常查询</div>" + res.value;
      }
      this.getMsg("role", msg);
      this.setMsgStart(res.value);
    },
    getMsg(type, msg) {
      var roleMsg = msgData.getRole(type, msg);
      if (this.loading) {
        this.loading = false;
        const length = this.list.length - 1;
        this.list[length].text = roleMsg.msg.text;
      } else {
      this.list.push(roleMsg.msg);
      }
    },
    setShowMsg() {
      if (this.msgData.text) {
@@ -141,6 +144,11 @@
        this.list.push(val);
      }
    },
    setLoading() {
      const loader = msgData.getLoader();
      this.list.push(loader);
      this.loading = true;
    },
    getLoadingFlag() {
      if (this.list.length == 0) {
        return;