Browse Source

修改人机对话

plg 11 months ago
parent
commit
40ba59eae7

+ 3 - 1
src/renderer/components/AnimationDes.vue

@@ -949,7 +949,8 @@ export default {
     //初始化websocket
     initWebsocket() {
       // const wsuri = "ws://192.168.1.103:8000/ws?uid=client&to_uid=server";
-      const wsuri = "ws://localhost:8000/ws?uid=client&to_uid=server";
+        const wsuri = "ws://127.0.0.1:8000/ws?uid=client&to_uid=server";
+      // const wsuri = "ws://localhost:8000/ws?uid=client&to_uid=server";
       // const wsuri = "ws://192.168.1.13:8000/ws?uid=client&to_uid=server";
       this.websock = new WebSocket(wsuri);
       this.websock.onmessage = this.websocketonmessage;
@@ -974,6 +975,7 @@ export default {
       let that = this;
       //数据接收
       const redata = JSON.parse(e.data);
+      console.log(redata)
       if (
         redata.content != "开启扫描成功" &&
         redata.content != "设置过滤成功" &&

+ 1 - 1
src/renderer/components/AnimationDouble.vue

@@ -1577,7 +1577,7 @@ export default {
     //初始化websocket
     initWebsocket() {
       // const wsuri = "ws://192.168.1.13:8000/ws?uid=client&to_uid=server";
-      const wsuri = "ws://localhost:8000/ws?uid=client&to_uid=server";
+      const wsuri = "ws://127.0.0.1:8000/ws?uid=client&to_uid=server";
       this.websock = new WebSocket(wsuri);
       this.websock.onmessage = this.websocketonmessage;
       this.websock.onopen = this.websocketonopen;

+ 1 - 0
src/renderer/components/LoginPage.vue

@@ -479,6 +479,7 @@ export default {
     };
   },
   mounted() {
+    this.$root.smartNum=0;
     this.$root.topPageFlag = false;
 
     this.dirpath = "C:\\DataPilot";

+ 15 - 11
src/renderer/components/MainTable.vue

@@ -236,23 +236,21 @@
     </div>
     <!-- 先是垂直布局 -->
     <!-- <div class="tan_out">
-    
-      <div class='tan_top'>
+      <div class="tan_top">
         <div>标题</div>
         <div>关闭</div>
       </div>
-    
-      <div  class='tan_center'>
+
+      <div class="tan_center">
         <div>中心</div>
         <div>中心</div>
       </div>
- 
-      <div  class='tan_foot'>
+
+      <div class="tan_foot">
         <div>底部</div>
         <div>底部</div>
       </div>
     </div> -->
-
   </div>
 </template>
 <script>
@@ -554,6 +552,12 @@ export default {
 
 .tan_out {
   position:fixed;
+  top:0;
+  left: 0;
+  right: 0;
+  bottom:0;
+  margin:auto;
+  z-index: 1000;
   width: 635px;
   height: 329px;
   background: url(../assets/tan/des_bg.png) no-repeat;
@@ -561,13 +565,13 @@ export default {
   display: flex;
   flex-direction: column;
 }
-.tan_top{
+.tan_top {
   /* flex:1 */
 }
-.tan_center{
-  flex:1
+.tan_center {
+  flex: 1;
 }
-.tan_foot{
+.tan_foot {
   /* flex:1 */
 }
 </style>

+ 1 - 1
src/renderer/components/ManageEquipment.vue

@@ -345,7 +345,7 @@ export default {
       });
     },
     initWebsocket() {
-      const wsuri = "ws://localhost:8000/ws?uid=client&to_uid=server";
+      const wsuri = "ws://127.0.0.1:8000/ws?uid=client&to_uid=server";
       // const wsuri = "ws://192.168.1.2:8000/ws?uid=client&to_uid=server";
       this.websock = new WebSocket(wsuri);
       this.websock.onmessage = this.websocketonmessage;

+ 112 - 106
src/renderer/components/Smart1.vue

@@ -41,12 +41,7 @@
                       <div class="message">{{ content.answer }}</div>
                     </div>
                     <div class="img-wrapper">
-                      <img
-                        width="60px"
-                        heigth="60px"
-                        class="img"
-                        :src="from2"
-                      />
+                      <img width="60px" heigth="60px" class="img" :src="from2" />
                     </div>
                   </div>
                 </el-col>
@@ -189,9 +184,7 @@ export default {
       chatContents: [],
       //前三个问题
       preList: [],
-      questionList: [
-        { index: 1, des: "能描述一下您最近训练的内容吗?", type: "1-2" },
-      ],
+      questionList: [{ index: 1, des: "能描述一下您最近训练的内容吗?", type: "1-2" }],
       //随机的4个数集合
       radomNumList: [],
       questionNum: 0,
@@ -235,12 +228,14 @@ export default {
   mounted() {
     window.jumpPage = this.jumpPage;
     const scrollview = this.$refs["scrollview"];
+    this.$root.smartNum = this.$root.smartNum + 1;
     this.init();
     //获取编号
     this.identifier = sessionStorage.getItem("num");
     this.userName = sessionStorage.getItem("name");
     // this.selectScale("20220805135201");
     scrollview.addEventListener("scroll", this.handleScroll, true);
+
     // /menu/evaluation
     // this.askEndMul(
     //   '	轻度:建议您使用系统中的虚拟现实、生物反馈训练<span onclick="jumpPage(1)" style="color:blue;cursor:pointer">(点击跳转)</span>、认知行为干预<span  onclick="jumpPage(2)" style="color:blue;cursor:pointer">(点击跳转--走出抑郁)</span>功能进行心理状态调'
@@ -284,24 +279,18 @@ export default {
       scaleInfoTemp.checkItems = item;
       this.scale_result.push(scaleInfoTemp);
       // bbc测试判断是否展示20~24题
-      if (
-        item != "是" &&
-        this.scale_flag == "20211101163739" &&
-        this.scale_index == 19
-      ) {
+      if (item != "是" && this.scale_flag == "20211101163739" && this.scale_index == 19) {
         this.scale_index = 24;
         for (let i = 20; i < 24; i++) {
           this.scale_result.push(this.scale_infos[i]);
         }
-        this.scale_checkItems =
-          this.scale_infos[this.scale_index].checkItems.split(";");
+        this.scale_checkItems = this.scale_infos[this.scale_index].checkItems.split(";");
         return;
       }
       //如果是单选题
 
       if (scaleInfoTemp.questionType == "0") {
-        if (this.scale_index <= this.scale_infos.length - 1)
-          this.scale_index += 1;
+        if (this.scale_index <= this.scale_infos.length - 1) this.scale_index += 1;
         this.answerSelect(this.tmpRadio);
         //scale_index == 题目总数,表示结束
         if (this.scale_index == this.scale_infos.length) {
@@ -350,8 +339,9 @@ export default {
             this.askEnd(a);
           }, 20);
 
-          this.scale_checkItems =
-            this.scale_infos[this.scale_index].checkItems.split(";");
+          this.scale_checkItems = this.scale_infos[this.scale_index].checkItems.split(
+            ";"
+          );
         }
       }
     },
@@ -363,13 +353,10 @@ export default {
         _this.scaleSelectFlag = true;
         if (res.data.code == 200 && res.data.data) {
           _this.resultJsonParams = res.data.data;
-          let testResult = JSON.parse(
-            res.data.data.userRecordEntity.testResult
-          )[0].version;
+          let testResult = JSON.parse(res.data.data.userRecordEntity.testResult)[0]
+            .version;
           if (_this.scale_flag === "20210910163158") {
-            let sleep = JSON.parse(
-              _this.resultJsonParams.userRecordEntity.testResult
-            );
+            let sleep = JSON.parse(_this.resultJsonParams.userRecordEntity.testResult);
             sleep = sleep[0].newTableContext.result[0].improvementSuggestions;
             _this.askEndMul(sleep);
             if (_this.emotionMul.length == 0) {
@@ -382,9 +369,7 @@ export default {
             // this.scale_checkItems = ["是", "否"];
             // this.inputFlag = 2;
           } else if (_this.scale_flag === "20220805135201") {
-            let sleep = JSON.parse(
-              _this.resultJsonParams.userRecordEntity.testResult
-            );
+            let sleep = JSON.parse(_this.resultJsonParams.userRecordEntity.testResult);
             sleep = sleep[0].tableContext;
             console.log(sleep);
             let str = "";
@@ -505,8 +490,7 @@ export default {
         this.scale_infos = res.data;
         this.scale_all = this.scale_infos.length;
         this.askEnd(this.scale_infos[this.scale_index].answer);
-        this.scale_checkItems =
-          this.scale_infos[this.scale_index].checkItems.split(";");
+        this.scale_checkItems = this.scale_infos[this.scale_index].checkItems.split(";");
         this.scale_percent = parseInt((this.scale_index + 1) / this.scale_all);
         this.scale_percent = ((this.scale_index + 1) * 100) / this.scale_all;
       });
@@ -687,29 +671,42 @@ export default {
                 i < res.data.intelligentDialogueEntities.content.length;
                 i++
               ) {
-                if (
-                  res.data.intelligentDialogueEntities.content[i].label == "0"
-                ) {
-                  this.chatContents.unshift({
-                    from: 1,
-                    question:
-                      res.data.intelligentDialogueEntities.content[i].content,
-                    from1: HeadImg,
-                  });
+                if (res.data.intelligentDialogueEntities.content[i].label == "0") {
+                  if (that.$root.smartNum == 1) {
+                    this.chatContents.unshift({
+                      from: 1,
+                      question: res.data.intelligentDialogueEntities.content[i].content,
+                      from1: HeadImg,
+                      isHistory: true,
+                    });
+                  } else {
+                    this.chatContents.unshift({
+                      from: 1,
+                      question: res.data.intelligentDialogueEntities.content[i].content,
+                      from1: HeadImg,
+                    });
+                  }
                 } else {
-                  this.chatContents.unshift({
-                    from: 2,
-                    answer:
-                      res.data.intelligentDialogueEntities.content[i].content,
-                    from1: HeadImg,
-                  });
+                  if (that.$root.smartNum == 1) {
+                    this.chatContents.unshift({
+                      from: 2,
+                      answer: res.data.intelligentDialogueEntities.content[i].content,
+                      from1: HeadImg,
+                      isHistory: true,
+                    });
+                  } else {
+                    this.chatContents.unshift({
+                      from: 2,
+                      answer: res.data.intelligentDialogueEntities.content[i].content,
+                      from1: HeadImg,
+                    });
+                  }
                 }
               }
               let contant1 = document.getElementById("contant1");
               this.sleep(300).then(() => {
-                contant1.scrollTop =2;
+                contant1.scrollTop = 2;
               });
-              // console.log(this.chatContents);
             }
           } else {
           }
@@ -756,27 +753,27 @@ export default {
       //http://127.0.0.1:9999
       //`http://127.0.0.1:9999/sentiment
       //http://aagvs5.natappfree.cc/sentiment
+      //http://127.0.0.1:9999/sentiment
+      //http://127.0.0.1:9999/sentiment
       let that = this;
-      axios
-        .post(`http://127.0.0.1:9999/sentiment`, { text: val })
-        .then((res) => {
-          console.log(res.data.sentiment);
-          if (
-            res.data.sentiment === "厌恶" ||
-            res.data.sentiment === "恐惧" ||
-            res.data.sentiment === "悲伤" ||
-            res.data.sentiment === "愤怒"
-          ) {
-            this.moonNegative += 1;
-          }
+      axios.post(`http://127.0.0.1:9999/sentiment`, { text: val }).then((res) => {
+        console.log(res.data.sentiment);
+        if (
+          res.data.sentiment === "厌恶" ||
+          res.data.sentiment === "恐惧" ||
+          res.data.sentiment === "悲伤" ||
+          res.data.sentiment === "愤怒"
+        ) {
+          this.moonNegative += 1;
+        }
 
-          //假如负面情绪大于5则需要调用量表方法
+        //假如负面情绪大于5则需要调用量表方法
 
-          // that.sendMsgFlag = true;
-          // that.threeAnswers.push(res.data.sentiment);
-          //如果是已婚人员则判断七个中是否存在4个负面情绪
-          //0为已婚人员
-        });
+        // that.sendMsgFlag = true;
+        // that.threeAnswers.push(res.data.sentiment);
+        //如果是已婚人员则判断七个中是否存在4个负面情绪
+        //0为已婚人员
+      });
     },
     //发送问题的接口
 
@@ -793,18 +790,34 @@ export default {
       if (this.chatContents.length < 5) {
         for (let i = 0; i < this.chatContents.length; i++) {
           if (this.chatContents[i].from == 1) {
-            list.push(this.chatContents[i].question);
+            console.log(this.chatContents[i].hasOwnProperty("isHistory"));
+            debugger;
+            if (!this.chatContents[i].hasOwnProperty("isHistory")) {
+              list.push(this.chatContents[i].question);
+            }
           } else {
-            list.push(this.chatContents[i].answer);
+            if (!this.chatContents[i].hasOwnProperty("isHistory")) {
+              debugger;
+              list.push(this.chatContents[i].answer);
+            }
           }
-          // list.push(chatContents.question)
         }
       } else {
         for (let i = 5; i > 0; i--) {
           if (this.chatContents[this.chatContents.length - i].from == 1) {
-            list.push(this.chatContents[this.chatContents.length - i].question);
+            debugger;
+            if (
+              !this.chatContents[this.chatContents.length - i].hasOwnProperty("isHistory")
+            ) {
+              list.push(this.chatContents[this.chatContents.length - i].question);
+            }
           } else {
-            list.push(this.chatContents[this.chatContents.length - i].answer);
+            debugger;
+            if (
+              !this.chatContents[this.chatContents.length - i].hasOwnProperty("isHistory")
+            ) {
+              list.push(this.chatContents[this.chatContents.length - i].answer);
+            }
           }
           // list.push(chatContents.question);
         }
@@ -820,6 +833,7 @@ export default {
       //`http://127.0.0.1:9998/chat`
       //http://127.0.0.1:9998/chat
       //http://ray-thunder.natapp1.cc/chat
+      debugger;
       HTTP_AXIOS({
         method: "post",
         url: `http://127.0.0.1:9998/chat`,
@@ -828,12 +842,6 @@ export default {
       })
         .then((res) => {
           if (res) {
-            // this.chatContents.push({
-            //   from: 1,
-            //   question: res.data.response,
-            //   from1: HeadImg,
-            // });
-
             let contant1 = document.getElementById("contant1");
             this.sleep(101).then(() => {
               contant1.scrollTop = contant1.scrollHeight;
@@ -884,8 +892,9 @@ export default {
       this.flagTime = setInterval(
         () => {
           if (this.printIndex < a.length) {
-            this.chatContents[this.chatContents.length - 1].question +=
-              a.charAt(this.printIndex);
+            this.chatContents[this.chatContents.length - 1].question += a.charAt(
+              this.printIndex
+            );
             this.printIndex++;
             if (flag) {
               let contant1 = document.getElementById("contant1");
@@ -905,8 +914,7 @@ export default {
               clearInterval(this.flagTime);
               let ob = {
                 label: 0,
-                content:
-                  this.chatContents[this.chatContents.length - 1].question,
+                content: this.chatContents[this.chatContents.length - 1].question,
               };
               this.saveRecord(ob);
               //在这判断负面情绪是否足够5个
@@ -946,31 +954,29 @@ export default {
     selectMood(val) {
       // this.sendMsgFlag=true;
       let that = this;
-      axios
-        .post(`http://192.168.219:9999/sentiment`, { text: val })
-        .then((res) => {
-          that.sendMsgFlag = true;
-          that.threeAnswers.push(res.data.sentiment);
-          //是否问问题的标志
-          //当答案小于3时需要接着提问
-          if (that.threeAnswers.length < 3) {
-            that.askQuestions();
-          } else if (that.threeAnswers.length === 3) {
-            //当等于3时需要判断是否接着提问
-            //当负面情绪小于2时则终止询问
-            //当负面情绪大于等于2时需要再次提问
-            that.judgeMood(2);
-          } else if (that.threeAnswers.length === 4) {
-            //当问题等于4时再次询问
-            that.askQuestions();
-          } else if (that.threeAnswers.length === 5) {
-            //调用判断结果负面情绪是否大于等于3
-            that.judgeMood(3);
-          }
+      axios.post(`http://192.168.219:9999/sentiment`, { text: val }).then((res) => {
+        that.sendMsgFlag = true;
+        that.threeAnswers.push(res.data.sentiment);
+        //是否问问题的标志
+        //当答案小于3时需要接着提问
+        if (that.threeAnswers.length < 3) {
+          that.askQuestions();
+        } else if (that.threeAnswers.length === 3) {
+          //当等于3时需要判断是否接着提问
+          //当负面情绪小于2时则终止询问
+          //当负面情绪大于等于2时需要再次提问
+          that.judgeMood(2);
+        } else if (that.threeAnswers.length === 4) {
+          //当问题等于4时再次询问
+          that.askQuestions();
+        } else if (that.threeAnswers.length === 5) {
+          //调用判断结果负面情绪是否大于等于3
+          that.judgeMood(3);
+        }
 
-          //当回答的答案大于等于3时判断是否结束,当负面情绪大于等于2时
-          // that.judgeMood();
-        });
+        //当回答的答案大于等于3时判断是否结束,当负面情绪大于等于2时
+        // that.judgeMood();
+      });
     },
     askEnd(val) {
       this.chatContents.push({
@@ -1227,4 +1233,4 @@ export default {
  height:70vh;
   overflow:auto;
 } */
-</style>
+</style>

+ 1 - 0
src/renderer/main.js

@@ -45,6 +45,7 @@ new Vue({
   },
   data: function () {
     return {
+      smartNum:0,
       topPageFlag:false,
       //登录类型设置
       // 设置全局变量 视频状态 加速度 状态, 脉搏状态 皮电状态

+ 2 - 7
static/mabenpao/index.html

@@ -95,9 +95,7 @@
         progressBarFull.style.width = 100 * progress + "%";
       }).then((unityInstance) => {
         loadingBar.style.display = "none";
-        fullscreenButton.onclick = () => {
-          unityInstance.SetFullscreen(1);
-        };
+    
         this.gameInstance = unityInstance;
         //gameInstance.SendMessage("Camera","Fireworklocity",0.45);
       }).catch((message) => {
@@ -111,10 +109,7 @@
     function Bloomsize(concentration) {
       this.gameInstance.SendMessage("Camera", "Fireworklocity", concentration);
     }
-    setInterval(() => {
-      let a = Math.random()
-      Bloomsize(a)
-    }, 1000);
+
     document.body.appendChild(script);
   </script>
 </body>

+ 4 - 4
static/tianping/index.html

@@ -109,10 +109,10 @@
     function Bloomsize(concentration) {
       this.gameInstance.SendMessage("Tianping", "Balance", concentration);
     }
-    setInterval(() => {
-      let a = Math.random()+','+Math.random()
-      Bloomsize(a)
-    }, 1000);
+    // setInterval(() => {
+    //   let a = Math.random()+','+Math.random()
+    //   Bloomsize(a)
+    // }, 1000);
     document.body.appendChild(script);
   </script>
 </body>