Smart1.vue 51 KB

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