const baseUrl = "https://fare.somnisix.top/";
const authorization = "eyJhbGciOiJIUzUxMiJ9.eyJ1c2VyX2lkIjoxLCJ1c2VyX2tleSI6Ijk5YzI3MjI2LTdkOWQtNDhiOC1hYjlhLWM4YjVjYWZiZGNkNyIsInVzZXJuYW1lIjoiYWRtaW4ifQ.zITQOINFkHs19_1RAgHS4I9YMaVxVq0Dsn3t6r_K7rv3rXvJy0sMtodejIMi_PNa_m4uQYxnU-6k3wC2LZht_Q";
const api = "system/sleepEvaluation";

const homeApi = "https://fare.somnisix.top";
const homeApiTest = "http://localhost:8080";
const token = "eyJhbGciOiJIUzUxMiJ9.eyJ1c2VyX2lkIjoxLCJ1c2VyX2tleSI6Ijk5YzI3MjI2LTdkOWQtNDhiOC1hYjlhLWM4YjVjYWZiZGNkNyIsInVzZXJuYW1lIjoiYWRtaW4ifQ.zITQOINFkHs19_1RAgHS4I9YMaVxVq0Dsn3t6r_K7rv3rXvJy0sMtodejIMi_PNa_m4uQYxnU-6k3wC2LZht_Q";


