柒零 hai 1 ano
pai
achega
435dacf4a5

+ 425 - 320
subpages/constitutionDiagnosis/constitutionDiagnosis.js

@@ -14,121 +14,121 @@ Page({
 		normalIcon: "/subpages/icons/ic_checkbox.svg",
 		activeColor: "color:#0BC3AA;",
 		normalColor: "color:#666666;",
-		
+
 		//一、身体综合
 		bodySynthesisOptions: [
-			{ value: '0',remark: 'A', label: '易疲劳,总感到疲倦' },
-			{ value: '1',remark: 'A', label: '好出汗,一活动就冒汗' },
-			{ value: '2',remark: 'A', label: '易感冒,恢复慢' },
-			{ value: '3',remark: 'A', label: '稍一活动就气喘' },
-			{ value: '4',remark: 'A', label: '疲劳后身体就不舒服' },
-			{ value: '5',remark: 'A', label: '无食欲' },
-			{ value: '6',remark: 'A', label: '手脚发凉' },
-			{ value: '7',remark: 'A', label: '肌肉无力' },
-			{ value: '8',remark: 'B', label: '腹部易滞气' },
-			{ value: '9',remark: 'B', label: '头痛、肩凝、关节痛、胃疼、手脚麻痹' },
-			{ value: '10',remark: 'B', label: '紧张、发怒后身体不舒服' },
-			{ value: '11',remark: 'B', label: '身体有痛感后,疼痛部位游走不定' },
-			{ value: '12',remark: 'C', label: '易眩晕和站起时头晕' },
-			{ value: '13',remark: 'C', label: '常感到心慌' },
-			{ value: '14',remark: 'C', label: '易头晕眼花' },
-			{ value: '15',remark: 'D', label: '有受伤和手术后的旧伤痛' },
-			{ value: '16',remark: 'D', label: '感到肩和腰、头有针扎样痛' },
-			{ value: '17',remark: 'D', label: '入夜后容易出现肩、腰、头疼痛' },
-			{ value: '18',remark: 'E', label: '喉咙易渴,常想喝水' },
-			{ value: '19',remark: 'E', label: '感冒愈后常干咳' },
-			{ value: '20',remark: 'E', label: '易便秘,大便呈球状' },
-			{ value: '21',remark: 'E', label: '尿量少、色浓' },
-			{ value: '22',remark: 'E', label: '身体总是发热' },
-			{ value: '23',remark: 'E', label: '持续低烧' },
-			{ value: '24',remark: 'F', label: '常感到身体和手脚沉重,易浮肿' },
-			{ value: '25',remark: 'F', label: '胃部不适、恶心' },
-			{ value: '26',remark: 'F', label: '雨天和湿度高时身体状况就很糟糕' },
-			{ value: '27',remark: 'F', label: '有时眩晕' },
-			{ value: '28',remark: 'F', label: '大便偏软' },
-			{ value: '29',remark: 'F', label: '易恶心、呕吐、晕车' },
+			{ value: '0', remark: 'A', label: '易疲劳,总感到疲倦' },
+			{ value: '1', remark: 'A', label: '好出汗,一活动就冒汗' },
+			{ value: '2', remark: 'A', label: '易感冒,恢复慢' },
+			{ value: '3', remark: 'A', label: '稍一活动就气喘' },
+			{ value: '4', remark: 'A', label: '疲劳后身体就不舒服' },
+			{ value: '5', remark: 'A', label: '无食欲' },
+			{ value: '6', remark: 'A', label: '手脚发凉' },
+			{ value: '7', remark: 'A', label: '肌肉无力' },
+			{ value: '8', remark: 'B', label: '腹部易滞气' },
+			{ value: '9', remark: 'B', label: '头痛、肩凝、关节痛、胃疼、手脚麻痹' },
+			{ value: '10', remark: 'B', label: '紧张、发怒后身体不舒服' },
+			{ value: '11', remark: 'B', label: '身体有痛感后,疼痛部位游走不定' },
+			{ value: '12', remark: 'C', label: '易眩晕和站起时头晕' },
+			{ value: '13', remark: 'C', label: '常感到心慌' },
+			{ value: '14', remark: 'C', label: '易头晕眼花' },
+			{ value: '15', remark: 'D', label: '有受伤和手术后的旧伤痛' },
+			{ value: '16', remark: 'D', label: '感到肩和腰、头有针扎样痛' },
+			{ value: '17', remark: 'D', label: '入夜后容易出现肩、腰、头疼痛' },
+			{ value: '18', remark: 'E', label: '喉咙易渴,常想喝水' },
+			{ value: '19', remark: 'E', label: '感冒愈后常干咳' },
+			{ value: '20', remark: 'E', label: '易便秘,大便呈球状' },
+			{ value: '21', remark: 'E', label: '尿量少、色浓' },
+			{ value: '22', remark: 'E', label: '身体总是发热' },
+			{ value: '23', remark: 'E', label: '持续低烧' },
+			{ value: '24', remark: 'F', label: '常感到身体和手脚沉重,易浮肿' },
+			{ value: '25', remark: 'F', label: '胃部不适、恶心' },
+			{ value: '26', remark: 'F', label: '雨天和湿度高时身体状况就很糟糕' },
+			{ value: '27', remark: 'F', label: '有时眩晕' },
+			{ value: '28', remark: 'F', label: '大便偏软' },
+			{ value: '29', remark: 'F', label: '易恶心、呕吐、晕车' },
 		],
-		
+
 		bodySynthesis: [],// 一、身体综合
-		
+
 		//二、面部五官
 		facialFeaturesOptions: [
-			{ value: '0',remark: 'B', label: '喉头部有异物感' },
-			{ value: '1',remark: 'C', label: '脸色不好' },
-			{ value: '2',remark: 'D', label: '眼圈发黑' },
-			{ value: '3',remark: 'E', label: '眼睛经常模糊不清' },
-			{ value: '4',remark: 'E', label: '多呈现消极、羸弱的面孔' },
-			{ value: '5',remark: 'F', label: '唾液和痰较多,中发黏' },
-			{ value: '6',remark: 'F', label: '易犯花粉症和鼻炎,容易淌鼻涕' },			
+			{ value: '0', remark: 'B', label: '喉头部有异物感' },
+			{ value: '1', remark: 'C', label: '脸色不好' },
+			{ value: '2', remark: 'D', label: '眼圈发黑' },
+			{ value: '3', remark: 'E', label: '眼睛经常模糊不清' },
+			{ value: '4', remark: 'E', label: '多呈现消极、羸弱的面孔' },
+			{ value: '5', remark: 'F', label: '唾液和痰较多,中发黏' },
+			{ value: '6', remark: 'F', label: '易犯花粉症和鼻炎,容易淌鼻涕' },
 		],
-		
+
 		facialFeatures: [],// 二、面部五官
-		
+
 		//三、皮肤毛发
 		skinHairOptions: [
-			{ value: '0',remark: 'C', label: '头发脆弱,脱发' },
-			{ value: '1',remark: 'C', label: '皮肤和指甲无光泽' },
-			{ value: '2',remark: 'D', label: '皮肤干燥易皲裂,色斑、雀斑多' },
-			{ value: '3',remark: 'D', label: '皮肤呈青紫色或黑紫色,不光滑' },
-			{ value: '4',remark: 'D', label: '肤色暗淡' },
-			{ value: '5',remark: 'E', label: '洗浴后皮肤很快干燥,易发痒' },
-			{ value: '6',remark: 'E', label: '皮肤纹理粗糙、毛孔张开' },			
+			{ value: '0', remark: 'C', label: '头发脆弱,脱发' },
+			{ value: '1', remark: 'C', label: '皮肤和指甲无光泽' },
+			{ value: '2', remark: 'D', label: '皮肤干燥易皲裂,色斑、雀斑多' },
+			{ value: '3', remark: 'D', label: '皮肤呈青紫色或黑紫色,不光滑' },
+			{ value: '4', remark: 'D', label: '肤色暗淡' },
+			{ value: '5', remark: 'E', label: '洗浴后皮肤很快干燥,易发痒' },
+			{ value: '6', remark: 'E', label: '皮肤纹理粗糙、毛孔张开' },
 		],
-		
+
 		skinHair: [],// 三、皮肤毛发
-		
+
 		//四、情绪方面
 		emotionOptions: [
-			{ value: '0',remark: 'A', label: '经常情绪低落,容易受伤害' },
-			{ value: '1',remark: 'B', label: '焦虑、易怒' },
-			{ value: '2',remark: 'B', label: '常长吁短叹、嗳气' },	
+			{ value: '0', remark: 'A', label: '经常情绪低落,容易受伤害' },
+			{ value: '1', remark: 'B', label: '焦虑、易怒' },
+			{ value: '2', remark: 'B', label: '常长吁短叹、嗳气' },
 		],
-		
+
 		emotion: [],// 四、情绪方面
-		
+
 		//五、月经方面
 		menstruationOptions: [
-			{ value: '0',remark: 'B', label: '月经前身体不适' },
-			{ value: '1',remark: 'C', label: '经血量少或月经周期过长' },
-			{ value: '2',remark: 'D', label: '月经痛加重、经血中有动物肝脏血块' },	
+			{ value: '0', remark: 'B', label: '月经前身体不适' },
+			{ value: '1', remark: 'C', label: '经血量少或月经周期过长' },
+			{ value: '2', remark: 'D', label: '月经痛加重、经血中有动物肝脏血块' },
 		],
-		
+
 		menstruation: [],// 五、月经方面
-		
+
 		//六、性格方面
 		characterOptions: [
-			{ value: '0',remark: 'A', label: '过度依赖人际关系' },
-			{ value: '1',remark: 'B', label: '具有攻击性,不善于体谅别人' },
-			{ value: '2',remark: 'C', label: '属冷静、认真型' },	
-			{ value: '3',remark: 'C', label: '善于制造一个自我世界并沉溺其中' },	
-			{ value: '4',remark: 'D', label: '忍耐性较强的性格,容易积聚压力' },	
-			{ value: '5',remark: 'D', label: '接人待物中规中矩,严守礼节' },	
-			{ value: '6',remark: 'F', label: '以自我为中心,争强好胜,嫉妒心强,爱慕虚荣' },	
-			{ value: '7',remark: 'F', label: '喜欢奢华、热闹的氛围' },	
+			{ value: '0', remark: 'A', label: '过度依赖人际关系' },
+			{ value: '1', remark: 'B', label: '具有攻击性,不善于体谅别人' },
+			{ value: '2', remark: 'C', label: '属冷静、认真型' },
+			{ value: '3', remark: 'C', label: '善于制造一个自我世界并沉溺其中' },
+			{ value: '4', remark: 'D', label: '忍耐性较强的性格,容易积聚压力' },
+			{ value: '5', remark: 'D', label: '接人待物中规中矩,严守礼节' },
+			{ value: '6', remark: 'F', label: '以自我为中心,争强好胜,嫉妒心强,爱慕虚荣' },
+			{ value: '7', remark: 'F', label: '喜欢奢华、热闹的氛围' },
 		],
-		
+
 		character: [],// 六、性格方面
-		
+
 		//七、睡眠
 		sleepOptions: [
-			{ value: '0',remark: 'B', label: '入睡闲难' },
-			{ value: '1',remark: 'C', label: '睡眠浅,易做梦' },
+			{ value: '0', remark: 'B', label: '入睡闲难' },
+			{ value: '1', remark: 'C', label: '睡眠浅,易做梦' },
 		],
-		
+
 		sleep: [],// 七、睡眠
-		
+
 		//八、舌头状态
 		tongueStateOptions: [
-			{ value: '0',remark: 'A', label: '整体色淡;厚、肿大;边缘呈齿状' },
-			{ value: '1',remark: 'B', label: '两侧赤红;中间色淡或偏白;薄薄的黄色舌苔' },
-			{ value: '2',remark: 'C', label: '舌体偏小;色淡、偏白,舌苔整体偏薄' },	
-			{ value: '3',remark: 'D', label: '舌色暗、偏紫色;有黑色斑点;舌下两根静脉粗粗地浮现出来' },	
-			{ value: '4',remark: 'E', label: '舌色整体发红;舌苔少、甚至没有;舌面有齿痕' },	
-			{ value: '5',remark: 'F', label: '舌苔厚、黏黏糊糊;舌苔色黄或白;舌体肿胀' },
+			{ value: '0', remark: 'A', label: '整体色淡;厚、肿大;边缘呈齿状' },
+			{ value: '1', remark: 'B', label: '两侧赤红;中间色淡或偏白;薄薄的黄色舌苔' },
+			{ value: '2', remark: 'C', label: '舌体偏小;色淡、偏白,舌苔整体偏薄' },
+			{ value: '3', remark: 'D', label: '舌色暗、偏紫色;有黑色斑点;舌下两根静脉粗粗地浮现出来' },
+			{ value: '4', remark: 'E', label: '舌色整体发红;舌苔少、甚至没有;舌面有齿痕' },
+			{ value: '5', remark: 'F', label: '舌苔厚、黏黏糊糊;舌苔色黄或白;舌体肿胀' },
 		],
-		
+
 		tongueState: [],// 八、舌头状态
-		
+
 		comScore: 0,
 		comScoreStatus: '',
 		comScoreIndex: 0,
@@ -170,12 +170,13 @@ Page({
 			color: "#ef00b3",
 			opacity: "0"
 		}],
-		
+
 		hotel: '',//酒店
 		room: '',//房间
 		mInputId: '',//自动滚动用的
-		intervalId1: null,
+		intervalId1: null,//保存数据
 		intervalId2: null,//授权解除定时任务
+		intervalId3: null,//导出excel
 	},
 
 
@@ -202,7 +203,7 @@ Page({
 			skinHair: e.detail
 		});
 	},
