index.js 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791
  1. import $ from './../../utils/Tool'
  2. import router from './../../utils/router'
  3. import {getSetting,getLocation} from './../../utils/auth'
  4. const AUTH = require('../../utils/auth')
  5. import icons from "../../utils/icon"
  6. import {getPropertyData,submitAdjust,getCurrentSeason} from '../../requests/api';
  7. import Toast from '../../vant-weapp/dist/toast/toast';
  8. import {
  9. userCheck,
  10. powerCheck,
  11. getEquipmentAction,
  12. getfeedBack,
  13. getSpacedetail,
  14. openSpace,
  15. workLeave,
  16. contactTenant
  17. } from "../../requests/api";
  18. let timer=null;
  19. Page({
  20. /**
  21. * 页面的初始数据
  22. */
  23. data: {
  24. spaceDetail:null,
  25. effectTime:-1,
  26. statusList: icons.statusList,
  27. spacestatusList:icons.spacestatusList,
  28. spaceStatus: "",
  29. spaceStatusId:null,
  30. tempType: [
  31. {
  32. id: 1,
  33. value: "有点冷",
  34. checked: false,
  35. imgSrc: "../../static/images/cold.png"
  36. },
  37. {
  38. id: 3,
  39. value: "有点热",
  40. checked: false,
  41. imgSrc: "../../static/images/hot.png"
  42. },
  43. {
  44. id: 2,
  45. value: "太冷了",
  46. checked: false,
  47. imgSrc: "../../static/images/severityCold.png"
  48. },
  49. {
  50. id: 4,
  51. value: "太热了",
  52. checked: false,
  53. imgSrc: "../../static/images/severityHot.png"
  54. },
  55. ],
  56. windType: [{
  57. id: 5,
  58. value: '风太大',
  59. checked: false,
  60. imgSrc: "../../static/images/severityWind.png"
  61. }],
  62. windTypeValue:-1,
  63. tempTypeValue:-1,
  64. currentIndex:-1,
  65. StandardMode:true, //模式选择
  66. envNamelist:$.store.get("envNamelist"),
  67. imgbaseUrl:$.store.get("imgbaseUrl"),
  68. headerShow:false,
  69. pageHight:0,
  70. guideInit:false,
  71. guideStep:1,
  72. longitude:null,
  73. latitude:null,
  74. feedBack:false, //控制反馈弹窗
  75. targetTemp:null,
  76. trunAction:false,
  77. equipmentStatustext:'',
  78. equipmentStatus:null,
  79. willAvg:null,
  80. tragetChart:[],
  81. tragetChartcopy:[],
  82. customPlan:[],
  83. customPlancopy:null,
  84. planTemp:null,
  85. trunupAction:false, //开机提示框
  86. secondIcon:0,
  87. secondSpaceStatus:null,
  88. chartIndex:null,
  89. targetIndex:0,
  90. singleOffice:false,
  91. nextOpenTime:'',
  92. bgSeasonType:null,
  93. havePower:{
  94. result:"fail",
  95. message:""
  96. },
  97. picInitUrl:$.store.get("picInitUrl"),
  98. },
  99. goBack(){
  100. router.pop()
  101. },
  102. changeMode(){
  103. if(this.data.spaceDetail.isClose.toString()!=="true"){
  104. this.setData({StandardMode:!this.data.StandardMode},()=>{
  105. if(!this.data.StandardMode){
  106. this.setData({effectTime:-1})
  107. this.getChartDate();
  108. }
  109. })
  110. }
  111. },
  112. toDetail(e){
  113. if(Object.keys(e.currentTarget.dataset).length){
  114. router.push("detail",e.currentTarget.dataset)
  115. }else{
  116. router.push("detail",{name:"温度",
  117. localname:"温度",
  118. param:"temperature",
  119. funcid:"Tdb",
  120. spaceid:this.data.spaceDetail.id,
  121. projectid:this.data.spaceDetail.projectId})
  122. }
  123. },
  124. // 检查是否过引导
  125. checkGuide(){
  126. if(this.data.spaceDetail.isClose.toString()=="true"){
  127. return
  128. }
  129. !$.storage.get('guideInit')&&this.getPageheight();
  130. this.setData({'guideInit':!$.storage.get('guideInit')})
  131. },
  132. // 反馈数据
  133. changeType(e) {
  134. if(this.data.bgSeasonType=="Transition"){
  135. wx.showModal({
  136. title: '现在是过渡季不可调节',
  137. showCancel: false,
  138. confirmText:"我知道了",//默认是“确定”
  139. // confirmColor: 'skyblue',//确定文字的颜色
  140. success: function (res) {
  141. },
  142. fail: function (res) { },//接口调用失败的回调函数
  143. complete: function (res) { },//接口调用结束的回调函数(调用成功、失败都会执行)
  144. })
  145. return ;
  146. }
  147. if(this.data.havePower.result!=="success"){
  148. Toast.fail(this.data.havePower.message);
  149. return
  150. }
  151. var currentIndex = e.currentTarget.dataset.index;
  152. if (e.currentTarget.dataset.type === "temp") {
  153. this.setData({
  154. tempTypeValue: currentIndex,
  155. currentIndex:currentIndex,
  156. feedBack:true
  157. });
  158. } else {
  159. this.setData({
  160. windTypeValue: currentIndex,
  161. currentIndex:currentIndex,
  162. feedBack:true
  163. });
  164. }
  165. let data = {
  166. "projectId":this.data.spaceDetail.projectId, //项目id
  167. "objectId": this.data.spaceDetail.id, //空间id
  168. "valueType": 1, //固定为1
  169. "itemId": currentIndex,
  170. "model":this.data.StandardMode?1:2,
  171. userId:$.store.get('userId')
  172. }
  173. getEquipmentAction(data).then(res => {
  174. this.setData({
  175. equipmentStatus: res.equipmentStatus
  176. });
  177. let textMsg = "";
  178. let textMsgarr=[];
  179. this.data.equipmentStatus.forEach(item => {
  180. if (item.actions) {
  181. item.actions.forEach(items => {
  182. let textMsgobj={};
  183. textMsgobj.name=item.localName;
  184. textMsgobj.actions=items;
  185. textMsgarr.push(textMsgobj);
  186. textMsg = textMsg + item.localName + '--' + items + ' ';
  187. })
  188. }
  189. })
  190. this.setData({
  191. equipmentStatustext: textMsgarr
  192. });
  193. })
  194. getfeedBack(data).then(res => {
  195. let notice = res.notice ? res.notice.split('。') : [];
  196. this.setData({
  197. spaceStatus: res.spaceStatus,
  198. spaceStatusId: res.icon - 1,
  199. notice: notice,
  200. willAvg:res.avg||'--',
  201. });
  202. this.buildContact();
  203. })
  204. },
  205. // 建立租户关联
  206. async buildContact(){
  207. let currentTenantId=$.storage.get('tenantId');
  208. if(currentTenantId!==this.data.spaceDetail.tenantId){
  209. // 通过扫码改变租户
  210. $.store.set('projectId',this.data.spaceDetail.projectId);
  211. $.store.set('tenantId',this.data.spaceDetail.tenantId);
  212. $.store.set('changeTenantId',true);
  213. $.storage.set('projectId',this.data.spaceDetail.projectId);
  214. $.storage.set('tenantId',this.data.spaceDetail.tenantId);
  215. }
  216. let top = (this.data.spaceDetail.top.toString())=="false"?0:1;
  217. const data={
  218. "userId":$.store.get('userId'),//用户id
  219. "projectId":this.data.spaceDetail.projectId,//项目id
  220. "spaceId":this.data.spaceDetail.id,//空间id
  221. "openId":$.store.get('openId'),
  222. flag:1,
  223. top:top,
  224. }
  225. console.log(this.data.spaceDetail.top,"this.data.spaceDetail.top?")
  226. await contactTenant(data).then(res=>{
  227. console.log("成功")
  228. })
  229. },
  230. // 下班节能
  231. turnDown(){
  232. if(this.data.havePower.result!=="success"){
  233. Toast.fail(this.data.havePower.message);
  234. return
  235. }
  236. let data = {
  237. model:1,
  238. "projectId":this.data.spaceDetail.projectId, //项目id
  239. "objectId":[this.data.spaceDetail.id], //空间id
  240. userId:$.store.get('userId'),
  241. nextOpenTime:this.data.spaceDetail.nextOpenTime||"",
  242. }
  243. workLeave(data).then(res=>{
  244. this.setData({trunAction:true});
  245. this.buildContact();
  246. })
  247. },
  248. // 重新开启
  249. turnUp(){
  250. if(this.data.havePower.result!=="success"){
  251. Toast.fail(this.data.havePower.message);
  252. return
  253. }
  254. let data = {
  255. "projectId":this.data.spaceDetail.projectId, //项目id
  256. "objectId": this.data.spaceDetail.id, //空间id
  257. model:1,
  258. userId:$.store.get('userId')
  259. }
  260. openSpace(data).then(res=>{
  261. this.setData({
  262. secondSpaceStatus: res.spaceStatus,
  263. secondNotice: res.notice,
  264. secondIcon: res.icon,
  265. trunupAction: true
  266. });
  267. this.buildContact();
  268. })
  269. },
  270. commitClose(){
  271. this.setData({trunupAction:false},()=>{
  272. this.isfeeded(true);
  273. this.getDetail();
  274. })
  275. },
  276. knowClick(){
  277. this.setData({feedBack:false,tempTypeValue:-1,windTypeValue:-1,},()=>{
  278. this.isfeeded();
  279. });
  280. },
  281. knowCloseClick(){
  282. this.setData({feedBack:false,trunAction:false},()=>{
  283. this.getDetail();
  284. this.isfeeded(true);
  285. });
  286. },
  287. // 获取容器高度
  288. getPageheight:function(){
  289. let that =this;
  290. wx.createSelectorQuery().select('#j_page').boundingClientRect(function(rect){
  291. that.setData({'pageHight':rect.height})
  292. }).exec()
  293. },
  294. //使页面滚动到容器底部
  295. pageScrollToBottom: function() {
  296. wx.pageScrollTo({
  297. scrollTop: this.data.pageHight
  298. })
  299. },
  300. // 步骤引导函数
  301. nextStep(e){
  302. if(this.data.guideStep==2){
  303. $.storage.set('guideInit',true);
  304. this.setData({'guideInit':false})
  305. }
  306. this.setData({'guideStep':2})
  307. this.pageScrollToBottom();
  308. },
  309. async isGetSetting(value) {
  310. let {authSetting} = await getSetting();
  311. if(authSetting['scope.userLocation']){
  312. await this.getUserLocation();
  313. }else{
  314. wx.showModal({
  315. title: '是否授权当前位置',
  316. content: '需要获取您的地理位置,请确认授权',
  317. confirmColor: '#f16765',
  318. success: res => {
  319. if (res.confirm) {
  320. wx.openSetting({
  321. success: async data => {
  322. await this.getUserLocation();
  323. value&&this.checkPower();
  324. },
  325. })
  326. } else {
  327. this.setData({havePower: {result: "fail",message: "未定位到您的位置"}})
  328. }
  329. }
  330. })
  331. }
  332. },
  333. // 获取位置信息
  334. async getUserLocation(cb) {
  335. var that = this;
  336. let {latitude,longitude} = await getLocation();
  337. this.setData({latitude,longitude});
  338. },
  339. // 是否有操作权限
  340. async checkPower() {
  341. await this.isGetSetting('cb');
  342. const data = {
  343. "criteria": {
  344. "projectId":this.data.spaceDetail.projectId,
  345. "spaceId": this.data.spaceDetail.id,
  346. "userId": $.store.get('userId'),
  347. "tenantId": this.data.spaceDetail.tenantId,
  348. "longitude": this.data.longitude,
  349. "latitude": this.data.latitude
  350. }
  351. };
  352. await powerCheck(data).then(res => {
  353. this.setData({
  354. havePower: res
  355. })
  356. })
  357. },
  358. // 获取实时曲线
  359. async getChartDate(){
  360. wx.showLoading({
  361. title:"加载中"
  362. });
  363. let data={
  364. projectId:this.data.spaceDetail.projectId,
  365. spaceId:this.data.spaceDetail.id,
  366. funcid:'Tdb'
  367. }
  368. let res = await getPropertyData(data);
  369. if(!res){
  370. throw "网络错误";
  371. }
  372. let {propertyData,dayTarget}=res;
  373. // 获取期望温度
  374. this.getHopeTemp(dayTarget).then(()=>{
  375. this.initDaytarget(dayTarget);
  376. this.initChartdate(propertyData,dayTarget);
  377. });
  378. wx.hideLoading();
  379. },
  380. initChartdate(propertyData,dayTarget){
  381. if(!propertyData&&!propertyData.length&&dayTarget&&!dayTarget.length){
  382. return ;
  383. }
  384. // 目标 { time: "1951",release:0, sales: 38,标准区间: [ 25, 45 ] },
  385. let baseArr=propertyData&&propertyData.slice(1) || [];
  386. let tragetChart = [];
  387. baseArr.forEach(item=>{
  388. item[1] = (item[1]=="-9999")?null:item[1];
  389. })
  390. if(baseArr.length===dayTarget.length){
  391. dayTarget.forEach((item,index)=>{
  392. let time ='';
  393. item.time&&(time = item.time.slice(0,2)+':'+item.time.slice(2,4));
  394. item['temperatureMin']&&(item['temperatureMin']=Number(item['temperatureMin'].toFixed(1)));
  395. item['temperatureMax']&&(item['temperatureMax']=Number(item['temperatureMax'].toFixed(1)));
  396. let initObj={
  397. time:time,
  398. release:index,
  399. sales:baseArr[index][1],
  400. 标准区间:[item['temperatureMin'],item['temperatureMax']],
  401. }
  402. tragetChart.push(initObj);
  403. })
  404. }
  405. this.setData({tragetChart,tragetChartcopy:tragetChart})
  406. },
  407. initDaytarget(value){
  408. if(!value||!value.length){
  409. return
  410. }
  411. let customPlan=[];
  412. // 格式化单位 15px为1度 28 18
  413. let lenpx=25;
  414. value.forEach((item,index)=>{
  415. if(item.time.slice(2,6)=="0000"){
  416. let obj={};
  417. obj.time=item.date+item.time;
  418. obj.id=index;
  419. obj.name=item.time.slice(0,2)+':'+item.time.slice(2,4);
  420. obj.maxValue= item.temperatureMax;
  421. obj.minValue = item.temperatureMin || 0;
  422. obj.distance=(obj.maxValue-obj.minValue)|| 0;
  423. obj.height=obj.distance*lenpx;
  424. obj.planTemp=Number(((obj.maxValue+obj.minValue)/2).toFixed(1));
  425. obj.y=(28 - obj.maxValue)*lenpx;
  426. customPlan.push(obj)
  427. }
  428. })
  429. this.setData({customPlancopy:this.copyobj(customPlan)})
  430. },
  431. getHopeTemp(value){
  432. return new Promise((reslove,reject)=>{
  433. if(!value||!value.length){
  434. return
  435. }
  436. let data=new Date();
  437. let hour = data.getHours();
  438. let min = data.getMinutes();
  439. let minIndex = Math.floor(min/15);
  440. if(minIndex>=3){
  441. hour = hour + 1;
  442. min = 0;
  443. }else{
  444. min = (minIndex+1)*15;
  445. }
  446. let targetTime = (hour>=10?`${hour}`:`0${hour}`)+(min>=10?`${min}`:`0${min}`);
  447. let isDatelist=[];
  448. let targetTemp;
  449. let targetIndex;
  450. value.forEach((item,index)=>{
  451. if(item.temperatureMax&&item.temperatureMin){
  452. isDatelist.push(index)
  453. }
  454. if(item.time===`${targetTime}00`){
  455. targetTemp= parseInt((item.temperatureMax + item.temperatureMin)/2);
  456. targetIndex = index
  457. }
  458. })
  459. if(targetTemp){
  460. this.setData({targetTemp:targetTemp,targetIndex:targetIndex})
  461. }else{
  462. let index = isDatelist.pop();
  463. targetTemp = parseInt((value[index].temperatureMax + value[index].temperatureMin)/2);
  464. this.setData({targetTemp:targetTemp,targetIndex:targetIndex})
  465. }
  466. reslove();
  467. })
  468. // 获取当前时间最近的15分钟
  469. },
  470. // 更改即时调节选项
  471. effectChange(event){
  472. this.setData({
  473. effectTime: event.detail,
  474. },()=>{
  475. let changeDate=JSON.parse(JSON.stringify(this.data.tragetChartcopy));
  476. if(event.detail==='1'){
  477. let len = (this.data.targetIndex+8)>changeDate.length?changeDate.length:(this.data.targetIndex+8)
  478. for(var i=this.data.targetIndex;i<len;i++){
  479. changeDate[i].sales = this.data.targetTemp;
  480. changeDate[i]['标准区间'] =[changeDate[i].sales-1,changeDate[i].sales+1];
  481. }
  482. }else if(event.detail==='2'){
  483. let len = changeDate.length;
  484. for(var i=this.data.targetIndex;i<len;i++){
  485. changeDate[i].sales = this.data.targetTemp;
  486. changeDate[i]['标准区间'] =[changeDate[i].sales-1,changeDate[i].sales+1];
  487. }
  488. }else{
  489. let len = (this.data.targetIndex+4)>changeDate.length?changeDate.length:(this.data.targetIndex+4);
  490. let start = (this.data.targetIndex-4)<0?0:(this.data.targetIndex-4);
  491. for(var i=start;i<len;i++){
  492. changeDate[i].sales = this.data.targetTemp;
  493. changeDate[i]['标准区间'] =[changeDate[i].sales-1,changeDate[i].sales+1];
  494. }
  495. }
  496. this.setData({tragetChart:changeDate});
  497. });
  498. },
  499. // 加期望温度
  500. addClick(){
  501. let tepNum=this.data.targetTemp;
  502. let firstNum = tepNum.toString().split('.')[0];
  503. let lastNum = tepNum.toString().split('.')[1];
  504. if(firstNum>=28){
  505. return
  506. }
  507. if(lastNum>=5){
  508. this.setData({targetTemp:Number(firstNum)+1})
  509. }else{
  510. this.setData({targetTemp:Number(firstNum)+0.5})
  511. }
  512. },
  513. // 减期望温度
  514. minusClick(){
  515. let tepNum=this.data.targetTemp;
  516. let firstNum = tepNum.toString().split('.')[0]
  517. let lastNum = tepNum.toString().split('.')[1]
  518. if(firstNum<=18&&!lastNum){
  519. return ;
  520. }
  521. if(lastNum>5){
  522. this.setData({targetTemp:Number(firstNum)+0.5})
  523. }else if(lastNum<=5){
  524. this.setData({targetTemp:Number(firstNum)})
  525. }else{
  526. this.setData({targetTemp:Number(firstNum)-0.5})
  527. }
  528. },
  529. // 修改期望温度
  530. taboneSubmit(){
  531. if(this.data.havePower.result!=="success"){
  532. Toast.fail(this.data.havePower.message);
  533. return
  534. }
  535. if(!this.data.effectTime||this.data.effectTime<0){
  536. wx.showToast({
  537. title:"未选择保持时间",
  538. icon:"none",
  539. duration: 1500
  540. })
  541. return
  542. }
  543. const data={
  544. "projectId": this.data.spaceDetail.projectId,
  545. "objectId": this.data.spaceDetail.id,
  546. "valueType": 2,
  547. "model":2,
  548. "durationType":this.data.effectTime || '',
  549. "value":this.data.targetTemp
  550. }
  551. submitAdjust(data).then(async res=>{
  552. if(res.result="success"){
  553. wx.hideLoading();
  554. setTimeout(function () {
  555. wx.showToast({
  556. title:"提交成功",
  557. duration: 2000
  558. })
  559. }, 300)
  560. }
  561. // this.setData({effectTime:-1})
  562. await this.buildContact();
  563. this.isfeeded();
  564. // this.getChartDate();
  565. })
  566. },
  567. // 修改全天温度
  568. tabtwoSubmit(){
  569. if(this.data.havePower.result!=="success"){
  570. Toast.fail(this.data.havePower.message);
  571. return
  572. }
  573. let customPlan = JSON.parse(JSON.stringify(this.data.customPlan));
  574. customPlan.forEach(item=>{
  575. delete item.id;
  576. delete item.name;
  577. delete item.planTemp;
  578. delete item.y;
  579. delete item.height;
  580. delete item.distance;
  581. })
  582. const data={
  583. "projectId": this.data.spaceDetail.projectId,
  584. "objectId": this.data.spaceDetail.id,
  585. "valueType": 3,
  586. "model":2,
  587. "value":this.data.targetTemp,
  588. "customPlan":customPlan
  589. }
  590. submitAdjust(data).then(async res=>{
  591. wx.hideLoading();
  592. setTimeout(function () {
  593. wx.showToast({
  594. title:"提交成功",
  595. duration: 2000
  596. })
  597. }, 300)
  598. await this.buildContact();
  599. this.isfeeded();
  600. // this.getChartDate();
  601. })
  602. },
  603. showTips(){
  604. wx.showModal({
  605. title: '提示',
  606. content: '非工作时间如需使用空调,或遇特殊问题,请联系环境管理员',
  607. showCancel:false,
  608. success: function (res) {
  609. }
  610. })
  611. },
  612. chartChange(e){
  613. let y =e.detail.y;
  614. this.throttle(this.updateChart(y,e),500)
  615. },
  616. preventTouchMove: function () {
  617. return
  618. },
  619. updateChart(y,e){
  620. let lenpx=25;
  621. let planTempMax = 28 - y/lenpx;
  622. let {index,distance} =e.currentTarget.dataset;
  623. let planTemp = Number(((planTempMax*2 - distance)/2).toFixed(1));
  624. let target=`customPlan[${index}].y`;
  625. let targetplan=`customPlan[${index}].planTemp`;
  626. let targetTempMax=`customPlan[${index}].maxValue`;
  627. let targetTempMin=`customPlan[${index}].minValue`;
  628. this.setData({[target]:y,[targetplan]:planTemp,chartIndex:index,[targetTempMax]:planTempMax,[targetTempMin]:planTempMax-2});
  629. },
  630. throttle(func, delay) {
  631. let prev = Date.now();
  632.   return function() {
  633. let context = this;
  634. let args = arguments;
  635. let now = Date.now();
  636.     if (now - prev >= delay) {
  637.       func.apply(context, args);
  638.       prev = Date.now();
  639.     }
  640.   }
  641. },
  642. fillZore(value) {
  643. if (value < 10) {
  644. value = 0 + value
  645. }
  646. return value
  647. },
  648. formatTimeall(value) {
  649. let stringValue;
  650. const date = new Date();
  651. var nowMonth = date.getMonth() + 1;
  652. let nowDay = date.getDate();
  653. let torrowDay = new Date(date);
  654. torrowDay.setDate(date.getDate() + 1);
  655. let torrowMonth = torrowDay.getMonth() + 1;
  656. nowDay = this.fillZore(nowDay);
  657. nowMonth = this.fillZore(nowMonth);
  658. torrowMonth = this.fillZore(torrowMonth);
  659. if (nowMonth == value.substring(4, 6) || torrowMonth == value.substring(4, 6)) {
  660. if (value.substring(6, 8) == nowDay) {
  661. stringValue = "今日"
  662. }
  663. let torrowVlue = torrowDay.getDate();
  664. torrowVlue = this.fillZore(torrowVlue);
  665. if (value.substring(6, 8) == torrowVlue) {
  666. stringValue = "明日"
  667. }
  668. }
  669. if (stringValue) {
  670. stringValue = stringValue + `${value.substring(8,10)}:${value.substring(10,12)}`
  671. } else {
  672. stringValue = `${value.substring(4,6)}月${value.substring(6,8)}日${value.substring(8,10)}:${value.substring(10,12)}`
  673. }
  674. return stringValue
  675. },
  676. isfeeded(value){
  677. !value&&router.pop();
  678. },
  679. copyobj(a){
  680. var c={};
  681. c=JSON.parse(JSON.stringify(a));
  682. return c;
  683. },
  684. tabChange(event){
  685. let that = this;
  686. if(event.detail.name==1){
  687. that.setData({customPlan:null,chartIndex:null},()=>{
  688. that.setData({customPlan:this.copyobj(this.data.customPlancopy)})
  689. })
  690. }else{
  691. this.setData({effectTime:-1})
  692. this.getChartDate();
  693. }
  694. },
  695. getnowSeason(){
  696. let day = new Date();
  697. let year = day.getFullYear();
  698. let month = day.getMonth() + 1;
  699. let today = day.getDate();
  700. const data={
  701. projectId:this.data.spaceDetail.projectId,
  702. date:`${year}${month}${today}`
  703. }
  704. getCurrentSeason(data).then(res=>{
  705. if(res.result=="success"){
  706. this.setData({bgSeasonType:res.data})
  707. }
  708. })
  709. },
  710. /**
  711. * 生命周期函数--监听页面加载
  712. */
  713. onLoad: function (options) {
  714. options = JSON.parse(decodeURIComponent(JSON.stringify(options)));
  715. if(options.md1){
  716. this.getDetail(options.md1);
  717. }else{
  718. this.setData({spaceDetail:options},()=>{
  719. this.checkGuide();
  720. this.getnowSeason();
  721. let higthSpace=["311","312"];
  722. if(this.data.spaceDetail.roomFuncType&&higthSpace.includes(this.data.spaceDetail.roomFuncType)){
  723. this.setData({singleOffice:true})
  724. }
  725. this.checkPower();
  726. })
  727. }
  728. },
  729. async getDetail(value){
  730. let data;
  731. if(value){
  732. let projectId = 'Pj' + value.substring(2, 12);
  733. this.setData({spaceId:value,projectId:projectId});
  734. data= {
  735. criteria: {
  736. "spaceId": value,
  737. "userId": $.store.get('userId'),
  738. "projectId": projectId
  739. }
  740. }
  741. }else{
  742. data= {
  743. criteria: {
  744. "spaceId": this.data.spaceDetail.id,
  745. "userId": $.store.get('userId'),
  746. "projectId": this.data.spaceDetail.projectId
  747. }
  748. }
  749. }
  750. wx.showLoading();
  751. let res = await getSpacedetail(data);
  752. wx.hideLoading();
  753. let {content} = res;
  754. this.setData({spaceDetail:content[0]},()=>{
  755. this.checkGuide();
  756. this.getnowSeason();
  757. // if(this.data.spaceDetail.nextOpenTime){
  758. // let value = this.formatTimeall(this.data.spaceDetail.nextOpenTime);
  759. // this.setData({nextOpenTime:value})
  760. // }
  761. if(this.data.spaceDetail.roomFuncType&&this.data.spaceDetail.roomFuncType.startsWith("31")){
  762. this.setData({singleOffice:true})
  763. }
  764. });
  765. $.storage.get("wxqcode")&&$.storage.set("wxqcode",'');
  766. // 判断是否可以调节
  767. await this.checkPower();
  768. },
  769. /**
  770. * 生命周期函数--监听页面初次渲染完成
  771. */
  772. onReady: function () {
  773. setTimeout(()=>{
  774. this.setData({'headerShow':true})
  775. },500)
  776. },
  777. })