| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750 |
- 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";
- let countABCDEF;
- Page({
- data: {
- activeIcon: "/subpages/icons/ic_selected_radio.svg",
- normalIcon: "/subpages/icons/ic_radio.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: '易恶心、呕吐、晕车' },
- ],
-
- 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: '易犯花粉症和鼻炎,容易淌鼻涕' },
- ],
-
- 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: '皮肤纹理粗糙、毛孔张开' },
- ],
-
- skinHair: [],// 三、皮肤毛发
-
- //四、情绪方面
- emotionOptions: [
- { 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: '月经痛加重、经血中有动物肝脏血块' },
- ],
-
- 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: '喜欢奢华、热闹的氛围' },
- ],
-
- character: [],// 六、性格方面
-
- //七、睡眠
- sleepOptions: [
- { 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: '舌苔厚、黏黏糊糊;舌苔色黄或白;舌体肿胀' },
- ],
-
- tongueState: [],// 八、舌头状态
-
- comScore: 0,
- comScoreStatus: '',
- comScoreIndex: 0,
- comScoreDesc: "",
- ratingResultsList: [{
- index: 0,
- title: "气虚型",
- icon: "/subpages/icons/ic_triangle_down_1.svg",
- color: "#70B3FE",
- opacity: "0"
- }, {
- index: 1,
- title: "气滞型",
- icon: "/subpages/icons/ic_triangle_down_2.svg",
- color: "#68D89E",
- opacity: "0"
- }, {
- index: 2,
- title: "血虚型",
- icon: "/subpages/icons/ic_triangle_down_3.svg",
- color: "#FFA95A",
- opacity: "0"
- }, {
- index: 3,
- title: "淤血型",
- icon: "/subpages/icons/ic_triangle_down_4.svg",
- color: "#cffc6d",
- opacity: "0"
- }, {
- index: 4,
- title: "水虚型",
- icon: "/subpages/icons/ic_triangle_down_1.svg",
- color: "#80f5ff",
- opacity: "0"
- }, {
- index: 5,
- title: "痰湿型",
- icon: "/subpages/icons/ic_triangle_down_2.svg",
- color: "#ef00b3",
- opacity: "0"
- }],
-
- hotel: '',//酒店
- room: '',//房间
- mInputId: '',//自动滚动用的
- intervalId1: null,
- intervalId2: null,//授权解除定时任务
- },
- // 一、身体综合
- bindBodySynthesis: function (e) {
- console.log(e)
- this.setData({
- bodySynthesis: e.detail
- });
- },
- // 二、面部五官
- bindFacialFeatures: function (e) {
- console.log(e)
- this.setData({
- facialFeatures: e.detail
- });
- },
- // 三、皮肤毛发
- bindSkinHair: function (e) {
- console.log(e)
- this.setData({
- skinHair: e.detail
- });
- },
-
- // 四、情绪方面
- bindEmotion: function (e) {
- console.log(e)
- this.setData({
- emotion: e.detail
- });
- },
-
- // 五、月经方面
- bindMenstruation: function (e) {
- console.log(e)
- this.setData({
- menstruation: e.detail
- });
- },
-
- // 六、性格方面
- bindCharacter: function (e) {
- console.log(e)
- this.setData({
- character: e.detail
- });
- },
-
- // 七、睡眠
- bindSleep: function (e) {
- console.log(e)
- this.setData({
- sleep: e.detail
- });
- },
-
- // 八、舌头状态
- bindTongueState: function (e) {
- console.log(e)
- this.setData({
- 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);
- //判断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;
- },
- // 提交问卷的函数
- submitSurvey: function () {
- var that = this;
- // 清空表单:
- this.setData({
- ratingResultsList: [{
- index: 0,
- title: "气虚型",
- icon: "/subpages/icons/ic_triangle_down_1.svg",
- color: "#70B3FE",
- opacity: "0"
- }, {
- index: 1,
- title: "气滞型",
- icon: "/subpages/icons/ic_triangle_down_2.svg",
- color: "#68D89E",
- opacity: "0"
- }, {
- index: 2,
- title: "血虚型",
- icon: "/subpages/icons/ic_triangle_down_3.svg",
- color: "#FFA95A",
- opacity: "0"
- }, {
- index: 3,
- title: "淤血型",
- icon: "/subpages/icons/ic_triangle_down_4.svg",
- color: "#cffc6d",
- opacity: "0"
- }, {
- index: 4,
- title: "水虚型",
- icon: "/subpages/icons/ic_triangle_down_1.svg",
- color: "#80f5ff",
- opacity: "0"
- }, {
- index: 5,
- title: "痰湿型",
- icon: "/subpages/icons/ic_triangle_down_2.svg",
- 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)
- );
- let comScoreIndex = [];
- let _comScoreStatus = "";
- let _comScoreDesc = ""
- if (!resultMostFrequentLetters || !Array.isArray(resultMostFrequentLetters)) {
- comScoreIndex = [];
- _comScoreStatus = "";
- _comScoreDesc = ""
- }else{
- // 遍历输入数组
- resultMostFrequentLetters.forEach(item => {
-
- if (item == 'A') {
- if(_comScoreStatus){
- _comScoreStatus += ",气虚型";
- }else{
- _comScoreStatus += "气虚型";
- }
- if(_comScoreDesc){
- _comScoreDesc += ",气虚型:填写内容";
- }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);
- }
-
- });
- }
- 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),
- })
- 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),
- //舌头状态是新增加项,赋给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),
- //value2 保存A、B、C、D、E、F 每个的个数
- value2:JSON.stringify(countABCDEF),
- comScoreStatus: _comScoreStatus,
- comScoreIndex: comScoreIndex,
- comScoreDesc: _comScoreDesc,
- };
-
- var isFinish = true;
- var emptyKey = "";
- // 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);
- if (!that.data.intervalId1) {
- that.data.intervalId1 = setInterval(() => {
- //提交到数据库
- wx.request({
- url: `${homeApi}/system/constitutionDiagnosis`, //
- 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) {
- }
- });
- }, 1000);
- }
- // wx.showToast({
- // title: '问卷提交成功',
- // icon: 'success',
- // duration: 2000
- // });
- },
- onCloseResultsDialog() {
- this.setData({ promptTextMessageFlag: false });
- },
- 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: '/subpages/scan/scan',
- })
- }, 2000) // 设置延时时间,单位为毫秒
- } else if (wx.getStorageSync('res').result.split('|').length != 2) {
- wx.showModal({
- title: '提示',
- content: '房间二维码不正确,请重新扫码',
- showCancel: false
- });
- setTimeout(function () {
- wx.reLaunch({
- url: '/subpages/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,
- });
- }
-
- },
- 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;
- },
-
- // 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;
- });
- },
-
- 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; // 可选,但建议清除以避免潜在的错误
- // }
- },
- });
|