textStep.js 45 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304
  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. list[index].value = values;
  525. this.setData({
  526. physiqueData: list
  527. })
  528. } else if (this.data.type == "sleep") {
  529. // 睡眠质量
  530. }
  531. },
  532. toNext() {
  533. if (this.data.step == 1) {
  534. // 判断基本信息是否为空
  535. } else {
  536. // 判断列表是否有值
  537. if (this.data.type == "physique") {
  538. // 体质
  539. var list = this.data.physiqueData;
  540. var index = this.data.step - 2;
  541. var values = list[index].value || [];
  542. if (values.length <= 0) {
  543. wx.showModal({
  544. title: '无法提交',
  545. content: '您还有部分题目未完成,请检查后重新提交',
  546. showCancel: false,
  547. confirmColor: '#0BC3AA',
  548. confirmText: "好的",
  549. success(res) {
  550. }
  551. })
  552. return
  553. }
  554. } else if (this.data.type == "sleep") {
  555. // 睡眠质量
  556. var list = this.data.sleepData;
  557. var index = this.data.step - 2;
  558. var values = list[index].value;
  559. if ((list[index].type == 'radio&input' && this.data.inputValue.length <= 0 && values.length <= 0) || (list[index].type != 'radio&input' && (!values || values.length <= 0))) {
  560. wx.showModal({
  561. title: '无法提交',
  562. content: '您还有部分题目未完成,请检查后重新提交',
  563. showCancel: false,
  564. confirmColor: '#0BC3AA',
  565. confirmText: "好的",
  566. success(res) {
  567. }
  568. })
  569. return
  570. }
  571. }
  572. }
  573. if (this.data.step < this.data.stepTotal) {
  574. this.setData({
  575. step: this.data.step + 1
  576. })
  577. } else {
  578. // 结束了
  579. console.log('结束了');
  580. if (this.data.type == "physique") {
  581. // 体质
  582. this.commitPhysique();
  583. } else if (this.data.type == "sleep") {
  584. // 睡眠质量
  585. var that = this;
  586. wx.showLoading({
  587. title: '加载中',
  588. })
  589. if (!that.data.intervalId1) {
  590. that.data.intervalId1 = setInterval(() => {
  591. that.commitSleep();
  592. }, 1000);
  593. }
  594. }
  595. }
  596. },
  597. commitPhysique() {
  598. var that = this;
  599. var list = this.data.physiqueData;
  600. let resultMostFrequentLetters = this.findMostFrequentLetters(
  601. this.getRemarkValues(list[0].options, list[0].value),
  602. this.getRemarkValues(list[1].options, list[1].value),
  603. this.getRemarkValues(list[2].options, list[2].value),
  604. this.getRemarkValues(list[3].options, list[3].value),
  605. this.getRemarkValues(list[4].options, list[4].value),
  606. this.getRemarkValues(list[5].options, list[5].value),
  607. this.getRemarkValues(list[6].options, list[6].value),
  608. this.getRemarkValues(list[7].options, list[7].value)
  609. );
  610. const { nickName } = wx.getStorageSync('userInfo');
  611. const unionid = wx.getStorageSync('unionid');
  612. let comScoreIndex = [];
  613. let _comScoreStatus = "";
  614. let _comScoreDesc = ""
  615. if (!resultMostFrequentLetters || !Array.isArray(resultMostFrequentLetters) || !resultMostFrequentLetters.length) {
  616. comScoreIndex = [];
  617. _comScoreStatus = "";
  618. _comScoreDesc = ""
  619. } else {
  620. comScoreIndex = [];
  621. // 遍历输入数组
  622. resultMostFrequentLetters.forEach(item => {
  623. console.log('item=' + item);
  624. if (item == 'A') {
  625. if (_comScoreStatus) {
  626. _comScoreStatus += "\n气虚型";
  627. } else {
  628. _comScoreStatus += "气虚型";
  629. }
  630. if (_comScoreDesc) {
  631. _comScoreDesc += "\n气虚型:填写内容";
  632. } else {
  633. _comScoreDesc += "气虚型:填写内容";
  634. }
  635. comScoreIndex.push(0);
  636. } else if (item == 'B') {
  637. if (_comScoreStatus) {
  638. _comScoreStatus += "\n气滞型";
  639. } else {
  640. _comScoreStatus += "气滞型";
  641. }
  642. if (_comScoreDesc) {
  643. _comScoreDesc += "\n气滞型:填写内容";
  644. } else {
  645. _comScoreDesc += "气滞型:填写内容";
  646. }
  647. comScoreIndex.push(1);
  648. } else if (item == 'C') {
  649. if (_comScoreStatus) {
  650. _comScoreStatus += "\n血虚型";
  651. } else {
  652. _comScoreStatus += "血虚型";
  653. }
  654. if (_comScoreDesc) {
  655. _comScoreDesc += "\n血虚型:填写内容";
  656. } else {
  657. _comScoreDesc += "血虚型:填写内容";
  658. }
  659. comScoreIndex.push(2);
  660. } else if (item == 'D') {
  661. if (_comScoreStatus) {
  662. _comScoreStatus += "\n淤血型";
  663. } else {
  664. _comScoreStatus += "淤血型";
  665. }
  666. if (_comScoreDesc) {
  667. _comScoreDesc += "\n淤血型:填写内容";
  668. } else {
  669. _comScoreDesc += "淤血型:填写内容";
  670. }
  671. comScoreIndex.push(3);
  672. } else if (item == 'E') {
  673. if (_comScoreStatus) {
  674. _comScoreStatus += "\n水虚型";
  675. } else {
  676. _comScoreStatus += "水虚型";
  677. }
  678. if (_comScoreDesc) {
  679. _comScoreDesc += "\n水虚型:填写内容";
  680. } else {
  681. _comScoreDesc += "水虚型:填写内容";
  682. }
  683. comScoreIndex.push(4);
  684. } else if (item == 'F') {
  685. if (_comScoreStatus) {
  686. _comScoreStatus += "\n痰湿型";
  687. } else {
  688. _comScoreStatus += "痰湿型";
  689. }
  690. if (_comScoreDesc) {
  691. _comScoreDesc += "\n痰湿型:填写内容";
  692. } else {
  693. _comScoreDesc += "痰湿型:填写内容";
  694. }
  695. comScoreIndex.push(5);
  696. }
  697. });
  698. }
  699. let surveyData = {
  700. hotel: this.data.hotel,
  701. room: this.data.room,
  702. userId: nickName,
  703. id2: unionid,
  704. bodySynthesis: this.getFormattedString(list[0].value, list[0].options),
  705. facialFeatures: this.getFormattedString(list[1].value, list[1].options),
  706. skinHair: this.getFormattedString(list[2].value, list[2].options),
  707. emotion: this.getFormattedString(list[3].value, list[3].options),
  708. menstruation: this.getFormattedString(list[4].value, list[4].options),
  709. character: this.getFormattedString(list[5].value, list[5].options),
  710. sleep: this.getFormattedString(list[6].value, list[6].options),
  711. //舌头状态是新增加项,赋给value1了,数据库里有value1...value8,以备增加项用
  712. value1: this.getFormattedString(list[7].value, list[7].options),
  713. //value2 保存A、B、C、D、E、F 每个的个数
  714. value2: JSON.stringify(countABCDEF),
  715. comScoreStatus: _comScoreStatus ? _comScoreStatus : '健康型',
  716. comScoreIndex: comScoreIndex.join(),
  717. comScoreDesc: _comScoreDesc,
  718. };
  719. var maxValueObj = that.findMaxValueKeyAndIndex(countABCDEF);
  720. console.log(countABCDEF);
  721. console.log(maxValueObj);
  722. // 体质提交
  723. if (!that.data.intervalId1) {
  724. that.data.intervalId1 = setInterval(() => {
  725. //提交到数据库
  726. wx.request({
  727. url: `${homeApi}/system/constitutionDiagnosis`, //
  728. method: 'POST',
  729. header: {
  730. 'content-type': 'application/json', // 默认值
  731. 'Authorization': 'Bearer ' + token // 在头部设置认证信息,例如使用Bearer Token
  732. },
  733. data: surveyData,
  734. success(res) {
  735. console.log('res===' + JSON.stringify(res));
  736. console.log('res.code===' + res.code);
  737. if (res && res.data && res.data.code == 200) {
  738. if (that.data.intervalId1) {
  739. clearInterval(that.data.intervalId1);
  740. that.data.intervalId1 = null;
  741. }
  742. wx.showToast({
  743. title: '问卷提交成功',
  744. icon: 'success',
  745. duration: 2000,
  746. success() {
  747. setTimeout(() => {
  748. wx.redirectTo({
  749. url: `/subpages/testResultB/testResultB?comScoreIndex=${maxValueObj.index}`
  750. })
  751. }, 1000);
  752. }
  753. });
  754. }
  755. },
  756. fail: function (error) {
  757. console.error('error', error);
  758. },
  759. complete: function (e) {
  760. }
  761. });
  762. }, 1000);
  763. }
  764. },
  765. commitSleep() {
  766. // 睡眠质量提交
  767. var that = this;
  768. const { nickName } = wx.getStorageSync('userInfo');
  769. const unionid = wx.getStorageSync('unionid');
  770. const answerJson = this.data.sleepData;
  771. let value1 = answerJson[0].value;
  772. let value2 = answerJson[1].value;
  773. let value3 = answerJson[2].value;
  774. let value4 = answerJson[3].value;
  775. let value5a = answerJson[4].value;
  776. let value5b = answerJson[5].value;
  777. let value5c = answerJson[6].value;
  778. let value5d = answerJson[7].value;
  779. let value5e = answerJson[8].value;
  780. let value5f = answerJson[9].value;
  781. let value5g = answerJson[10].value;
  782. let value5h = answerJson[11].value;
  783. let value5i = answerJson[12].value;
  784. let value5j = answerJson[13].value;
  785. let value5jDes = '';//这个值没有算
  786. let value6 = answerJson[14].value;
  787. let value7 = answerJson[15].value;
  788. let value8 = answerJson[16].value;
  789. let value9 = answerJson[17].value;
  790. let value10 = answerJson[18].value;
  791. let value11 = answerJson[19].value;
  792. let value12 = answerJson[20].value;
  793. let value13 = answerJson[21].value;
  794. let value14 = answerJson[22].value;
  795. let value15 = answerJson[23].value;
  796. let value15Des = that.data.inputValue;//这个值没有算
  797. //计算规则 https://mp.weixin.qq.com/s/QyTzuPoNErMjc2KcA1M61g
  798. let comA = 0;//条目6
  799. let comB = 0;
  800. let comB1 = 0;
  801. let comC = 0;
  802. let comD = 0;
  803. let comE = 0;
  804. let comF = 0;
  805. let comG = 0;
  806. comA = this.resultABCD(value6);
  807. comB1 = this.resultABCD(value2) + this.resultABCD(value5a);
  808. if (comB1 == 0) {
  809. comB = 0;
  810. } else if (comB1 >= 1 && comB1 <= 2) {
  811. comB = 1;
  812. } else if (comB1 >= 3 && comB1 <= 4) {
  813. comB = 2;
  814. } else if (comB1 >= 5 && comB1 <= 6) {
  815. comB = 3;
  816. }
  817. let value41 = parseInt((value4.split(':')[0]), 10) || 0;
  818. let value42 = parseInt((value4.split(':')[1]), 10) || 0;
  819. let value43 = value41 * 60 + value42;
  820. if (value43 > 420) {
  821. comC = 0;
  822. } else if (value43 >= 360 && value43 <= 420) {
  823. comC = 1;
  824. } else if (value43 >= 300 && value43 < 360) {
  825. comC = 2;
  826. } else if (value43 < 300) {
  827. comC = 3;
  828. }
  829. let datediff = this.calculateTimeDifference(value1, value3);
  830. let sleepRate = datediff ? ((value43 / datediff) * 100) : 0;
  831. if (sleepRate >= 85) {
  832. comD = 0;
  833. } else if (sleepRate >= 75 && sleepRate <= 84) {
  834. comD = 1;
  835. } else if (sleepRate >= 65 && sleepRate < 74) {
  836. comD = 2;
  837. } else if (sleepRate < 65) {
  838. comD = 3;
  839. }
  840. let value5All = this.resultABCD(value5b)
  841. + this.resultABCD(value5c)
  842. + this.resultABCD(value5d)
  843. + this.resultABCD(value5e)
  844. + this.resultABCD(value5f)
  845. + this.resultABCD(value5g)
  846. + this.resultABCD(value5h)
  847. + this.resultABCD(value5i)
  848. + this.resultABCD(value5j);
  849. if (value5All == 0) {
  850. comE = 0;
  851. } else if (value5All >= 1 && value5All <= 9) {
  852. comE = 1;
  853. } else if (value5All >= 10 && value5All <= 18) {
  854. comE = 2;
  855. } else if (value5All >= 19 && value5All <= 27) {
  856. comE = 3;
  857. }
  858. comF = this.resultABCD(value7);
  859. let valueGAll = this.resultABCD(value8) + this.resultABCD(value9);
  860. if (valueGAll == 0) {
  861. comG = 0;
  862. } else if (valueGAll >= 1 && valueGAll <= 2) {
  863. comG = 1;
  864. } else if (valueGAll >= 3 && valueGAll <= 4) {
  865. comG = 2;
  866. } else if (valueGAll >= 5 && valueGAll <= 6) {
  867. comG = 3;
  868. }
  869. let comAll = comA + comB + comC + comD + comE + comF + comG;
  870. let comScoreIndex = 0;
  871. let _comScoreStatus = "";
  872. let _comScoreDesc = "";
  873. if (comAll >= 0 && comAll <= 5) {
  874. _comScoreStatus = "非常好";
  875. } else if (comAll >= 6 && comAll <= 10) {
  876. _comScoreStatus = "良好";
  877. comScoreIndex = 1;
  878. } else if (comAll >= 11 && comAll <= 15) {
  879. _comScoreStatus = "一般";
  880. comScoreIndex = 2;
  881. } else {
  882. // if (comAll >= 16 && comAll <= 21)
  883. _comScoreStatus = "差";
  884. comScoreIndex = 3;
  885. }
  886. if (this.judgmentScoreRange(comAll, 0, 5)) {
  887. _comScoreDesc = "你目前的睡眠质量非常高,而且健康状况良好,这一切应该继续保持下去。"
  888. } else if (this.judgmentScoreRange(comAll, 6, 10)) {
  889. _comScoreDesc = "你的睡眠质量平平,健康状况也受到影响, 如果再不引起你对睡眠质量的足够重视, 那么你的睡眠质量很可能会迅速下降,向下一级别发展。"
  890. } else if (this.judgmentScoreRange(comAll, 11, 15)) {
  891. _comScoreDesc = "如果你在这一级别内,那么你的睡眠质量可 就亮起红灯了。你必须警惕,因为你的睡眠质量确实比较糟糕,健康状况明显受损。饮食起居会受到一定影响,甚至部分工作你都开始感觉吃力。"
  892. } else {
  893. _comScoreDesc = "天啊!你的睡眠质量已经到了令人发指的地 步—长期睡眠不足导致了你的健康状况严重恶化,这就是你工作力不从心,情绪起伏不定的原因。"
  894. }
  895. let surveyData = {
  896. hotel: this.data.hotel,
  897. room: this.data.room,
  898. userId: nickName,
  899. id2: unionid,
  900. value1: value1,
  901. value2: value2,
  902. value3: value3,
  903. value4: value4,
  904. value5a: value5a,
  905. value5b: value5b,
  906. value5c: value5c,
  907. value5d: value5d,
  908. value5e: value5e,
  909. value5f: value5f,
  910. value5g: value5g,
  911. value5h: value5h,
  912. value5i: value5i,
  913. value5j: value5j,
  914. value5jDes: value5jDes,
  915. value6: value6,
  916. value7: value7,
  917. value8: value8,
  918. value9: value9,
  919. value10: value10,
  920. value11: value11,
  921. value12: value12,
  922. value13: value13,
  923. value14: value14,
  924. value15: value15,
  925. value15Des: value15Des,
  926. value16: comAll,//备用16(评分)
  927. value17: _comScoreStatus,//备用17(评分说明)
  928. value18: _comScoreDesc,
  929. value18: comA + ',' + comB + ',' + comC + ',' + comD + ',' + comE + ',' + comF + ',' + comG //备用18(comA、comB、comC、comD、comE、comF、comG)
  930. };
  931. //提交到数据库
  932. wx.request({
  933. url: `${homeApi}/system/questionInvest`, //
  934. method: 'POST',
  935. header: {
  936. 'content-type': 'application/json', // 默认值
  937. 'Authorization': 'Bearer ' + token // 在头部设置认证信息,例如使用Bearer Token
  938. },
  939. data: surveyData,
  940. success(res) {
  941. console.log('res===' + JSON.stringify(res));
  942. console.log('res.code===' + res.data.code);
  943. if (res && res.data && res.data.code == 200) {
  944. wx.hideLoading();
  945. if (that.data.intervalId1) {
  946. clearInterval(that.data.intervalId1);
  947. that.data.intervalId1 = null;
  948. }
  949. wx.showToast({
  950. title: '问卷提交成功',
  951. icon: 'success',
  952. duration: 2000,
  953. success() {
  954. setTimeout(() => {
  955. wx.redirectTo({
  956. url: `/subpages/testResultA/testResultA?comScore=${comAll}`
  957. })
  958. }, 1000);
  959. }
  960. });
  961. }
  962. },
  963. fail: function (error) {
  964. console.error('error', error);
  965. },
  966. complete: function (e) {
  967. }
  968. });
  969. },
  970. handleSelectDate(event) {
  971. var item = event.currentTarget.dataset.item;
  972. const value = item.value || "";
  973. this.setData({ currentDateItem: item, currentDate: value, showDateDialog: true });
  974. console.log(this.data.currentDateItem);
  975. },
  976. onCloseDateDialog() {
  977. this.setData({ showDateDialog: false, currentDateItem: null });
  978. },
  979. onCloseResultsDialog() {
  980. this.setData({ promptTextMessageFlag: false });
  981. },
  982. onDateInput(event) {
  983. const item = this.data.currentDateItem;
  984. if (!item) {
  985. return
  986. }
  987. if (this.data.type == "physique") {
  988. // 体质
  989. } else if (this.data.type == "sleep") {
  990. // 睡眠质量
  991. let sleepData = this.data.sleepData;
  992. for (let i = 0; i < sleepData.length; i++) {
  993. const element = sleepData[i];
  994. if (element.id == item.id) {
  995. element.value = event.detail;
  996. break;
  997. }
  998. }
  999. console.log(event);
  1000. this.setData({
  1001. sleepData: sleepData
  1002. });
  1003. }
  1004. this.onCloseDateDialog()
  1005. },
  1006. // 睡眠质量的方法
  1007. resultABCD: function (a) {
  1008. if (a == 'a') {
  1009. return 0;
  1010. } else if (a == 'b') {
  1011. return 1;
  1012. } else if (a == 'c') {
  1013. return 2;
  1014. } else if (a == 'd') {
  1015. return 3;
  1016. }
  1017. },
  1018. judgmentScoreRange(scoreValue, startScore, endScore) {
  1019. return scoreValue >= startScore && scoreValue <= endScore;
  1020. },
  1021. // 将时间字符串转换为分钟数
  1022. timeStringToMinutes: function (timeStr) {
  1023. var parts = timeStr.split(":");
  1024. return parseInt(parts[0], 10) * 60 + parseInt(parts[1], 10);
  1025. },
  1026. // 计算时间差(分钟)
  1027. calculateTimeDifference: function (sleepTimeStr, wakeUpTimeStr) {
  1028. // 将时间字符串转换为分钟
  1029. var sleepTimeMinutes = this.timeStringToMinutes(sleepTimeStr);
  1030. var wakeUpTimeMinutes = this.timeStringToMinutes("24:00") + this.timeStringToMinutes(wakeUpTimeStr); // 加上第二天的0点到起床时间的分钟数
  1031. // 计算时间差
  1032. var diffInMinutes = wakeUpTimeMinutes - sleepTimeMinutes;
  1033. // 将分钟数转换回时间字符串格式 HH:mm
  1034. var diffInHours = Math.floor(diffInMinutes / 60);
  1035. var diffInMins = diffInMinutes % 60;
  1036. // 返回时间差字符串
  1037. return diffInMinutes;
  1038. },
  1039. // 体质的方法
  1040. // 取出最大值的obj
  1041. findMaxValueKeyAndIndex(obj) {
  1042. if (typeof obj !== 'object' || obj === null || Array.isArray(obj)) {
  1043. throw new Error('Input must be a plain object');
  1044. }
  1045. let maxKey = null;
  1046. let maxValue = 0;
  1047. let maxIndex = 6;
  1048. const keys = Object.keys(obj);
  1049. keys.forEach((key, index) => {
  1050. const value = obj[key];
  1051. if (value > maxValue) {
  1052. maxValue = value;
  1053. maxKey = key;
  1054. maxIndex = index;
  1055. }
  1056. });
  1057. return {
  1058. key: maxKey,
  1059. value: maxValue,
  1060. index: maxIndex
  1061. };
  1062. },
  1063. /**
  1064. * A、B、C、D、E、F 最后积累的数量对比,按数量多少来判断,6个分别对应:气虚型、气滞型、血虚型、淤血型、水虚型、痰湿型
  1065. * 找出对象中值最大的键
  1066. * @param {Object} obj - 包含键值对的对象
  1067. * @returns {string|null} - 值最大的键,如果没有找到则返回null
  1068. */
  1069. findKeyWithMaxValue(obj) {
  1070. if (typeof obj !== 'object' || obj === null || Array.isArray(obj)) {
  1071. throw new Error('Input must be a plain object');
  1072. }
  1073. let maxKey = null;
  1074. let maxValue = 0;
  1075. for (let key in obj) {
  1076. if (obj.hasOwnProperty(key)) {
  1077. if (obj[key] > maxValue) {
  1078. maxValue = obj[key];
  1079. maxKey = key;
  1080. }
  1081. }
  1082. }
  1083. return maxKey;
  1084. },
  1085. areAllArraysEmpty: function (arr1, arr2, arr3, arr4, arr5, arr6, arr7, arr8) {
  1086. // 定义一个数组来包含所有传入的数组
  1087. const arrays = [arr1, arr2, arr3, arr4, arr5, arr6, arr7, arr8];
  1088. // 遍历这个数组,检查每一项(即传入的数组)是否为空
  1089. for (let i = 0; i < arrays.length; i++) {
  1090. // 检查当前数组是否为空(即长度为0)
  1091. if (arrays[i] && arrays[i].length > 0) {
  1092. // 如果发现任何一个数组不为空,则返回false
  1093. return false;
  1094. }
  1095. }
  1096. // 如果所有数组都检查过了,且都是空的,则返回true
  1097. return true;
  1098. },
  1099. //统计这8个数组,总共包含A,B,C,D,E,F的个数,返回最多的一项(也可能多项):
  1100. //如果有多个 最多 的情况,返回最多的几个,如果都是0或者空,返回空
  1101. findMostFrequentLetters: function (arr1, arr2, arr3, arr4, arr5, arr6, arr7, arr8) {
  1102. //判断6个数组是否都为空
  1103. if (this.areAllArraysEmpty(arr1, arr2, arr3, arr4, arr5, arr6, arr7, arr8))
  1104. return '';
  1105. // 初始化一个对象来存储每个字母的计数
  1106. const letterCounts = {
  1107. A: 0,
  1108. B: 0,
  1109. C: 0,
  1110. D: 0,
  1111. E: 0,
  1112. F: 0
  1113. };
  1114. // 定义一个辅助函数来更新计数
  1115. function updateCounts(arr) {
  1116. if (Array.isArray(arr)) {
  1117. arr.forEach(item => {
  1118. if (typeof item === 'string' && ['A', 'B', 'C', 'D', 'E', 'F'].includes(item)) {
  1119. letterCounts[item]++;
  1120. }
  1121. });
  1122. }
  1123. }
  1124. // 对每个数组调用辅助函数
  1125. updateCounts(arr1);
  1126. updateCounts(arr2);
  1127. updateCounts(arr3);
  1128. updateCounts(arr4);
  1129. updateCounts(arr5);
  1130. updateCounts(arr6);
  1131. updateCounts(arr7);
  1132. updateCounts(arr8);
  1133. countABCDEF = letterCounts;
  1134. // 找出出现次数最多的字母及其计数
  1135. let maxCount = 0;
  1136. let mostFrequentLetters = [];
  1137. for (let letter in letterCounts) {
  1138. if (letterCounts[letter] == 0) {
  1139. continue;
  1140. }
  1141. if (letterCounts[letter] > maxCount) {
  1142. maxCount = letterCounts[letter];
  1143. mostFrequentLetters = [letter]; // 重置为当前最多的字母
  1144. } else if (letterCounts[letter] === maxCount) {
  1145. mostFrequentLetters.push(letter); // 如果计数相同,则添加到列表中
  1146. }
  1147. }
  1148. // 如果所有字母的计数都是0或数组为空,则返回空
  1149. if (mostFrequentLetters.length === 0) {
  1150. return '';
  1151. }
  1152. // 返回出现次数最多的字母或字母集合
  1153. return mostFrequentLetters;
  1154. },
  1155. //根据第二个数组对应第一个数组的value列,取第一个数组的remark的值,组成新的数组
  1156. getRemarkValues: function (options, values) {
  1157. if (!options || options.length === 0 || !values || values.length === 0) {
  1158. return [];
  1159. }
  1160. // 初始化一个空数组来存储结果
  1161. let remarkValues = [];
  1162. // 遍历values数组
  1163. values.forEach(value => {
  1164. // 遍历options数组
  1165. options.forEach(option => {
  1166. // 如果找到了对应的value,则将该option的remark添加到result数组中
  1167. if (option.value == value) {
  1168. remarkValues.push(option.remark);
  1169. }
  1170. });
  1171. });
  1172. // 返回包含所有remark值的数组
  1173. return remarkValues;
  1174. },
  1175. getFormattedString: function (arr1, arr2) {
  1176. // 检查 arr1 和 arr2 是否为非空数组
  1177. if (!arr1 || !arr2 || !Array.isArray(arr1) || arr1.length === 0 || !Array.isArray(arr2) || arr2.length === 0) {
  1178. return '';
  1179. }
  1180. let result = '';
  1181. arr1.forEach(value => {
  1182. const valueStr = value ? value.toString() : '';
  1183. const item = arr2.find(obj => obj.value == valueStr);
  1184. if (item) {
  1185. result += ` ${item.remark}、${item.label} char10`;
  1186. }
  1187. });
  1188. return result;
  1189. },
  1190. /**
  1191. * 生命周期函数--监听页面初次渲染完成
  1192. */
  1193. onReady() {
  1194. },
  1195. /**
  1196. * 生命周期函数--监听页面显示
  1197. */
  1198. onShow() {
  1199. },
  1200. /**
  1201. * 生命周期函数--监听页面隐藏
  1202. */
  1203. onHide() {
  1204. var that = this;
  1205. if (that.data.intervalId1) {
  1206. clearInterval(that.data.intervalId1);
  1207. that.data.intervalId1 = null;
  1208. }
  1209. },
  1210. /**
  1211. * 生命周期函数--监听页面卸载
  1212. */
  1213. onUnload() {
  1214. var that = this;
  1215. if (that.data.intervalId1) {
  1216. clearInterval(that.data.intervalId1);
  1217. that.data.intervalId1 = null;
  1218. }
  1219. },
  1220. /**
  1221. * 页面相关事件处理函数--监听用户下拉动作
  1222. */
  1223. onPullDownRefresh() {
  1224. },
  1225. /**
  1226. * 页面上拉触底事件的处理函数
  1227. */
  1228. onReachBottom() {
  1229. },
  1230. /**
  1231. * 用户点击右上角分享
  1232. */
  1233. onShareAppMessage() {
  1234. }
  1235. })