소스 검색

修改文件

[plg137200.] 1 년 전
부모
커밋
4f54b7a253

+ 13 - 1
.gitignore

@@ -5,10 +5,22 @@ build/*
 !build/icon
 !build/script
 coverage
-exe/*
+exe/jar
+exe/mysql/mysql-5.7.24-winx64/*
+!exe/mysql/mysql-5.7.24-winx64/bin
+exe/mysql/mysql-5.7.24-winx64/bin/*
+!exe/mysql/mysql-5.7.24-winx64/bin/mysql_init.bat
+!exe/mysql/mysql-5.7.24-winx64/bin/mysql_stop.bat
+exe/phoneApk
+exe/ct1
+exe/bling.mp3
+exe/rpc_thrift.exe
+exe/healthKnowledge
+exe/13188.wav
 node_modules/
 npm-debug.log
 npm-debug.log.*
 thumbs.db
 /dist
 !.gitkeep
+

+ 1 - 0
exe/global.js

@@ -0,0 +1 @@
+var env = {dev: 'http://localhost:8088/',prod: 'http://localhost:8088/'};export default env;

BIN
exe/music/bling.mp3


BIN
exe/music/pop.mp3


+ 0 - 0
exe/mysql/log.txt


+ 56 - 0
exe/mysql/mysql-5.7.24-winx64/bin/mysql_init.bat

@@ -0,0 +1,56 @@
+@echo off
+rem ������·���л�����ǰ�ű�����Ŀ¼
+cd /d %~dp0
+
+rem ��ʼ��װmysql
+echo ----1.start installing Mysql ---->>../log.txt
+"%cd%\mysqld.exe" --initialize-insecure --user=mysql --console 
+cd ..
+set "mysqlpath=%cd%">>../log.txt
+set basedir=%cd%
+set basedir=%basedir:\=/%
+
+>my.ini echo [mysqld]
+>>my.ini echo port=54034
+>>my.ini echo basedir=%basedir%
+>>my.ini echo datadir=%basedir%/Data
+>>my.ini echo max_connections=200
+>>my.ini echo max_connect_errors=10
+>>my.ini echo character-set-server=utf8mb4
+>>my.ini echo default-storage-engine=INNODB
+>>my.ini echo local_infile=ON
+>>my.ini echo.
+>>my.ini echo [mysql]
+>>my.ini echo default-character-set=utf8mb4
+>>my.ini echo local_infile=ON
+>>my.ini echo.
+>>my.ini echo [client]
+>>my.ini echo port=54034
+>>my.ini echo default-character-set=utf8mb4
+
+cd bin
+"%mysqlpath%\bin\mysqld.exe" install ct --defaults-file="%mysqlpath%\my.ini"
+
+rem ����mysql��������
+echo ----2. start Mysql service---- >>../log.txt
+rem pause
+net start ct
+sc config ct  start= auto
+net stop ct 
+net start ct
+
+rem ����mysql���������������д������ݿ��ʼ��
+echo ----3.setting Mysql environment ---->>../log.txt 
+cd ..
+"%cd%\bin\mysqladmin" -u root password Mysql@.2020
+"%cd%\bin\mysql.exe" -uroot -pMysql@.2020 ct < "%cd%\sql\grant.sql"
+echo %Path%
+echo %Path%|find /i "%mysqlpath%" && set IsNull=true || set IsNull=false
+echo %IsNull%
+if not %IsNull%==true (
+wmic ENVIRONMENT create name="MYSQL_HOME_CT",username="<system>",VariableValue="%mysqlpath%"
+rem ׷��path����
+wmic ENVIRONMENT where "name='PATH' and username='<system>'" set VariableValue="%path%;%%MYSQL_HOME_CT%%\bin;"
+echo ----4. Mysql environment create/append success---->>/log.txt 
+)
+pause >nul

+ 7 - 0
exe/mysql/mysql-5.7.24-winx64/bin/mysql_stop.bat

@@ -0,0 +1,7 @@
+@echo off
+cd /d %~dp0
+echo ----1.[Mysql] start uninstalling Mysql ---->>../log.txt
+sc stop ct
+sc delete ct
+echo ----2. [Mysql] uninstall finished---- >>../log.txt
+exit

BIN
exe/pop.mp3


파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 127 - 121
package-lock.json


+ 1 - 0
package.json

@@ -110,6 +110,7 @@
     "ws": "7.5.1"
   },
   "devDependencies": {
+    "@types/ringbufferjs": "^1.1.2",
     "@types/serialport": "^8.0.1",
     "@types/sqlite3": "^3.1.7",
     "@types/thrift": "^0.10.10",

+ 35 - 6
src/main/index.js

@@ -55,11 +55,11 @@ let loadingWindow
 //设置访问路径
 //打包访问的路径
 
-let serveUrl = "./resources/exe"
-let serveUrlJar = '\\resources\\exe'
+// let serveUrl = "./resources/exe"
+// let serveUrlJar = '\\resources\\exe'
 //本地访问的路径
-// let serveUrl = "./exe"
-// let serveUrlJar = '\\exe'
+let serveUrl = "./exe"
+let serveUrlJar = '\\exe'
 /**
  * Set `__static` path to static files in production
  * https://simulatedgreg.gitbooks.io/electron-vue/content/en/using-static-assets.html
@@ -241,7 +241,7 @@ if (pluseStart.data === null || pluseStart.data.trim().toUpperCase().indexOf('LI
 }
 
 ipcMain.on('pulse-message-stop', function (event, arg) {
-  
+
   // console.log(arg) // prints "ping"
   ws_public.send('PULSE-STOP')
   // 返回值后向渲染进程传输数据
@@ -536,6 +536,33 @@ ipcMain.on('asynchronoushrv-listcom', function (event, arg) {
   }
 })
 
+
+ipcMain.on('asynchronoushrv-naoData', function (event, arg) {
+
+  let data = arg;
+  let buf=Buffer.from(data,'hex')
+  // let buf= hex2ArrayBuffer(data);
+  // var array = ['1a', '2b', '3c', '4d', '5e', '6f']
+  // var hex_array = array.map(el => parseInt(el, 16))
+  // var uarray = new Uint8Array(hex_array)
+  // var buf = Buffer.from(data)
+  console.log(buf)
+  // console.log('来通知主进程了')
+  //进到这里边  
+  buf.forEach(q => {
+    ring.enq(q)
+    handleByte(q)
+  })
+})
+// function hex2ArrayBuffer(hex_str) {
+//   // let hex_str = 'AA5504B10000B5'
+//   let typedArray = new Uint8Array(hex_str.match(/[\da-f]{2}/gi).map(function (h) {
+//     return parseInt(h, 16)
+//   }))
+//   let buffer = typedArray.buffer
+//   return buffer
+// }
+
 // ipcMain.on('asynchronousselect-message123', function (event, arg) {
 //   // console.log(arg) // prints "ping"
 //   console.log("串口选择发过来了");
@@ -580,6 +607,8 @@ function openEEG(serialPort) {
   })
 }
 
+
+
 function handleByte() {
   let parseList
   if (ring.size() >= bigPackageLen) {
@@ -924,7 +953,7 @@ webGlobal()
 
 //启动docker
 function startDocker() {
-  execFile("C:/nlp/nlp" + '/start.bat', function (err, data) {
+  execFile("C:/nlp/nlp" + '/start1.bat', function (err, data) {
     console.log(err)
     console.log(data.toString())
   })

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

@@ -68,12 +68,13 @@
           <div class="equipment_status">
             <span class="desSty">设备未连接:</span>
             <img
+              @click="openTableFun"
               style="width: 14px; height: 20px"
               src="../assets/newAnimation/lanya.png"
             />
           </div>
           &nbsp;&nbsp;&nbsp;&nbsp;
-          <span class="desSty">查看波形图</span>
+          <span class="desSty" @click="viewEchartsFun">查看波形图</span>
           <span
             style="font-size: 12px"
             v-show="equipment == '2' && pulseTimeNum < 180 && pulseTimeNum > 0"
@@ -118,17 +119,107 @@
       </el-col>
       <el-col :span="1"> &nbsp; </el-col>
     </el-row>
+
+    <el-dialog title="提示" :visible.sync="tableVisible" width="60%" center>
+      <span>
+        <el-table
+          :data="scanData"
+          style="width: 100%"
+          :header-cell-style="{
+            background: '#66B497',
+            color: '#FFFFFF',
+            'letter-spacing': '4px',
+          }"
+        >
+          <!-- <el-table-column type="selection" align="center" width="55">
+            </el-table-column> -->
+          <el-table-column prop="Rssi" align="center" label="信号强度">
+          </el-table-column>
+          <el-table-column
+            prop="Name"
+            :formatter="nameFormatter"
+            align="center"
+            label="类型"
+          >
+          </el-table-column>
+          <el-table-column prop="MAC" align="center" label="mac">
+          </el-table-column>
+
+          <el-table-column label="操作" align="center">
+            <template slot-scope="scope">
+              <el-button
+                @click="linkFun(scope.$index, scope.row)"
+                class="xl_d_button"
+                size="mini"
+                slot="reference"
+              >
+                <span v-if="linkIndex == scope.$index">已连接</span
+                ><span v-if="linkIndex != scope.$index">连接</span></el-button
+              >
+            </template>
+          </el-table-column>
+        </el-table>
+      </span>
+      <span slot="footer" class="dialog-footer">
+        <el-button @click="tableVisible = false">取 消</el-button>
+        <el-button type="primary" @click="tableVisible = false"
+          >确 定</el-button
+        >
+      </span>
+    </el-dialog>
+    <el-dialog
+      title="查看波形图"
+      :visible.sync="echartsVisible"
+      width="80%"
+      center
+    >
+      <span>
+        <div class="outPage">
+          <div id="eegOne" class="naoOneClass"></div>
+        </div>
+        <div class="outPage">
+          <div id="eegTwo" class="naoOneClass"></div>
+        </div>
+        <div class="outThreePage">
+          <div id="eegThree" class="naoOneClass"></div>
+        </div>
+      </span>
+      <span slot="footer" class="dialog-footer">
+        <el-button @click="echartsVisible = false">取 消</el-button>
+        <el-button type="primary" @click="echartsVisible = false"
+          >确 定</el-button
+        >
+      </span>
+    </el-dialog>
   </div>
 </template>
 <script>
 //一个弹出框显示脑电或心电的显示图,外边显示脑电设备状态
 // 查看选择设备的状态,判断波形是哪个?
+import * as echarts from "echarts";
 import Utils from "./util.js";
 const fs = require("fs");
 const { ipcRenderer } = require("electron");
+const RingBuffer = require("ringbufferjs");
+// import  RingBuffer from 'ringbufferjs'
 export default {
   data() {
     return {
+      //echarts渲染标志
+      echartsVisible: false,
+      echartsOne: null,
+      echartsTwo: null,
+      echartsThree: null,
+
+      optionOne: null,
+      optionTwo: null,
+      optionThree: null,
+      //打开设备进行选择的列表
+      openTableFlag: "",
+      scanData: [],
+      websock: null,
+      tableVisible: false,
+      linkIndex: null,
       //是否是单个训练
       singleFlag: true,
       buttonDisable: true,
@@ -262,6 +353,7 @@ export default {
     };
   },
   mounted() {
+    // RingBuffer=null;
     //添加监听接收到数据后开始驱动
     //脑电监听
 
@@ -274,8 +366,12 @@ export default {
     window.addEventListener("resize", function () {
       // that.getSize();
       if (flagAnimation) {
+        
         setTimeout(() => {
           that.getSize();
+           that.echartsOne.resize();
+          that.echartsTwo.resize();
+          that.echartsThree.resize();
           flagAnimation = true;
         }, 1000);
       }
@@ -289,6 +385,7 @@ export default {
     }, 1000);
     that.singleFlag = that.$route.query.single;
     console.log(that.singleFlag);
+
     ipcRenderer.on("accelerationData-message", (event, arg) => {
       if (arg["_c"].size == 1) {
         this.waveData.push(arg["_c"].get("rawWaveData"));
@@ -298,6 +395,7 @@ export default {
         }
       } else {
         if (arg["_c"].size == 11) {
+          console.log(arg);
           // 当不为undefined时
           let ll = 11;
           // 获取长度
@@ -362,7 +460,7 @@ export default {
             this.focusNao.shift();
           }
           // this.numEleDom = this.focusNaoAll.length.toString();
-          if (this.currentFlag) {
+          if (this.echartsVisible) {
             this.renderEegOne();
             this.renderEegTwo();
             this.renderEegThree();
@@ -370,8 +468,153 @@ export default {
         }
       }
     });
+    this.initWebsocket();
+  },
+  destroyed() {
+    this.websock.close(1000);
   },
   methods: {
+    viewEchartsFun() {
+      this.echartsVisible = true;
+
+      setTimeout(() => {
+        if (this.echartsOne == null) {
+          this.echartsOne = echarts.init(document.getElementById("eegOne"));
+          this.echartsTwo = echarts.init(document.getElementById("eegTwo"));
+          this.echartsThree = echarts.init(document.getElementById("eegThree"));
+        }
+
+        // 先调用
+        this.renderEegOne();
+        this.renderEegTwo();
+        this.renderEegThree();
+      }, 2000);
+    },
+    //进行解析脑电数据
+
+    linkFun(index, val) {
+      // debugger;
+      let that = this;
+      that.$http.postTmp(
+        `/v1/device/connection`,
+        {
+          chip: val.Chip + "",
+          mac: val.MAC,
+          addrType: val.BdadrType,
+          filterName: val.Name == "BW-ECG-01" ? "1" : "0",
+        },
+        (res) => {
+          // debugger;
+          if (res.data.code == 200) {
+            this.linkIndex = index;
+            that.openData();
+            this.$message.success("设备连接成功");
+            // that.tableData = res.data;
+            // that.totolSize = res.data.totalElements;
+          } else {
+            // this.$message.error("访问服务器失败!");
+            this.$message.error(res.data.message);
+          }
+        }
+      );
+    },
+    //打开数据接口
+    openData() {
+      let that = this;
+      that.$http.getTmp(`/v1/device/open/notify`, {}, (res) => {
+        debugger;
+        if (res.code == 200) {
+          // that.tableData = res.data;
+          // that.totolSize = res.data.totalElements;
+        } else {
+          this.$message.error("访问服务器失败!");
+        }
+      });
+    },
+    nameFormatter(val) {
+      if (val.Name == "BW-ECG-01") {
+        return "心电";
+      } else {
+        return "脑电";
+      }
+    },
+    openTableFun() {
+      this.tableVisible = true;
+      //调用扫描接口
+      this.queryScan();
+    },
+    //扫描设备
+    queryScan() {
+      let that = this;
+      that.$http.postTmp(`/v1/device/scan`, {}, (res) => {
+        console.log(res);
+        if (res.code == 200) {
+          that.scanData = res.data;
+          // that.totolSize = res.data.totalElements;
+        } else {
+          this.$message.error("访问服务器失败!");
+        }
+      });
+    },
+    //进来后先连接websocket
+    //连上后进行扫描
+    //扫描以后出现列表
+    //列表出现后点击连接并打开数据如果有数据才算成功
+
+    //初始化websocket
+    initWebsocket() {
+      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;
+      this.websock.onerror = this.websocketonerror;
+      this.websock.onclose = this.websocketclose;
+    },
+    websocketonopen() {
+      //连接建立之后执行send方法发送数据
+      let actions = { test: "12345" };
+      this.websocketsend(JSON.stringify(actions));
+    },
+    websocketonerror() {
+      //连接建立失败重连
+      this.initWebSocket();
+    },
+    websocketsend(Data) {
+      //数据发送
+      this.websock.send(Data);
+    },
+    websocketonmessage(e) {
+      //数据接收
+      const redata = JSON.parse(e.data);
+      // console.log(redata);
+      if (redata.content != "Successful connection to socket service") {
+        //判断设备类型是device还是data
+        if (redata.msgType == "device") {
+          let dataLin = JSON.parse(redata.content);
+          let list = [];
+          for (var key in dataLin) {
+            list.push(dataLin[key]);
+          }
+          this.scanData = list;
+        } else {
+          let dataLin = JSON.parse(redata.content);
+
+          ipcRenderer.send("asynchronoushrv-naoData", dataLin.value);
+          // if(){
+
+          // }
+        }
+
+        // console.log(this.scanData);
+      }
+    },
+    websocketclose(e) {
+      if (e.code == 1005) {
+        this.initWebsocket();
+      } else {
+        console.log("断开连接", e);
+      }
+    },
     //保存文件
     saveFileGame(val) {
       fs.appendFile("D:\\pulseGame.txt", val + "@", (err) => {
@@ -683,7 +926,7 @@ export default {
           break;
         default:
           // this.urlThreeP = "../../../static/candle/index.html";
-        this.urlThreeP = __static + "/candle/index.html";
+          this.urlThreeP = __static + "/candle/index.html";
       }
       this.gameScene = val;
       this.flag = this.gameScene;
@@ -698,6 +941,574 @@ export default {
     goBack() {
       this.$router.go(-1);
     },
+    renderEegOne() {
+      let sarr = [];
+      // 当全量小于等于10时  显示1-10
+      if (this.focusNaoAll.length <= 10) {
+        for (let i = 0; i <= 10; i++) {
+          // i = i.toFixed(3);
+          sarr.push(i.toString());
+        }
+      } else if (this.focusNaoAll.length > 10) {
+        for (
+          let i = this.focusNaoAll.length - 10;
+          i < this.focusNaoAll.length;
+          i++
+        ) {
+          sarr.push(i.toString());
+        }
+      }
+      this.optionOne = {
+        animation: false,
+        title: {
+          text: "频谱成分",
+          subtext: "",
+          left: "center",
+          align: "right",
+          x: "center",
+          y: "bottom",
+        },
+        grid: {
+          bottom: 80,
+        },
+        legend: {
+          data: [
+            "Delta",
+            "Theta",
+            "Low Alpha",
+            "High Alpha",
+            "Low Beta",
+            "High Beta",
+            "Low Gamma",
+            "Mid Gamma",
+          ],
+        },
+        xAxis: [
+          {
+            name: "秒(s)",
+            type: "category",
+            boundaryGap: false,
+            axisLine: { onZero: false },
+            splitLine: { show: true },
+            data: sarr,
+            axisLabel: {
+              // interval: 999,
+              formatter: function (value, index) {
+                let a = parseInt(value);
+                if (a % 1000 == 0) {
+                  if ((a / 1000) % 2 == 0) {
+                    return a / 1000;
+                  }
+                }
+                return value;
+              },
+            },
+          },
+        ],
+        yAxis: [
+          {
+            name: "",
+            type: "value",
+            // max: 500,
+          },
+        ],
+        series: [
+          {
+            smooth: true,
+            showSymbol: false,
+            name: "Delta",
+            type: "line",
+
+            areaStyle: {},
+            lineStyle: {
+              width: 1,
+            },
+            emphasis: {
+              focus: "series",
+            },
+            markArea: {
+              silent: true,
+              itemStyle: {
+                opacity: 0.3,
+              },
+              data: [
+                [
+                  {
+                    xAxis: "2009/9/10\n7:00",
+                  },
+                  {
+                    xAxis: "2009/9/20\n7:00",
+                  },
+                ],
+              ],
+            },
+            data: this.deltaData,
+          },
+          {
+            smooth: true,
+            showSymbol: false,
+            name: "Theta",
+            type: "line",
+
+            areaStyle: {},
+            lineStyle: {
+              width: 1,
+            },
+            emphasis: {
+              focus: "series",
+            },
+            markArea: {
+              silent: true,
+              itemStyle: {
+                opacity: 0.3,
+              },
+              data: [
+                [
+                  {
+                    xAxis: "2009/9/10\n7:00",
+                  },
+                  {
+                    xAxis: "2009/9/20\n7:00",
+                  },
+                ],
+              ],
+            },
+            data: this.thetaData,
+          },
+          {
+            smooth: true,
+            showSymbol: false,
+            name: "Low Alpha",
+            type: "line",
+
+            areaStyle: {},
+            lineStyle: {
+              width: 1,
+            },
+            emphasis: {
+              focus: "series",
+            },
+            markArea: {
+              silent: true,
+              itemStyle: {
+                opacity: 0.3,
+              },
+              data: [
+                [
+                  {
+                    xAxis: "2009/9/10\n7:00",
+                  },
+                  {
+                    xAxis: "2009/9/20\n7:00",
+                  },
+                ],
+              ],
+            },
+            data: this.lowAlphaData,
+          },
+          {
+            smooth: true,
+            showSymbol: false,
+            name: "High Alpha",
+            type: "line",
+
+            areaStyle: {},
+            lineStyle: {
+              width: 1,
+            },
+            emphasis: {
+              focus: "series",
+            },
+            markArea: {
+              silent: true,
+              itemStyle: {
+                opacity: 0.3,
+              },
+              data: [
+                [
+                  {
+                    xAxis: "2009/9/10\n7:00",
+                  },
+                  {
+                    xAxis: "2009/9/20\n7:00",
+                  },
+                ],
+              ],
+            },
+            data: this.highAlphaData,
+          },
+          {
+            smooth: true,
+            showSymbol: false,
+            name: "Low Beta",
+            type: "line",
+
+            areaStyle: {},
+            lineStyle: {
+              width: 1,
+            },
+            emphasis: {
+              focus: "series",
+            },
+            markArea: {
+              silent: true,
+              itemStyle: {
+                opacity: 0.3,
+              },
+              data: [
+                [
+                  {
+                    xAxis: "2009/9/10\n7:00",
+                  },
+                  {
+                    xAxis: "2009/9/20\n7:00",
+                  },
+                ],
+              ],
+            },
+            data: this.lowBetaData,
+          },
+
+          {
+            smooth: true,
+            showSymbol: false,
+            name: "High Beta",
+            type: "line",
+
+            areaStyle: {},
+            lineStyle: {
+              width: 1,
+            },
+            emphasis: {
+              focus: "series",
+            },
+            markArea: {
+              silent: true,
+              itemStyle: {
+                opacity: 0.3,
+              },
+              data: [
+                [
+                  {
+                    xAxis: "2009/9/10\n7:00",
+                  },
+                  {
+                    xAxis: "2009/9/20\n7:00",
+                  },
+                ],
+              ],
+            },
+            data: this.highBetaData,
+          },
+          {
+            smooth: true,
+            showSymbol: false,
+            name: "Low Gamma",
+            type: "line",
+
+            areaStyle: {},
+            lineStyle: {
+              width: 1,
+            },
+            emphasis: {
+              focus: "series",
+            },
+            markArea: {
+              silent: true,
+              itemStyle: {
+                opacity: 0.3,
+              },
+              data: [
+                [
+                  {
+                    xAxis: "2009/9/10\n7:00",
+                  },
+                  {
+                    xAxis: "2009/9/20\n7:00",
+                  },
+                ],
+              ],
+            },
+            data: this.lowGammaData,
+          },
+          {
+            smooth: true,
+            showSymbol: false,
+            name: "Mid Gamma",
+            type: "line",
+
+            areaStyle: {},
+            lineStyle: {
+              width: 1,
+            },
+            emphasis: {
+              focus: "series",
+            },
+            markArea: {
+              silent: true,
+              itemStyle: {
+                opacity: 0.3,
+              },
+              data: [
+                [
+                  {
+                    xAxis: "2009/9/10\n7:00",
+                  },
+                  {
+                    xAxis: "2009/9/20\n7:00",
+                  },
+                ],
+              ],
+            },
+            data: this.midGammaData,
+          },
+        ],
+      };
+      this.echartsOne.setOption(this.optionOne);
+    },
+    renderEegTwo() {
+      let sarr = [];
+      // 当全量小于等于10时  显示1-10
+      if (this.focusNaoAll.length <= 10) {
+        for (let i = 0; i <= 10; i++) {
+          // i = i.toFixed(3);
+          sarr.push(i.toString());
+        }
+      } else if (this.focusNaoAll.length > 10) {
+        for (
+          let i = this.focusNaoAll.length - 10;
+          i < this.focusNaoAll.length;
+          i++
+        ) {
+          sarr.push(i.toString());
+        }
+      }
+
+      this.optionTwo = {
+        animation: false,
+        title: {
+          text: "注意力指标",
+          subtext: "",
+          left: "center",
+          align: "right",
+          x: "center",
+          y: "bottom",
+        },
+        grid: {
+          bottom: 80,
+        },
+        legend: {
+          data: ["Noise", "Attention", "Medition"],
+          // left: 10,
+        },
+        xAxis: [
+          {
+            name: "秒(s)",
+            type: "category",
+            boundaryGap: false,
+            axisLine: { onZero: false },
+            splitLine: { show: true },
+            data: sarr,
+          },
+        ],
+        yAxis: [
+          {
+            name: "秒(s)",
+            type: "value",
+            // max: 500,
+          },
+          // {
+          //   name: "秒(s)",
+          //   nameLocation: "start",
+          //   // max: 5,
+          //   type: "value",
+          //   inverse: false,
+          // },
+        ],
+        series: [
+          {
+            smooth: true,
+            showSymbol: false,
+            name: "Noise",
+            type: "line",
+            yAxisIndex: 0,
+            areaStyle: {},
+            lineStyle: {
+              width: 1,
+            },
+            emphasis: {
+              focus: "series",
+            },
+            markArea: {
+              silent: true,
+              itemStyle: {
+                opacity: 0.3,
+              },
+              data: [
+                [
+                  {
+                    xAxis: "2009/9/10\n7:00",
+                  },
+                  {
+                    xAxis: "2009/9/20\n7:00",
+                  },
+                ],
+              ],
+            },
+            data: this.noiseData,
+          },
+          {
+            smooth: true,
+            showSymbol: false,
+            name: "Attention",
+            type: "line",
+            yAxisIndex: 0,
+            areaStyle: {},
+            lineStyle: {
+              width: 1,
+            },
+            emphasis: {
+              focus: "series",
+            },
+            markArea: {
+              silent: true,
+              itemStyle: {
+                opacity: 0.3,
+              },
+              data: [
+                [
+                  {
+                    xAxis: "2009/9/10\n7:00",
+                  },
+                  {
+                    xAxis: "2009/9/20\n7:00",
+                  },
+                ],
+              ],
+            },
+            data: this.attentionData,
+          },
+          {
+            smooth: true,
+            showSymbol: false,
+            name: "Medition",
+            type: "line",
+            yAxisIndex: 0,
+            areaStyle: {},
+            lineStyle: {
+              width: 1,
+            },
+            emphasis: {
+              focus: "series",
+            },
+            markArea: {
+              silent: true,
+              itemStyle: {
+                opacity: 0.3,
+              },
+              data: [
+                [
+                  {
+                    xAxis: "2009/9/10\n7:00",
+                  },
+                  {
+                    xAxis: "2009/9/20\n7:00",
+                  },
+                ],
+              ],
+            },
+            data: this.meditationData,
+          },
+        ],
+      };
+      this.echartsTwo.setOption(this.optionTwo);
+    },
+    renderEegThree() {
+      let sarr = [];
+      // 当全量小于等于10时  显示1-10
+      if (this.waveDataAll.length <= 5120) {
+        for (let i = 0; i <= 5120; i++) {
+          // i = i.toFixed(3);
+          sarr.push(i.toString());
+        }
+      } else if (this.waveDataAll.length > 5120) {
+        for (
+          let i = this.waveDataAll.length - 5120;
+          i < this.waveDataAll.length;
+          i++
+        ) {
+          sarr.push(i.toString());
+        }
+      }
+
+      this.optionThree = {
+        animation: false,
+        title: {
+          text: "原始信号",
+          subtext: "",
+          left: "center",
+          align: "right",
+          x: "center",
+          y: "bottom",
+        },
+        grid: {
+          bottom: 80,
+        },
+        legend: {
+          data: ["RAW Wave"],
+          // left: 10,
+        },
+        xAxis: [
+          {
+            name: "秒(s)",
+            type: "category",
+            boundaryGap: false,
+            axisLine: { onZero: false },
+            splitLine: { show: true },
+            data: sarr,
+            axisLabel: {
+              interval: 512,
+              formatter: function (value, index) {
+                // 当当前value除以1000为整数是
+                // console.log(value);
+                // 将value转化为int类型
+                let a = parseInt(value);
+                a = Math.round(a / 512);
+                // if (a %510 == 0) {
+                //   // if ((a / 1000) % 2 == 0) {
+                //   //   return a / 1000;
+                //   // }
+                //   return a / 1000;
+                // }
+                return a;
+              },
+            },
+          },
+        ],
+        yAxis: [
+          {
+            name: "",
+            type: "value",
+            // max: 500,
+          },
+        ],
+        series: [
+          {
+            smooth: true,
+            showSymbol: false,
+
+            name: "RAW Wave",
+            type: "line",
+
+            lineStyle: {
+              width: 1,
+            },
+            data: this.waveData,
+          },
+        ],
+      };
+      this.echartsThree.setOption(this.optionThree);
+    },
   },
 };
 </script>
@@ -765,4 +1576,9 @@ canvas {
   flex-direction: row;
   flex: 1;
 }
+.naoOneClass {
+  width: 100%;
+  height: 30vh;
+  width: 100%;
+}
 </style>

+ 194 - 74
src/renderer/components/ManageEquipment.vue

@@ -2,63 +2,24 @@
   <div class="main_right_height">
     <TopDes :flag="false" topDesFont="设备管理"></TopDes>
     <div>
-      <!-- <el-row>
-        <el-col :span="1">&nbsp;</el-col>
-        <el-col :span="20" style="margin-top: 15px">
-          <div style="display: flex" class="xl_input">
-            <el-date-picker
-              v-model="value1"
-              type="daterange"
-              range-separator="至"
-              start-placeholder="开始日期"
-              end-placeholder="结束日期"
-              @change="timeChange"
-            >
-            </el-date-picker>
-            &nbsp;&nbsp;&nbsp;&nbsp;
-            <el-input
-              placeholder="请输入用户姓名"
-              v-model="nameSearch"
-              @input="searchEle"
-              prefix-icon="el-icon-search"
-            >
-            </el-input>
-          </div>
-        </el-col>
-      </el-row> -->
       <el-row style="margin-top: 15px">
         <el-col :span="1">&nbsp;</el-col>
-        <el-col :span="22" style="text-align: left">
-          <!-- <el-button
-            size="small"
-            @click="download(1, 1)"
-            class="xl_down_button"
-            :disabled="multipleSelection.length === 0 && disableFlag"
-          >
-            批量下载(原始数据)</el-button
-          >
+        <el-col :span="11" style="text-align: left">
           <el-button
             size="small"
-            :disabled="tableData.length === 0 && disableFlag"
-            @click="download(1, 2)"
             class="xl_down_button"
+            @click="addEquipment()"
           >
-            全部下载(原始数据)</el-button
-          > -->
-          <!-- <el-button
-            size="small"
-            @click="download(2, 1)"
-            class="xl_down_button"
-            :disabled="multipleSelection.length === 0 && disableFlag"
+            新增设备</el-button
           >
-            批量下载</el-button
-          > -->
+        </el-col>
+        <el-col :span="11" style="text-align: left">
           <el-button
             size="small"
             class="xl_down_button"
-            @click="addEquipment()"
+            @click="scanEquipment()"
           >
-            新增设备</el-button
+            扫描设备</el-button
           >
         </el-col>
         <el-col :span="1">&nbsp;</el-col>
@@ -67,7 +28,7 @@
     <div style="margin-top: 16px">
       <el-row>
         <el-col :span="1"> &nbsp;</el-col>
-        <el-col :span="22">
+        <el-col :span="11">
           <el-table
             :data="tableData"
             style="width: 100%"
@@ -92,23 +53,7 @@
             </el-table-column>
             <el-table-column prop="Mac" align="center" label="mac">
             </el-table-column>
-            <!-- <el-table-column
-              prop="CreatedAt"
-              align="center"
-              label="创建时间"
-              :formatter="dateForMa"
-            ></el-table-column> -->
-            <!-- <el-table-column prop="profession" label="职业"></el-table-column> -->
-            <!-- <el-table-column label="查看测试记录" align="center">
-              <template slot-scope="scope">
-                <el-button
-                  class="xl_d_button"
-                  size="mini"
-                  @click="removeFun(scope.$index, scope.row)"
-                  >移除</el-button
-                >
-              </template>
-            </el-table-column> -->
+
             <el-table-column label="操作" align="center">
               <template slot-scope="scope">
                 <!-- <el-button
@@ -117,11 +62,64 @@
                   @click="singleDownload(scope.$index, scope.row)"
                   >扫描设备</el-button
                 > -->
-                <el-button
+                <el-popconfirm
+                  confirmButtonText="确定"
+                  cancelButtonText="取消"
+                  @confirm="removeFun(scope.$index, scope.row)"
+                  icon="el-icon-info"
+                  iconColor="red"
+                  title="确定要删除该设备吗?"
+                >
+                  <el-button class="xl_d_button" size="mini" slot="reference"
+                    >删除</el-button
+                  >
+                </el-popconfirm>
+                <!-- <el-button
                   class="xl_d_button"
                   size="mini"
                   @click="removeFun(scope.$index, scope.row)"
                   >移除</el-button
+                > -->
+              </template>
+            </el-table-column>
+          </el-table>
+        </el-col>
+        <el-col :span="11">
+          <el-table
+            :data="scanData"
+            style="width: 100%"
+            @selection-change="handleSelectionChange"
+            :header-cell-style="{
+              background: '#66B497',
+              color: '#FFFFFF',
+              'letter-spacing': '4px',
+            }"
+            :row-class-name="tableRowClassName"
+          >
+            <!-- <el-table-column type="selection" align="center" width="55">
+            </el-table-column> -->
+            <el-table-column prop="Rssi" align="center" label="信号强度">
+            </el-table-column>
+            <el-table-column
+              prop="Name"
+              :formatter="nameFormatter"
+              align="center"
+              label="类型"
+            >
+            </el-table-column>
+            <el-table-column prop="MAC" align="center" label="mac">
+            </el-table-column>
+
+            <el-table-column label="操作" align="center">
+              <template slot-scope="scope">
+                <el-button
+                  @click="linkFun(scope.$index, scope.row)"
+                  class="xl_d_button"
+                  size="mini"
+                  slot="reference"
+                >
+                  <span v-if="linkIndex == scope.$index">已连接</span
+                  ><span v-if="linkIndex != scope.$index">连接</span></el-button
                 >
               </template>
             </el-table-column>
@@ -210,24 +208,132 @@ export default {
       totolSize: 10,
       nameSearch: "",
       tableData: [],
+      scanData: [],
       multipleSelection: [],
       flag: "",
       disableFlag: true,
+      websock: null,
+      linkIndex: null,
     };
   },
+  created() {
+    this.initWebsocket();
+  },
   mounted() {
     this.flag = this.$route.query.flag;
     this.queryEle();
   },
+  destroyed() {
+    //离开之后断开websocket连接
+    this.websock.close(1000);
+  },
   methods: {
-    removeFun(val, row) {
+    nameFormatter(val) {
+      if (val.Name == "BW-ECG-01") {
+        return "心电";
+      } else {
+        return "脑电";
+      }
+    },
+    linkFun(index, val) {
       // debugger;
-      let path = `v1/device/${row.Mac}/remove`;
-
-      this.$http.delete(path, {}, (res) => {
+      let that = this;
+      that.$http.postTmp(
+        `/v1/device/connection`,
+        {
+          chip: val.Chip + "",
+          mac: val.MAC,
+          addrType: val.BdadrType,
+          filterName: val.Name == "BW-ECG-01" ? "1" : "0",
+        },
+        (res) => {
+          // debugger;
+          if (res.data.code == 200) {
+            this.linkIndex = index;
+            that.openData();
+            this.$message.success("设备连接成功");
+            // that.tableData = res.data;
+            // that.totolSize = res.data.totalElements;
+          } else {
+            // this.$message.error("访问服务器失败!");
+             this.$message.error(res.data.message);
+          }
+        }
+      );
+    },
+    openData() {
+      let that = this;
+      that.$http.getTmp(`/v1/device/open/notify`, {}, (res) => {
         debugger;
         if (res.code == 200) {
-          this.$message(res.message);
+          // that.tableData = res.data;
+          // that.totolSize = res.data.totalElements;
+        } else {
+          this.$message.error("访问服务器失败!");
+        }
+      });
+    },
+    initWebsocket() {
+      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;
+      this.websock.onerror = this.websocketonerror;
+      this.websock.onclose = this.websocketclose;
+    },
+    websocketonopen() {
+      //连接建立之后执行send方法发送数据
+      let actions = { test: "12345" };
+      this.websocketsend(JSON.stringify(actions));
+    },
+    websocketonerror() {
+      //连接建立失败重连
+      this.initWebSocket();
+    },
+    websocketonmessage(e) {
+      //数据接收
+      const redata = JSON.parse(e.data);
+      console.log(redata);
+      if (redata.content != "Successful connection to socket service") {
+        //判断设备类型是device还是data
+        if (redata.msgType == "device") {
+          let dataLin = JSON.parse(redata.content);
+          let list = [];
+          for (var key in dataLin) {
+            list.push(dataLin[key]);
+          }
+          this.scanData = list;
+        }else{
+          let dataLin = JSON.parse(redata.content);
+          // if(){
+
+          // }
+        }
+
+        // console.log(this.scanData);
+      }
+    },
+    websocketsend(Data) {
+      //数据发送
+      this.websock.send(Data);
+    },
+    websocketclose(e) {
+      // console.log("断开连接", e);
+      if (e.code == 1005) {
+        this.initWebsocket();
+      } else {
+        console.log("断开连接", e);
+      }
+      //关闭
+    },
+    scanEquipment() {
+      this.queryScan();
+    },
+    removeFun(val, row) {
+      let path = `v1/device/${row.Mac}/remove`;
+      this.$http.deleteTmp(path, {}, (res) => {
+        if (res.data.code == 200) {
+          this.$message(res.data.message);
           this.queryEle();
         }
       });
@@ -245,11 +351,12 @@ export default {
         type: this.type,
         mac: this.mac,
       };
-      this.$http.post(path, data, (res) => {
-        debugger;
-        if (res.code == 200) {
+      this.$http.postTmp(path, data, (res) => {
+        if (res.data.code == 200) {
           this.centerDialogVisible = false;
           this.queryEle();
+        } else {
+          this.$message.error(res.data.message);
         }
       });
     },
@@ -382,9 +489,22 @@ export default {
       this.pageNum = 1;
       this.queryEle();
     },
+    //扫描设备
+    queryScan() {
+      let that = this;
+      that.$http.postTmp(`/v1/device/scan`, {}, (res) => {
+        console.log(res);
+        if (res.code == 200) {
+          that.scanData = res.data;
+          // that.totolSize = res.data.totalElements;
+        } else {
+          this.$message.error("访问服务器失败!");
+        }
+      });
+    },
     queryEle() {
       let that = this;
-      that.$http.get(`/v1/device/list/1`, {}, (res) => {
+      that.$http.getTmp(`/v1/device/list/1`, {}, (res) => {
         if (res.code == 200) {
           that.tableData = res.data;
           // that.totolSize = res.data.totalElements;

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

@@ -1203,7 +1203,7 @@ export default {
   display: inline-table;
   background-color: #1fd18e;
   color: #ffffff;
-  /* margin-top: 25px; */
+  margin-top: 25px;
 }
 .message {
   word-break: break-all;

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 888 - 149
src/renderer/components/Smart1.vue


+ 605 - 0
src/renderer/components/Smart2.vue

@@ -0,0 +1,605 @@
+<template>
+  <div class="main_right_height">
+    <div class="smart_content">
+      <el-row>
+        <el-col :span="1">&nbsp;</el-col>
+        <el-col :span="22">
+          <div class="chat-window" id="contant1">
+            <div
+              class="chat-msg-content"
+              id="rongqi"
+              v-for="content in chatContents"
+              :key="content.index"
+            >
+              <div
+                v-if="content.from == 1"
+                :key="content.id"
+                class="main_answer_right"
+                style="margin-top: 10px"
+              >
+                <div class="img-wrapper">
+                  <img width="60px" heigth="60px" class="img" :src="from1" />
+                </div>
+                <div class="message-wrapper message-wrapper-left">
+                  <div class="message">{{ content.question }}</div>
+                </div>
+              </div>
+              <el-row v-else style="margin-top: 10px">
+                <el-col :span="10"> &nbsp; </el-col>
+                <el-col :span="14">
+                  <div class="main_answer_left" style="float: right">
+                    <div class="message-wrapper message-wrapper-right">
+                      <div class="message">{{ content.answer }}</div>
+                    </div>
+                    <div class="img-wrapper">
+                      <img
+                        width="60px"
+                        heigth="60px"
+                        class="img"
+                        :src="from2"
+                      />
+                    </div>
+                  </div>
+                </el-col>
+              </el-row>
+            </div>
+          </div>
+        </el-col>
+        <el-col :span="1">&nbsp;</el-col>
+      </el-row>
+      <div class="smart_line_class"></div>
+      <el-row v-show="inputFlag === 1" class="footSend">
+        <!-- <el-col :span="1"> &nbsp; </el-col> -->
+        <el-col :span="22">
+          <el-input
+            class="xl_input"
+            type="textarea"
+            resize="none"
+            placeholder="请输入内容"
+            v-model="desc"
+            show-word-limit
+            @keyup.enter.native="sendMsg"
+            clearable
+          >
+          </el-input>
+        </el-col>
+        <el-col :span="2" style="">
+          &nbsp;&nbsp;
+          <!-- {{sendMsgFlag}}
+            {{desc.length>0}}
+            !((!sendMsgFlag)||(desc.length>0)) -->
+          <el-button
+            :disabled="desc.length == 0 || buttonFlag"
+            class="xl_d_send"
+            @click="sendMsg"
+            >发送</el-button
+          >
+        </el-col>
+      </el-row>
+      <el-row v-show="inputFlag === 2" class="footSendSelect">
+        <el-col :span="1"> &nbsp; </el-col>
+        <el-col :span="22" style="margin-top: 20px; margin-bottom: 20px">
+          <div>
+            <el-radio
+              style="margin-top: 10px"
+              v-for="(item, index) in scale_checkItems"
+              :key="index"
+              v-model="radio"
+              :label="item"
+              fill="#57ACBB"
+              @change="selectRadio(item)"
+              >{{ item }}</el-radio
+            >
+          </div></el-col
+        >
+        <el-col :span="1"> &nbsp; </el-col>
+      </el-row>
+      <el-row v-show="inputFlag === 3" class="footSendSelect">
+        <el-col :span="1"> &nbsp; </el-col>
+        <el-col :span="22" style="margin-top: 20px; margin-bottom: 20px">
+          <div>
+            <el-radio
+              :disabled="!scaleSelectFlag"
+              style="margin-top: 10px"
+              v-for="(item, index) in scale_checkItems"
+              :key="index"
+              v-model="radio"
+              :label="item"
+              fill="#57ACBB"
+              @change="choiceTriger(item)"
+              >{{ item }}</el-radio
+            >
+          </div></el-col
+        >
+        <el-col :span="1"> &nbsp; </el-col>
+      </el-row>
+    </div>
+  </div>
+</template>
+<script>
+import HeadImg from "@/assets/lion.png";
+import HeadImg1 from "@/assets/persion.png";
+import axios from "axios";
+const HTTP_AXIOS = axios.create();
+export default {
+  data() {
+    return {
+      buttonFlag: false,
+      pageNum: 1,
+      pageSize: 10,
+      tmpRadio: "",
+      radio: "",
+      inputFlag: 1,
+      desc: "",
+      from1: HeadImg,
+      from2: HeadImg1,
+      chatContents: [],
+      //前三个问题
+      preList: [],
+      questionList: [
+        { index: 1, des: "能描述一下您最近训练的内容吗?", type: "1-2" },
+      ],
+      //随机的4个数集合
+      radomNumList: [],
+      questionNum: 0,
+
+      //随机4个问题的集合
+      randomQuestion: [],
+      //随机4个答案的集合
+      randomAnswer: [],
+      //全部题目
+      scale_infos: [{ answer: "" }],
+      //题目总数
+      scale_all: 0,
+      scale_checkItems: [],
+      //进度参数
+      scale_percent: [],
+      //
+      scale_index: 0,
+      // 答案数据
+      scale_result: [],
+
+      //检测情绪前的发送数据条数
+      threeAnswers: [],
+
+      //负面情绪标志
+      moonNegative: 0,
+      scale_flag: "",
+      pressure_flag: "",
+      sendMsgFlag: true,
+      scaleSelectFlag: true,
+
+      flagTime: null,
+      printIndex: 0,
+    };
+  },
+  created() {},
+  mounted() {
+    this.init();
+    // this.selectScale("20220805135201");
+  },
+  methods: {
+    init() {
+      //进入页面后先执行查询前50条数据的接口
+      // this.selectPage();
+    },
+    //查询记录的方法
+    selectPage() {
+      this.$http.post(
+        `///`,
+        {
+          pageNum: this.pageNum,
+          pageSize: this.pageSize,
+        },
+        (res) => {
+          if (res.data.code == 200) {
+          } else {
+          }
+        }
+      );
+      for (let i = 0; i < 5; i++) {
+        this.chatContents.push({
+          from: 1,
+          question: "对话内容" + i,
+          from1: HeadImg,
+        });
+        this.chatContents.push({
+          from: 2,
+          answer: "对话内容" + i,
+          from1: HeadImg,
+        });
+      }
+      //手动加10条
+    },
+    sleep(time) {
+      return new Promise((resolve) => setTimeout(resolve, time));
+    },
+
+    sendMsg() {
+      this.sendMsgFlag = false;
+      let contant1 = document.getElementById("contant1");
+      let tmp = {
+        from: 2,
+        answer: this.desc,
+        from1: HeadImg,
+      };
+      this.chatContents.push(tmp);
+      this.getQuestion();
+      // 让滚动条始终在最底部
+      this.sleep(101).then(() => {
+        contant1.scrollTop = contant1.scrollHeight;
+      });
+      this.desc = "";
+      //立马调用
+      //进行提问的接口
+      //第一个问题出来后先对答案进行解析
+    },
+    //获取问题的接口//需要传输上下文关系,应该是需要上一个问题回答的是啥
+    getQuestion() {
+      let that = this;
+      that.buttonFlag = true;
+
+      //循环当前问题
+      let list = [];
+      for (let i = 0; i < this.chatContents.length; i++) {
+        if (this.chatContents[i].from == 1) {
+          list.push(this.chatContents[i].question);
+        } else {
+          list.push(this.chatContents[i].answer);
+        }
+        // list.push(chatContents.question)
+      }
+      // 进入页面后调用加载中的方法
+      //三个点轮询播放
+      this.chatContents.push({
+        from: 1,
+        question: "",
+        from1: HeadImg,
+      });
+      this.pFun("......", false);
+      //`http://127.0.0.1:9999/chat`
+      HTTP_AXIOS({
+        method: "post",
+        url: `http://127.0.0.1:9999/chat`,
+        data: { text: list },
+        timeout: 300000,
+      })
+        .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;
+            });
+
+            clearInterval(this.flagTime);
+            this.pFun(res.data.response, true);
+            //请求成功后返回的参数
+            //console.log(res);
+          }
+        })
+        .catch((error) => {
+          if (error.config.timeout == 300000) {
+            Message.error("请求超时,请检查网络");
+          } else {
+            console.log(error);
+          }
+        });
+    },
+    pFun(val, flag) {
+      let that = this;
+      //3个循环播放
+      this.chatContents[this.chatContents.length - 1].question = "";
+      this.printIndex = 0;
+      let a = val;
+      clearInterval(this.flagTime);
+      this.flagTime = setInterval(
+        () => {
+          if (this.printIndex < a.length) {
+            this.chatContents[this.chatContents.length - 1].question +=
+              a.charAt(this.printIndex);
+            this.printIndex++;
+          } else {
+            if (flag) {
+              that.buttonFlag = false;
+              //清除定时器
+              let contant1 = document.getElementById("contant1");
+              this.sleep(101).then(() => {
+                contant1.scrollTop = contant1.scrollHeight;
+              });
+              clearInterval(this.flagTime);
+            } else {
+              this.printIndex = 0;
+              this.chatContents[this.chatContents.length - 1].question = ".";
+            }
+          }
+        },
+        flag ? 60 : 300
+      );
+    },
+
+    //保存记录的接口
+    // saveRecord(val) {
+    //   this.$http.post(
+    //     `///`,
+    //     {
+    //       data: val,
+    //     },
+    //     (res) => {
+    //       if (res.data.code == 200) {
+    //       } else {
+    //       }
+    //     }
+    //   );
+    // },
+    //调用接口查询情绪
+    selectMood(val) {
+      // this.sendMsgFlag=true;
+      let that = this;
+      axios
+        .post(`http://127.0.0.1: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();
+        });
+    },
+    askEnd(val) {
+      this.chatContents.push({
+        from: 1,
+        question: val,
+        from1: HeadImg,
+      });
+      let contant1 = document.getElementById("contant1");
+      this.sleep(101).then(() => {
+        contant1.scrollTop = contant1.scrollHeight;
+      });
+    },
+    answerSelect(val) {
+      this.chatContents.push({
+        from: 2,
+        answer: val,
+        from1: HeadImg,
+      });
+    },
+    askQuestions() {
+      this.chatContents.push({
+        from: 1,
+        question: this.preList[this.threeAnswers.length].des,
+        from1: HeadImg,
+      });
+      this.questionNum++;
+    },
+    goBack() {
+      this.$router.go(-1);
+    },
+  },
+};
+</script>
+<style scoped>
+.mainTable-top {
+  margin-top: 5%;
+}
+.mainTable-top-two {
+  margin-top: 10%;
+}
+.mainTable-tab {
+  cursor: pointer;
+  margin-left: 100px;
+  margin-right: 100px;
+  border-radius: 5px;
+  border: 1px solid #000000;
+  text-align: center;
+  height: 150px;
+  margin-bottom: 100px;
+}
+.mainTable-tab-p {
+  padding-top: 40px;
+}
+.musicTitle {
+  display: block;
+  font-size: 18px;
+  color: #57acbb;
+  margin-bottom: 5px;
+}
+.main_answer_left {
+  display: flex;
+  /* text-align: left; */
+}
+.main_answer_right {
+  display: flex;
+  /* text-align: right; */
+}
+.message-wrapper {
+  background-color: #ffffff;
+}
+.message-wrapper-left {
+  margin-left: 10px;
+  /* border-radius: 0 1rem 1rem 1rem; */
+  border-radius: 4px 4px 4px 4px;
+  max-width: 20.86667rem;
+  display: inline-table;
+}
+.message-wrapper-right {
+  margin-right: 10px;
+  border-radius: 4px 4px 4px 4px;
+  max-width: 20.86667rem;
+  display: inline-table;
+  background-color: #1fd18e;
+  color: #ffffff;
+  /* margin-top: 25px; */
+}
+.message {
+  word-break: break-all;
+  padding: 18px;
+  /* font-size: 20px; */
+}
+
+.xl_d_button {
+  background: rgb(87, 172, 187);
+  opacity: 1;
+  border-radius: 50%;
+  font-size: 20px;
+  font-family: PingFang SC;
+  font-weight: 400;
+  color: #ffffff;
+  width: 40px;
+  line-height: 40px;
+  text-align: center;
+}
+.xl_d_button:hover {
+  background: rgb(87, 172, 187);
+  opacity: 1;
+  /* border-radius: 18px; */
+  font-size: 14px;
+  font-family: PingFang SC;
+  font-weight: 400;
+  color: #ffffff;
+}
+.xl_d_button:focus {
+  background: rgb(87, 172, 187);
+  opacity: 1;
+  /* border-radius: 18px; */
+  font-size: 14px;
+  font-family: PingFang SC;
+  font-weight: 400;
+  color: #ffffff;
+}
+.refrshSmart {
+  float: right;
+  cursor: pointer;
+}
+.xl_input >>> .el-input__inner {
+  border: 0;
+  border-radius: 4px;
+  background-color: #f4f4f4;
+}
+.footSend {
+  background: #ffffff;
+  position: absolute;
+  height: 80px;
+  margin-left: 2%;
+  width: 90%;
+  border-radius: 14px;
+  bottom: 50px;
+}
+.smart_line_class {
+  /* background: #BBC5D4; */
+  position: absolute;
+  height: 1px;
+  margin-left: 2%;
+  width: 90%;
+  border-radius: 14px;
+  bottom: 150px;
+  border-bottom: 1px solid #bbc5d4;
+}
+.footSend >>> .el-textarea__inner {
+  border: 0px solid #ffffff !important;
+  border-radius: 14px !important;
+}
+.footSendSelect {
+  background: #ffffff;
+  /* padding-bottom: 40px; */
+  position: absolute;
+  margin-left: 2%;
+  width: 90%;
+  bottom: 40px;
+}
+.xl_d_send {
+  margin-top: 18px;
+  color: #087b50;
+  background: #c6f0ed !important;
+  opacity: 1;
+  font-size: 14px;
+  font-family: PingFang SC;
+  font-weight: 400;
+  text-align: center;
+  border: 0px;
+  border-radius: 10px;
+}
+.xl_d_send:hover {
+  margin-top: 18px;
+  color: #087b50;
+  background: #c6f0ed !important;
+  opacity: 1;
+  font-size: 14px;
+  font-family: PingFang SC;
+  font-weight: 400;
+  text-align: center;
+  border-radius: 10px;
+}
+.xl_d_send:focus {
+  margin-top: 18px;
+  color: #087b50;
+  background: #c6f0ed !important;
+  opacity: 1;
+  font-size: 14px;
+  font-family: PingFang SC;
+  font-weight: 400;
+  text-align: center;
+  border-radius: 10px;
+}
+.xl_d_send.is-disabled,
+.xl_d_send.is-disabled:hover,
+.xl_d_send.is-disabled:focus {
+  margin-top: 18px;
+  color: #087b50;
+  background: #c6f0ed !important;
+  opacity: 1;
+  font-size: 14px;
+  font-family: PingFang SC;
+  font-weight: 400;
+  text-align: center;
+  border-radius: 10px;
+}
+
+.main_right_height {
+  /* padding:40px; */
+  height: 100vh !important;
+  display: block !important;
+  overflow-y: auto !important;
+  background-color: #ffffff;
+}
+
+.smart_content {
+  height: 88%;
+  margin-top: 5%;
+  width: 94%;
+  margin-left: 3%;
+  border-radius: 40px;
+  background: #f6f6f6;
+}
+.chat-window {
+  height: 70vh;
+  overflow: auto;
+  /* overflow-y:hidden; */
+}
+
+/* .contant1{
+ height:70vh;
+  overflow:auto;
+} */
+</style>

+ 78 - 3
src/utils/http.js

@@ -5,11 +5,16 @@ import router from "@/router";
 import global from '../../exe/global.js'
 sessionStorage.setItem("baseUrl", global.dev)
 // sessionStorage.setItem("baseUrl", 'http://10.113.248.5:8088/')
-// sessionStorage.setItem("baseUrl", 'http://192.168.2.116:8000/')
+// sessionStorage.setItem("baseUrl", 'http://localhost:8000/')
 
 axios.defaults.baseURL = global.dev;
 // axios.defaults.baseURL = 'http://10.113.248.5:8088/';
-// axios.defaults.baseURL = 'http://192.168.2.116:8000/';
+// axios.defaults.baseURL = 'http://localhost:8000/';
+
+// 创建一个 Axios 实例并设置 baseURL 适应不同服务器的baseUrl
+const apiInstance = axios.create({
+  baseURL: 'http://localhost:8000/'
+});
 
 // axios.defaults.baseURL = "/api";
 
@@ -73,6 +78,7 @@ axios.interceptors.response.use(
   }
 );
 
+
 const http = {
   gets: (url, data, sCallBack) => {
     if (data) {
@@ -99,6 +105,20 @@ const http = {
       }
     });
   },
+  getTmp: (url, data, sCallBack) => {
+    if (data) {
+      data = data;
+      //data = Encrypt(JSON.stringify(data));
+    }
+    apiInstance.get(url, { params: data }).then((res) => {
+      //res.data = JSON.parse(Decrypt(res.data));
+      res.data = res.data;
+      //res.data = JSON.parse(res.data);
+      if (sCallBack) {
+        sCallBack(res.data);
+      }
+    });
+  },
   post: (url, data, sucessCallBack, errCallBack) => {
     if (data) {
       //data = Encrypt(JSON.stringify(data));
@@ -116,6 +136,40 @@ const http = {
         if (sucessCallBack) {
           sucessCallBack(res);
         }
+      } else if (res.data.code == 400) {
+        if (sucessCallBack) {
+          sucessCallBack(res);
+        }
+      } else {
+        if (errCallBack) {
+          errCallBack(res);
+        } else {
+          Message.error(res.data.msg);
+        }
+      }
+    });
+  },
+  postTmp: (url, data, sucessCallBack, errCallBack) => {
+    if (data) {
+      //data = Encrypt(JSON.stringify(data));
+      //data =JSON.stringify(data);
+
+    }
+    apiInstance.post(url, data).then((res) => {
+      if (res) {
+        //res = JSON.parse(Decrypt(res.data));
+        res = res
+        //res = JSON.parse(res);
+        //res = JSON.parse(res.data);
+      }
+      if (res.data.code == 200) {
+        if (sucessCallBack) {
+          sucessCallBack(res);
+        }
+      } else if (res.data.code == 400) {
+        if (sucessCallBack) {
+          sucessCallBack(res);
+        }
       } else {
         if (errCallBack) {
           errCallBack(res);
@@ -202,7 +256,28 @@ const http = {
       if (res) {
         // res = JSON.parse(Decrypt(res.data));
       }
-      if (res.code == 200) {
+      if (res.data.code == 200) {
+        if (sucessCallBack) {
+          sucessCallBack(res);
+        }
+      } else {
+        if (errCallBack) {
+          errCallBack(res);
+        } else {
+          Message.error(res.msg);
+        }
+      }
+    });
+  },
+  deleteTmp(url, data, sucessCallBack, errCallBack) {
+    if (data) {
+      // data = Encrypt(JSON.stringify(data));
+    }
+    apiInstance.delete(url, { data: data }).then((res) => {
+      if (res) {
+        // res = JSON.parse(Decrypt(res.data));
+      }
+      if (res.data.code == 200) {
         if (sucessCallBack) {
           sucessCallBack(res);
         }

이 변경점에서 너무 많은 파일들이 변경되어 몇몇 파일들은 표시되지 않았습니다.