-	
+
 	// 四、情绪方面
 	bindEmotion: function (e) {
 		console.log(e)
@@ -210,7 +211,7 @@ Page({
 			emotion: e.detail
 		});
 	},
-	
+
 	// 五、月经方面
 	bindMenstruation: function (e) {
 		console.log(e)
@@ -218,7 +219,7 @@ Page({
 			menstruation: e.detail
 		});
 	},
-	
+
 	// 六、性格方面
 	bindCharacter: function (e) {
 		console.log(e)
@@ -226,7 +227,7 @@ Page({
 			character: e.detail
 		});
 	},
-	
+
 	// 七、睡眠
 	bindSleep: function (e) {
 		console.log(e)
@@ -234,7 +235,7 @@ Page({
 			sleep: e.detail
 		});
 	},
-	
+
 	// 八、舌头状态
 	bindTongueState: function (e) {
 		console.log(e)
@@ -242,79 +243,79 @@ Page({
 			tongueState: e.detail
 		});
 	},
-	
+
 	//统计这8个数组,总共包含A,B,C,D,E,F的个数,返回最多的一项(也可能多项):
 	//如果有多个 最多 的情况,返回最多的几个,如果都是0或者空,返回空
-	findMostFrequentLetters: function(arr1, arr2, arr3, arr4, arr5, arr6, arr7, arr8) {  
-		
-		console.log('arr1='+arr1);
-		console.log('arr2='+arr2);
-		console.log('arr3='+arr3);
-		console.log('arr4='+arr4);
-		console.log('arr5='+arr5);
-		console.log('arr6='+arr6);
-		console.log('arr7='+arr7);
-		console.log('arr8='+arr8);
+	findMostFrequentLetters: function (arr1, arr2, arr3, arr4, arr5, arr6, arr7, arr8) {
+
+		console.log('arr1=' + arr1);
+		console.log('arr2=' + arr2);
+		console.log('arr3=' + arr3);
+		console.log('arr4=' + arr4);
+		console.log('arr5=' + arr5);
+		console.log('arr6=' + arr6);
+		console.log('arr7=' + arr7);
+		console.log('arr8=' + arr8);
 		//判断6个数组是否都为空
-		if(this.areAllArraysEmpty(arr1, arr2, arr3, arr4, arr5, arr6, arr7, arr8))
-		return '';
-	    // 初始化一个对象来存储每个字母的计数  
-	        const letterCounts = {  
-	            A: 0,  
-	            B: 0,  
-	            C: 0,  
-	            D: 0,  
-	            E: 0,  
-	            F: 0  
-	        };  
-	      
-	        // 定义一个辅助函数来更新计数  
-	        function updateCounts(arr) {  
-	            if (Array.isArray(arr)) {  
-	                arr.forEach(item => {  
-	                    if (typeof item === 'string' && ['A', 'B', 'C', 'D', 'E', 'F'].includes(item)) {  
-	                        letterCounts[item]++;  
-	                    }  
-	                });  
-	            }  
-	        }  
-	      
-	        // 对每个数组调用辅助函数  
-	        updateCounts(arr1);  
-	        updateCounts(arr2);  
-	        updateCounts(arr3);  
-	        updateCounts(arr4);  
-	        updateCounts(arr5);  
-	        updateCounts(arr6);  
-			updateCounts(arr7);
-			updateCounts(arr8);
-			countABCDEF = letterCounts;
-	        // 找出出现次数最多的字母及其计数  
-	        let maxCount = 0;  
-	        let mostFrequentLetters = [];  
-	      
-	        for (let letter in letterCounts) {  
-	            if (letterCounts[letter] > maxCount) {  
-	                maxCount = letterCounts[letter];  
-	                mostFrequentLetters = [letter]; // 重置为当前最多的字母  
-	            } else if (letterCounts[letter] === maxCount) {  
-	                mostFrequentLetters.push(letter); // 如果计数相同,则添加到列表中  
-	            }  
-	        }  
-	      
-	        // 如果所有字母的计数都是0或数组为空,则返回空  
-	        if (mostFrequentLetters.length === 0) {  
-	            return '';  
-	        }  
-	      
-	        // 返回出现次数最多的字母或字母集合  
-	        return mostFrequentLetters;   
+		if (this.areAllArraysEmpty(arr1, arr2, arr3, arr4, arr5, arr6, arr7, arr8))
+			return '';
+		// 初始化一个对象来存储每个字母的计数  
+		const letterCounts = {
+			A: 0,
+			B: 0,
+			C: 0,
+			D: 0,
+			E: 0,
+			F: 0
+		};
+
+		// 定义一个辅助函数来更新计数  
+		function updateCounts(arr) {
+			if (Array.isArray(arr)) {
+				arr.forEach(item => {
+					if (typeof item === 'string' && ['A', 'B', 'C', 'D', 'E', 'F'].includes(item)) {
+						letterCounts[item]++;
+					}
+				});
+			}
+		}
+
+		// 对每个数组调用辅助函数  
+		updateCounts(arr1);
+		updateCounts(arr2);
+		updateCounts(arr3);
+		updateCounts(arr4);
+		updateCounts(arr5);
+		updateCounts(arr6);
+		updateCounts(arr7);
+		updateCounts(arr8);
+		countABCDEF = letterCounts;
+		// 找出出现次数最多的字母及其计数  
+		let maxCount = 0;
+		let mostFrequentLetters = [];
+
+		for (let letter in letterCounts) {
+			if (letterCounts[letter] > maxCount) {
+				maxCount = letterCounts[letter];
+				mostFrequentLetters = [letter]; // 重置为当前最多的字母  
+			} else if (letterCounts[letter] === maxCount) {
+				mostFrequentLetters.push(letter); // 如果计数相同,则添加到列表中  
+			}
+		}
+
+		// 如果所有字母的计数都是0或数组为空,则返回空  
+		if (mostFrequentLetters.length === 0) {
+			return '';
+		}
+
+		// 返回出现次数最多的字母或字母集合  
+		return mostFrequentLetters;
 	},
 	// 提交问卷的函数  
 	submitSurvey: function () {
 		var that = this;
 		// 清空表单:
-		this.setData({  
+		this.setData({
 			ratingResultsList: [{
 				index: 0,
 				title: "气虚型",
@@ -352,21 +353,21 @@ Page({
 				color: "#ef00b3",
 				opacity: "0"
 			}],
-		});  
+		});
 		const { nickName } = wx.getStorageSync('userInfo');
 		const unionid = wx.getStorageSync('unionid');
 		console.log('nickName==' + nickName);
 		console.log('unionid==' + unionid);
 		let resultMostFrequentLetters = this.findMostFrequentLetters(
-												  this.getRemarkValues(this.data.bodySynthesisOptions,this.data.bodySynthesis),
-												  this.getRemarkValues(this.data.facialFeaturesOptions,this.data.facialFeatures),
-												  this.getRemarkValues(this.data.skinHairOptions,this.data.skinHair),
-												  this.getRemarkValues(this.data.emotionOptions,this.data.emotion),
-												  this.getRemarkValues(this.data.menstruationOptions,this.data.menstruation),
-												  this.getRemarkValues(this.data.characterOptions,this.data.character),
-												  this.getRemarkValues(this.data.sleepOptions,this.data.sleep),
-												  this.getRemarkValues(this.data.tongueStateOptions,this.data.tongueState)
-										);
+			this.getRemarkValues(this.data.bodySynthesisOptions, this.data.bodySynthesis),
+			this.getRemarkValues(this.data.facialFeaturesOptions, this.data.facialFeatures),
+			this.getRemarkValues(this.data.skinHairOptions, this.data.skinHair),
+			this.getRemarkValues(this.data.emotionOptions, this.data.emotion),
+			this.getRemarkValues(this.data.menstruationOptions, this.data.menstruation),
+			this.getRemarkValues(this.data.characterOptions, this.data.character),
+			this.getRemarkValues(this.data.sleepOptions, this.data.sleep),
+			this.getRemarkValues(this.data.tongueStateOptions, this.data.tongueState)
+		);
 		let comScoreIndex = [];
 		let _comScoreStatus = "";
 		let _comScoreDesc = ""
@@ -374,118 +375,118 @@ Page({
 			comScoreIndex = [];
 			_comScoreStatus = "";
 			_comScoreDesc = ""
-		}else{
+		} else {
 			// 遍历输入数组  
-			  resultMostFrequentLetters.forEach(item => {  
-			     
-				 if (item == 'A') {
-					 if(_comScoreStatus){
-						 _comScoreStatus += ",气虚型";
-					 }else{
-						 _comScoreStatus += "气虚型";
-					 }
-					 if(_comScoreDesc){
-						 _comScoreDesc += ",气虚型:填写内容";
-					 }else{
-						 _comScoreDesc += "气虚型:填写内容";
-					 }
+			resultMostFrequentLetters.forEach(item => {
+
+				if (item == 'A') {
+					if (_comScoreStatus) {
+						_comScoreStatus += "\n气虚型";
+					} else {
+						_comScoreStatus += "气虚型";
+					}
+					if (_comScoreDesc) {
+						_comScoreDesc += "\n气虚型:填写内容";
+					} else {
+						_comScoreDesc += "气虚型:填写内容";
+					}
 					comScoreIndex.push(0);
-				 } else if (item == 'B') {
-				 	if(_comScoreStatus){
-				 		 _comScoreStatus += ",气滞型";
-				 	 }else{
-				 		 _comScoreStatus += "气滞型";
-				 	 }
-					 if(_comScoreDesc){
-					 	 _comScoreDesc += ",气滞型:填写内容";
-					 }else{
-					 	 _comScoreDesc += "气滞型:填写内容";
-					 }
-				 	comScoreIndex.push(1);
-				 } else if (item == 'C') {
-				 	if(_comScoreStatus){
-				 		 _comScoreStatus += ",血虚型";
-				 	 }else{
-				 		 _comScoreStatus += "血虚型";
-				 	 }
-					 if(_comScoreDesc){
-						 _comScoreDesc += ",血虚型:填写内容";
-					 }else{
-						 _comScoreDesc += "血虚型:填写内容";
-					 }
-				 	comScoreIndex.push(2);
-				 } else if (item == 'D') {
-				 	if(_comScoreStatus){
-				 		 _comScoreStatus += ",淤血型";
-				 	 }else{
-				 		 _comScoreStatus += "淤血型";
-				 	 }
-					 if(_comScoreDesc){
-						 _comScoreDesc += ",淤血型:填写内容";
-					 }else{
-						 _comScoreDesc += "淤血型:填写内容";
-					 }
-				 	comScoreIndex.push(3);
-				 } else if (item == 'E') {
-				 	if(_comScoreStatus){
-				 		 _comScoreStatus += ",水虚型";
-				 	 }else{
-				 		 _comScoreStatus += "水虚型";
-				 	 }
-					 if(_comScoreDesc){
-						 _comScoreDesc += ",水虚型:填写内容";
-					 }else{
-						 _comScoreDesc += "水虚型:填写内容";
-					 }
-				 	comScoreIndex.push(4);
-				 } else if (item == 'F') {
-				 	if(_comScoreStatus){
-				 		 _comScoreStatus += ",痰湿型";
-				 	 }else{
-				 		 _comScoreStatus += "痰湿型";
-				 	 }
-					 if(_comScoreDesc){
-						 _comScoreDesc += ",痰湿型:填写内容";
-					 }else{
-						 _comScoreDesc += "痰湿型:填写内容";
-					 }
-				 	comScoreIndex.push(5);
-				 }
-				 
-			  }); 
+				} else if (item == 'B') {
+					if (_comScoreStatus) {
+						_comScoreStatus += "\n气滞型";
+					} else {
+						_comScoreStatus += "气滞型";
+					}
+					if (_comScoreDesc) {
+						_comScoreDesc += "\n气滞型:填写内容";
+					} else {
+						_comScoreDesc += "气滞型:填写内容";
+					}
+					comScoreIndex.push(1);
+				} else if (item == 'C') {
+					if (_comScoreStatus) {
+						_comScoreStatus += "\n血虚型";
+					} else {
+						_comScoreStatus += "血虚型";
+					}
+					if (_comScoreDesc) {
+						_comScoreDesc += "\n血虚型:填写内容";
+					} else {
+						_comScoreDesc += "血虚型:填写内容";
+					}
+					comScoreIndex.push(2);
+				} else if (item == 'D') {
+					if (_comScoreStatus) {
+						_comScoreStatus += "\n淤血型";
+					} else {
+						_comScoreStatus += "淤血型";
+					}
+					if (_comScoreDesc) {
+						_comScoreDesc += "\n淤血型:填写内容";
+					} else {
+						_comScoreDesc += "淤血型:填写内容";
+					}
+					comScoreIndex.push(3);
+				} else if (item == 'E') {
+					if (_comScoreStatus) {
+						_comScoreStatus += "\n水虚型";
+					} else {
+						_comScoreStatus += "水虚型";
+					}
+					if (_comScoreDesc) {
+						_comScoreDesc += "\n水虚型:填写内容";
+					} else {
+						_comScoreDesc += "水虚型:填写内容";
+					}
+					comScoreIndex.push(4);
+				} else if (item == 'F') {
+					if (_comScoreStatus) {
+						_comScoreStatus += "\n痰湿型";
+					} else {
+						_comScoreStatus += "痰湿型";
+					}
+					if (_comScoreDesc) {
+						_comScoreDesc += "\n痰湿型:填写内容";
+					} else {
+						_comScoreDesc += "痰湿型:填写内容";
+					}
+					comScoreIndex.push(5);
+				}
+
+			});
 		}
-		console.log('comScoreIndex='+comScoreIndex.join());
-		console.log('_comScoreStatus='+_comScoreStatus);
-		console.log('_comScoreDesc='+_comScoreDesc);
+		console.log('comScoreIndex=' + comScoreIndex.join());
+		console.log('_comScoreStatus=' + _comScoreStatus);
+		console.log('_comScoreDesc=' + _comScoreDesc);
 		this.setData({
 			comScoreStatus: _comScoreStatus,
 			comScoreIndex: comScoreIndex.join(),
 			comScoreDesc: _comScoreDesc,
 			promptTextMessageFlag: true,
-			ratingResultsList:this.updateOpacity(this.data.ratingResultsList,comScoreIndex),
+			ratingResultsList: this.updateOpacity(this.data.ratingResultsList, comScoreIndex),
 		})
-		console.log('ratingResultsList='+JSON.stringify(this.data.ratingResultsList));
+		console.log('ratingResultsList=' + JSON.stringify(this.data.ratingResultsList));
 		let surveyData = {
 			hotel: this.data.hotel,
 			room: this.data.room,
 			userId: nickName,
 			id2: unionid,
-			bodySynthesis: (!this.data.bodySynthesis || this.data.bodySynthesis.length === 0) ? '' : (Array.isArray(this.data.bodySynthesis) ? this.data.bodySynthesis.map(item => String(item)).join(',') : this.data.bodySynthesis),
-			facialFeatures: (!this.data.facialFeatures || this.data.facialFeatures.length === 0) ? '' : (Array.isArray(this.data.facialFeatures) ? this.data.facialFeatures.map(item => String(item)).join(',') : this.data.facialFeatures),
-			skinHair: (!this.data.skinHair || this.data.skinHair.length === 0) ? '' : (Array.isArray(this.data.skinHair) ? this.data.skinHair.map(item => String(item)).join(',') : this.data.skinHair),
-			emotion: (!this.data.emotion || this.data.emotion.length === 0) ? '' : (Array.isArray(this.data.emotion) ? this.data.emotion.map(item => String(item)).join(',') : this.data.emotion),
-			menstruation: (!this.data.menstruation || this.data.menstruation.length === 0) ? '' : (Array.isArray(this.data.menstruation) ? this.data.menstruation.map(item => String(item)).join(',') : this.data.menstruation),
-			character: (!this.data.character || this.data.character.length === 0) ? '' : (Array.isArray(this.data.character) ? this.data.character.map(item => String(item)).join(',') : this.data.character),
-			sleep: (!this.data.sleep || this.data.sleep.length === 0) ? '' : (Array.isArray(this.data.sleep) ? this.data.sleep.map(item => String(item)).join(',') : this.data.sleep),
+			bodySynthesis: this.getFormattedString(this.data.bodySynthesis, this.data.bodySynthesisOptions),
+			facialFeatures: this.getFormattedString(this.data.facialFeatures, this.data.facialFeaturesOptions),
+			skinHair: this.getFormattedString(this.data.skinHair, this.data.skinHairOptions),
+			emotion: this.getFormattedString(this.data.emotion, this.data.emotionOptions),
+			menstruation: this.getFormattedString(this.data.menstruation, this.data.menstruationOptions),
+			character: this.getFormattedString(this.data.character, this.data.characterOptions),
+			sleep: this.getFormattedString(this.data.sleep, this.data.sleepOptions),
 			//舌头状态是新增加项,赋给value1了,数据库里有value1...value8,以备增加项用
-			value1: (!this.data.tongueState || this.data.tongueState.length === 0) ? '' : (Array.isArray(this.data.tongueState) ? this.data.tongueState.map(item => String(item)).join(',') : this.data.tongueState),
+			value1: this.getFormattedString(this.data.tongueState, this.data.tongueStateOptions),
 			//value2 保存A、B、C、D、E、F 每个的个数
-			value2:JSON.stringify(countABCDEF),
+			value2: JSON.stringify(countABCDEF),
 			comScoreStatus: _comScoreStatus,
 			comScoreIndex: comScoreIndex,
 			comScoreDesc: _comScoreDesc,
 		};
-		
+
 		var isFinish = true;
 		var emptyKey = "";
 
@@ -540,7 +541,7 @@ Page({
 									}, 1000);
 								}
 							});
-				
+
 						}
 					},
 					fail: function (error) {
@@ -558,6 +559,61 @@ Page({
 		// 	duration: 2000
 		// });
 	},
+	export() {
+		var that = this;
+		const { nickName } = wx.getStorageSync('userInfo');
+		const unionid = wx.getStorageSync('unionid');
+		let exportData = {
+			hotel: this.data.hotel,
+			room: this.data.room,
+			userId: nickName,
+			id2: unionid,
+		}
+		if (!that.data.intervalId1) {
+			that.data.intervalId1 = setInterval(() => {
+				wx.request({
+					url: `${homeApi}/system/constitutionDiagnosis/export`,
+					method: 'POST',
+					header: {
+						'content-type': 'application/json', // 默认值
+						'Authorization': 'Bearer ' + token // 在头部设置认证信息,例如使用Bearer Token
+					},
+					// 参数
+					data: exportData,
+					responseType: "arraybuffer", // 该属性处理二进制数据
+					success: res => {
+						console.log('res==' + JSON.stringify(res));
+						if (res.statusCode == 200) {
+							if (that.data.intervalId3) {
+								clearInterval(that.data.intervalId3);
+								that.data.intervalId3 = null;
+							}
+							const fs = wx.getFileSystemManager(); // 获取全局唯一的文件管理器 
+							fs.writeFile({ //写文件
+								// wx.env.USER_DATA_PATH是小程序提供的访问用户文件路劲的变量
+								filePath: wx.env.USER_DATA_PATH + '/' + '体质问卷调查.xlsx',  // 一般后端回返回文件名
+								data: res.data,  // res.data就是获取到的二进制文件流
+								encoding: "binary", //二进制流文件必须是 binary
+								success(e) {
+									wx.openDocument({ // 打开文档
+										filePath: wx.env.USER_DATA_PATH + '/' + '体质问卷调查.xlsx',
+										showMenu: true, // 显示右上角菜单
+										success: function (res) {
+											console.log("打开文件", res);
+										},
+									})
+								}
+							})
+						}
+
+					},
+					error(err) {
+						console.log('export-err==' + err)
+					}
+				})
+			}, 2000);
+		}
+	},
 	onCloseResultsDialog() {
 		this.setData({ promptTextMessageFlag: false });
 	},
@@ -591,6 +647,27 @@ Page({
 				})
 			}, 2000) // 设置延时时间,单位为毫秒
 		} else {
+			// const expiresAt = wx.getStorageSync('scanResultExpiresAt');
+			// const now = Date.now() 
+			// if (expiresAt || expiresAt < now) {
+			//   // 扫码结果已过期  
+			//   wx.showToast({  
+			//     title: '扫码结果失效或已过期,请重新扫码',  
+			//     icon: 'none'  
+			//   });  
+			//   // 清除过期的扫码结果  
+			//   wx.removeStorageSync('scanResultExpiresAt');  
+			//   setTimeout(function() {
+			//       wx.reLaunch({
+			//       		url: '/pages/scan/scan',
+			//       })
+			//     }, 2000) // 设置延时时间,单位为毫秒
+
+			// }else{
+			// 	//续期
+			// 	wx.setStorageSync('scanResultExpiresAt', Date.now() + 2 * 60 * 60 * 1000)
+			// }
+
 			let hotelTemp = '';
 			let roomTemp = '';
 
@@ -601,73 +678,73 @@ Page({
 				room: roomTemp,
 			});
 		}