Page({
	data: {

		activeIcon: "/subpages/icons/ic_selected_radio.svg",
		normalIcon: "/subpages/icons/ic_radio.svg",
		activeColor: "color:#0BC3AA;",
		normalColor: "color:#666666;",
		ageOptions: [
			{ value: '0', label: '20岁以下' },
			{ value: '1', label: '20-29岁' },
			{ value: '2', label: '30-39岁' },
			{ value: '3', label: '40-49岁' },
			{ value: '4', label: '50岁以上' },
		],
		careerOptions: [
			{ value: '0', label: '学生' },
			{ value: '1', label: '上班族' },
			{ value: '2', label: '自由职业者' },
			{ value: '3', label: '企业经营者' },
			{ value: '4', label: '政府、事业等单位人员' },
			{ value: '5', label: '其他（请注明）' },
		],
		noSatisfiedOptions: [
			{ value: '0', label: '设备操作有困难' },
			{ value: '1', label: '对睡眠帮助较小' },
			{ value: '2', label: '都满意' },
			{ value: '3', label: '其他原因（请详细说明）' },
		],
		career: '',
		careerInput: '',
		stayExperOptions: [
			{ value: '0', label: '非常好' },
			{ value: '1', label: '较好' },
			{ value: '2', label: '一般' },
			{ value: '3', label: '较差' },
			{ value: '4', label: '非常差' },
		],
		stayExper: '',
		comfortOptions: [
			{ value: '0', label: '非常舒适' },
			{ value: '1', label: '舒适' },
			// ... 其他选项  
		],
		improvementOptions: [
			{ value: '0', label: '舒适度' },
			{ value: '1', label: '功能性' },
			// ... 其他选项  
		],
		//哪些方式来帮助改善睡眠
		improvementSleepOptions: [
			{ value: '0', label: '调整作息时间' },
			{ value: '1', label: '锻炼' },
			{ value: '2', label: '使用助眠产品（如香薰、耳塞、眼罩等）' },
			{ value: '3', label: '冥想或深呼吸' },
			{ value: '4', label: '寻求医疗帮助' },
			{ value: '5', label: '不采取措施' },
		],
		//哪些方面让您比较满意
		satisfiedOptions: [
			{ value: '0', label: '便捷的设备操作' },
			{ value: '1', label: '适宜的睡眠环境' },
			{ value: '2', label: '人性化的睡眠监测' },
			{ value: '3', label: '体贴的睡眠辅助设施（如助眠视频、音乐等）' },

		],
		wayImprovementSleepOptions: [
			{ value: '0', label: '监测睡眠质量和提供反馈' },
			{ value: '1', label: '自动调整睡眠环境（如温度、光线）' },
			{ value: '2', label: '提供个性化的睡眠建议' },
			{ value: '3', label: '远程医疗咨询或诊断' },
			{ value: '4', label: '其他[请在此区域内作答]' },
		],
		getSleepHealthOptions: [
			{ value: '0', label: '互联网' },
			{ value: '1', label: '社交媒体' },
			{ value: '2', label: '书籍或杂志' },
			{ value: '3', label: '医疗专业人士' },
			{ value: '4', label: '朋友或家人' },
			{ value: '5', label: '其他[请在此区域内作答]' },
		],
		influenceSleepOptions: [
			{ value: '0', label: '工作压力' },
			{ value: '1', label: '生活压力' },
			{ value: '2', label: '环境噪音' },
			{ value: '3', label: '光线过亮' },
			{ value: '4', label: '身体不适（如疼痛、消化不良等）' },
			{ value: '5', label: '心理问题（如焦虑、抑郁等）' },
			{ value: '6', label: '其他（请注明）' },
		],
		improvSleepMethodsOptions: [
			{ value: '0', label: '听轻音乐' },
			{ value: '1', label: '喝热牛奶' },
			{ value: '2', label: '进行放松训练（如深呼吸、冥想等）' },
			{ value: '3', label: '使用助眠药物' },
			{ value: '4', label: '其他（请注明）' },
		],

		gender: '',
		sleepEnvironmentComfort: '',
		productComfort: '',
		improvementAreas: [], // 使用数组来存储多选答案  
		ImprovementSleep: [],//哪些方式来帮助改善睡眠
		improvementSleep: [],
		satisfied: [],// 哪些方面让您比较满意
		suggestion: '', // 文本输入的建议
		thirdPlatformsInput: '',//填写第三方平台
		noSatisfied: [],//体验不满意的原因
		wayImprovementSleep: [],//哪些方式来帮助改善睡眠
		wayImprovementSleepInput: '',//请填写帮助改善睡眠方式文本
		getSleepHealth: [],// 从哪里获取关于睡眠健康的信息
		getSleepHealthInput: '',//您通常从哪里获取关于睡眠健康的信息文本
		influenceSleep: [],//您认为以下哪些因素会影响您的睡眠
		influenceSleepInput: '',//您认为以下哪些因素会影响您的睡眠文本
		improvSleepMethods: [],//您认为以下哪些因素会影响您的睡眠
		improvSleepMethodsInput: '',//您认为以下哪些因素会影响您的睡眠文本
		age: '',//您的年龄
		noSatisfiedInput: '',//让您对本次睡眠房入住体验不满意的原因是文本
		channel: '',//您是通过什么渠道预定到的本酒店睡眠房？
		hotel: '',//酒店
		room: '',//房间
		mInputId: '',//自动滚动用的
		intervalId1: null,
		intervalId2: null,//授权解除定时任务
	},

	// 处理性别选择  
	bindGenderChange: function (e) {
		this.setData({
			gender: e.detail
		});
	},

	// 处理入住体验的选择  
	bindStayExperOptions: function (e) {
		this.setData({
			stayExper: e.detail
		});
	},

	// 处理睡眠环境舒适度（温度、湿度）的选择  
	bindSleepEnvironmentComfort: function (e) {
		this.setData({
			sleepEnvironmentComfort: e.detail.value
		});
	},

	// 处理睡眠产品舒适度的选择  
	bindProductComfort: function (e) {
		this.setData({
			productComfort: e.detail.value
		});
	},

	// 处理改进空间的多选问题  
	bindImprovementAreas: function (e) {
		this.setData({
			improvementAreas: e.detail.value
		});
	},
	bindChannelChange: function (e) {
		this.setData({
			channel: e.detail
		});
	},
	// 改善睡眠
	bindImprovementSleep: function (e) {
		this.setData({
			improvementSleep: e.detail
		});
	},

	// 改善睡眠
	bindGetSleepHealth: function (e) {
		this.setData({
			getSleepHealth: e.detail
		});
	},

	//您认为以下哪些因素会影响您的睡眠
	bindInfluenceSleep: function (e) {
		this.setData({
			influenceSleep: e.detail
		});
	},

	//您通常使用什么方法来改善睡眠质量
	bindImprovSleepMethods: function (e) {
		this.setData({
			improvSleepMethods: e.detail
		});
	},

	// 体验不满意的原因
	bindNoSatisfiedChange: function (e) {
		this.setData({
			noSatisfied: e.detail
		});
	},

	bindCareerChange: function (e) {
		this.setData({
			career: e.detail
		});
	},
	bindAgeChange: function (e) {
		this.setData({
			age: e.detail
		});
	},
	// 哪些方面的多选问题
	bindSatisfied: function (e) {
		console.log(e)
		this.setData({
			satisfied: e.detail
		});
	},

	// 哪些方式来帮助改善睡眠
	bindWayImprovementSleep: function (e) {
		this.setData({
			wayImprovementSleep: e.detail
		});
	},
	bindNoSatisfiedInput: function (e) {
		this.setData({
			noSatisfiedInput: e.detail.value
		});
	},
	bindCareerInputInput: function (e) {
		this.setData({
			careerInput: e.detail.value
		});
	},

	bindGetSleepHealthInput: function (e) {
		this.setData({
			getSleepHealthInput: e.detail.value
		});
	},


	bindInfluenceSleepInput: function (e) {
		this.setData({
			influenceSleepInput: e.detail.value
		});
	},

	bindImprovSleepMethodsInput: function (e) {
		this.setData({
			improvSleepMethodsInput: e.detail.value
		});
	},

	// 方式来帮助改善睡眠文本输入
	bindWayImprovementSleepInput: function (e) {
		this.setData({
			wayImprovementSleepInput: e.detail.value
		});
	},

	bindThirdPlatformsInputInput: function (e) {
		this.setData({
			thirdPlatformsInput: e.detail.value
		});
	},

	// 职业填写
	bindSuggestionInput: function (e) {
		this.setData({
			suggestion: e.detail.value
		});
	},
	checkBoxInputValue(e) {
		var valueList = e.currentTarget.dataset.list || [];
		var value = e.currentTarget.dataset.name;
		var type = e.currentTarget.dataset.type;
		const that = this;
		setTimeout(() => {
			if (type == "wayImprovementSleep") {
				var tempList = that.data.wayImprovementSleep
				if (!tempList || (Array.isArray(tempList) && (!tempList.length || !tempList.includes(value)))) {
					valueList[valueList.length] = value
					that.setData({
						wayImprovementSleep: valueList
					})

				}
			} else if (type == "getSleepHealth") {
				var tempList = that.data.getSleepHealth
				if (!tempList || (Array.isArray(tempList) && (!tempList.length || !tempList.includes(value)))) {
					valueList[valueList.length] = value
					that.setData({
						getSleepHealth: valueList
					})

				}
			} else if (type == "influenceSleep") {
				var tempList = that.data.influenceSleep
				if (!tempList || (Array.isArray(tempList) && (!tempList.length || !tempList.includes(value)))) {
					valueList[valueList.length] = value
					that.setData({
						influenceSleep: valueList
					})

				}
			} else if (type == "improvSleepMethods") {
				var tempList = that.data.improvSleepMethods
				if (!tempList || (Array.isArray(tempList) && (!tempList.length || !tempList.includes(value)))) {
					valueList[valueList.length] = value
					that.setData({
						improvSleepMethods: valueList
					})

				}
			}
		}, 150);


		// careerInput: this.data.careerInput,
		// 	thirdPlatformsInput: this.data.thirdPlatformsInput,
		// 		noSatisfied: this.data.noSatisfied,
		// 			noSatisfiedInput: this.data.noSatisfiedInput,
		// wayImprovementSleep: this.data.wayImprovementSleep,
		// 	wayImprovementSleepInput: this.data.wayImprovementSleepInput,
		// getSleepHealth: this.data.getSleepHealth,
		// 	getSleepHealthInput: this.data.getSleepHealthInput,
		// influenceSleep: this.data.influenceSleep,
		// 	influenceSleepInput: this.data.influenceSleepInput,
		// 		improvSleepMethods: this.data.improvSleepMethods,
		// 			improvSleepMethodsInput: this.data.improvSleepMethodsInput,
	},
	// 提交问卷的函数  
	submitSurvey: function () {
		var that = this;
		const { nickName } = wx.getStorageSync('userInfo');
		const unionid = wx.getStorageSync('unionid');
		console.log('nickName==' + nickName);
		console.log('unionid==' + unionid);
		let surveyData = {
			hotel: this.data.hotel,
			room: this.data.room,
			gender: this.data.gender,
			stayExper: this.data.stayExper,
			userId: nickName,
			id2: unionid,

			//sleepEnvironmentComfort: this.data.sleepEnvironmentComfort,
			//productComfort: this.data.productComfort,
			//improvementAreas: this.data.improvementAreas,

			satisfied: (!this.data.satisfied || this.data.satisfied.length === 0) ? '' : (Array.isArray(this.data.satisfied) ? this.data.satisfied.map(item => String(item)).join(',') : this.data.satisfied),
			suggestion: this.data.suggestion,
			career: this.data.career,
			careerInput: this.data.careerInput,//1
			thirdPlatformsInput: this.data.thirdPlatformsInput,//2
			noSatisfied: (!this.data.noSatisfied || this.data.noSatisfied.length === 0) ? '' : (Array.isArray(this.data.noSatisfied) ? this.data.noSatisfied.map(item => String(item)).join(',') : this.data.noSatisfied),
			noSatisfiedInput: this.data.noSatisfiedInput,//3
			improvementSleep: (!this.data.improvementSleep || this.data.improvementSleep.length === 0) ? '' : (Array.isArray(this.data.improvementSleep) ? this.data.improvementSleep.map(item => String(item)).join(',') : this.data.improvementSleep),
			wayImprovementSleep: (!this.data.wayImprovementSleep || this.data.wayImprovementSleep.length === 0) ? '' : (Array.isArray(this.data.wayImprovementSleep) ? this.data.wayImprovementSleep.map(item => String(item)).join(',') : this.data.wayImprovementSleep),
			wayImprovementSleepInput: this.data.wayImprovementSleepInput,//4
			getSleepHealth: (!this.data.getSleepHealth || this.data.getSleepHealth.length === 0) ? '' : (Array.isArray(this.data.getSleepHealth) ? this.data.getSleepHealth.map(item => String(item)).join(',') : this.data.getSleepHealth),
			getSleepHealthInput: this.data.getSleepHealthInput,//5
			influenceSleep: (!this.data.influenceSleep || this.data.influenceSleep.length === 0) ? '' : (Array.isArray(this.data.influenceSleep) ? this.data.influenceSleep.map(item => String(item)).join(',') : this.data.influenceSleep),
			influenceSleepInput: this.data.influenceSleepInput,//6
			improvSleepMethods: (!this.data.improvSleepMethods || this.data.improvSleepMethods.length === 0) ? '' : (Array.isArray(this.data.improvSleepMethods) ? this.data.improvSleepMethods.map(item => String(item)).join(',') : this.data.improvSleepMethods),
			improvSleepMethodsInput: this.data.improvSleepMethodsInput,//7
			age: this.data.age,
			channel: this.data.channel,
			//数据库存的是：bindGetSleepHealth bindGetSleepHealthInput
			bindGetSleepHealth: (!this.data.getSleepHealth || this.data.getSleepHealth.length === 0) ? '' : (Array.isArray(this.data.getSleepHealth) ? this.data.getSleepHealth.map(item => String(item)).join(',') : this.data.getSleepHealth),
			bindGetSleepHealthInput: this.data.getSleepHealthInput,
		};

		let checkList = {
			age: this.data.age,
			career: this.data.career,
			gender: this.data.gender,
			channel: this.data.channel,
			stayExper: this.data.stayExper,
			satisfied: this.data.satisfied,
			noSatisfied: this.data.noSatisfied,
			improvementSleep: this.data.improvementSleep,
			wayImprovementSleep: this.data.wayImprovementSleep,
			getSleepHealth: this.data.getSleepHealth,
			influenceSleep: this.data.influenceSleep,
			improvSleepMethods: this.data.improvSleepMethods,
			suggestion: this.data.suggestion,

			// sleepEnvironmentComfort: this.data.sleepEnvironmentComfort,
			// productComfort: this.data.productComfort,
			// improvementAreas: this.data.improvementAreas,
			// thirdPlatformsInput: this.data.thirdPlatformsInput,
		}

		let checkInputList = [
			{
				name: "career",
				type: "radio",
				checkList: this.data.career,
				checkValue: "5",
				checkInput: this.data.careerInput
			}, {
				name: "channel",
				type: "radio",
				checkList: this.data.channel,
				checkValue: "2",
				checkInput: this.data.thirdPlatformsInput
			}, {
				name: "noSatisfied",
				type: "radio",
				checkList: this.data.noSatisfied,
				checkValue: "3",
				checkInput: this.data.noSatisfiedInput
			}, {
				name: "wayImprovementSleep",
				type: "checkbox",
				checkList: this.data.wayImprovementSleep,
				checkValue: "4",
				checkInput: this.data.wayImprovementSleepInput
			}, {
				name: "getSleepHealth",
				type: "checkbox",
				checkList: this.data.getSleepHealth,
				checkValue: "5",
				checkInput: this.data.getSleepHealthInput
			}, {
				name: "influenceSleep",
				type: "checkbox",
				checkList: this.data.influenceSleep,
				checkValue: "6",
				checkInput: this.data.influenceSleepInput
			}, {
				name: "improvSleepMethods",
				type: "checkbox",
				checkList: this.data.improvSleepMethods,
				checkValue: "4",
				checkInput: this.data.improvSleepMethodsInput
			}
		]

		var isFinish = true;
		var emptyKey = "";

		for (const key in checkList) {
			if (checkList.hasOwnProperty(key)) {
				const element = checkList[key];
				if (!element || (Array.isArray(element) && element.length <= 0)) { // 检查属性值是否为空  
					// 这里可以添加更复杂的判断，比如仅针对字符串检查是否为空字符串  
					// if (typeof obj[key] === 'string' && obj[key].trim() === '') {  
					isFinish = false;
					emptyKey = key;
					wx.showModal({
						title: '无法提交',
						content: '您还有部分题目未完成，请检查后重新提交',
						showCancel: false,
						confirmColor: '#0BC3AA',
						confirmText: "好的",
						success(res) {
							console.log(emptyKey.toString());
							that.setData({
								mInputId: emptyKey.toString()
							})

						}
					})
					return; // 停止循环  
				}
			}
		}

		for (let i = 0; i < checkInputList.length; i++) {
			const element = checkInputList[i];
			if ((element.type == 'checkbox' && Array.isArray(element.checkList) && element.checkList.includes(element.checkValue) && !element.checkInput) || (element.type == 'radio' && element.checkList == element.checkValue && !element.checkInput)) { // 检查属性值是否为空  
				// 这里可以添加更复杂的判断，比如仅针对字符串检查是否为空字符串  
				// if (typeof obj[key] === 'string' && obj[key].trim() === '') {  
				isFinish = false;
				emptyKey = element.name;
				wx.showModal({
					title: '无法提交',
					content: '您还有部分题目未完成，请检查后重新提交',
					showCancel: false,
					confirmColor: '#0BC3AA',
					confirmText: "好的",
					success(res) {
						console.log(emptyKey.toString());
						that.setData({
							mInputId: emptyKey.toString()
						})

					}
				})
				return; // 停止循环  
			}

		}

		if (!isFinish) {
			wx.showModal({
				title: '无法提交',
				content: '您还有部分题目未完成，请检查后重新提交',
				showCancel: false,
				confirmColor: '#0BC3AA',
				confirmText: "好的",
				success(res) {
					console.log(emptyKey.toString());
					that.setData({
						mInputId: emptyKey.toString()
					})

				}
			})
			return;
		}

		// 将surveyData发送到服务器  
		console.log('提交的问卷数据：', surveyData);

		//提交到数据库
		wx.request({
			url: `${homeApi}/system/sleepEvaluation`, //
			method: 'POST',
			header: {
				'content-type': 'application/json', // 默认值
				'Authorization': 'Bearer ' + token // 在头部设置认证信息，例如使用Bearer Token
			},
			data: surveyData,
			success(res) {
				console.log('res===' + JSON.stringify(res));
				console.log('res.code===' + res.code);
				if (res && res.data && res.data.code == 200) {
					if (that.data.intervalId1) {
						clearInterval(that.data.intervalId1);
						that.data.intervalId1 = null;
					}
					wx.showToast({
						title: '问卷提交成功',
						icon: 'success',
						duration: 2000,
						success() {
							setTimeout(() => {
								wx.navigateBack()
							}, 1500);
						}
					});

				}
			},
			fail: function (error) {
				console.error('error', error);
			},
			complete: function (e) {
			}
		});


		// wx.showToast({
		// 	title: '问卷提交成功',
		// 	icon: 'success',
		// 	duration: 2000
		// });

		// 清空表单：  
		// this.setData({  
		// gender: '', 
		// careerInput:'',
		// stayExper:'',
		// sleepEnvironmentComfort: '',  
		// productComfort: '',  
		// improvementAreas: [], // 使用数组来存储多选答案  
		// ImprovementSleep: [],//哪些方式来帮助改善睡眠
		// satisfied: [],// 哪些方面让您比较满意
		// suggestion: '', // 文本输入的建议
		// thirdPlatformsInput: '',//填写第三方平台
		// noSatisfied: '',//体验不满意的原因
		// wayImprovementSleep: '',//哪些方式来帮助改善睡眠
		// wayImprovementSleepInput: '',//请填写帮助改善睡眠方式文本
		// getSleepHealth: [],// 从哪里获取关于睡眠健康的信息
		// getSleepHealthInput: '',//您通常从哪里获取关于睡眠健康的信息文本
		// influenceSleep: [],//您认为以下哪些因素会影响您的睡眠
		// influenceSleepInput: '',//您认为以下哪些因素会影响您的睡眠文本
		// improvSleepMethods: [],//您认为以下哪些因素会影响您的睡眠
		// improvSleepMethodsInput: '',//您认为以下哪些因素会影响您的睡眠文本
		// age: '',//您的年龄
		// noSatisfiedInput: '',//让您对本次睡眠房入住体验不满意的原因文本
		// channel: '',
		// });  
	},
	onLoad(option) {
		var that = this;
		console.log("sleepEvaluation页面");
		// wx.clearStorage();
		console.log('option.res=' + JSON.stringify(wx.getStorageSync('res')));
		if (!wx.getStorageSync('res') || !wx.getStorageSync('res').result) {
			wx.showModal({
				title: '提示',
				content: '请先扫描房间二维码',
				showCancel: false
			});

			setTimeout(function () {
				wx.reLaunch({
					url: '/pages/scan/scan',
				})
			}, 2000) // 设置延时时间，单位为毫秒
		} else if (wx.getStorageSync('res').result.split('|').length != 2) {
			wx.showModal({
				title: '提示',
				content: '房间二维码不正确，请重新扫码',
				showCancel: false
			});

			setTimeout(function () {
				wx.reLaunch({
					url: '/pages/scan/scan',
				})
			}, 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 = '';

			hotelTemp = wx.getStorageSync('res').result.split('|')[0];
			roomTemp = wx.getStorageSync('res').result.split('|')[1];
			this.setData({
				hotel: hotelTemp,
				room: roomTemp,
			});
		}
	},
	submitDB: function () {
		var that = this;
		if (!that.data.intervalId1) {
			that.data.intervalId1 = setInterval(() => {
				that.submitSurvey();
			}, 1000);
		}
	},
	onShow: function (options) {
		// var that = this;
		// if (!that.data.intervalId2) {
		// 	that.data.intervalId2 = setInterval(() => {
		// 		// 这里执行你的代码  
		// 		console.log('sleepEvaluation页面：'+Date.now());
		// 	}, 10000);
		// }
	},
	// startInterval: function () {
	// 	 var that = this;
	// 	 if (!that.data.intervalId) {
	// 	 	that.data.intervalId = setInterval(() => {
	// 	 		that.submitSurvey();
	// 	 	}, 1000);
	// 	 }  
	// },
	// clearInterval: function () {
	// 	   var that = this;
	//   	   if (that.data.intervalId) {
	//   		 clearInterval(that.data.intervalId);  
	//   		 that.data.intervalId = null;
	//   	   }
	//   },
	/**
	 * 生命周期函数--监听页面隐藏
	 */
	onHide: function () {
		var that = this;
		if (that.data.intervalId1) {
			clearInterval(that.data.intervalId1);
			that.data.intervalId1 = null;
		}
		// if (this.data.intervalId2) {
		// 	clearInterval(this.data.intervalId2);
		// 	this.data.intervalId2 = null; // 可选，但建议清除以避免潜在的错误  
		// }
	},
	/**
	 * 生命周期函数--监听页面卸载
	 */
	onUnload: function () {
		var that = this;
		if (that.data.intervalId1) {
			clearInterval(that.data.intervalId1);
			that.data.intervalId1 = null;
		}
		// if (this.data.intervalId2) {
		// 	clearInterval(this.data.intervalId2);
		// 	this.data.intervalId2 = null; // 可选，但建议清除以避免潜在的错误  
		// }
	},
});