textStep.js 46 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327
  1. // subpages/textStep/textStep.js
  2. const baseUrl = "https://fare.somnisix.top/";
  3. const authorization = "eyJhbGciOiJIUzUxMiJ9.eyJ1c2VyX2lkIjoxLCJ1c2VyX2tleSI6Ijk5YzI3MjI2LTdkOWQtNDhiOC1hYjlhLWM4YjVjYWZiZGNkNyIsInVzZXJuYW1lIjoiYWRtaW4ifQ.zITQOINFkHs19_1RAgHS4I9YMaVxVq0Dsn3t6r_K7rv3rXvJy0sMtodejIMi_PNa_m4uQYxnU-6k3wC2LZht_Q";
  4. const api = "system/sleepEvaluation";
  5. const homeApi = "https://fare.somnisix.top";
  6. const homeApiTest = "http://localhost:8080";
  7. const token = "eyJhbGciOiJIUzUxMiJ9.eyJ1c2VyX2lkIjoxLCJ1c2VyX2tleSI6Ijk5YzI3MjI2LTdkOWQtNDhiOC1hYjlhLWM4YjVjYWZiZGNkNyIsInVzZXJuYW1lIjoiYWRtaW4ifQ.zITQOINFkHs19_1RAgHS4I9YMaVxVq0Dsn3t6r_K7rv3rXvJy0sMtodejIMi_PNa_m4uQYxnU-6k3wC2LZht_Q";
  8. let countABCDEF;
  9. Page({
  10. /**
  11. * 页面的初始数据
  12. */
  13. data: {
  14. type: "sleep",//报告类型
  15. testTitle: "睡眠质量指数评测",
  16. step: 1,
  17. stepTotal: 9,
  18. gender: 1,//1 男 2 女
  19. age: '',//年龄
  20. height: '',//身高
  21. weight: '',//体重
  22. currentDate: "",
  23. currentDateItem: null,
  24. showDateDialog: false,
  25. formatter(type, value) {
  26. if (type === 'hour') {
  27. return `${value}时`;
  28. }
  29. if (type === 'minute') {
  30. return `${value}分`;
  31. }
  32. return value;
  33. },
  34. hotel: '',//酒店
  35. room: '',//房间
  36. physiqueData: [
  37. {
  38. id: 1,
  39. title: '身体综合(多选)',
  40. type: 'checkbox',
  41. value: [],//选出来的values
  42. options: [
  43. { value: '0', remark: 'A', label: '易疲劳,总感到疲倦' },
  44. { value: '1', remark: 'A', label: '好出汗,一活动就冒汗' },
  45. { value: '2', remark: 'A', label: '易感冒,恢复慢' },
  46. { value: '3', remark: 'A', label: '稍一活动就气喘' },
  47. { value: '4', remark: 'A', label: '疲劳后身体就不舒服' },
  48. { value: '5', remark: 'A', label: '无食欲' },
  49. { value: '6', remark: 'A', label: '手脚发凉' },
  50. { value: '7', remark: 'A', label: '肌肉无力' },
  51. { value: '8', remark: 'B', label: '腹部易滞气' },
  52. { value: '9', remark: 'B', label: '头痛、肩凝、关节痛、胃疼、手脚麻痹' },
  53. { value: '10', remark: 'B', label: '紧张、发怒后身体不舒服' },
  54. { value: '11', remark: 'B', label: '身体有痛感后,疼痛部位游走不定' },
  55. { value: '12', remark: 'C', label: '易眩晕和站起时头晕' },
  56. { value: '13', remark: 'C', label: '常感到心慌' },
  57. { value: '14', remark: 'C', label: '易头晕眼花' },
  58. { value: '15', remark: 'D', label: '有受伤和手术后的旧伤痛' },
  59. { value: '16', remark: 'D', label: '感到肩和腰、头有针扎样痛' },
  60. { value: '17', remark: 'D', label: '入夜后容易出现肩、腰、头疼痛' },
  61. { value: '18', remark: 'E', label: '喉咙易渴,常想喝水' },
  62. { value: '19', remark: 'E', label: '感冒愈后常干咳' },
  63. { value: '20', remark: 'E', label: '易便秘,大便呈球状' },
  64. { value: '21', remark: 'E', label: '尿量少、色浓' },
  65. { value: '22', remark: 'E', label: '身体总是发热' },
  66. { value: '23', remark: 'E', label: '持续低烧' },
  67. { value: '24', remark: 'F', label: '常感到身体和手脚沉重,易浮肿' },
  68. { value: '25', remark: 'F', label: '胃部不适、恶心' },
  69. { value: '26', remark: 'F', label: '雨天和湿度高时身体状况就很糟糕' },
  70. { value: '27', remark: 'F', label: '有时眩晕' },
  71. { value: '28', remark: 'F', label: '大便偏软' },
  72. { value: '29', remark: 'F', label: '易恶心、呕吐、晕车' },
  73. { value: '30', remark: '', label: '以上都没有' },
  74. ]
  75. },
  76. {
  77. id: 2,
  78. title: '面部五官(多选)',
  79. type: 'checkbox',
  80. value: [],//选出来的values
  81. options: [
  82. { value: '0', remark: 'B', label: '喉头部有异物感' },
  83. { value: '1', remark: 'C', label: '脸色不好' },
  84. { value: '2', remark: 'D', label: '眼圈发黑' },
  85. { value: '3', remark: 'E', label: '眼睛经常模糊不清' },
  86. { value: '4', remark: 'E', label: '多呈现消极、羸弱的面孔' },
  87. { value: '5', remark: 'F', label: '唾液和痰较多,中发黏' },
  88. { value: '6', remark: 'F', label: '易犯花粉症和鼻炎,容易淌鼻涕' },
  89. { value: '7', remark: '', label: '以上都没有' },
  90. ]
  91. },
  92. {
  93. id: 3,
  94. title: '皮肤毛发(多选)',
  95. type: 'checkbox',
  96. value: [],//选出来的values
  97. options: [
  98. { value: '0', remark: 'C', label: '头发脆弱,脱发' },
  99. { value: '1', remark: 'C', label: '皮肤和指甲无光泽' },
  100. { value: '2', remark: 'D', label: '皮肤干燥易皲裂,色斑、雀斑多' },
  101. { value: '3', remark: 'D', label: '皮肤呈青紫色或黑紫色,不光滑' },
  102. { value: '4', remark: 'D', label: '肤色暗淡' },
  103. { value: '5', remark: 'E', label: '洗浴后皮肤很快干燥,易发痒' },
  104. { value: '6', remark: 'E', label: '皮肤纹理粗糙、毛孔张开' },
  105. { value: '7', remark: '', label: '以上都没有' },
  106. ]
  107. },
  108. {
  109. id: 4,
  110. title: '情绪方面(多选)',
  111. type: 'checkbox',
  112. value: [],//选出来的values
  113. options: [
  114. { value: '0', remark: 'A', label: '经常情绪低落,容易受伤害' },
  115. { value: '1', remark: 'B', label: '焦虑、易怒' },
  116. { value: '2', remark: 'B', label: '常长吁短叹、嗳气' },
  117. { value: '3', remark: '', label: '以上都没有' },
  118. ]
  119. },
  120. {
  121. id: 5,
  122. title: '月经方面(多选)',
  123. type: 'checkbox',
  124. value: [],//选出来的values
  125. options: [
  126. { value: '0', remark: 'B', label: '月经前身体不适' },
  127. { value: '1', remark: 'C', label: '经血量少或月经周期过长' },
  128. { value: '2', remark: 'D', label: '月经痛加重、经血中有动物肝脏血块' },
  129. { value: '3', remark: '', label: '以上都没有' },
  130. ]
  131. },
  132. {
  133. id: 6,
  134. title: '性格方面(多选)',
  135. type: 'checkbox',
  136. value: [],//选出来的values
  137. options: [
  138. { value: '0', remark: 'A', label: '过度依赖人际关系' },
  139. { value: '1', remark: 'B', label: '具有攻击性,不善于体谅别人' },
  140. { value: '2', remark: 'C', label: '属冷静、认真型' },
  141. { value: '3', remark: 'C', label: '善于制造一个自我世界并沉溺其中' },
  142. { value: '4', remark: 'D', label: '忍耐性较强的性格,容易积聚压力' },
  143. { value: '5', remark: 'D', label: '接人待物中规中矩,严守礼节' },
  144. { value: '6', remark: 'F', label: '以自我为中心,争强好胜,嫉妒心强,爱慕虚荣' },
  145. { value: '7', remark: 'F', label: '喜欢奢华、热闹的氛围' },
  146. { value: '8', remark: '', label: '以上都没有' },
  147. ]
  148. },
  149. {
  150. id: 7,
  151. title: '睡眠(多选)',
  152. type: 'checkbox',
  153. value: [],//选出来的values
  154. options: [
  155. { value: '0', remark: 'B', label: '入睡困难' },
  156. { value: '1', remark: 'C', label: '睡眠浅,易做梦' },
  157. { value: '2', remark: '', label: '以上都没有' },
  158. ]
  159. },
  160. {
  161. id: 8,
  162. title: '舌头状态(多选)',
  163. type: 'checkbox',
  164. value: [],//选出来的values
  165. options: [
  166. { value: '0', remark: 'A', label: '整体色淡;厚、肿大;边缘呈齿状' },
  167. { value: '1', remark: 'B', label: '两侧赤红;中间色淡或偏白;薄薄的黄色舌苔' },
  168. { value: '2', remark: 'C', label: '舌体偏小;色淡、偏白,舌苔整体偏薄' },
  169. { value: '3', remark: 'D', label: '舌色暗、偏紫色;有黑色斑点;舌下两根静脉粗粗地浮现出来' },
  170. { value: '4', remark: 'E', label: '舌色整体发红;舌苔少、甚至没有;舌面有齿痕' },
  171. { value: '5', remark: 'F', label: '舌苔厚、黏黏糊糊;舌苔色黄或白;舌体肿胀' },
  172. { value: '6', remark: '', label: '以上都没有' },
  173. ]
  174. }
  175. ],
  176. sleepData: [
  177. {
  178. id: 1,
  179. title: '过去1个月通常上床睡觉的时间是?',
  180. type: 'date',
  181. value: '',//选出来的value
  182. options: [
  183. { value: '', label: '上床睡觉的时间' },
  184. ]
  185. }, {
  186. id: 2,
  187. title: '过去1个月你每晚通常要多长时间(分钟)才能入睡?',
  188. type: 'radio',
  189. value: '',//选出来的value
  190. options: [
  191. { value: 'a', label: '<15分钟' },
  192. { value: 'b', label: '16-30分钟' },
  193. { value: 'c', label: '31-60分钟' },
  194. { value: 'd', label: '>60分钟' },
  195. ]
  196. }, {
  197. id: 3,
  198. title: '过去1个月每天早上通常什么时候起床?',
  199. type: 'date',
  200. value: '',//选出来的value
  201. options: [
  202. { value: '', label: '起床时间' },
  203. ]
  204. }, {
  205. id: 4,
  206. title: '过去1个月你每天实际睡眠的时间有多少?',
  207. type: 'date',
  208. value: '',//选出来的value
  209. options: [
  210. { value: '', label: '每晚实际睡眠时间' },
  211. ]
  212. }, {
  213. id: 5,
  214. title: '过去1个月你是否因为以下问题而经常睡眠不好?',
  215. subTitle: 'A.不能在30分钟内入睡',
  216. type: 'radio',
  217. value: '',//选出来的value
  218. options: [
  219. { value: 'a', label: '过去1个月没有' },
  220. { value: 'b', label: '每周平均不足1个晚上' },
  221. { value: 'c', label: '每周平均1-2个晚上' },
  222. { value: 'd', label: '每周平均3个或更多晚上' },
  223. ]
  224. }, {
  225. id: 6,
  226. title: '过去1个月你是否因为以下问题而经常睡眠不好?',
  227. subTitle: 'B.在晚上睡眠中醒来或早醒',
  228. type: 'radio',
  229. value: '',//选出来的value
  230. options: [
  231. { value: 'a', label: '过去1个月没有' },
  232. { value: 'b', label: '每周平均不足1个晚上' },
  233. { value: 'c', label: '每周平均1-2个晚上' },
  234. { value: 'd', label: '每周平均3个或更多晚上' },
  235. ]
  236. }, {
  237. id: 7,
  238. title: '过去1个月你是否因为以下问题而经常睡眠不好?',
  239. subTitle: 'C.晚上有无起床上洗手间',
  240. type: 'radio',
  241. value: '',//选出来的value
  242. options: [
  243. { value: 'a', label: '过去1个月没有' },
  244. { value: 'b', label: '每周平均不足1个晚上' },
  245. { value: 'c', label: '每周平均1-2个晚上' },
  246. { value: 'd', label: '每周平均3个或更多晚上' },
  247. ]
  248. }, {
  249. id: 8,
  250. title: '过去1个月你是否因为以下问题而经常睡眠不好?',
  251. subTitle: 'D.不舒服的呼吸',
  252. type: 'radio',
  253. value: '',//选出来的value
  254. options: [
  255. { value: 'a', label: '过去1个月没有' },
  256. { value: 'b', label: '每周平均不足1个晚上' },
  257. { value: 'c', label: '每周平均1-2个晚上' },
  258. { value: 'd', label: '每周平均3个或更多晚上' },
  259. ]
  260. }, {
  261. id: 9,
  262. title: '过去1个月你是否因为以下问题而经常睡眠不好?',
  263. subTitle: 'E.大声咳嗽或打鼾',
  264. type: 'radio',
  265. value: '',//选出来的value
  266. options: [
  267. { value: 'a', label: '过去1个月没有' },
  268. { value: 'b', label: '每周平均不足1个晚上' },
  269. { value: 'c', label: '每周平均1-2个晚上' },
  270. { value: 'd', label: '每周平均3个或更多晚上' },
  271. ]
  272. }, {
  273. id: 10,
  274. title: '过去1个月你是否因为以下问题而经常睡眠不好?',
  275. subTitle: 'F.感到寒冷',
  276. type: 'radio',
  277. value: '',//选出来的value
  278. options: [
  279. { value: 'a', label: '过去1个月没有' },
  280. { value: 'b', label: '每周平均不足1个晚上' },
  281. { value: 'c', label: '每周平均1-2个晚上' },
  282. { value: 'd', label: '每周平均3个或更多晚上' },
  283. ]
  284. }, {
  285. id: 11,
  286. title: '过去1个月你是否因为以下问题而经常睡眠不好?',
  287. subTitle: 'G.感到太热',
  288. type: 'radio',
  289. value: '',//选出来的value
  290. options: [
  291. { value: 'a', label: '过去1个月没有' },
  292. { value: 'b', label: '每周平均不足1个晚上' },
  293. { value: 'c', label: '每周平均1-2个晚上' },
  294. { value: 'd', label: '每周平均3个或更多晚上' },
  295. ]
  296. }, {
  297. id: 12,
  298. title: '过去1个月你是否因为以下问题而经常睡眠不好?',
  299. subTitle: 'H.做噩梦',
  300. type: 'radio',
  301. value: '',//选出来的value
  302. options: [
  303. { value: 'a', label: '过去1个月没有' },
  304. { value: 'b', label: '每周平均不足1个晚上' },
  305. { value: 'c', label: '每周平均1-2个晚上' },
  306. { value: 'd', label: '每周平均3个或更多晚上' },
  307. ]
  308. }, {
  309. id: 13,
  310. title: '过去1个月你是否因为以下问题而经常睡眠不好?',
  311. subTitle: 'H.出现疼痛',
  312. type: 'radio',
  313. value: '',//选出来的value
  314. options: [
  315. { value: 'a', label: '过去1个月没有' },
  316. { value: 'b', label: '每周平均不足1个晚上' },
  317. { value: 'c', label: '每周平均1-2个晚上' },
  318. { value: 'd', label: '每周平均3个或更多晚上' },
  319. ]
  320. }, {
  321. id: 14,
  322. title: '过去1个月你是否因为以下问题而经常睡眠不好?',
  323. subTitle: 'J.其他影响睡眠的事情',
  324. type: 'radio',
  325. value: '',//选出来的value
  326. options: [
  327. { value: 'a', label: '过去1个月没有' },
  328. { value: 'b', label: '每周平均不足1个晚上' },
  329. { value: 'c', label: '每周平均1-2个晚上' },
  330. { value: 'd', label: '每周平均3个或更多晚上' },
  331. ]
  332. }, {
  333. id: 15,
  334. title: '你对过去1个月睡眠质量评分',
  335. type: 'radio',
  336. value: '',//选出来的value
  337. options: [
  338. { value: 'a', label: '非常好' },
  339. { value: 'b', label: '尚好' },
  340. { value: 'c', label: '不好' },
  341. { value: 'd', label: '非常差' },
  342. ]
  343. }, {
  344. id: 16,
  345. title: '近1个月你用催眠药物的情况',
  346. type: 'radio',
  347. value: '',//选出来的value
  348. options: [
  349. { value: 'a', label: '过去1个月没有' },
  350. { value: 'b', label: '每周平均不足1个晚上' },
  351. { value: 'c', label: '每周平均1-2个晚上' },
  352. { value: 'd', label: '每周平均3个或更多晚上' },
  353. ]
  354. }, {
  355. id: 17,
  356. title: '过去1个月你在开车、吃饭或参加社会活动时难以保持清醒状态?',
  357. type: 'radio',
  358. value: '',//选出来的value
  359. options: [
  360. { value: 'a', label: '过去1个月没有' },
  361. { value: 'b', label: '每周平均不足1个晚上' },
  362. { value: 'c', label: '每周平均1-2个晚上' },
  363. { value: 'd', label: '每周平均3个或更多晚上' },
  364. ]
  365. }, {
  366. id: 18,
  367. title: '过去1个月你在积极完成事情上有无困难?',
  368. type: 'radio',
  369. value: '',//选出来的value
  370. options: [
  371. { value: 'a', label: '没有困难' },
  372. { value: 'b', label: '有一点困难' },
  373. { value: 'c', label: '每周平均1-2个晚上' },
  374. { value: 'd', label: '每周平均3个或更多晚上' },
  375. ]
  376. }, {
  377. id: 19,
  378. title: '你是与人同睡一床(睡觉同伴,包括配偶等)或有室友?',
  379. type: 'radio',
  380. value: '',//选出来的value
  381. options: [
  382. { value: 'a', label: '没有与人同睡一床或有室友' },
  383. { value: 'b', label: '同伴或室友在另外房间' },
  384. { value: 'c', label: '同伴在同一房间但不睡同床' },
  385. { value: 'd', label: '同伴在同一床上' },
  386. ]
  387. }, {
  388. id: 20,
  389. title: '在你睡觉时,有无打鼾声',
  390. type: 'radio',
  391. value: '',//选出来的value
  392. options: [
  393. { value: 'a', label: '过去1个月没有' },
  394. { value: 'b', label: '每周平均不足1个晚上' },
  395. { value: 'c', label: '每周平均1-2个晚上' },
  396. { value: 'd', label: '每周平均3个或更多晚上' },
  397. ]
  398. }, {
  399. id: 21,
  400. title: '在你睡觉时,呼吸之间有没有长时间停顿',
  401. type: 'radio',
  402. value: '',//选出来的value
  403. options: [
  404. { value: 'a', label: '过去1个月没有' },
  405. { value: 'b', label: '每周平均不足1个晚上' },
  406. { value: 'c', label: '每周平均1-2个晚上' },
  407. { value: 'd', label: '每周平均3个或更多晚上' },
  408. ]
  409. }, {
  410. id: 22,
  411. title: '在你睡觉时,你的腿有无抽动或者有痉挛',
  412. type: 'radio',
  413. value: '',//选出来的value
  414. options: [
  415. { value: 'a', label: '过去1个月没有' },
  416. { value: 'b', label: '每周平均不足1个晚上' },
  417. { value: 'c', label: '每周平均1-2个晚上' },
  418. { value: 'd', label: '每周平均3个或更多晚上' },
  419. ]
  420. }, {
  421. id: 23,
  422. title: '在你睡觉时是否出现不能辨认方向或混乱状态',
  423. type: 'radio',
  424. value: '',//选出来的value
  425. options: [
  426. { value: 'a', label: '过去1个月没有' },
  427. { value: 'b', label: '每周平均不足1个晚上' },
  428. { value: 'c', label: '每周平均1-2个晚上' },
  429. { value: 'd', label: '每周平均3个或更多晚上' },
  430. ]
  431. },
  432. {
  433. id: 24,
  434. title: '在你睡觉时你有无其他睡不安宁的情况',
  435. type: 'radio&input',
  436. subTitle: '若有,请描述',
  437. value: '',//选出来的value
  438. options: [
  439. { value: 'a', label: '过去1个月没有' },
  440. { value: 'b', label: '每周平均不足1个晚上' },
  441. { value: 'c', label: '每周平均1-2个晚上' },
  442. { value: 'd', label: '每周平均3个或更多晚上' },
  443. ]
  444. }],
  445. inputValue: '',// 睡眠质量专用
  446. intervalId1:null
  447. },
  448. /**
  449. * 生命周期函数--监听页面加载
  450. */
  451. onLoad(options) {
  452. if (options.type) {
  453. var type = options.type;
  454. var testTitle = "";
  455. var testDesc = "";
  456. var stepTotal = 1;
  457. if (type == "physique") {
  458. // 体质
  459. testTitle = "体质诊断检测";
  460. testDesc = "本测试表由山东省中医药大学中医专家组(具有中医针灸师、中医芳香疗法指导师、医院临床检验科资质的主任医师们)提出。中医学依据气、血、水的平衡状态,将人分为六种体质。要改善身体的“不调”,最重要的就是先了解自己的体质。有人也可能是不同体质混合的“复合型”,而且人的体质日常是变化的,因此应根据每天变化的身体状态进行相应调理的养生疗法。我们根据人体部位分了八个方面,请从下面选项里选出和自己相符的项,提交后,系统会进行判断,并显示您的体质、分析和建议。";
  461. stepTotal = this.data.physiqueData.length + 1;
  462. } else if (type == "sleep") {
  463. // 睡眠质量
  464. testTitle = "睡眠质量指数评测";
  465. testDesc = "本测评系统依据山东睡眠质量指数量表(SDPSQI)开发。\nSDPSQI由山东省中医药大学医学中心精神科睡眠和生物节律研究中心睡眠专家组编制,专门用于评定被试者近一个月的主观睡眠质量。SDPSQI作为一种科学、系统的睡眠质量评估工具为了解个体睡眠状况、诊断睡眠障碍以及制定相应的干预措施提供了重要的工具和平台。";
  466. stepTotal = this.data.sleepData.length + 1;
  467. }
  468. this.setData({
  469. testTitle,
  470. testDesc,
  471. type,
  472. stepTotal
  473. })
  474. }
  475. let hotelTemp = '';
  476. let roomTemp = '';
  477. hotelTemp = wx.getStorageSync('hotelEmpower');
  478. roomTemp = wx.getStorageSync('roomEmpower');
  479. this.setData({
  480. hotel: hotelTemp,
  481. room: roomTemp,
  482. });
  483. },
  484. leftBack() {
  485. wx.navigateBack()
  486. },
  487. checkGender(e) {
  488. console.log(e.currentTarget.dataset.id);
  489. this.setData({
  490. gender: e.currentTarget.dataset.id - 0
  491. })
  492. },
  493. //单选框
  494. handleRadioBox(e) {
  495. if (this.data.type == "physique") {
  496. // 体质
  497. } else if (this.data.type == "sleep") {
  498. // 睡眠质量
  499. var list = this.data.sleepData;
  500. var index = e.currentTarget.dataset.index;
  501. var subIndex = e.currentTarget.dataset.subindex;
  502. var value = list[index].options[subIndex].value;
  503. list[index].value = value;
  504. this.setData({
  505. sleepData: list
  506. })
  507. }
  508. },
  509. // 多选框
  510. handleCheckBox(e) {
  511. console.log(e.currentTarget.dataset);
  512. if (this.data.type == "physique") {
  513. // 体质
  514. var list = this.data.physiqueData;
  515. var index = e.currentTarget.dataset.index;
  516. var subIndex = e.currentTarget.dataset.subindex;
  517. var values = list[index].value || [];
  518. var value = list[index].options[subIndex].value;
  519. if (values.indexOf(value) >= 0) {
  520. values = values.filter((item) => item != value);
  521. } else {
  522. values.push(value);
  523. }
  524. var b = this.verifyAll(list[index].options,values)
  525. if (b) {
  526. values = values[values.length-1]==b ?[b]:[values[values.length-1]]
  527. }
  528. list[index].value = values;
  529. this.setData({
  530. physiqueData: list
  531. })
  532. } else if (this.data.type == "sleep") {
  533. // 睡眠质量
  534. }
  535. },
  536. verifyAll: function (dataset, values) {
  537. let flag = false
  538. if (dataset ) {
  539. values.forEach((item, index) => {
  540. if (dataset[item].label == "以上都没有"){
  541. flag = item
  542. }
  543. return flag
  544. })
  545. }
  546. return flag
  547. },
  548. toPrevious() {
  549. if (this.data.step > 1) {
  550. this.setData({
  551. step: this.data.step - 1
  552. })
  553. }
  554. },
  555. toNext() {
  556. if (this.data.step == 1) {
  557. // 判断基本信息是否为空
  558. } else {
  559. // 判断列表是否有值
  560. if (this.data.type == "physique") {
  561. // 体质
  562. var list = this.data.physiqueData;
  563. var index = this.data.step - 2;
  564. var values = list[index].value || [];
  565. if (values.length <= 0) {
  566. wx.showModal({
  567. title: '无法提交',
  568. content: '您还有部分题目未完成,请检查后重新提交',
  569. showCancel: false,
  570. confirmColor: '#0BC3AA',
  571. confirmText: "好的",
  572. success(res) {
  573. }
  574. })
  575. return
  576. }
  577. } else if (this.data.type == "sleep") {
  578. // 睡眠质量
  579. var list = this.data.sleepData;
  580. var index = this.data.step - 2;
  581. var values = list[index].value;
  582. if ((list[index].type == 'radio&input' && this.data.inputValue.length <= 0 && values.length <= 0) || (list[index].type != 'radio&input' && (!values || values.length <= 0))) {
  583. wx.showModal({
  584. title: '无法提交',
  585. content: '您还有部分题目未完成,请检查后重新提交',
  586. showCancel: false,
  587. confirmColor: '#0BC3AA',
  588. confirmText: "好的",
  589. success(res) {
  590. }
  591. })
  592. return
  593. }
  594. }
  595. }
  596. if (this.data.step < this.data.stepTotal) {
  597. this.setData({
  598. step: this.data.step + 1
  599. })
  600. } else {
  601. // 结束了
  602. console.log('结束了');
  603. if (this.data.type == "physique") {
  604. // 体质
  605. this.commitPhysique();
  606. } else if (this.data.type == "sleep") {
  607. // 睡眠质量
  608. var that = this;
  609. wx.showLoading({
  610. title: '加载中',
  611. })
  612. if (!that.data.intervalId1) {
  613. that.data.intervalId1 = setInterval(() => {
  614. that.commitSleep();
  615. }, 1000);
  616. }
  617. }
  618. }
  619. },
  620. commitPhysique() {
  621. var that = this;
  622. var list = this.data.physiqueData;
  623. let resultMostFrequentLetters = this.findMostFrequentLetters(
  624. this.getRemarkValues(list[0].options, list[0].value),
  625. this.getRemarkValues(list[1].options, list[1].value),
  626. this.getRemarkValues(list[2].options, list[2].value),
  627. this.getRemarkValues(list[3].options, list[3].value),
  628. this.getRemarkValues(list[4].options, list[4].value),
  629. this.getRemarkValues(list[5].options, list[5].value),
  630. this.getRemarkValues(list[6].options, list[6].value),
  631. this.getRemarkValues(list[7].options, list[7].value)
  632. );
  633. const { nickName } = wx.getStorageSync('userInfo');
  634. const unionid = wx.getStorageSync('unionid');
  635. let comScoreIndex = [];
  636. let _comScoreStatus = "";
  637. let _comScoreDesc = ""
  638. if (!resultMostFrequentLetters || !Array.isArray(resultMostFrequentLetters) || !resultMostFrequentLetters.length) {
  639. comScoreIndex = [];
  640. _comScoreStatus = "";
  641. _comScoreDesc = ""
  642. } else {
  643. comScoreIndex = [];
  644. // 遍历输入数组
  645. resultMostFrequentLetters.forEach(item => {
  646. console.log('item=' + item);
  647. if (item == 'A') {
  648. if (_comScoreStatus) {
  649. _comScoreStatus += "\n气虚型";
  650. } else {
  651. _comScoreStatus += "气虚型";
  652. }
  653. if (_comScoreDesc) {
  654. _comScoreDesc += "\n气虚型:填写内容";
  655. } else {
  656. _comScoreDesc += "气虚型:填写内容";
  657. }
  658. comScoreIndex.push(0);
  659. } else if (item == 'B') {
  660. if (_comScoreStatus) {
  661. _comScoreStatus += "\n气滞型";
  662. } else {
  663. _comScoreStatus += "气滞型";
  664. }
  665. if (_comScoreDesc) {
  666. _comScoreDesc += "\n气滞型:填写内容";
  667. } else {
  668. _comScoreDesc += "气滞型:填写内容";
  669. }
  670. comScoreIndex.push(1);
  671. } else if (item == 'C') {
  672. if (_comScoreStatus) {
  673. _comScoreStatus += "\n血虚型";
  674. } else {
  675. _comScoreStatus += "血虚型";
  676. }
  677. if (_comScoreDesc) {
  678. _comScoreDesc += "\n血虚型:填写内容";
  679. } else {
  680. _comScoreDesc += "血虚型:填写内容";
  681. }
  682. comScoreIndex.push(2);
  683. } else if (item == 'D') {
  684. if (_comScoreStatus) {
  685. _comScoreStatus += "\n淤血型";
  686. } else {
  687. _comScoreStatus += "淤血型";
  688. }
  689. if (_comScoreDesc) {
  690. _comScoreDesc += "\n淤血型:填写内容";
  691. } else {
  692. _comScoreDesc += "淤血型:填写内容";
  693. }
  694. comScoreIndex.push(3);
  695. } else if (item == 'E') {
  696. if (_comScoreStatus) {
  697. _comScoreStatus += "\n水虚型";
  698. } else {
  699. _comScoreStatus += "水虚型";
  700. }
  701. if (_comScoreDesc) {
  702. _comScoreDesc += "\n水虚型:填写内容";
  703. } else {
  704. _comScoreDesc += "水虚型:填写内容";
  705. }
  706. comScoreIndex.push(4);
  707. } else if (item == 'F') {
  708. if (_comScoreStatus) {
  709. _comScoreStatus += "\n痰湿型";
  710. } else {
  711. _comScoreStatus += "痰湿型";
  712. }
  713. if (_comScoreDesc) {
  714. _comScoreDesc += "\n痰湿型:填写内容";
  715. } else {
  716. _comScoreDesc += "痰湿型:填写内容";
  717. }
  718. comScoreIndex.push(5);
  719. }
  720. });
  721. }
  722. let surveyData = {
  723. hotel: this.data.hotel,
  724. room: this.data.room,
  725. userId: nickName,
  726. id2: unionid,
  727. bodySynthesis: this.getFormattedString(list[0].value, list[0].options),
  728. facialFeatures: this.getFormattedString(list[1].value, list[1].options),
  729. skinHair: this.getFormattedString(list[2].value, list[2].options),
  730. emotion: this.getFormattedString(list[3].value, list[3].options),
  731. menstruation: this.getFormattedString(list[4].value, list[4].options),
  732. character: this.getFormattedString(list[5].value, list[5].options),
  733. sleep: this.getFormattedString(list[6].value, list[6].options),
  734. //舌头状态是新增加项,赋给value1了,数据库里有value1...value8,以备增加项用
  735. value1: this.getFormattedString(list[7].value, list[7].options),
  736. //value2 保存A、B、C、D、E、F 每个的个数
  737. value2: JSON.stringify(countABCDEF),
  738. comScoreStatus: _comScoreStatus ? _comScoreStatus : '健康型',
  739. comScoreIndex: comScoreIndex.join(),
  740. comScoreDesc: _comScoreDesc,
  741. };
  742. var maxValueObj = that.findMaxValueKeyAndIndex(countABCDEF);
  743. console.log(countABCDEF);
  744. console.log(maxValueObj);
  745. // 体质提交
  746. if (!that.data.intervalId1) {
  747. that.data.intervalId1 = setInterval(() => {
  748. //提交到数据库
  749. wx.request({
  750. url: `${homeApi}/system/constitutionDiagnosis`, //
  751. method: 'POST',
  752. header: {
  753. 'content-type': 'application/json', // 默认值
  754. 'Authorization': 'Bearer ' + token // 在头部设置认证信息,例如使用Bearer Token
  755. },
  756. data: surveyData,
  757. success(res) {
  758. console.log('res===' + JSON.stringify(res));
  759. console.log('res.code===' + res.code);
  760. if (res && res.data && res.data.code == 200) {
  761. if (that.data.intervalId1) {
  762. clearInterval(that.data.intervalId1);
  763. that.data.intervalId1 = null;
  764. }
  765. wx.showToast({
  766. title: '问卷提交成功',
  767. icon: 'success',
  768. duration: 2000,
  769. success() {
  770. setTimeout(() => {
  771. wx.redirectTo({
  772. url: `/subpages/testResultB/testResultB?comScoreIndex=${maxValueObj.index}`
  773. })
  774. }, 1000);
  775. }
  776. });
  777. }
  778. },
  779. fail: function (error) {
  780. console.error('error', error);
  781. },
  782. complete: function (e) {
  783. }
  784. });
  785. }, 1000);
  786. }
  787. },
  788. commitSleep() {
  789. // 睡眠质量提交
  790. var that = this;
  791. const { nickName } = wx.getStorageSync('userInfo');
  792. const unionid = wx.getStorageSync('unionid');
  793. const answerJson = this.data.sleepData;
  794. let value1 = answerJson[0].value;
  795. let value2 = answerJson[1].value;
  796. let value3 = answerJson[2].value;
  797. let value4 = answerJson[3].value;
  798. let value5a = answerJson[4].value;
  799. let value5b = answerJson[5].value;
  800. let value5c = answerJson[6].value;
  801. let value5d = answerJson[7].value;
  802. let value5e = answerJson[8].value;
  803. let value5f = answerJson[9].value;
  804. let value5g = answerJson[10].value;
  805. let value5h = answerJson[11].value;
  806. let value5i = answerJson[12].value;
  807. let value5j = answerJson[13].value;
  808. let value5jDes = '';//这个值没有算
  809. let value6 = answerJson[14].value;
  810. let value7 = answerJson[15].value;
  811. let value8 = answerJson[16].value;
  812. let value9 = answerJson[17].value;
  813. let value10 = answerJson[18].value;
  814. let value11 = answerJson[19].value;
  815. let value12 = answerJson[20].value;
  816. let value13 = answerJson[21].value;
  817. let value14 = answerJson[22].value;
  818. let value15 = answerJson[23].value;
  819. let value15Des = that.data.inputValue;//这个值没有算
  820. //计算规则 https://mp.weixin.qq.com/s/QyTzuPoNErMjc2KcA1M61g
  821. let comA = 0;//条目6
  822. let comB = 0;
  823. let comB1 = 0;
  824. let comC = 0;
  825. let comD = 0;
  826. let comE = 0;
  827. let comF = 0;
  828. let comG = 0;
  829. comA = this.resultABCD(value6);
  830. comB1 = this.resultABCD(value2) + this.resultABCD(value5a);
  831. if (comB1 == 0) {
  832. comB = 0;
  833. } else if (comB1 >= 1 && comB1 <= 2) {
  834. comB = 1;
  835. } else if (comB1 >= 3 && comB1 <= 4) {
  836. comB = 2;
  837. } else if (comB1 >= 5 && comB1 <= 6) {
  838. comB = 3;
  839. }
  840. let value41 = parseInt((value4.split(':')[0]), 10) || 0;
  841. let value42 = parseInt((value4.split(':')[1]), 10) || 0;
  842. let value43 = value41 * 60 + value42;
  843. if (value43 > 420) {
  844. comC = 0;
  845. } else if (value43 >= 360 && value43 <= 420) {
  846. comC = 1;
  847. } else if (value43 >= 300 && value43 < 360) {
  848. comC = 2;
  849. } else if (value43 < 300) {
  850. comC = 3;
  851. }
  852. let datediff = this.calculateTimeDifference(value1, value3);
  853. let sleepRate = datediff ? ((value43 / datediff) * 100) : 0;
  854. if (sleepRate >= 85) {
  855. comD = 0;
  856. } else if (sleepRate >= 75 && sleepRate <= 84) {
  857. comD = 1;
  858. } else if (sleepRate >= 65 && sleepRate < 74) {
  859. comD = 2;
  860. } else if (sleepRate < 65) {
  861. comD = 3;
  862. }
  863. let value5All = this.resultABCD(value5b)
  864. + this.resultABCD(value5c)
  865. + this.resultABCD(value5d)
  866. + this.resultABCD(value5e)
  867. + this.resultABCD(value5f)
  868. + this.resultABCD(value5g)
  869. + this.resultABCD(value5h)
  870. + this.resultABCD(value5i)
  871. + this.resultABCD(value5j);
  872. if (value5All == 0) {
  873. comE = 0;
  874. } else if (value5All >= 1 && value5All <= 9) {
  875. comE = 1;
  876. } else if (value5All >= 10 && value5All <= 18) {
  877. comE = 2;
  878. } else if (value5All >= 19 && value5All <= 27) {
  879. comE = 3;
  880. }
  881. comF = this.resultABCD(value7);
  882. let valueGAll = this.resultABCD(value8) + this.resultABCD(value9);
  883. if (valueGAll == 0) {
  884. comG = 0;
  885. } else if (valueGAll >= 1 && valueGAll <= 2) {
  886. comG = 1;
  887. } else if (valueGAll >= 3 && valueGAll <= 4) {
  888. comG = 2;
  889. } else if (valueGAll >= 5 && valueGAll <= 6) {
  890. comG = 3;
  891. }
  892. let comAll = comA + comB + comC + comD + comE + comF + comG;
  893. let comScoreIndex = 0;
  894. let _comScoreStatus = "";
  895. let _comScoreDesc = "";
  896. if (comAll >= 0 && comAll <= 5) {
  897. _comScoreStatus = "非常好";
  898. } else if (comAll >= 6 && comAll <= 10) {
  899. _comScoreStatus = "良好";
  900. comScoreIndex = 1;
  901. } else if (comAll >= 11 && comAll <= 15) {
  902. _comScoreStatus = "一般";
  903. comScoreIndex = 2;
  904. } else {
  905. // if (comAll >= 16 && comAll <= 21)
  906. _comScoreStatus = "差";
  907. comScoreIndex = 3;
  908. }
  909. if (this.judgmentScoreRange(comAll, 0, 5)) {
  910. _comScoreDesc = "你目前的睡眠质量非常高,而且健康状况良好,这一切应该继续保持下去。"
  911. } else if (this.judgmentScoreRange(comAll, 6, 10)) {
  912. _comScoreDesc = "你的睡眠质量平平,健康状况也受到影响, 如果再不引起你对睡眠质量的足够重视, 那么你的睡眠质量很可能会迅速下降,向下一级别发展。"
  913. } else if (this.judgmentScoreRange(comAll, 11, 15)) {
  914. _comScoreDesc = "如果你在这一级别内,那么你的睡眠质量可 就亮起红灯了。你必须警惕,因为你的睡眠质量确实比较糟糕,健康状况明显受损。饮食起居会受到一定影响,甚至部分工作你都开始感觉吃力。"
  915. } else {
  916. _comScoreDesc = "天啊!你的睡眠质量已经到了令人发指的地 步—长期睡眠不足导致了你的健康状况严重恶化,这就是你工作力不从心,情绪起伏不定的原因。"
  917. }
  918. let surveyData = {
  919. hotel: this.data.hotel,
  920. room: this.data.room,
  921. userId: nickName,
  922. id2: unionid,
  923. value1: value1,
  924. value2: value2,
  925. value3: value3,
  926. value4: value4,
  927. value5a: value5a,
  928. value5b: value5b,
  929. value5c: value5c,
  930. value5d: value5d,
  931. value5e: value5e,
  932. value5f: value5f,
  933. value5g: value5g,
  934. value5h: value5h,
  935. value5i: value5i,
  936. value5j: value5j,
  937. value5jDes: value5jDes,
  938. value6: value6,
  939. value7: value7,
  940. value8: value8,
  941. value9: value9,
  942. value10: value10,
  943. value11: value11,
  944. value12: value12,
  945. value13: value13,
  946. value14: value14,
  947. value15: value15,
  948. value15Des: value15Des,
  949. value16: comAll,//备用16(评分)
  950. value17: _comScoreStatus,//备用17(评分说明)
  951. value18: _comScoreDesc,
  952. value18: comA + ',' + comB + ',' + comC + ',' + comD + ',' + comE + ',' + comF + ',' + comG //备用18(comA、comB、comC、comD、comE、comF、comG)
  953. };
  954. //提交到数据库
  955. wx.request({
  956. url: `${homeApi}/system/questionInvest`, //
  957. method: 'POST',
  958. header: {
  959. 'content-type': 'application/json', // 默认值
  960. 'Authorization': 'Bearer ' + token // 在头部设置认证信息,例如使用Bearer Token
  961. },
  962. data: surveyData,
  963. success(res) {
  964. console.log('res===' + JSON.stringify(res));
  965. console.log('res.code===' + res.data.code);
  966. if (res && res.data && res.data.code == 200) {
  967. wx.hideLoading();
  968. if (that.data.intervalId1) {
  969. clearInterval(that.data.intervalId1);
  970. that.data.intervalId1 = null;
  971. }
  972. wx.showToast({
  973. title: '问卷提交成功',
  974. icon: 'success',
  975. duration: 2000,
  976. success() {
  977. setTimeout(() => {
  978. wx.redirectTo({
  979. url: `/subpages/testResultA/testResultA?comScore=${comAll}`
  980. })
  981. }, 1000);
  982. }
  983. });
  984. }
  985. },
  986. fail: function (error) {
  987. console.error('error', error);
  988. },
  989. complete: function (e) {
  990. }
  991. });
  992. },
  993. handleSelectDate(event) {
  994. var item = event.currentTarget.dataset.item;
  995. const value = item.value || "";
  996. this.setData({ currentDateItem: item, currentDate: value, showDateDialog: true });
  997. console.log(this.data.currentDateItem);
  998. },
  999. onCloseDateDialog() {
  1000. this.setData({ showDateDialog: false, currentDateItem: null });
  1001. },
  1002. onCloseResultsDialog() {
  1003. this.setData({ promptTextMessageFlag: false });
  1004. },
  1005. onDateInput(event) {
  1006. const item = this.data.currentDateItem;
  1007. if (!item) {
  1008. return
  1009. }
  1010. if (this.data.type == "physique") {
  1011. // 体质
  1012. } else if (this.data.type == "sleep") {
  1013. // 睡眠质量
  1014. let sleepData = this.data.sleepData;
  1015. for (let i = 0; i < sleepData.length; i++) {
  1016. const element = sleepData[i];
  1017. if (element.id == item.id) {
  1018. element.value = event.detail;
  1019. break;
  1020. }
  1021. }
  1022. console.log(event);
  1023. this.setData({
  1024. sleepData: sleepData
  1025. });
  1026. }
  1027. this.onCloseDateDialog()
  1028. },
  1029. // 睡眠质量的方法
  1030. resultABCD: function (a) {
  1031. if (a == 'a') {
  1032. return 0;
  1033. } else if (a == 'b') {
  1034. return 1;
  1035. } else if (a == 'c') {
  1036. return 2;
  1037. } else if (a == 'd') {
  1038. return 3;
  1039. }
  1040. },
  1041. judgmentScoreRange(scoreValue, startScore, endScore) {
  1042. return scoreValue >= startScore && scoreValue <= endScore;
  1043. },
  1044. // 将时间字符串转换为分钟数
  1045. timeStringToMinutes: function (timeStr) {
  1046. var parts = timeStr.split(":");
  1047. return parseInt(parts[0], 10) * 60 + parseInt(parts[1], 10);
  1048. },
  1049. // 计算时间差(分钟)
  1050. calculateTimeDifference: function (sleepTimeStr, wakeUpTimeStr) {
  1051. // 将时间字符串转换为分钟
  1052. var sleepTimeMinutes = this.timeStringToMinutes(sleepTimeStr);
  1053. var wakeUpTimeMinutes = this.timeStringToMinutes("24:00") + this.timeStringToMinutes(wakeUpTimeStr); // 加上第二天的0点到起床时间的分钟数
  1054. // 计算时间差
  1055. var diffInMinutes = wakeUpTimeMinutes - sleepTimeMinutes;
  1056. // 将分钟数转换回时间字符串格式 HH:mm
  1057. var diffInHours = Math.floor(diffInMinutes / 60);
  1058. var diffInMins = diffInMinutes % 60;
  1059. // 返回时间差字符串
  1060. return diffInMinutes;
  1061. },
  1062. // 体质的方法
  1063. // 取出最大值的obj
  1064. findMaxValueKeyAndIndex(obj) {
  1065. if (typeof obj !== 'object' || obj === null || Array.isArray(obj)) {
  1066. throw new Error('Input must be a plain object');
  1067. }
  1068. let maxKey = null;
  1069. let maxValue = 0;
  1070. let maxIndex = 6;
  1071. const keys = Object.keys(obj);
  1072. keys.forEach((key, index) => {
  1073. const value = obj[key];
  1074. if (value > maxValue) {
  1075. maxValue = value;
  1076. maxKey = key;
  1077. maxIndex = index;
  1078. }
  1079. });
  1080. return {
  1081. key: maxKey,
  1082. value: maxValue,
  1083. index: maxIndex
  1084. };
  1085. },
  1086. /**
  1087. * A、B、C、D、E、F 最后积累的数量对比,按数量多少来判断,6个分别对应:气虚型、气滞型、血虚型、淤血型、水虚型、痰湿型
  1088. * 找出对象中值最大的键
  1089. * @param {Object} obj - 包含键值对的对象
  1090. * @returns {string|null} - 值最大的键,如果没有找到则返回null
  1091. */
  1092. findKeyWithMaxValue(obj) {
  1093. if (typeof obj !== 'object' || obj === null || Array.isArray(obj)) {
  1094. throw new Error('Input must be a plain object');
  1095. }
  1096. let maxKey = null;
  1097. let maxValue = 0;
  1098. for (let key in obj) {
  1099. if (obj.hasOwnProperty(key)) {
  1100. if (obj[key] > maxValue) {
  1101. maxValue = obj[key];
  1102. maxKey = key;
  1103. }
  1104. }
  1105. }
  1106. return maxKey;
  1107. },
  1108. areAllArraysEmpty: function (arr1, arr2, arr3, arr4, arr5, arr6, arr7, arr8) {
  1109. // 定义一个数组来包含所有传入的数组
  1110. const arrays = [arr1, arr2, arr3, arr4, arr5, arr6, arr7, arr8];
  1111. // 遍历这个数组,检查每一项(即传入的数组)是否为空
  1112. for (let i = 0; i < arrays.length; i++) {
  1113. // 检查当前数组是否为空(即长度为0)
  1114. if (arrays[i] && arrays[i].length > 0) {
  1115. // 如果发现任何一个数组不为空,则返回false
  1116. return false;
  1117. }
  1118. }
  1119. // 如果所有数组都检查过了,且都是空的,则返回true
  1120. return true;
  1121. },
  1122. //统计这8个数组,总共包含A,B,C,D,E,F的个数,返回最多的一项(也可能多项):
  1123. //如果有多个 最多 的情况,返回最多的几个,如果都是0或者空,返回空
  1124. findMostFrequentLetters: function (arr1, arr2, arr3, arr4, arr5, arr6, arr7, arr8) {
  1125. //判断6个数组是否都为空
  1126. if (this.areAllArraysEmpty(arr1, arr2, arr3, arr4, arr5, arr6, arr7, arr8))
  1127. return '';
  1128. // 初始化一个对象来存储每个字母的计数
  1129. const letterCounts = {
  1130. A: 0,
  1131. B: 0,
  1132. C: 0,
  1133. D: 0,
  1134. E: 0,
  1135. F: 0
  1136. };
  1137. // 定义一个辅助函数来更新计数
  1138. function updateCounts(arr) {
  1139. if (Array.isArray(arr)) {
  1140. arr.forEach(item => {
  1141. if (typeof item === 'string' && ['A', 'B', 'C', 'D', 'E', 'F'].includes(item)) {
  1142. letterCounts[item]++;
  1143. }
  1144. });
  1145. }
  1146. }
  1147. // 对每个数组调用辅助函数
  1148. updateCounts(arr1);
  1149. updateCounts(arr2);
  1150. updateCounts(arr3);
  1151. updateCounts(arr4);
  1152. updateCounts(arr5);
  1153. updateCounts(arr6);
  1154. updateCounts(arr7);
  1155. updateCounts(arr8);
  1156. countABCDEF = letterCounts;
  1157. // 找出出现次数最多的字母及其计数
  1158. let maxCount = 0;
  1159. let mostFrequentLetters = [];
  1160. for (let letter in letterCounts) {
  1161. if (letterCounts[letter] == 0) {
  1162. continue;
  1163. }
  1164. if (letterCounts[letter] > maxCount) {
  1165. maxCount = letterCounts[letter];
  1166. mostFrequentLetters = [letter]; // 重置为当前最多的字母
  1167. } else if (letterCounts[letter] === maxCount) {
  1168. mostFrequentLetters.push(letter); // 如果计数相同,则添加到列表中
  1169. }
  1170. }
  1171. // 如果所有字母的计数都是0或数组为空,则返回空
  1172. if (mostFrequentLetters.length === 0) {
  1173. return '';
  1174. }
  1175. // 返回出现次数最多的字母或字母集合
  1176. return mostFrequentLetters;
  1177. },
  1178. //根据第二个数组对应第一个数组的value列,取第一个数组的remark的值,组成新的数组
  1179. getRemarkValues: function (options, values) {
  1180. if (!options || options.length === 0 || !values || values.length === 0) {
  1181. return [];
  1182. }
  1183. // 初始化一个空数组来存储结果
  1184. let remarkValues = [];
  1185. // 遍历values数组
  1186. values.forEach(value => {
  1187. // 遍历options数组
  1188. options.forEach(option => {
  1189. // 如果找到了对应的value,则将该option的remark添加到result数组中
  1190. if (option.value == value) {
  1191. remarkValues.push(option.remark);
  1192. }
  1193. });
  1194. });
  1195. // 返回包含所有remark值的数组
  1196. return remarkValues;
  1197. },
  1198. getFormattedString: function (arr1, arr2) {
  1199. // 检查 arr1 和 arr2 是否为非空数组
  1200. if (!arr1 || !arr2 || !Array.isArray(arr1) || arr1.length === 0 || !Array.isArray(arr2) || arr2.length === 0) {
  1201. return '';
  1202. }
  1203. let result = '';
  1204. arr1.forEach(value => {
  1205. const valueStr = value ? value.toString() : '';
  1206. const item = arr2.find(obj => obj.value == valueStr);
  1207. if (item) {
  1208. result += ` ${item.remark}、${item.label} char10`;
  1209. }
  1210. });
  1211. return result;
  1212. },
  1213. /**
  1214. * 生命周期函数--监听页面初次渲染完成
  1215. */
  1216. onReady() {
  1217. },
  1218. /**
  1219. * 生命周期函数--监听页面显示
  1220. */
  1221. onShow() {
  1222. },
  1223. /**
  1224. * 生命周期函数--监听页面隐藏
  1225. */
  1226. onHide() {
  1227. var that = this;
  1228. if (that.data.intervalId1) {
  1229. clearInterval(that.data.intervalId1);
  1230. that.data.intervalId1 = null;
  1231. }
  1232. },
  1233. /**
  1234. * 生命周期函数--监听页面卸载
  1235. */
  1236. onUnload() {
  1237. var that = this;
  1238. if (that.data.intervalId1) {
  1239. clearInterval(that.data.intervalId1);
  1240. that.data.intervalId1 = null;
  1241. }
  1242. },
  1243. /**
  1244. * 页面相关事件处理函数--监听用户下拉动作
  1245. */
  1246. onPullDownRefresh() {
  1247. },
  1248. /**
  1249. * 页面上拉触底事件的处理函数
  1250. */
  1251. onReachBottom() {
  1252. },
  1253. /**
  1254. * 用户点击右上角分享
  1255. */
  1256. onShareAppMessage() {
  1257. }
  1258. })