-		
+
 	},
-	areAllArraysEmpty: function (arr1, arr2, arr3, arr4, arr5, arr6, arr7, arr8) {  
-	  // 定义一个数组来包含所有传入的数组  
-	  const arrays = [arr1, arr2, arr3, arr4, arr5, arr6, arr7, arr8];  
-	  
-	  // 遍历这个数组,检查每一项(即传入的数组)是否为空  
-	  for (let i = 0; i < arrays.length; i++) {  
-	    // 检查当前数组是否为空(即长度为0)  
-	    if (arrays[i] && arrays[i].length > 0) {  
-	      // 如果发现任何一个数组不为空,则返回false  
-	      return false;  
-	    }  
-	  }  
-	  
-	  // 如果所有数组都检查过了,且都是空的,则返回true  
-	  return true;  
+	areAllArraysEmpty: function (arr1, arr2, arr3, arr4, arr5, arr6, arr7, arr8) {
+		// 定义一个数组来包含所有传入的数组  
+		const arrays = [arr1, arr2, arr3, arr4, arr5, arr6, arr7, arr8];
+
+		// 遍历这个数组,检查每一项(即传入的数组)是否为空  
+		for (let i = 0; i < arrays.length; i++) {
+			// 检查当前数组是否为空(即长度为0)  
+			if (arrays[i] && arrays[i].length > 0) {
+				// 如果发现任何一个数组不为空,则返回false  
+				return false;
+			}
+		}
+
+		// 如果所有数组都检查过了,且都是空的,则返回true  
+		return true;
 	},
 	//根据第二个数组对应第一个数组的value列,取第一个数组的remark的值,组成新的数组
-	getRemarkValues: function(options, values) {
-		
-	  if (!options || options.length === 0 || !values || values.length === 0) {  
-	      return [];  
-	    } 
-	  // 初始化一个空数组来存储结果  
-	  let remarkValues = [];  
-	  
-	  // 遍历values数组  
-	  values.forEach(value => {  
-	    // 遍历options数组  
-	    options.forEach(option => {  
-	      // 如果找到了对应的value,则将该option的remark添加到result数组中  
-	      if (option.value == value) {  
-	        remarkValues.push(option.remark);   
-	      }  
-	    });  
-	  });  
-	  console.log('remarkValues='+remarkValues);
-	  // 返回包含所有remark值的数组  
-	  return remarkValues;  
+	getRemarkValues: function (options, values) {
+
+		if (!options || options.length === 0 || !values || values.length === 0) {
+			return [];
+		}
+		// 初始化一个空数组来存储结果  
+		let remarkValues = [];
+
+		// 遍历values数组  
+		values.forEach(value => {
+			// 遍历options数组  
+			options.forEach(option => {
+				// 如果找到了对应的value,则将该option的remark添加到result数组中  
+				if (option.value == value) {
+					remarkValues.push(option.remark);
+				}
+			});
+		});
+		console.log('remarkValues=' + remarkValues);
+		// 返回包含所有remark值的数组  
+		return remarkValues;
 	},
-	
+
 	// ratingResultsList里的index和list字段相对应,如果两个值相等,将opacity的值改为'1'
-	  updateOpacity: function(ratingResultsList, list) {
-	    // 如果ratingResultsList为空,则直接返回  
-	    if (!ratingResultsList || ratingResultsList.length === 0) {  
-	      return ratingResultsList;  
-	    }  
-	  
-	    // 如果list为空,则直接返回原ratingResultsList  
-	    if (!list || list.length === 0) {  
-	      return ratingResultsList;  
-	    }  
-	  
-	    // 否则,进行更新操作  
-	    return ratingResultsList.map(item => {  
-	      // 如果item的index在list中,则修改opacity为'1',否则保持原样  
-	      if (list.includes(item.index)) {  
-	        return {  
-	          ...item,  
-	          opacity: '1'  
-	        };  
-	      }  
-	      return item;  
-	    });  
-	  },
-	  
+	updateOpacity: function (ratingResultsList, list) {
+		// 如果ratingResultsList为空,则直接返回  
+		if (!ratingResultsList || ratingResultsList.length === 0) {
+			return ratingResultsList;
+		}
+
+		// 如果list为空,则直接返回原ratingResultsList  
+		if (!list || list.length === 0) {
+			return ratingResultsList;
+		}
+
+		// 否则,进行更新操作  
+		return ratingResultsList.map(item => {
+			// 如果item的index在list中,则修改opacity为'1',否则保持原样  
+			if (list.includes(item.index)) {
+				return {
+					...item,
+					opacity: '1'
+				};
+			}
+			return item;
+		});
+	},
+
 	submitDB: function () {
 		var that = this;
 		if (!that.data.intervalId1) {
@@ -713,6 +790,10 @@ Page({
 		// 	clearInterval(this.data.intervalId2);
 		// 	this.data.intervalId2 = null; // 可选,但建议清除以避免潜在的错误  
 		// }
+		if (that.data.intervalId3) {
+			clearInterval(that.data.intervalId3);
+			that.data.intervalId3 = null;
+		}
 	},
 	/**
 	 * 生命周期函数--监听页面卸载
@@ -727,5 +808,29 @@ Page({
 		// 	clearInterval(this.data.intervalId2);
 		// 	this.data.intervalId2 = null; // 可选,但建议清除以避免潜在的错误  
 		// }
+		if (that.data.intervalId3) {
+			clearInterval(that.data.intervalId3);
+			that.data.intervalId3 = null;
+		}
 	},
+
+	//取出arr2的value和arr1对应的remark和label项,取出的数据组装成一个字符串,加上'char10'
+	getFormattedString: function (arr1, arr2) {
+		// 检查 arr1 和 arr2 是否为非空数组  
+		if (!arr1 || !arr2 || !Array.isArray(arr1) || arr1.length === 0 || !Array.isArray(arr2) || arr2.length === 0) {
+			return '';
+		}
+
+		let result = '';
+
+		arr1.forEach(value => {
+			const valueStr = value ? value.toString() : '';
+			const item = arr2.find(obj => obj.value == valueStr);
+			if (item) {
+				result += ` ${item.remark}、${item.label} char10`;
+			}
+		});
+
+		return result;
+	}
 });

+ 2 - 2
subpages/constitutionDiagnosis/constitutionDiagnosis.wxml

@@ -132,8 +132,8 @@
 				</van-checkbox-group>
 			</view>
 
-			<!-- 提交按钮 -->
-			<text class="commit-btn" bindtap="submitSurvey">提交问卷</text>
+			<!-- 提交按钮 --><text class="commit-btn" bindtap="submitSurvey">提交问卷</text>
+			<text class="export-btn" bindtap="export">导出</text>
 			<view style="height: 80rpx;"></view>
 			<!-- <view class="bottom-view">
       <text style="font-weight:600">感谢您的参与和支持!</text>

+ 13 - 1
subpages/constitutionDiagnosis/constitutionDiagnosis.wxss

@@ -200,7 +200,19 @@ input {
   display: block;
   color: #FFFFFF;
   font-size: 32rpx;
-  margin: 80rpx auto 80rpx auto;
+  margin: 80rpx auto 40rpx auto;
+  background: linear-gradient(278deg, #0ABCA4 0%, rgba(11, 195, 170, 0.8) 100%);
+}
+
+.export-btn {
+  line-height: 90rpx;
+  border-radius: 45rpx;
+  text-align: center;
+  width: calc(100vw - 120rpx);
+  display: block;
+  color: #FFFFFF;
+  font-size: 32rpx;
+  margin: 0rpx auto 40rpx auto;
   background: linear-gradient(278deg, #0ABCA4 0%, rgba(11, 195, 170, 0.8) 100%);
 }