Smart1.vue 49 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648
  1. <template>
  2. <div class="main_right_height">
  3. <div class="smart_content">
  4. <div style="height: 30px">&nbsp;</div>
  5. <div class="chat-window" id="contant1" ref="scrollview" style="margin-top: 20px">
  6. <!-- <div class="chat-window" id="contant1" ref="scrollview" style="margin-top: 20px"> -->
  7. <div v-if="echoFlag" style="text-align: center">
  8. <i class="el-icon-loading"></i>
  9. </div>
  10. <div
  11. class="chat-msg-content"
  12. id="rongqi"
  13. v-for="(content, index) in chatContents"
  14. :key="content.index"
  15. >
  16. <div
  17. v-if="content.from == 1"
  18. :key="content.id"
  19. class="main_answer_right"
  20. style="margin-top: 10px; padding-left: 20px"
  21. >
  22. <div class="img-wrapper">
  23. <img width="60px" heigth="60px" class="img" :src="from1" />
  24. </div>
  25. <div class="message-wrapper message-wrapper-left">
  26. <!-- {{ content.question }} -->
  27. <div class="message" v-html="content.question"></div>
  28. </div>
  29. </div>
  30. <el-row v-else style="margin-top: 10px; padding-right: 20px">
  31. <el-col :span="10"> &nbsp; </el-col>
  32. <el-col :span="14" s>
  33. <div
  34. class="main_answer_left"
  35. style="float: right"
  36. v-show="content.type == 1"
  37. >
  38. <div class="message-wrapper message-wrapper-right">
  39. <div class="message">{{ content.answer }}</div>
  40. </div>
  41. <div class="img-wrapper">
  42. <img width="60px" heigth="60px" class="img" :src="from2" />
  43. </div>
  44. </div>
  45. <div
  46. class="main_answer_left"
  47. style="float: right"
  48. v-show="content.type == 3 && index == chatContents.length - 1"
  49. >
  50. <div class="smart_mul_form2">
  51. <el-checkbox-group v-model="emotionMul" border class="check_column">
  52. <el-checkbox
  53. border
  54. @change="mulItem(item.name)"
  55. v-for="item in content.scale_MulItems"
  56. :label="item.name"
  57. :disabled="item.disable"
  58. :key="item.name"
  59. >{{ item.name }}</el-checkbox
  60. >
  61. </el-checkbox-group>
  62. &nbsp;&nbsp;<el-button
  63. @click="selectionComplete"
  64. size="mini"
  65. class="smart_mul_button_select"
  66. :disabled="emotionMul.length == 0"
  67. >确认选择</el-button
  68. >
  69. </div>
  70. <div class="img-wrapper">
  71. <img width="60px" heigth="60px" class="img" :src="from2" />
  72. </div>
  73. </div>
  74. <div
  75. class="main_answer_left"
  76. style="float: right"
  77. v-show="content.type == 2 && index == chatContents.length - 1"
  78. >
  79. <div class="smart_mul_form2">
  80. <el-radio
  81. border
  82. class="smart_radio"
  83. style="
  84. margin-top: 10px;
  85. margin-right: 30px;
  86. width: 200px;
  87. background: #ffffff;
  88. margin-left: 0px;
  89. "
  90. v-for="(item, index) in content.scale_checkItems"
  91. :key="index"
  92. v-model="radio"
  93. :label="item"
  94. fill="#57ACBB"
  95. @change="selectRadio(item, content.isScale)"
  96. >{{ item }}</el-radio
  97. >
  98. </div>
  99. <div class="img-wrapper">
  100. <img width="60px" heigth="60px" class="img" :src="from2" />
  101. </div>
  102. </div>
  103. </el-col>
  104. </el-row>
  105. </div>
  106. </div>
  107. <div class="smart_line_class"></div>
  108. <el-row v-show="inputFlag === 1" class="footSend">
  109. <!-- <el-col :span="1"> &nbsp; </el-col> -->
  110. <div style="flex: 1">
  111. <el-input
  112. class="xl_input"
  113. type="textarea"
  114. resize="none"
  115. placeholder="请输入内容"
  116. v-model="desc"
  117. show-word-limit
  118. @keyup.enter.native="sendMsg"
  119. clearable
  120. >
  121. </el-input>
  122. </div>
  123. <!-- <el-col :span="21">
  124. </el-col> -->
  125. <div class="send_buttom_style">
  126. <div style="flex: 1">&nbsp;</div>
  127. <el-button class="xl_d_send" @click="refreshFun">刷&nbsp;&nbsp;新</el-button>
  128. </div>
  129. <div class="send_buttom_style">
  130. <div style="flex: 1">&nbsp;</div>
  131. <el-button
  132. :disabled="desc.length == 0 || buttonFlag"
  133. class="xl_d_send"
  134. @click="sendMsg"
  135. >发&nbsp;&nbsp;送</el-button
  136. >
  137. </div>
  138. <!-- <el-col :span="3" class="send_buttom_style" style="">
  139. <div style="flex:1"> &nbsp;</div>
  140. <el-button :disabled="desc.length == 0 || buttonFlag" class="xl_d_send"
  141. @click="sendMsg">发&nbsp;&nbsp;送</el-button>
  142. </el-col> -->
  143. </el-row>
  144. <el-row v-show="inputFlag === 2" class="footSendSelect">
  145. <el-col :span="1"> &nbsp; </el-col>
  146. <el-col :span="22" style="margin-top: 20px; margin-bottom: 20px">
  147. <div>
  148. <el-radio
  149. style="margin-top: 10px"
  150. v-for="(item, index) in scale_checkItems"
  151. :key="index"
  152. v-model="radio"
  153. :label="item"
  154. fill="#57ACBB"
  155. @change="selectRadio(item)"
  156. >{{ item }}</el-radio
  157. >
  158. </div>
  159. </el-col>
  160. <el-col :span="1"> &nbsp; </el-col>
  161. </el-row>
  162. <el-row v-show="inputFlag === 3" class="footSendSelect">
  163. <el-col :span="1"> &nbsp; </el-col>
  164. <el-col :span="22" style="margin-top: 20px; margin-bottom: 20px">
  165. <div>
  166. <el-radio
  167. :disabled="!scaleSelectFlag"
  168. style="margin-top: 10px"
  169. v-for="(item, index) in scale_checkItems"
  170. :key="index"
  171. v-model="radio"
  172. :label="item"
  173. fill="#57ACBB"
  174. @change="choiceTriger(item)"
  175. >{{ item }}</el-radio
  176. >
  177. </div>
  178. </el-col>
  179. <el-col :span="1"> &nbsp; </el-col>
  180. </el-row>
  181. </div>
  182. </div>
  183. </template>
  184. <script>
  185. import HeadImg from "@/assets/lion.png";
  186. import HeadImg1 from "@/assets/persion.png";
  187. import axios from "axios";
  188. const HTTP_AXIOS = axios.create();
  189. export default {
  190. data() {
  191. return {
  192. identifier: "",
  193. //用户测试记录
  194. userName: "",
  195. //this.scale_checkItems = ["抑郁", "焦虑", "压力", "睡眠问题", "无"];
  196. emotionMul: [],
  197. //多选复制体
  198. emotionMulCopy: [],
  199. scale_MulItems: [
  200. { name: "抑郁", disable: false },
  201. { name: "焦虑", disable: false },
  202. { name: "应激", disable: false },
  203. { name: "睡眠问题", disable: false },
  204. { name: "无", disable: false },
  205. ],
  206. buttonFlag: false,
  207. pageNum: 1,
  208. pageSize: 10,
  209. tmpRadio: "",
  210. radio: "",
  211. inputFlag: 1,
  212. desc: "",
  213. from1: HeadImg,
  214. from2: HeadImg1,
  215. chatContents: [],
  216. //前三个问题
  217. preList: [],
  218. questionList: [{ index: 1, des: "能描述一下您最近训练的内容吗?", type: "1-2" }],
  219. //随机的4个数集合
  220. radomNumList: [],
  221. questionNum: 0,
  222. //随机4个问题的集合
  223. randomQuestion: [],
  224. //随机4个答案的集合
  225. randomAnswer: [],
  226. //全部题目
  227. scale_infos: [{ answer: "" }],
  228. //题目总数
  229. scale_all: 0,
  230. scale_checkItems: [],
  231. //进度参数
  232. scale_percent: [],
  233. //
  234. scale_index: 0,
  235. // 答案数据
  236. scale_result: [],
  237. //检测情绪前的发送数据条数
  238. threeAnswers: [],
  239. //负面情绪标志
  240. moonNegative: 0,
  241. scale_flag: "",
  242. pressure_flag: "",
  243. sendMsgFlag: true,
  244. scaleSelectFlag: true,
  245. flagTime: null,
  246. printIndex: 0,
  247. //当回显接口正在调用时为true
  248. echoFlag: false,
  249. //当前返回历史记录
  250. currenRecordTotol: 0,
  251. selectParams: "",
  252. //压力
  253. stress: "",
  254. //压力分
  255. stressScore: 0,
  256. //抑郁
  257. depressed: "",
  258. depressedScore: 0,
  259. //焦虑
  260. anxiety: "",
  261. anxietyScore: 0,
  262. //睡眠 的建议
  263. sleepZD: "",
  264. suggestion: "",
  265. ///总得分 焦虑抑郁应激总的分
  266. scoreJYY: 0,
  267. sleepScore: 0,
  268. };
  269. },
  270. created() {},
  271. mounted() {
  272. window.jumpPage = this.jumpPage;
  273. const scrollview = this.$refs["scrollview"];
  274. this.$root.smartNum = this.$root.smartNum + 1;
  275. this.init();
  276. //获取编号
  277. this.identifier = sessionStorage.getItem("num");
  278. this.userName = sessionStorage.getItem("name");
  279. // this.selectScale("20220805135201");
  280. scrollview.addEventListener("scroll", this.handleScroll, true);
  281. this.judgeModel();
  282. // /menu/evaluation
  283. // this.askEndMul(
  284. // ' 轻度:建议您使用系统中的虚拟现实、生物反馈训练<span onclick="jumpPage(1)" style="color:blue;cursor:pointer">(点击跳转)</span>、认知行为干预<span onclick="jumpPage(2)" style="color:blue;cursor:pointer">(点击跳转--走出抑郁)</span>功能进行心理状态调'
  285. // );
  286. },
  287. beforeDestroy() {
  288. let that = this;
  289. const scrollview = this.$refs["scrollview"];
  290. scrollview.removeEventListener("scroll", that.handleScroll);
  291. },
  292. methods: {
  293. refreshFun() {
  294. console.log("1111111111");
  295. //重置聊天对话
  296. //将记录清空然后开始调用查询的返回的接口
  297. this.chatContents = [];
  298. this.moonNegative = 0;
  299. this.pageNum = 1;
  300. this.pageSize = 10;
  301. clearInterval(this.flagTime);
  302. this.buttonFlag = false;
  303. this.selectPage();
  304. },
  305. judgeModel() {
  306. const cmd = require("node-cmd");
  307. let syncData = cmd.runSync("netstat -ano|findstr 9999");
  308. //假如数据库正在运行不动数据库状态
  309. if (syncData.data == null) {
  310. // this.$message.info("情绪判别模型尚未启动");
  311. this.$message({
  312. message:'情绪判别模型尚未启动',
  313. type:'info',
  314. duration:1000
  315. })
  316. }
  317. // if (syncData.data.includes("RUNNING")) {
  318. // }else{
  319. // this.$message.info('情绪判别模型尚未启动')
  320. // }
  321. let syncData1 = cmd.runSync("netstat -ano|findstr 9999");
  322. //假如数据库正在运行不动数据库状态
  323. if (syncData1.data == null) {
  324. // this.$message.info("对话模型尚未启动");
  325. this.$message({
  326. message:'对话模型尚未启动',
  327. type:'info',
  328. duration:1000
  329. })
  330. }
  331. // if (syncData1.data.includes("RUNNING")) {
  332. // }else{
  333. // this.$message.info('对话模型尚未启动')
  334. // }
  335. },
  336. handleScroll() {
  337. let scrollview = this.$refs["scrollview"];
  338. console.log(scrollview.scrollTop);
  339. if (scrollview.scrollTop == 0) {
  340. //当前没有调接口的时候
  341. if (!this.echoFlag) {
  342. //判断上一次的页面是否足够10条如果不够就不查询了
  343. //页面页数加1
  344. if (this.currenRecordTotol == this.pageSize) {
  345. this.pageNum++;
  346. this.selectPage();
  347. }
  348. }
  349. //当等于0时需要调用加载上一页
  350. }
  351. // console.log("qlkhdeqj1");
  352. //滚动监听事件
  353. },
  354. //上来就监听数据变化 如果有变化就保存最后一条数据
  355. //如果保存保存后
  356. // choiceTriger(item) {
  357. // let that = this;
  358. // that.radioChange(item);
  359. // },
  360. // 选中选项
  361. radioChange(item) {
  362. this.tmpRadio = item;
  363. var scaleInfoTemp = Object.assign({}, this.scale_infos[this.scale_index]);
  364. this.radio = "";
  365. scaleInfoTemp.checkItems = item;
  366. this.scale_result.push(scaleInfoTemp);
  367. // bbc测试判断是否展示20~24题
  368. if (item != "是" && this.scale_flag == "20211101163739" && this.scale_index == 19) {
  369. this.scale_index = 24;
  370. for (let i = 20; i < 24; i++) {
  371. this.scale_result.push(this.scale_infos[i]);
  372. }
  373. this.scale_checkItems = this.scale_infos[this.scale_index].checkItems.split(";");
  374. this.chatContents.push({
  375. from: 2,
  376. answer: "",
  377. from1: HeadImg,
  378. isHistory: true,
  379. type: 2,
  380. scale_checkItems: this.scale_infos[this.scale_index].checkItems.split(";"),
  381. isScale: true,
  382. });
  383. return;
  384. }
  385. //如果是单选题
  386. if (scaleInfoTemp.questionType == "0") {
  387. if (this.scale_index <= this.scale_infos.length - 1) this.scale_index += 1;
  388. this.answerSelect(this.tmpRadio);
  389. //scale_index == 题目总数,表示结束
  390. if (this.scale_index == this.scale_infos.length) {
  391. this.scale_index -= 1;
  392. this.scaleSelectFlag = false;
  393. //发送测试结果给后台
  394. // this.$message({
  395. // message: "测试完成,即将生成测试报告!",
  396. // type: "success",
  397. // });
  398. // console.log("==--3--------->", this.testPlanId);
  399. console.log(
  400. "==---4-------->",
  401. sessionStorage.getItem("b80bb7740288fda1f201890375a60c8f")
  402. );
  403. this.$http.post(
  404. `v1/result/${this.scale_flag}`,
  405. {
  406. scale_result: this.scale_result,
  407. identifier: sessionStorage.getItem("num"),
  408. },
  409. (res) => {
  410. this.next_and_last_button = false;
  411. if (res.data.code == 200) {
  412. this.resultJson = res.data.data;
  413. if (this.scale_flag == "20210725100704") {
  414. } else {
  415. this.getAnswerQuestionPaymentSuccess(this.resultJson);
  416. }
  417. } else {
  418. this.$message.error("访问服务器失败!");
  419. }
  420. }
  421. );
  422. } else {
  423. // 我觉得很难让自己安静下来
  424. let a = this.scale_infos[this.scale_index].answer + "";
  425. // console.log(a);
  426. //this.askEnd(this.scale_infos[this.scale_index].answer);
  427. // setTimeout(() => {
  428. this.askEnd(a);
  429. // }, 20);
  430. this.scale_checkItems = this.scale_infos[this.scale_index].checkItems.split(
  431. ";"
  432. );
  433. this.chatContents.push({
  434. from: 2,
  435. answer: "",
  436. from1: HeadImg,
  437. isHistory: true,
  438. type: 2,
  439. scale_checkItems: this.scale_infos[this.scale_index].checkItems.split(";"),
  440. isScale: true,
  441. });
  442. }
  443. }
  444. },
  445. //判断如何显示
  446. showSuggetion() {
  447. console.log(this.depressed);
  448. console.log(this.anxiety);
  449. console.log(this.stress);
  450. // //压力
  451. // stress: "",
  452. // //压力分
  453. // stressScore: 0,
  454. // //抑郁
  455. // depressed: "",
  456. // depressedScore: 0,
  457. // //焦虑
  458. // anxiety: "",
  459. // anxietyScore: 0,
  460. // //睡眠 的建议
  461. // sleepZD: "",
  462. // suggestion: "",
  463. // ///总得分 焦虑抑郁应激总的分
  464. // scoreJYY: 0,
  465. // sleepScore: 0,
  466. // if (this.emotionMul.indexOf("抑郁") != -1) {
  467. // this.emotionMulCopy.push("抑郁");
  468. // }
  469. //判断是否包含抑郁
  470. let sumStr = `建议您使用系统中的虚拟现实、生物反馈训练<span onclick="jumpPage(6)" style="color:blue;cursor:pointer">(点击跳转)</span>、认知行为干预`;
  471. let jumpStr = "";
  472. if (this.selectParams.indexOf("抑郁") != -1) {
  473. if (this.depressed != "") {
  474. this.askEndMul(this.depressed);
  475. }
  476. if (this.depressedScore >= 7 && this.depressedScore <= 13) {
  477. jumpStr += `<span onclick="jumpPage(2)" style="color:blue;cursor:pointer">(点击跳转--走出抑郁)</span>、`;
  478. }
  479. }
  480. if (this.selectParams.indexOf("焦虑") != -1) {
  481. if (this.anxiety != "") {
  482. this.askEndMul(this.anxiety);
  483. }
  484. if (this.anxietyScore >= 7 && this.anxietyScore <= 13) {
  485. jumpStr += `<span onclick="jumpPage(1)" style="color:blue;cursor:pointer">(点击跳转--战胜焦虑)</span>、`;
  486. }
  487. //如果包含的话
  488. }
  489. if (this.selectParams.indexOf("应激") != -1) {
  490. if (this.stress != "") {
  491. this.askEndMul(this.stress);
  492. }
  493. if (this.stressScore >= 7 && this.stressScore <= 13) {
  494. jumpStr += `<span onclick="jumpPage(4)" style="color:blue;cursor:pointer">(点击跳转--克服应激)</span>、`;
  495. }
  496. //如果包含的话
  497. }
  498. if (this.selectParams.indexOf("睡眠问题") != -1) {
  499. debugger;
  500. //如果包含的话
  501. if (this.sleepZD != "") {
  502. this.askEndMul(this.sleepZD);
  503. }
  504. if (this.sleepScore >= 19 && this.sleepScore <= 34) {
  505. jumpStr += `<span onclick="jumpPage(3)" style="color:blue;cursor:pointer">(点击跳转--远离失眠)</span>、`;
  506. }
  507. }
  508. let res = jumpStr.replace(/(.*)、/, "$1");
  509. debugger;
  510. // sumStr += `进行心理状态调试。`;
  511. sumStr = sumStr + res + `进行心理状态调适。`;
  512. //判断
  513. if (
  514. this.sleepScore >= 35 ||
  515. this.stressScore >= 14 ||
  516. this.anxietyScore >= 14 ||
  517. this.depressedScore >= 14 ||
  518. this.scoreJYY >= 42
  519. ) {
  520. sumStr = `您可能存在较为严重的心理健康问题,建议您尽快到医院进行专业诊断和治疗。`;
  521. }
  522. if (
  523. this.sleepScore < 19 &&
  524. this.depressedScore < 7 &&
  525. this.anxietyScore < 7 &&
  526. this.stressScore < 7
  527. ) {
  528. sumStr = `您心理健康状态良好,希望您继续保持。`;
  529. }
  530. this.askEndMul(sumStr);
  531. //判断焦虑抑郁量表的分数
  532. // if (this.scoreJYY > 0) {
  533. // }
  534. // //判断睡眠量表的分数
  535. // if (this.sleepScore) {
  536. // }
  537. },
  538. getAnswerQuestionPaymentSuccess(id) {
  539. // sessionStorage.setItem("back_page", "1");
  540. let _this = this;
  541. _this.$http.post(`v1/record/find/${id}`, {}, (res) => {
  542. _this.scaleSelectFlag = true;
  543. if (res.data.code == 200 && res.data.data) {
  544. _this.resultJsonParams = res.data.data;
  545. let testResult = JSON.parse(res.data.data.userRecordEntity.testResult)[0]
  546. .version;
  547. if (_this.scale_flag === "20210910163158") {
  548. let sleep = JSON.parse(_this.resultJsonParams.userRecordEntity.testResult);
  549. this.sleepScore = sleep[0].newTableContext.result[0].score;
  550. sleep = sleep[0].newTableContext.result[0].improvementSuggestions;
  551. this.sleepZD = sleep;
  552. // _this.askEndMul(sleep);
  553. if (_this.emotionMul.length == 0) {
  554. _this.showSuggetion();
  555. } else {
  556. _this.judgeNum();
  557. }
  558. } else if (_this.scale_flag === "20220805135201") {
  559. let sleep = JSON.parse(_this.resultJsonParams.userRecordEntity.testResult);
  560. sleep = sleep[0].tableContext;
  561. console.log(sleep);
  562. let str = "";
  563. for (let i = 0; i < sleep.length; i++) {
  564. //if (_this.pressure_flag === "压力") {
  565. // if(){}
  566. if (sleep[i].name === "压力指导语") {
  567. if (_this.emotionMulCopy.indexOf("应激") != -1) {
  568. //str = "压力建议:" + sleep[i].value[0] + " ";
  569. this.stress = sleep[i].value[0] + " ";
  570. //压力得分
  571. // _this.askEndMul("应激建议:" + sleep[i].value[0] + " ");
  572. }
  573. }
  574. if (sleep[i].name === "压力得分") {
  575. if (_this.emotionMulCopy.indexOf("应激") != -1) {
  576. //str = "压力建议:" + sleep[i].value[0] + " ";
  577. this.stressScore = Number(sleep[i].value[0]);
  578. //压力得分
  579. // _this.askEndMul("应激建议:" + sleep[i].value[0] + " ");
  580. }
  581. }
  582. //}
  583. // if (_this.pressure_flag === "焦虑") {
  584. if (sleep[i].name === "焦虑指导语") {
  585. if (_this.emotionMulCopy.indexOf("焦虑") != -1) {
  586. // str = "焦虑建议:" + sleep[i].value[0] + " ";
  587. this.anxiety = sleep[i].value[0] + " ";
  588. // this.askEndMul("焦虑建议:" + sleep[i].value[0] + " ");
  589. }
  590. }
  591. if (sleep[i].name === "焦虑得分") {
  592. if (_this.emotionMulCopy.indexOf("焦虑") != -1) {
  593. // str = "焦虑建议:" + sleep[i].value[0] + " ";
  594. this.anxietyScore = Number(sleep[i].value[0]);
  595. // this.askEndMul("焦虑建议:" + sleep[i].value[0] + " ");
  596. }
  597. }
  598. //}
  599. //if (_this.pressure_flag === "抑郁") {
  600. if (sleep[i].name === "抑郁指导语") {
  601. if (_this.emotionMulCopy.indexOf("抑郁") != -1) {
  602. //str = "抑郁建议:" + sleep[i].value[0] + " ";
  603. this.depressed = sleep[i].value[0] + " ";
  604. // this.askEndMul("抑郁建议:" + sleep[i].value[0] + " ");
  605. }
  606. }
  607. if (sleep[i].name === "抑郁得分") {
  608. if (_this.emotionMulCopy.indexOf("抑郁") != -1) {
  609. //str = "抑郁建议:" + sleep[i].value[0] + " ";
  610. this.depressedScore = Number(sleep[i].value[0]);
  611. // this.askEndMul("抑郁建议:" + sleep[i].value[0] + " ");
  612. }
  613. }
  614. }
  615. for (let i = 0; i < sleep.length; i++) {
  616. if (sleep[i].name === "总分") {
  617. let score = parseInt(sleep[i].value[0]);
  618. this.scoreJYY = score;
  619. // if (score >= 0 && score <= 20) {
  620. // this.askEndMul(
  621. // ' 轻度:建议您使用系统中的虚拟现实、生物反馈训练<span onclick="jumpPage(1)" style="color:blue;cursor:pointer">(点击跳转)</span>、认知行为干预<span onclick="jumpPage(2)" style="color:blue;cursor:pointer">(点击跳转--走出抑郁)</span>功能进行心理状态调试。'
  622. // );
  623. // }
  624. }
  625. }
  626. console.log(sleep);
  627. // _this.askEnd(str);
  628. if (_this.emotionMul.length == 0) {
  629. _this.showSuggetion();
  630. //在此处输出总建议
  631. } else {
  632. _this.judgeNum();
  633. }
  634. // _this.askEnd("您还想跟我再聊一聊吗?");
  635. // this.scale_checkItems = ["是", "否"];
  636. }
  637. // let testResult = JSON.parse(
  638. // res.data.data.userRecordEntity.testResult
  639. // )[0].version;
  640. // if (testResult == 2) {
  641. // _this.$router.push({
  642. // name: "scaleResultSCl",
  643. // params: { tableData: _this.resultJsonParams }
  644. // });
  645. // } else {
  646. // _this.$router.push({
  647. // name: "scaleResult",
  648. // params: { tableData: _this.resultJsonParams }
  649. // });
  650. // }
  651. }
  652. });
  653. },
  654. jumpPage(val) {
  655. let that = this;
  656. console.log(val);
  657. if (val == 6) {
  658. //跳转到生物反馈
  659. // this.$router.push(c)
  660. this.$router.push({ path: "/menu/animation" });
  661. this.$emit("updateProjectId", "swfk");
  662. } else {
  663. this.$router.push({ path: "/menu/treatDepression", query: { id: val } });
  664. this.$emit("updateProjectId", "rzgy");
  665. }
  666. // if (val == 2) {
  667. // // this.$router.push({ path: "/menu/intervene/treatDepression", query: { id: 2 } });
  668. // // this.$router.push({ path: "/menu/intervene", query: { id: 2 } });
  669. // // this.$router.push({ path: "/menu/intervene" });
  670. // // this.$router.push({ path: "/menu/evaluation", query: { id: 2 } });
  671. // // that.$router.push({ path: "/menu/treatDepression", query: { id: 2 } });
  672. // // this.$router.push({ path: "/menu/animation" });
  673. // //跳转到//认知干预
  674. // }
  675. },
  676. askEndMul(val) {
  677. this.chatContents.push({
  678. from: 1,
  679. question: val,
  680. from1: HeadImg,
  681. //类型 1 描述
  682. //类型 2 单选
  683. //类型 3 多选
  684. isHistory: true,
  685. type: 1,
  686. });
  687. let ob = {
  688. label: 0,
  689. content: val,
  690. };
  691. this.saveRecord(ob);
  692. this.downPage();
  693. },
  694. downPage() {
  695. let contant1 = document.getElementById("contant1");
  696. this.sleep(101).then(() => {
  697. contant1.scrollTop = contant1.scrollHeight;
  698. });
  699. },
  700. //获取量表问题
  701. selectScale(flag) {
  702. this.$http.get(`v1/scale/${flag}`, {}, (res) => {
  703. this.scale_index = 0;
  704. this.scale_result = [];
  705. this.scale_infos = res.data;
  706. this.scale_all = this.scale_infos.length;
  707. this.askEnd(this.scale_infos[this.scale_index].answer);
  708. this.scale_checkItems = this.scale_infos[this.scale_index].checkItems.split(";");
  709. //将数据放入数组
  710. this.chatContents.push({
  711. from: 2,
  712. answer: "",
  713. from1: HeadImg,
  714. type: 2,
  715. scale_checkItems: this.scale_infos[this.scale_index].checkItems.split(";"),
  716. isHistory: true,
  717. isScale: true,
  718. });
  719. this.scale_percent = parseInt((this.scale_index + 1) / this.scale_all);
  720. this.scale_percent = ((this.scale_index + 1) * 100) / this.scale_all;
  721. });
  722. },
  723. //点击用户选择完毕
  724. selectionComplete() {
  725. this.buttonFlag = false;
  726. //设置一个全局的变量 知道选择的是那个选项
  727. let val = this.emotionMul.toString();
  728. this.selectParams = val;
  729. this.answerSelect(val);
  730. //应该先判断是否包含 抑郁,焦虑,压力
  731. //如果包含的话,需要将其存进数组
  732. this.emotionMulCopy = [];
  733. if (this.emotionMul.indexOf("抑郁") != -1) {
  734. this.emotionMulCopy.push("抑郁");
  735. }
  736. if (this.emotionMul.indexOf("焦虑") != -1) {
  737. this.emotionMulCopy.push("焦虑");
  738. }
  739. if (this.emotionMul.indexOf("应激") != -1) {
  740. this.emotionMulCopy.push("应激");
  741. }
  742. console.log(this.emotionMulCopy);
  743. this.judgeNum();
  744. //假如选择了一个--不管是无,还是睡眠,还是焦虑
  745. },
  746. //点击进行选择
  747. judgeNum() {
  748. debugger;
  749. if (this.emotionMul.length == 1) {
  750. let a = this.emotionMul[0];
  751. this.selectRadio(a, false);
  752. //清空选项
  753. this.emotionMul = [];
  754. } else if (this.emotionMul.length > 1) {
  755. //判断是否含有睡眠字段
  756. //如果含有睡眠字段
  757. //且长度大于2时
  758. if (this.emotionMul.indexOf("睡眠问题") != -1) {
  759. if (this.emotionMul.length > 2) {
  760. this.emotionMul = ["抑郁", "睡眠问题"];
  761. }
  762. } else {
  763. this.emotionMul = ["抑郁"];
  764. }
  765. //选择的大于1
  766. //假如选了两个抑郁,焦虑
  767. let aLin = this.emotionMul[0];
  768. this.selectRadio(aLin, false);
  769. let a = [];
  770. for (let i = 0; i < this.emotionMul.length; i++) {
  771. if (i > 0) {
  772. a.push(this.emotionMul[i]);
  773. }
  774. }
  775. console.log(a);
  776. this.emotionMul = a;
  777. }
  778. },
  779. selectRadio(val, isScale) {
  780. //当是量表的时候需要执行量表的逻辑
  781. if (isScale) {
  782. this.radioChange(val);
  783. } else {
  784. //当不是量表的时候需要执行不是量表的逻辑
  785. if (val == "无") {
  786. // this.answerSelect("无");
  787. }
  788. if (val === "无") {
  789. this.askEnd("您可能存在心理健康方面问题,建议寻求专业人员的指导");
  790. //隐藏选项框和输入框进行提示
  791. } else if (val === "睡眠问题") {
  792. // this.inputFlag = 3;
  793. this.askEnd(
  794. "为了进一步判断您是否存在睡眠方面的问题,下面我会问您一些问题,请您选择作答"
  795. );
  796. // this.askEnd("睡眠问卷");
  797. // this.scale_checkItems = ["好的"];
  798. this.chatContents.push({
  799. from: 2,
  800. answer: "",
  801. from1: HeadImg,
  802. type: 2,
  803. scale_checkItems: ["好的"],
  804. isHistory: true,
  805. isScale: false,
  806. });
  807. // this.inputFlag = 2;
  808. this.scale_flag = "20210910163158";
  809. // this.selectScale(this.scale_flag);
  810. //调用接口睡眠量表
  811. } else if (val === "抑郁" || val === "焦虑" || val === "应激") {
  812. if (val === "抑郁") {
  813. this.pressure_flag = "抑郁";
  814. }
  815. if (val === "焦虑") {
  816. this.pressure_flag = "焦虑";
  817. }
  818. if (val === "应激") {
  819. this.pressure_flag = "应激";
  820. }
  821. // this.inputFlag = 3;
  822. this.askEnd(
  823. "为了进一步判断您是否存在心理健康方面的问题,下面我会问您一些问题,请您选择作答"
  824. );
  825. // this.askEnd("抑郁、焦虑、压力问卷");
  826. this.scale_checkItems = ["好的"];
  827. this.chatContents.push({
  828. from: 2,
  829. answer: "",
  830. from1: HeadImg,
  831. type: 2,
  832. scale_checkItems: ["好的"],
  833. isHistory: true,
  834. isScale: false,
  835. });
  836. //
  837. // this.inputFlag = 2;
  838. this.scale_flag = "20220805135201";
  839. // this.selectScale(this.scale_flag);
  840. //调用接口抑郁焦虑压力问卷
  841. } else if (val === "好的") {
  842. // this.inputFlag = 3;
  843. // if(this.scale_flag==='20210910163158'){
  844. // }
  845. this.answerSelect("好的");
  846. this.selectScale(this.scale_flag);
  847. } else if (val === "是") {
  848. //从头开始
  849. this.init("reStart");
  850. // this.inputFlag = 1;
  851. } else if (val === "否") {
  852. //结束测试
  853. // this.askEnd("对话结束");
  854. // this.inputFlag = 0;
  855. }
  856. }
  857. //应该是先判断是否有量表选择的
  858. // this.answerSelect(val);
  859. //如果是包含 抑郁 焦虑 压力 在这其中,则
  860. // if(this.emotionMulCopy.indexOf(val)!=-1){
  861. // this.answerSelect(this.emotionMulCopy.toString());
  862. // }else{
  863. // this.answerSelect(val);
  864. // }
  865. },
  866. mulItem(val) {
  867. console.log(this.emotionMul);
  868. //先判断是否是点击否,如果点击否
  869. //则需要判断里边是否存在否
  870. //如果里边不存在,选中后其他选项都置为空
  871. if (val == "无") {
  872. console.log(this.emotionMul.indexOf("无") == -1);
  873. if (this.emotionMul.indexOf("无") == -1) {
  874. //不存在
  875. for (let i = 0; i < this.scale_MulItems.length; i++) {
  876. this.scale_MulItems[i].disable = false;
  877. }
  878. } else {
  879. //存在
  880. this.emotionMul = ["无"];
  881. //scale_MulItems
  882. //循环问题
  883. for (let i = 0; i < this.scale_MulItems.length; i++) {
  884. if (this.scale_MulItems[i].name !== "无") {
  885. this.scale_MulItems[i].disable = true;
  886. }
  887. }
  888. }
  889. }
  890. },
  891. init() {
  892. //进入页面后先执行查询前50条数据的接口
  893. //查询前5条数据
  894. this.selectPage();
  895. let contant1 = document.getElementById("contant1");
  896. this.sleep(300).then(() => {
  897. contant1.scrollTop = contant1.scrollHeight;
  898. });
  899. },
  900. //查询记录的方法
  901. selectPage() {
  902. let that = this;
  903. that.echoFlag = true;
  904. this.$http.get(
  905. `/intelligent/dialogueRecords?identifier=${sessionStorage.getItem(
  906. "num"
  907. )}&pageNum=${that.pageNum}&pageSize=${that.pageSize}&type=0`,
  908. {},
  909. (res) => {
  910. if (res.code == 200) {
  911. that.echoFlag = false;
  912. // res.data.
  913. if (res.data.intelligentDialogueEntities.content.length > 0) {
  914. that.currenRecordTotol =
  915. res.data.intelligentDialogueEntities.content.length;
  916. //判断当前是第几页
  917. //如果是第一个
  918. for (
  919. let i = 0;
  920. i < res.data.intelligentDialogueEntities.content.length;
  921. i++
  922. ) {
  923. if (res.data.intelligentDialogueEntities.content[i].label == "0") {
  924. if (that.$root.smartNum == 1) {
  925. this.chatContents.unshift({
  926. from: 1,
  927. question: res.data.intelligentDialogueEntities.content[i].content,
  928. from1: HeadImg,
  929. isHistory: true,
  930. type: 1,
  931. });
  932. } else {
  933. this.chatContents.unshift({
  934. from: 1,
  935. question: res.data.intelligentDialogueEntities.content[i].content,
  936. from1: HeadImg,
  937. isHistory: true,
  938. type: 1,
  939. });
  940. }
  941. } else {
  942. if (that.$root.smartNum == 1) {
  943. this.chatContents.unshift({
  944. from: 2,
  945. answer: res.data.intelligentDialogueEntities.content[i].content,
  946. from1: HeadImg,
  947. isHistory: true,
  948. type: 1,
  949. });
  950. } else {
  951. this.chatContents.unshift({
  952. from: 2,
  953. answer: res.data.intelligentDialogueEntities.content[i].content,
  954. from1: HeadImg,
  955. isHistory: true,
  956. type: 1,
  957. });
  958. }
  959. }
  960. }
  961. let contant1 = document.getElementById("contant1");
  962. this.sleep(300).then(() => {
  963. contant1.scrollTop = 2;
  964. });
  965. }
  966. } else {
  967. }
  968. }
  969. );
  970. },
  971. sleep(time) {
  972. return new Promise((resolve) => setTimeout(resolve, time));
  973. },
  974. sendMsg() {
  975. //判断对话长度是否大于0
  976. //如果大于0 则取最后看最后一个是不是form等于2如果是2 类型是2或3时则不反应
  977. if (this.chatContents.length > 0) {
  978. if (this.chatContents[this.chatContents.length - 1].from !== 1) {
  979. if (
  980. this.chatContents[this.chatContents.length - 1].type == 2 ||
  981. this.chatContents[this.chatContents.length - 1].type == 3
  982. ) {
  983. return;
  984. }
  985. }
  986. }
  987. if (this.desc.length == 0 || this.buttonFlag) {
  988. return;
  989. }
  990. this.sendMsgFlag = false;
  991. let contant1 = document.getElementById("contant1");
  992. let tmp = {
  993. from: 2,
  994. answer: this.desc,
  995. from1: HeadImg,
  996. type: 1,
  997. };
  998. this.chatContents.push(tmp);
  999. this.getQuestion();
  1000. //在调用一个方法,将这个值的情绪发送给另一个方法
  1001. this.getMood(this.desc);
  1002. //调用保存接口
  1003. let ob = {
  1004. label: 1,
  1005. content: this.desc,
  1006. };
  1007. this.saveRecord(ob);
  1008. // 让滚动条始终在最底部
  1009. this.sleep(101).then(() => {
  1010. contant1.scrollTop = contant1.scrollHeight;
  1011. });
  1012. this.desc = "";
  1013. //立马调用
  1014. //进行提问的接口
  1015. //第一个问题出来后先对答案进行解析
  1016. },
  1017. getMood(val) {
  1018. //代替对话
  1019. this.moonNegative += 1;
  1020. // http://127.0.0.1:9999/sentiment
  1021. //http://127.0.0.1:9999
  1022. //`http://127.0.0.1:9999/sentiment
  1023. //http://aagvs5.natappfree.cc/sentiment
  1024. //http://127.0.0.1:9999/sentiment
  1025. //http://127.0.0.1:9999/sentiment
  1026. //情绪判别
  1027. // let that = this;
  1028. // axios.post(`http://127.0.0.1:9999/sentiment`, { text: val }).then((res) => {
  1029. // console.log(res.data.sentiment);
  1030. // if (
  1031. // res.data.sentiment === "厌恶" ||
  1032. // res.data.sentiment === "恐惧" ||
  1033. // res.data.sentiment === "悲伤" ||
  1034. // res.data.sentiment === "愤怒"
  1035. // ) {
  1036. // this.moonNegative += 1;
  1037. // }
  1038. // //假如负面情绪大于5则需要调用量表方法
  1039. // // that.sendMsgFlag = true;
  1040. // // that.threeAnswers.push(res.data.sentiment);
  1041. // //如果是已婚人员则判断七个中是否存在4个负面情绪
  1042. // //0为已婚人员
  1043. // });
  1044. },
  1045. //发送问题的接口
  1046. //获取问题的接口//需要传输上下文关系,应该是需要上一个问题回答的是啥
  1047. getQuestion() {
  1048. let that = this;
  1049. that.buttonFlag = true;
  1050. //循环当前问题
  1051. let list = [];
  1052. //传输到后台的上下文.最大限制6条吧
  1053. //当回显的条数小于6条时走下边的逻辑
  1054. if (this.chatContents.length < 5) {
  1055. for (let i = 0; i < this.chatContents.length; i++) {
  1056. if (this.chatContents[i].from == 1) {
  1057. console.log(this.chatContents[i].hasOwnProperty("isHistory"));
  1058. if (!this.chatContents[i].hasOwnProperty("isHistory")) {
  1059. list.push(this.chatContents[i].question);
  1060. }
  1061. } else {
  1062. if (!this.chatContents[i].hasOwnProperty("isHistory")) {
  1063. list.push(this.chatContents[i].answer);
  1064. }
  1065. }
  1066. }
  1067. } else {
  1068. for (let i = 5; i > 0; i--) {
  1069. if (this.chatContents[this.chatContents.length - i].from == 1) {
  1070. if (
  1071. !this.chatContents[this.chatContents.length - i].hasOwnProperty("isHistory")
  1072. ) {
  1073. list.push(this.chatContents[this.chatContents.length - i].question);
  1074. }
  1075. } else {
  1076. if (
  1077. !this.chatContents[this.chatContents.length - i].hasOwnProperty("isHistory")
  1078. ) {
  1079. list.push(this.chatContents[this.chatContents.length - i].answer);
  1080. }
  1081. }
  1082. // list.push(chatContents.question);
  1083. }
  1084. }
  1085. // 进入页面后调用加载中的方法
  1086. //三个点轮询播放
  1087. this.chatContents.push({
  1088. from: 1,
  1089. question: "",
  1090. from1: HeadImg,
  1091. type: 1,
  1092. });
  1093. this.pFun("......", false);
  1094. //`http://127.0.0.1:9998/chat`
  1095. //http://127.0.0.1:9998/chat
  1096. //http://ray-thunder.natapp1.cc/chat
  1097. //代替智能对话
  1098. let contant1 = document.getElementById("contant1");
  1099. this.sleep(101).then(() => {
  1100. contant1.scrollTop = contant1.scrollHeight;
  1101. });
  1102. clearInterval(this.flagTime);
  1103. this.pFun("我收到了", true);
  1104. //先判断list是否是奇数 如果是奇数就没问题如果并不是奇数择传输少一位即可
  1105. // if(list.length%2==0){
  1106. // list.shift()
  1107. // }
  1108. // console.log('list')
  1109. // console.log(list)
  1110. // HTTP_AXIOS({
  1111. // method: "post",
  1112. // url: `http://127.0.0.1:9998/chat`,
  1113. // data: { text: list },
  1114. // timeout: 300000,
  1115. // })
  1116. // .then((res) => {
  1117. // if (res) {
  1118. // let contant1 = document.getElementById("contant1");
  1119. // this.sleep(101).then(() => {
  1120. // contant1.scrollTop = contant1.scrollHeight;
  1121. // });
  1122. // clearInterval(this.flagTime);
  1123. // this.pFun(res.data.response, true);
  1124. // //请求成功后返回的参数
  1125. // //console.log(res);
  1126. // }
  1127. // })
  1128. // .catch((error) => {
  1129. // if (error.config.timeout == 300000) {
  1130. // Message.error("请求超时,请检查网络");
  1131. // } else {
  1132. // console.log(error);
  1133. // }
  1134. // });
  1135. },
  1136. startScale() {
  1137. // this.inputFlag = 4;
  1138. //进行提问
  1139. this.buttonFlag = true;
  1140. this.chatContents.push({
  1141. from: 1,
  1142. question: "请问您近期是否存在以下方面的困扰(请选择)",
  1143. from1: HeadImg,
  1144. isHistory: true,
  1145. type: 1,
  1146. });
  1147. let ob = {
  1148. label: 0,
  1149. content: "请问您近期是否存在以下方面的困扰(请选择)",
  1150. type: 1,
  1151. };
  1152. this.saveRecord(ob);
  1153. this.chatContents.push({
  1154. from: 2,
  1155. question: "",
  1156. from1: HeadImg,
  1157. isHistory: true,
  1158. type: 3,
  1159. scale_MulItems: [
  1160. { name: "抑郁", disable: false },
  1161. { name: "焦虑", disable: false },
  1162. { name: "应激", disable: false },
  1163. { name: "睡眠问题", disable: false },
  1164. { name: "无", disable: false },
  1165. ],
  1166. isScale: false,
  1167. });
  1168. // this.scale_MulItems = [
  1169. // { name: "抑郁", disable: false },
  1170. // { name: "焦虑", disable: false },
  1171. // { name: "应激", disable: false },
  1172. // { name: "睡眠问题", disable: false },
  1173. // { name: "无", disable: false },
  1174. // ];
  1175. },
  1176. pFun(val, flag) {
  1177. let that = this;
  1178. //3个循环播放
  1179. this.chatContents[this.chatContents.length - 1].question = "";
  1180. this.printIndex = 0;
  1181. let a = val;
  1182. clearInterval(this.flagTime);
  1183. this.flagTime = setInterval(
  1184. () => {
  1185. if (this.printIndex < a.length) {
  1186. this.chatContents[this.chatContents.length - 1].question += a.charAt(
  1187. this.printIndex
  1188. );
  1189. this.printIndex++;
  1190. if (flag) {
  1191. let contant1 = document.getElementById("contant1");
  1192. this.sleep(101).then(() => {
  1193. contant1.scrollTop = contant1.scrollHeight;
  1194. });
  1195. }
  1196. } else {
  1197. if (flag) {
  1198. that.buttonFlag = false;
  1199. //清除定时器
  1200. let contant1 = document.getElementById("contant1");
  1201. this.sleep(101).then(() => {
  1202. contant1.scrollTop = contant1.scrollHeight;
  1203. });
  1204. // this.saveRecord(this.chatContents[this.chatContents.length - 1].question)
  1205. clearInterval(this.flagTime);
  1206. let ob = {
  1207. label: 0,
  1208. content: this.chatContents[this.chatContents.length - 1].question,
  1209. };
  1210. this.saveRecord(ob);
  1211. //在这判断负面情绪是否足够5个
  1212. if (this.moonNegative == 5) {
  1213. this.startScale();
  1214. }
  1215. } else {
  1216. this.printIndex = 0;
  1217. this.chatContents[this.chatContents.length - 1].question = ".";
  1218. }
  1219. }
  1220. },
  1221. flag ? 60 : 300
  1222. );
  1223. },
  1224. //保存记录的接口
  1225. saveRecord(val) {
  1226. let data = {
  1227. identifier: this.identifier,
  1228. label: val.label,
  1229. content: val.content,
  1230. userName: this.userName,
  1231. questionNo: "",
  1232. type: "0",
  1233. };
  1234. console.log(data);
  1235. // this.$message.success("保存成功");
  1236. this.$http.post(`/intelligent/save`, data, (res) => {
  1237. if (res.data.code == 200) {
  1238. console.log(val.content);
  1239. } else {
  1240. }
  1241. });
  1242. },
  1243. //调用接口查询情绪
  1244. askEnd(val) {
  1245. this.chatContents.push({
  1246. from: 1,
  1247. question: val,
  1248. from1: HeadImg,
  1249. isHistory: true,
  1250. type: 1,
  1251. });
  1252. let ob = {
  1253. label: 0,
  1254. content: val,
  1255. };
  1256. let contant1 = document.getElementById("contant1");
  1257. this.sleep(101).then(() => {
  1258. this.saveRecord(ob);
  1259. contant1.scrollTop = contant1.scrollHeight;
  1260. });
  1261. },
  1262. answerSelect(val) {
  1263. this.chatContents.push({
  1264. from: 2,
  1265. answer: val,
  1266. from1: HeadImg,
  1267. isHistory: true,
  1268. type: 1,
  1269. });
  1270. let ob = {
  1271. label: 1,
  1272. content: val,
  1273. };
  1274. this.saveRecord(ob);
  1275. },
  1276. askQuestions() {
  1277. this.chatContents.push({
  1278. from: 1,
  1279. question: this.preList[this.threeAnswers.length].des,
  1280. from1: HeadImg,
  1281. isHistory: true,
  1282. type: 1,
  1283. });
  1284. let ob = {
  1285. label: 0,
  1286. content: val,
  1287. };
  1288. this.saveRecord(ob);
  1289. this.questionNum++;
  1290. },
  1291. goBack() {
  1292. this.$router.go(-1);
  1293. },
  1294. },
  1295. };
  1296. </script>
  1297. <style scoped>
  1298. .mainTable-top {
  1299. margin-top: 5%;
  1300. }
  1301. .mainTable-top-two {
  1302. margin-top: 10%;
  1303. }
  1304. .mainTable-tab {
  1305. cursor: pointer;
  1306. margin-left: 100px;
  1307. margin-right: 100px;
  1308. border-radius: 5px;
  1309. border: 1px solid #000000;
  1310. text-align: center;
  1311. height: 150px;
  1312. margin-bottom: 100px;
  1313. }
  1314. .mainTable-tab-p {
  1315. padding-top: 40px;
  1316. }
  1317. .musicTitle {
  1318. display: block;
  1319. font-size: 18px;
  1320. color: #57acbb;
  1321. margin-bottom: 5px;
  1322. }
  1323. .main_answer_left {
  1324. display: flex;
  1325. /* text-align: left; */
  1326. }
  1327. .main_answer_right {
  1328. display: flex;
  1329. /* text-align: right; */
  1330. }
  1331. .message-wrapper {
  1332. background-color: #ffffff;
  1333. }
  1334. .message-wrapper-left {
  1335. margin-left: 10px;
  1336. /* border-radius: 0 1rem 1rem 1rem; */
  1337. border-radius: 4px 4px 4px 4px;
  1338. max-width: 20.86667rem;
  1339. display: inline-table;
  1340. }
  1341. .message-wrapper-right {
  1342. margin-right: 10px;
  1343. border-radius: 4px 4px 4px 4px;
  1344. max-width: 20.86667rem;
  1345. display: inline-table;
  1346. background-color: #1fd18e;
  1347. color: #ffffff;
  1348. /* margin-top: 25px; */
  1349. }
  1350. .message {
  1351. word-break: break-all;
  1352. padding: 18px;
  1353. /* font-size: 20px; */
  1354. }
  1355. .xl_d_button {
  1356. background: rgb(87, 172, 187);
  1357. opacity: 1;
  1358. border-radius: 50%;
  1359. font-size: 20px;
  1360. font-family: PingFang SC;
  1361. font-weight: 400;
  1362. color: #ffffff;
  1363. width: 40px;
  1364. line-height: 40px;
  1365. text-align: center;
  1366. }
  1367. .xl_d_button:hover {
  1368. background: rgb(87, 172, 187);
  1369. opacity: 1;
  1370. /* border-radius: 18px; */
  1371. font-size: 14px;
  1372. font-family: PingFang SC;
  1373. font-weight: 400;
  1374. color: #ffffff;
  1375. }
  1376. .xl_d_button:focus {
  1377. background: rgb(87, 172, 187);
  1378. opacity: 1;
  1379. /* border-radius: 18px; */
  1380. font-size: 14px;
  1381. font-family: PingFang SC;
  1382. font-weight: 400;
  1383. color: #ffffff;
  1384. }
  1385. .refrshSmart {
  1386. float: right;
  1387. cursor: pointer;
  1388. }
  1389. .xl_input >>> .el-input__inner {
  1390. border: 0;
  1391. border-radius: 4px;
  1392. background-color: #f4f4f4;
  1393. height: 120px;
  1394. }
  1395. .footSend {
  1396. background: #ffffff;
  1397. /* position: absolute; */
  1398. height: 120px;
  1399. margin-left: 2%;
  1400. width: 96%;
  1401. border-radius: 14px;
  1402. margin-bottom: 35px;
  1403. display: flex;
  1404. flex-direction: row;
  1405. /* bottom: 50px; */
  1406. }
  1407. .smart_line_class {
  1408. /* background: #BBC5D4; */
  1409. /* position: absolute; */
  1410. height: 1px;
  1411. margin-left: 2%;
  1412. width: 96%;
  1413. border-radius: 14px;
  1414. bottom: 150px;
  1415. border-bottom: 1px solid #bbc5d4;
  1416. margin-bottom: 32px;
  1417. margin-top: 10px;
  1418. }
  1419. .footSend >>> .el-textarea__inner {
  1420. border: 0px solid #ffffff !important;
  1421. border-radius: 14px !important;
  1422. height: 100px !important;
  1423. }
  1424. .footSendSelect {
  1425. background: #ffffff;
  1426. /* padding-bottom: 40px; */
  1427. position: absolute;
  1428. margin-left: 2%;
  1429. width: 90%;
  1430. bottom: 40px;
  1431. }
  1432. .xl_d_send {
  1433. margin-top: 18px;
  1434. color: #087b50;
  1435. background: #c6f0ed !important;
  1436. opacity: 1;
  1437. font-size: 14px;
  1438. font-family: PingFang SC;
  1439. font-weight: 400;
  1440. text-align: center;
  1441. border: 0px;
  1442. border-radius: 10px;
  1443. margin-right: 10px;
  1444. margin-bottom: 10px;
  1445. width: 80px;
  1446. }
  1447. .xl_d_send:hover {
  1448. margin-top: 18px;
  1449. color: #087b50;
  1450. background: #c6f0ed !important;
  1451. opacity: 1;
  1452. font-size: 14px;
  1453. font-family: PingFang SC;
  1454. font-weight: 400;
  1455. text-align: center;
  1456. border-radius: 10px;
  1457. margin-right: 10px;
  1458. margin-bottom: 10px;
  1459. }
  1460. .xl_d_send:focus {
  1461. margin-top: 18px;
  1462. color: #087b50;
  1463. background: #c6f0ed !important;
  1464. opacity: 1;
  1465. font-size: 14px;
  1466. font-family: PingFang SC;
  1467. font-weight: 400;
  1468. text-align: center;
  1469. border-radius: 10px;
  1470. }
  1471. .xl_d_send.is-disabled,
  1472. .xl_d_send.is-disabled:hover,
  1473. .xl_d_send.is-disabled:focus {
  1474. margin-top: 18px;
  1475. color: #087b50;
  1476. background: #c6f0ed !important;
  1477. opacity: 1;
  1478. font-size: 14px;
  1479. font-family: PingFang SC;
  1480. font-weight: 400;
  1481. text-align: center;
  1482. border-radius: 10px;
  1483. }
  1484. .main_right_height {
  1485. /* padding:40px; */
  1486. height: 100vh !important;
  1487. display: block !important;
  1488. /* overflow-y: auto !important; */
  1489. overflow-y: hidden !important;
  1490. background-color: #ffffff;
  1491. }
  1492. .smart_content {
  1493. height: 88%;
  1494. /* height: 88%; */
  1495. margin-top: 5%;
  1496. width: 94%;
  1497. margin-left: 3%;
  1498. border-radius: 40px;
  1499. background: #f6f6f6;
  1500. display: flex;
  1501. flex-direction: column;
  1502. }
  1503. .chat-window {
  1504. overflow-y: scroll;
  1505. /* height: 70vh; */
  1506. flex: 1;
  1507. overflow: auto;
  1508. /* overflow-y:hidden; */
  1509. }
  1510. .smart_mul_button {
  1511. display: flex;
  1512. flex-direction: row;
  1513. align-items: center;
  1514. }
  1515. .smart_mid {
  1516. flex: 1;
  1517. overflow-y: auto;
  1518. }
  1519. .send_buttom_style {
  1520. height: 100%;
  1521. display: flex;
  1522. flex-direction: column;
  1523. align-items: flex-end;
  1524. }
  1525. .smart_mul_form2 {
  1526. display: flex;
  1527. flex-direction: column;
  1528. align-items: center;
  1529. }
  1530. .check_column {
  1531. display: flex;
  1532. flex-direction: column;
  1533. }
  1534. .check_column .check {
  1535. /* margin-left: 30px; */
  1536. }
  1537. .check_column .el-checkbox.is-bordered + .el-checkbox.is-bordered {
  1538. margin-left: 0px !important;
  1539. width: 120px;
  1540. }
  1541. .check_column .el-checkbox.is-bordered {
  1542. margin-top: 2px;
  1543. background-color: #ffffff;
  1544. }
  1545. .smart_radio .el-radio.is-bordered + .el-radio.is-bordered {
  1546. margin-left: 0px !important;
  1547. }
  1548. .smart_mul_button_select {
  1549. width: 120px;
  1550. left: 0;
  1551. }
  1552. /* .contant1{
  1553. height:70vh;
  1554. overflow:auto;
  1555. } */
  1556. </style>