index.js 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779
  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. 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. const data={
  217. "userId":$.store.get('userId'),//用户id
  218. "projectId":this.data.spaceDetail.projectId,//项目id
  219. "spaceId":this.data.spaceDetail.id,//空间id
  220. "openId":$.store.get('openId'),
  221. flag:1
  222. }
  223. contactTenant(data).then(res=>{
  224. console.log("成功")
  225. })
  226. },
  227. // 下班节能
  228. turnDown(){
  229. if(this.data.havePower.result!=="success"){
  230. Toast.fail(this.data.havePower.message);
  231. return
  232. }
  233. let data = {
  234. model:1,
  235. "projectId":this.data.spaceDetail.projectId, //项目id
  236. "objectId":[this.data.spaceDetail.id], //空间id
  237. userId:$.store.get('userId'),
  238. nextOpenTime:this.data.spaceDetail.nextOpenTime||"",
  239. }
  240. workLeave(data).then(res=>{
  241. this.setData({trunAction:true});
  242. this.buildContact();
  243. })
  244. },
  245. // 重新开启
  246. turnUp(){
  247. if(this.data.havePower.result!=="success"){
  248. Toast.fail(this.data.havePower.message);
  249. return
  250. }
  251. let data = {
  252. "projectId":this.data.spaceDetail.projectId, //项目id
  253. "objectId": this.data.spaceDetail.id, //空间id
  254. model:1,
  255. userId:$.store.get('userId')
  256. }
  257. openSpace(data).then(res=>{
  258. this.setData({
  259. secondSpaceStatus: res.spaceStatus,
  260. secondNotice: res.notice,
  261. secondIcon: res.icon,
  262. trunupAction: true
  263. });
  264. this.buildContact();
  265. })
  266. },
  267. commitClose(){
  268. this.setData({trunupAction:false},()=>{
  269. this.isfeeded(true);
  270. this.getDetail();
  271. })
  272. },
  273. knowClick(){
  274. this.setData({feedBack:false,tempTypeValue:-1,windTypeValue:-1,},()=>{
  275. this.isfeeded();
  276. });
  277. },
  278. knowCloseClick(){
  279. this.setData({feedBack:false,trunAction:false},()=>{
  280. this.getDetail();
  281. this.isfeeded(true);
  282. });
  283. },
  284. // 获取容器高度
  285. getPageheight:function(){
  286. let that =this;
  287. wx.createSelectorQuery().select('#j_page').boundingClientRect(function(rect){
  288. that.setData({'pageHight':rect.height})
  289. }).exec()
  290. },
  291. //使页面滚动到容器底部
  292. pageScrollToBottom: function() {
  293. wx.pageScrollTo({
  294. scrollTop: this.data.pageHight
  295. })
  296. },
  297. // 步骤引导函数
  298. nextStep(e){
  299. if(this.data.guideStep==2){
  300. $.storage.set('guideInit',true);
  301. this.setData({'guideInit':false})
  302. }
  303. this.setData({'guideStep':2})
  304. this.pageScrollToBottom();
  305. },
  306. async isGetSetting(value) {
  307. let {authSetting} = await getSetting();
  308. if(authSetting['scope.userLocation']){
  309. await this.getUserLocation();
  310. }else{
  311. wx.showModal({
  312. title: '是否授权当前位置',
  313. content: '需要获取您的地理位置,请确认授权',
  314. confirmColor: '#f16765',
  315. success: res => {
  316. if (res.confirm) {
  317. wx.openSetting({
  318. success: async data => {
  319. await this.getUserLocation();
  320. value&&this.checkPower();
  321. },
  322. })
  323. } else {
  324. this.setData({havePower: {result: "fail",message: "未定位到您的位置"}})
  325. }
  326. }
  327. })
  328. }
  329. },
  330. // 获取位置信息
  331. async getUserLocation(cb) {
  332. var that = this;
  333. let {latitude,longitude} = await getLocation();
  334. this.setData({latitude,longitude});
  335. },
  336. // 是否有操作权限
  337. async checkPower() {
  338. await this.isGetSetting('cb');
  339. const data = {
  340. "criteria": {
  341. "projectId":this.data.spaceDetail.projectId,
  342. "spaceId": this.data.spaceDetail.id,
  343. "userId": $.store.get('userId'),
  344. "tenantId": this.data.spaceDetail.tenantId,
  345. "longitude": this.data.longitude,
  346. "latitude": this.data.latitude
  347. }
  348. };
  349. await powerCheck(data).then(res => {
  350. this.setData({
  351. havePower: res
  352. })
  353. })
  354. },
  355. // 获取实时曲线
  356. async getChartDate(){
  357. wx.showLoading({
  358. title:"加载中"
  359. });
  360. let data={
  361. projectId:this.data.spaceDetail.projectId,
  362. spaceId:this.data.spaceDetail.id,
  363. funcid:'Tdb'
  364. }
  365. let res = await getPropertyData(data);
  366. if(!res){
  367. throw "网络错误";
  368. }
  369. let {propertyData,dayTarget}=res;
  370. // 获取期望温度
  371. this.getHopeTemp(dayTarget).then(()=>{
  372. this.initDaytarget(dayTarget);
  373. this.initChartdate(propertyData,dayTarget);
  374. });
  375. wx.hideLoading();
  376. },
  377. initChartdate(propertyData,dayTarget){
  378. if(!propertyData&&!propertyData.length&&dayTarget&&!dayTarget.length){
  379. return ;
  380. }
  381. // 目标 { time: "1951",release:0, sales: 38,标准区间: [ 25, 45 ] },
  382. let baseArr=propertyData&&propertyData.slice(1) || [];
  383. let tragetChart = [];
  384. baseArr.forEach(item=>{
  385. item[1] = (item[1]=="-9999")?null:item[1];
  386. })
  387. if(baseArr.length===dayTarget.length){
  388. dayTarget.forEach((item,index)=>{
  389. let time ='';
  390. item.time&&(time = item.time.slice(0,2)+':'+item.time.slice(2,4));
  391. item['temperatureMin']&&(item['temperatureMin']=Number(item['temperatureMin'].toFixed(1)));
  392. item['temperatureMax']&&(item['temperatureMax']=Number(item['temperatureMax'].toFixed(1)));
  393. let initObj={
  394. time:time,
  395. release:index,
  396. sales:baseArr[index][1],
  397. 标准区间:[item['temperatureMin'],item['temperatureMax']],
  398. }
  399. tragetChart.push(initObj);
  400. })
  401. }
  402. this.setData({tragetChart,tragetChartcopy:tragetChart})
  403. },
  404. initDaytarget(value){
  405. if(!value||!value.length){
  406. return
  407. }
  408. let customPlan=[];
  409. // 格式化单位 15px为1度 28 18
  410. let lenpx=25;
  411. value.forEach((item,index)=>{
  412. if(item.time.slice(2,6)=="0000"){
  413. let obj={};
  414. obj.time=item.date+item.time;
  415. obj.id=index;
  416. obj.name=item.time.slice(0,2)+':'+item.time.slice(2,4);
  417. obj.maxValue= item.temperatureMax;
  418. obj.minValue = item.temperatureMin || 0;
  419. obj.distance=(obj.maxValue-obj.minValue)|| 0;
  420. obj.height=obj.distance*lenpx;
  421. obj.planTemp=Number(((obj.maxValue+obj.minValue)/2).toFixed(1));
  422. obj.y=(28 - obj.maxValue)*lenpx;
  423. customPlan.push(obj)
  424. }
  425. })
  426. this.setData({customPlancopy:this.copyobj(customPlan)})
  427. },
  428. getHopeTemp(value){
  429. return new Promise((reslove,reject)=>{
  430. if(!value||!value.length){
  431. return
  432. }
  433. let data=new Date();
  434. let hour = data.getHours();
  435. let min = data.getMinutes();
  436. let minIndex = Math.floor(min/15);
  437. if(minIndex>=3){
  438. hour = hour + 1;
  439. min = 0;
  440. }else{
  441. min = (minIndex+1)*15;
  442. }
  443. let targetTime = (hour>=10?`${hour}`:`0${hour}`)+(min>=10?`${min}`:`0${min}`);
  444. let isDatelist=[];
  445. let targetTemp;
  446. let targetIndex;
  447. value.forEach((item,index)=>{
  448. if(item.temperatureMax&&item.temperatureMin){
  449. isDatelist.push(index)
  450. }
  451. if(item.time===`${targetTime}00`){
  452. targetTemp= parseInt((item.temperatureMax + item.temperatureMin)/2);
  453. targetIndex = index
  454. }
  455. })
  456. if(targetTemp){
  457. this.setData({targetTemp:targetTemp,targetIndex:targetIndex})
  458. }else{
  459. let index = isDatelist.pop();
  460. targetTemp = parseInt((value[index].temperatureMax + value[index].temperatureMin)/2);
  461. this.setData({targetTemp:targetTemp,targetIndex:targetIndex})
  462. }
  463. reslove();
  464. })
  465. // 获取当前时间最近的15分钟
  466. },
  467. // 更改即时调节选项
  468. effectChange(event){
  469. this.setData({
  470. effectTime: event.detail,
  471. },()=>{
  472. let changeDate=JSON.parse(JSON.stringify(this.data.tragetChartcopy));
  473. if(event.detail==='1'){
  474. let len = (this.data.targetIndex+8)>changeDate.length?changeDate.length:(this.data.targetIndex+8)
  475. for(var i=this.data.targetIndex;i<len;i++){
  476. changeDate[i].sales = this.data.targetTemp;
  477. changeDate[i]['标准区间'] =[changeDate[i].sales-1,changeDate[i].sales+1];
  478. }
  479. }else if(event.detail==='2'){
  480. let len = changeDate.length;
  481. for(var i=this.data.targetIndex;i<len;i++){
  482. changeDate[i].sales = this.data.targetTemp;
  483. changeDate[i]['标准区间'] =[changeDate[i].sales-1,changeDate[i].sales+1];
  484. }
  485. }else{
  486. let len = (this.data.targetIndex+4)>changeDate.length?changeDate.length:(this.data.targetIndex+4);
  487. let start = (this.data.targetIndex-4)<0?0:(this.data.targetIndex-4);
  488. for(var i=start;i<len;i++){
  489. changeDate[i].sales = this.data.targetTemp;
  490. changeDate[i]['标准区间'] =[changeDate[i].sales-1,changeDate[i].sales+1];
  491. }
  492. }
  493. this.setData({tragetChart:changeDate});
  494. });
  495. },
  496. // 加期望温度
  497. addClick(){
  498. let tepNum=this.data.targetTemp;
  499. let firstNum = tepNum.toString().split('.')[0]
  500. let lastNum = tepNum.toString().split('.')[1]
  501. if(lastNum>=5){
  502. this.setData({targetTemp:Number(firstNum)+1})
  503. }else{
  504. this.setData({targetTemp:Number(firstNum)+0.5})
  505. }
  506. },
  507. // 减期望温度
  508. minusClick(){
  509. let tepNum=this.data.targetTemp;
  510. let firstNum = tepNum.toString().split('.')[0]
  511. let lastNum = tepNum.toString().split('.')[1]
  512. if(lastNum>5){
  513. this.setData({targetTemp:Number(firstNum)+0.5})
  514. }else if(lastNum<=5){
  515. this.setData({targetTemp:Number(firstNum)})
  516. }else{
  517. this.setData({targetTemp:Number(firstNum)-0.5})
  518. }
  519. },
  520. // 修改期望温度
  521. taboneSubmit(){
  522. if(this.data.havePower.result!=="success"){
  523. Toast.fail(this.data.havePower.message);
  524. return
  525. }
  526. if(!this.data.effectTime||this.data.effectTime<0){
  527. wx.showToast({
  528. title:"未选择保持时间",
  529. icon:"none",
  530. duration: 1500
  531. })
  532. return
  533. }
  534. const data={
  535. "projectId": this.data.spaceDetail.projectId,
  536. "objectId": this.data.spaceDetail.id,
  537. "valueType": 2,
  538. "model":2,
  539. "durationType":this.data.effectTime || '',
  540. "value":this.data.targetTemp
  541. }
  542. submitAdjust(data).then(res=>{
  543. if(res.result="success"){
  544. wx.hideLoading();
  545. setTimeout(function () {
  546. wx.showToast({
  547. title:"提交成功",
  548. duration: 2000
  549. })
  550. }, 300)
  551. }
  552. this.setData({effectTime:-1})
  553. this.buildContact();
  554. this.getChartDate();
  555. })
  556. },
  557. // 修改全天温度
  558. tabtwoSubmit(){
  559. if(this.data.havePower.result!=="success"){
  560. Toast.fail(this.data.havePower.message);
  561. return
  562. }
  563. let customPlan = JSON.parse(JSON.stringify(this.data.customPlan));
  564. customPlan.forEach(item=>{
  565. delete item.id;
  566. delete item.name;
  567. delete item.planTemp;
  568. delete item.y;
  569. delete item.height;
  570. delete item.distance;
  571. })
  572. const data={
  573. "projectId": this.data.spaceDetail.projectId,
  574. "objectId": this.data.spaceDetail.id,
  575. "valueType": 3,
  576. "model":2,
  577. "value":this.data.targetTemp,
  578. "customPlan":customPlan
  579. }
  580. submitAdjust(data).then(res=>{
  581. wx.hideLoading();
  582. setTimeout(function () {
  583. wx.showToast({
  584. title:"提交成功",
  585. duration: 2000
  586. })
  587. }, 300)
  588. this.buildContact();
  589. this.getChartDate();
  590. })
  591. },
  592. showTips(){
  593. wx.showModal({
  594. title: '提示',
  595. content: '非工作时间如需使用空调,或遇特殊问题,请联系环境管理员',
  596. showCancel:false,
  597. success: function (res) {
  598. }
  599. })
  600. },
  601. chartChange(e){
  602. let y =e.detail.y;
  603. this.throttle(this.updateChart(y,e),500)
  604. },
  605. preventTouchMove: function () {
  606. return
  607. },
  608. updateChart(y,e){
  609. let lenpx=25;
  610. let planTempMax = 28 - y/lenpx;
  611. let {index,distance} =e.currentTarget.dataset;
  612. let planTemp = Number(((planTempMax*2 - distance)/2).toFixed(1));
  613. let target=`customPlan[${index}].y`;
  614. let targetplan=`customPlan[${index}].planTemp`;
  615. let targetTempMax=`customPlan[${index}].maxValue`;
  616. let targetTempMin=`customPlan[${index}].minValue`;
  617. this.setData({[target]:y,[targetplan]:planTemp,chartIndex:index,[targetTempMax]:planTempMax,[targetTempMin]:planTempMax-2});
  618. },
  619. throttle(func, delay) {
  620. let prev = Date.now();
  621.   return function() {
  622. let context = this;
  623. let args = arguments;
  624. let now = Date.now();
  625.     if (now - prev >= delay) {
  626.       func.apply(context, args);
  627.       prev = Date.now();
  628.     }
  629.   }
  630. },
  631. fillZore(value) {
  632. if (value < 10) {
  633. value = 0 + value
  634. }
  635. return value
  636. },
  637. formatTimeall(value) {
  638. let stringValue;
  639. const date = new Date();
  640. var nowMonth = date.getMonth() + 1;
  641. let nowDay = date.getDate();
  642. let torrowDay = new Date(date);
  643. torrowDay.setDate(date.getDate() + 1);
  644. let torrowMonth = torrowDay.getMonth() + 1;
  645. nowDay = this.fillZore(nowDay);
  646. nowMonth = this.fillZore(nowMonth);
  647. torrowMonth = this.fillZore(torrowMonth);
  648. if (nowMonth == value.substring(4, 6) || torrowMonth == value.substring(4, 6)) {
  649. if (value.substring(6, 8) == nowDay) {
  650. stringValue = "今日"
  651. }
  652. let torrowVlue = torrowDay.getDate();
  653. torrowVlue = this.fillZore(torrowVlue);
  654. if (value.substring(6, 8) == torrowVlue) {
  655. stringValue = "明日"
  656. }
  657. }
  658. if (stringValue) {
  659. stringValue = stringValue + `${value.substring(8,10)}:${value.substring(10,12)}`
  660. } else {
  661. stringValue = `${value.substring(4,6)}月${value.substring(6,8)}日${value.substring(8,10)}:${value.substring(10,12)}`
  662. }
  663. return stringValue
  664. },
  665. isfeeded(value){
  666. !value&&router.pop();
  667. },
  668. copyobj(a){
  669. var c={};
  670. c=JSON.parse(JSON.stringify(a));
  671. return c;
  672. },
  673. tabChange(event){
  674. let that = this;
  675. if(event.detail.name==1){
  676. that.setData({customPlan:null,chartIndex:null},()=>{
  677. that.setData({customPlan:this.copyobj(this.data.customPlancopy)})
  678. })
  679. }else{
  680. this.setData({effectTime:-1})
  681. this.getChartDate();
  682. }
  683. },
  684. getnowSeason(){
  685. let day = new Date();
  686. let year = day.getFullYear();
  687. let month = day.getMonth() + 1;
  688. let today = day.getDate();
  689. const data={
  690. projectId:this.data.spaceDetail.projectId,
  691. date:`${year}${month}${today}`
  692. }
  693. getCurrentSeason(data).then(res=>{
  694. if(res.result=="success"){
  695. this.setData({bgSeasonType:res.data})
  696. }
  697. })
  698. },
  699. /**
  700. * 生命周期函数--监听页面加载
  701. */
  702. onLoad: function (options) {
  703. options = JSON.parse(decodeURIComponent(JSON.stringify(options)));
  704. if(options.md1){
  705. this.getDetail(options.md1);
  706. }else{
  707. this.setData({spaceDetail:options},()=>{
  708. this.checkGuide();
  709. this.getnowSeason();
  710. if(this.data.spaceDetail.roomFuncType&&this.data.spaceDetail.roomFuncType.startsWith("31")){
  711. this.setData({singleOffice:true})
  712. }
  713. this.checkPower();
  714. })
  715. }
  716. },
  717. async getDetail(value){
  718. let data;
  719. if(value){
  720. let projectId = 'Pj' + value.substring(2, 12);
  721. this.setData({spaceId:value,projectId:projectId});
  722. data= {
  723. criteria: {
  724. "spaceId": value,
  725. "userId": $.store.get('userId'),
  726. "projectId": projectId
  727. }
  728. }
  729. }else{
  730. data= {
  731. criteria: {
  732. "spaceId": this.data.spaceDetail.id,
  733. "userId": $.store.get('userId'),
  734. "projectId": this.data.spaceDetail.projectId
  735. }
  736. }
  737. }
  738. wx.showLoading();
  739. let res = await getSpacedetail(data);
  740. wx.hideLoading();
  741. let {content} = res;
  742. this.setData({spaceDetail:content[0]},()=>{
  743. this.checkGuide();
  744. this.getnowSeason();
  745. if(this.data.spaceDetail.nextOpenTime){
  746. let value = this.formatTimeall(this.data.spaceDetail.nextOpenTime);
  747. this.setData({nextOpenTime:value})
  748. }
  749. if(this.data.spaceDetail.roomFuncType&&this.data.spaceDetail.roomFuncType.startsWith("31")){
  750. this.setData({singleOffice:true})
  751. }
  752. });
  753. $.storage.get("wxqcode")&&$.storage.set("wxqcode",'');
  754. // 判断是否可以调节
  755. await this.checkPower();
  756. },
  757. /**
  758. * 生命周期函数--监听页面初次渲染完成
  759. */
  760. onReady: function () {
  761. setTimeout(()=>{
  762. this.setData({'headerShow':true})
  763. },500)
  764. },
  765. })