status.vue 32 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295
  1. <template>
  2. <view class="container">
  3. <view style="height: 20px;line-height:15px;padding: 2px;text-align: center;position: fixed;right: -5px;top:30px;z-index: 9999;background: rgb(243,157,116);color: white;border-radius: 5px;font-size: 10px;width: 120rpx;" @click="goBack">
  4. {{$t('charge.break')}}
  5. </view>
  6. <view v-if="locale == 'en'" style="height: 40px;line-height:15px;padding: 2px;text-align: center;position: fixed;right: -5px;top:120px;z-index: 9999;background: #1A87FF;color: white;border-radius: 5px;font-size: 10px;width: 120rpx;" @click="modifyPwd">
  7. {{$t('charge.modifypwd')}}
  8. </view>
  9. <view v-else style="height: 20px;line-height:15px;padding: 2px;text-align: center;position: fixed;right: -5px;top:120px;z-index: 9999;background: #1A87FF;color: white;border-radius: 5px;font-size: 10px;width: 120rpx;" @click="modifyPwd">
  10. {{$t('charge.modifypwd')}}
  11. </view>
  12. <view style=";position: relative;height: 250px;margin-top:2vh;">
  13. <view class="dtop">
  14. <view class="can">
  15. <view class="box">
  16. <view class="three">
  17. <view class="four"></view>
  18. <view class="five"></view>
  19. <view class="six"></view>
  20. </view>
  21. <view class="dot"></view>
  22. <view class="dot"></view>
  23. <view class="dot"></view>
  24. <view class="dot"></view>
  25. <view class="dot"></view>
  26. </view>
  27. <!-- <canvas id="c">-->
  28. <!-- </canvas>-->
  29. <view class="stip">
  30. <view class="p0" st="">{{i18('设备号')}}:{{uuid}}</view>
  31. <view class="p1">
  32. <view v-if="portStatus == 2">
  33. {{$t('charge.charging')}}
  34. </view>
  35. <view v-else-if="portStatus == 6">
  36. {{$t('charge.planed')}}
  37. </view>
  38. <view v-else-if="portStatus == 5">
  39. {{$t('charge.connected')}}
  40. </view>
  41. <view v-else>
  42. {{$t('charge.nocharge')}}
  43. </view>
  44. </view>
  45. </view>
  46. </view>
  47. </view>
  48. </view>
  49. <view style="display: flex;flex-direction: row;margin:0 33%;" v-if="curPort.length>1">
  50. <view class="port_item" :class="item.id==choosePort?'selected_item':''" v-for="item in curPort" @click="selectPort(item.id);">{{ i18(item.text )}}</view>
  51. </view>
  52. <view class="dstatus">
  53. <view class="ditem">
  54. <image class="itemimg" src="/static/images/new/tmp.png"/>
  55. <view class="item-value">{{deviceTemp}}℃</view>
  56. <span class="item-text">{{$t('charge.devtemper')}}</span>
  57. </view>
  58. <view class="ditem">
  59. <image class="itemimg" src="/static/images/new/dianya.png"/>
  60. <view class="item-value">{{ deviceV }}V</view>
  61. <span class="item-text">{{$t('charge.voltage')}}</span>
  62. </view>
  63. <view class="ditem">
  64. <image class="itemimg" src="/static/images/new/dianliu.png"/>
  65. <view class="item-value" v-if="deviceV==0">0A</view>
  66. <view class="item-value" v-else>
  67. {{currentValue}}A
  68. </view>
  69. <span class="item-text">{{$t('charge.current')}}</span>
  70. </view>
  71. <view class="ditem">
  72. <image class="itemimg" src="/static/images/new/shjian.png"/>
  73. <view class="item-value" >{{ chargeTime }}{{ i18('分钟') }}</view>
  74. <span class="item-text">{{$t('charge.chargetime')}}</span>
  75. </view>
  76. <view class="ditem">
  77. <image class="itemimg" src="/static/images/new/gonglv.png"/>
  78. <view class="item-value" >{{ gonglv }}W</view>
  79. <span class="item-text">{{$t('charge.power')}}</span>
  80. </view>
  81. <view class="ditem">
  82. <image class="itemimg" src="/static/images/new/dianliang.png"/>
  83. <view class="item-value" >{{ dianliang}} {{ i18('度') }}</view>
  84. <span class="item-text">{{$t('charge.elec')}}</span>
  85. </view>
  86. </view>
  87. <view class="dbtns">
  88. <view class="start" @click="toPage">
  89. <image style="width:25px;height: 25px;margin-right: 5px;" src="/static/images/new/start.png"/>
  90. <span>{{$t('charge.startcharge')}}</span>
  91. </view>
  92. <view class="get" @click="getInfo">
  93. <image style="width:25px;height: 25px;margin-right: 5px;" src="/static/images/new/get.png"/>
  94. <span>{{$t('charge.getinfo')}}</span>
  95. </view>
  96. </view>
  97. <view class="dtip">
  98. <view style="margin:10px 0px;color: #1A87FF;"><img style="width: 13px;height: 13px" src="/static/images/new/tip.png">{{i18('温馨提示')}}</view>
  99. <view>1,{{i18('桩控制最大输出电流,当功率没有达到请检查车的状态或者车的设置')}};</view>
  100. <view>2,{{i18('启动充电-&gt;设备管理->可设置设备最大输出电流')}}</view>
  101. <view>3,{{i18('为保障您远程启动正常充电,请确保枪头完全连接充电口,同时确认您的爱车处于立即充电状态下')}};</view>
  102. <view>4,{{i18('注意规范安全充电,停好车,锁好车。')}}</view>
  103. </view>
  104. <u-picker @cancel="showPort=false" @confirm="confirmPort" :show="showPort" :columns="portList" keyName="text"></u-picker>
  105. <u-picker @cancel="cancelPicker" @confirm="confirm" :show="showPlan" :columns="planCols" @change="changeHandler"></u-picker>
  106. <u-modal :show="showPwd" :confirmText="i18('确认')" :cancelText="i18('取消')" @confirm="inputPwd" @cancel="cancel" :showCancelButton="true" :title="$t('charge.modifypwd')" >
  107. <view class="slot-content">
  108. <view>
  109. <u--input
  110. type="number"
  111. :placeholder="$t('charge.oldpwd')"
  112. border="surround"
  113. v-model="oldPwd"
  114. ></u--input>
  115. </view>
  116. <view style="margin-top:5px">
  117. <u--input
  118. type="number"
  119. :placeholder="$t('charge.newpwd')"
  120. border="surround"
  121. v-model="pwd"
  122. ></u--input>
  123. </view>
  124. </view>
  125. </u-modal>
  126. <u-modal :show="showInitPwd" :confirmText="i18('确认')" :cancelText="i18('取消')" @confirm="inputPwd" @cancel="cancel" :showCancelButton="true" :title="i18('当前密码为初始密码,请修改')" >
  127. <view class="slot-content">
  128. <view style="margin-bottom:10px;">
  129. {{i18('请保存好设备序列号。可用于找回密码')}}
  130. </view>
  131. <view style="margin-bottom:10px;text-decoration: underline" @click="copyPwd">
  132. {{i18('设备序列号')}} :{{uuid}}
  133. </view>
  134. <view>
  135. <u--input
  136. type="number"
  137. :placeholder="$t('charge.oldpwd')"
  138. border="surround"
  139. v-model="oldPwd"
  140. ></u--input>
  141. </view>
  142. <view style="margin-top:5px">
  143. <u--input
  144. type="number"
  145. :placeholder="$t('charge.newpwd')"
  146. border="surround"
  147. v-model="pwd"
  148. ></u--input>
  149. </view>
  150. </view>
  151. </u-modal>
  152. </view>
  153. </template>
  154. <script>
  155. import {getDeviceInfo,getPortDetail,startCharge,stopCharge,sendPortDetailCmd,checkStatusChange,getPlanInfo,cancelPlan,parseDataObj,planCharge,getPwd,setPwd,getUUID} from "@/utils/weitiandi/device/device.js";
  156. // #ifdef APP
  157. import ecUI from '@/utils/ecUI.js'
  158. import ecBLE from '@/utils/ecBLE/ecBLE.js'
  159. // #endif
  160. // #ifdef MP
  161. const ecUI = require('@/utils/ecUI.js')
  162. const ecBLE = require('@/utils/ecBLE/ecBLE.js')
  163. // #endif
  164. import i18 from '@/utils/i18.js'
  165. let ctx
  166. let isCheckScroll = true
  167. let isCheckRevHex = false
  168. let isCheckSendHex = false
  169. let sendData = ''
  170. export default {
  171. data() {
  172. return {
  173. chargeTime:0,
  174. deviceTemp:0,
  175. deviceV:0,
  176. currentValue:0,
  177. gonglv:0,
  178. dianliang:0,
  179. portStatus:0,
  180. locale:"",
  181. oldPwd:"",
  182. pwd:"",
  183. showPwd:false,
  184. planCols:[ ],
  185. columnData:[],
  186. showPlan:false,
  187. deviceInfo:{},
  188. visitTime:"",
  189. timer:null,
  190. showPort:false,
  191. portDetail:{portStatus:0,power:0,voltage:0,time:0,dev_temper:0,elec:0,dev_temper:0},
  192. statusTimer:"",
  193. connected:false,
  194. scriptTask:null,
  195. choosePort:1,
  196. portList:[[{port:1,text:"端口一"}]],
  197. planInfo:null,
  198. days:["","周一","周二","周三","周四","周五","周六","周日"],
  199. textRevData: '',
  200. picker:null,
  201. firstInit:false,
  202. hasRight:false,
  203. startAutoCharge:true,
  204. initPwd:"123456",
  205. showInitPwd:false,
  206. uuid:"",
  207. curPort:[],
  208. firstRender:false,
  209. }
  210. },
  211. computed: {
  212. imgUrl() {
  213. return getApp().globalData.config.imgUrl;
  214. }
  215. },
  216. onLoad() {
  217. // #ifdef MP
  218. this.firstRender = true;
  219. // #endif
  220. this.locale = uni.getLocale();
  221. console.log("status comeing")
  222. this.checkPassword();
  223. // this.messageCallback({"type":103,"real_data":{"port_first_status":1,"power":0,"elec":0,"money":0,"time":0,"port_second_status":2,"power_1":0,"elec_1":3,"money_1":50000,"time_1":367,"dev_temper":17,"voltage":228,"":249,"portStatus":1,"currentValue":"0.0"}})
  224. },
  225. onShow(){
  226. uni.setNavigationBarTitle({
  227. title: this.$t('page.detail')
  228. })
  229. this.buletooth();
  230. },
  231. onUnload (){
  232. this.closeSocket();
  233. },
  234. methods: {
  235. selectPort(id){
  236. this.choosePort = id;
  237. console.log(this.choosePort)
  238. this.getInfo();
  239. },
  240. copyPwd(){
  241. uni.setClipboardData({
  242. data: this.uuid,
  243. success: function () {
  244. this.$modal.showToast("复制成功");
  245. }
  246. });
  247. },
  248. i18(text){
  249. return i18(text)
  250. },
  251. toPage(){
  252. uni.navigateTo({
  253. url: '/pages/weitiandi/bluetooth/index'
  254. });
  255. },
  256. cancel(){
  257. this.showPwd = false;
  258. },
  259. modifyPwd(){
  260. this.showPwd = true;
  261. },
  262. inputPwd(){
  263. let rightPwd = uni.getStorageSync("pwd");
  264. if(!this.oldPwd){
  265. this.$modal.showToast("原密码不能为空");
  266. return;
  267. }
  268. if(rightPwd != this.oldPwd){
  269. this.$modal.showToast("原密码不对");
  270. return;
  271. }
  272. if(this.pwd == "000000"){
  273. this.$modal.showToast("密码不能设置为000000");
  274. return;
  275. }
  276. if(this.pwd == "123456"){
  277. this.$modal.showToast("密码不能设置为123456");
  278. return;
  279. }
  280. if(!this.pwd){
  281. this.$modal.showToast("密码不能为空");
  282. }else {
  283. setPwd(this.pwd);
  284. this.oldPwd = this.pwd;
  285. uni.removeStorageSync("pwd");
  286. this.$modal.showToast("密码修改成功");
  287. this.showPwd = false;
  288. this.showInitPwd = false;
  289. // this.goBack();
  290. }
  291. },
  292. confirm(e) {
  293. let value = e.value;
  294. console.log('confirm', value)
  295. let day = value[0];
  296. let date = new Date();
  297. let nowDay = date.getDate();
  298. let hour = value[1]+"";
  299. hour = parseInt(hour.substr(0,hour.length-1),10);
  300. let min = value[2]+"";
  301. min = parseInt(min.substr(0,min.length-1),10);
  302. let todayTotalMin = 0;
  303. let planDate = {min:min,hour:hour};
  304. let nowHour = date.getHours();
  305. let nowMin = date.getMinutes();
  306. let nowDate ={min:nowMin,hour:nowHour};
  307. if("今日" == day){
  308. todayTotalMin = this.getGapMin(planDate,nowDate)
  309. }else {
  310. let nowHour = date.getHours();
  311. let min = date.getMinutes();
  312. let maxDate ={min:59,hour:23};
  313. todayTotalMin = this.getGapMin(maxDate,nowDate);
  314. let minDate = {min:0,hour:0};
  315. todayTotalMin +=this.getGapMin(planDate,minDate);
  316. }
  317. console.log(todayTotalMin);
  318. this.cancelPicker();
  319. if(todayTotalMin<=0 || todayTotalMin>1440){
  320. this.$modal.showToast("最大预约时间为24小时");
  321. }else{
  322. planCharge(this.choosePort,todayTotalMin).then(res=>{
  323. this.getInfo(true);
  324. });
  325. }
  326. },
  327. getGapMin(date1,date2){
  328. let min1 = date1.min;
  329. let hour1 = date1.hour;
  330. let min2 = date2.min;
  331. let hour2 = date2.hour;
  332. let total1 = min1+hour1*60;
  333. let total2 = min2+hour2*60;
  334. return total1-total2;
  335. },
  336. cancelPicker(e) {
  337. this.showPlan = false
  338. },
  339. changeHandler(e){
  340. const {
  341. columnIndex,
  342. value,
  343. values, // values为当前变化列的数组内容
  344. index,
  345. // 微信小程序无法将picker实例传出来,只能通过ref操作
  346. picker = this.$refs.uPicker
  347. } = e
  348. let day = e.value[0];
  349. // 当第一列值发生变化时,变化第二列(后一列)对应的选项
  350. this.picker = picker;
  351. if (columnIndex === 0) {
  352. // picker为选择器this实例,变化第二列对应的选项
  353. if(day == "今日"){
  354. picker.setColumnValues(1, this.columnData[1])
  355. }else{
  356. picker.setColumnValues(1, this.columnData[0])
  357. }
  358. }
  359. },
  360. checkPassword(){
  361. setTimeout(function (){
  362. getUUID();
  363. },500);
  364. let rightPwd = uni.getStorageSync("pwd");
  365. if(rightPwd === this.initPwd){
  366. this.showInitPwd = true;
  367. this.oldPwd = rightPwd;
  368. }
  369. },
  370. recon(){
  371. let self = this;
  372. ecUI.showLoading('设备连接中')
  373. let blueid = uni.getStorageSync('blueid');
  374. ecBLE.onBLEConnectionStateChange(res => {
  375. ecUI.hideLoading()
  376. if (res.ok) {
  377. self.buletooth();
  378. } else {
  379. uni.removeStorageSync('blueid');
  380. ecUI.showModal(
  381. '提示',
  382. '连接失败,errCode=' + res.errCode + ',errMsg=' + res.errMsg
  383. )
  384. }
  385. })
  386. ecBLE.createBLEConnection(blueid);
  387. },
  388. buletooth(){
  389. let self = this;
  390. ctx = this
  391. isCheckScroll = true
  392. isCheckRevHex = false
  393. isCheckSendHex = false
  394. sendData = ''
  395. //on disconnect
  396. ecBLE.onBLEConnectionStateChange(() => {
  397. uni.showModal({
  398. title: '提示',
  399. content: '蓝牙断开连接',
  400. confirmText:"点击重连",
  401. showCancel:false,
  402. success: function (res) {
  403. if (res.confirm) {
  404. uni.reLaunch({
  405. url: '/pages/bluetooth/index/index'
  406. });
  407. // self.recon()
  408. } else if (res.cancel) {
  409. console.log('用户点击取消');
  410. }
  411. }
  412. });
  413. })
  414. //receive data
  415. ecBLE.onBLECharacteristicValueChange((str, strHex) => {
  416. isCheckRevHex = true;
  417. let data =
  418. (isCheckRevHex ? strHex.replace(/[0-9a-fA-F]{2}/g, ' $&') : str)
  419. // console.log(data)
  420. self.$modal.closeLoading();
  421. console.log("收到消息:"+data);
  422. //AA 67 0D 05 00 00 00 00 00 00 00 00 00 25 E2 00 80
  423. data = parseDataObj(data);
  424. self.messageCallback(data);
  425. })
  426. self.getInfo();
  427. },
  428. messageCallback(data,flag){
  429. let self = this;
  430. let type = data.type;
  431. let real_data = data.real_data;
  432. if(type == 103){
  433. self.portDetail = real_data;
  434. self.portList = [[]];
  435. self.curPort = [];
  436. let port_first_status = self.portDetail["port_first_status"];
  437. let port_second_status = self.portDetail["port_second_status"]
  438. if(port_first_status){
  439. self.portList[0].push({port:1,text:"端口一"});
  440. self.curPort.push({
  441. text:"端口一",
  442. status:port_first_status,
  443. id:1,
  444. })
  445. let power = self.portDetail.power;
  446. let voltage = parseInt(self.portDetail.voltage);
  447. if(voltage >0){
  448. let current = power/voltage;
  449. current = current.toFixed(1);
  450. self.portDetail.currentValue = current;
  451. }
  452. }
  453. if(port_second_status){
  454. self.portList[0].push({port:2,text:"端口二"});
  455. self.curPort.push({
  456. text:"端口二",
  457. status:port_second_status,
  458. id:2
  459. })
  460. let power = self.portDetail.power_1;
  461. let voltage = parseInt(self.portDetail.voltage);
  462. if(voltage >0){
  463. let current = power/voltage;
  464. current = current.toFixed(1);
  465. self.portDetail.currentValue_1 = current;
  466. }
  467. }
  468. let choosePort = self.choosePort
  469. /**
  470. * chargeTime:0,
  471. * deviceTemp:0,
  472. * deviceV:0,
  473. * currentValue:0,
  474. * gonglv:0,
  475. * dianliang:0,
  476. * portStatus:0,
  477. */
  478. if(choosePort == 1){
  479. self.portDetail.portStatus = port_first_status;
  480. self.chargeTime = self.portDetail.time;
  481. self.gonglv = self.portDetail.power;
  482. self.dianliang = self.portDetail.elec/100;
  483. self.currentValue = self.portDetail.currentValue;
  484. }else if(choosePort == 2){
  485. self.portDetail.portStatus = port_second_status;
  486. self.chargeTime = self.portDetail.time_1;
  487. self.gonglv = self.portDetail.power_1;
  488. self.dianliang = self.portDetail.elec_1/100;
  489. self.currentValue = self.portDetail.currentValue_1;
  490. }
  491. self.portStatus = self.portDetail.portStatus;
  492. self.deviceTemp = self.portDetail.dev_temper;
  493. self.deviceV = self.portDetail.voltage;
  494. self.$modal.closeLoading();
  495. }
  496. if(type == 116){
  497. self.$modal.closeLoading();
  498. self.getInfo();
  499. }
  500. if(type == 113){
  501. self.$modal.closeLoading();
  502. self.getInfo();
  503. }
  504. if(type == 96){
  505. }
  506. if(type == 253){
  507. self.$modal.closeLoading();
  508. self.uuid = real_data.substr(0,6);
  509. }
  510. self.$forceUpdate();
  511. if(!flag){
  512. console.log('收到服务器内容:' + JSON.stringify(data));
  513. }
  514. console.log("当前对象内容")
  515. console.log(self.portDetail)
  516. if(!this.firstInit){
  517. this.firstInit = true;
  518. let autoCharge = self.getAutoChargeValue()
  519. if(self.portDetail.portStatus == 5 && autoCharge == 1){
  520. self.startCharge();
  521. }
  522. }
  523. },
  524. getAutoChargeValue(){
  525. let autoCharge = uni.getStorageSync("autoCharge");
  526. if(!autoCharge ){
  527. autoCharge = 1;
  528. }
  529. return autoCharge;
  530. },
  531. planCharge(){
  532. if(this.portDetail.portStatus == 6){
  533. this.$modal.confirm("确认取消预约?").then(res=>{
  534. this.cancelPlan();
  535. })
  536. }else{
  537. this.toPlan()
  538. }
  539. },
  540. sendBlueData(){
  541. ecBLE.writeBLECharacteristicValue(tempSendData, false)
  542. },
  543. cancelPlan(){
  544. cancelPlan(this.choosePort).then(res=>{
  545. this.$modal.msg("取消成功");
  546. this.getInfo(true);
  547. })
  548. },
  549. getPlanInfo(){
  550. getPlanInfo(this.deviceInfo.deviceId,this.choosePort).then(res=>{
  551. let data = res.data;
  552. if(data != null){
  553. let planType = data.planType;
  554. if(planType == 1){//单次预约
  555. let planInfo = {};
  556. planInfo.runTime = data.runTime;
  557. this.planInfo = planInfo;
  558. this.planInfo.id = data.id;
  559. }else{
  560. let planInfo = {};
  561. planInfo.runTime = data.runTime;
  562. let repeatDays = data.repeatDays;
  563. let days = repeatDays.split(",")
  564. let strs = "";
  565. for (let i = 0; i < days.length; i++) {
  566. if(strs.length>0){
  567. strs+=",";
  568. }
  569. strs +=this.days[days[i]];
  570. }
  571. this.planInfo = planInfo;
  572. this.planInfo.runTime = strs+" "+data.repeatTime;
  573. this.planInfo.id = data.id;
  574. }
  575. }
  576. })
  577. },
  578. confirmPort(e){
  579. let value = e.value[0]
  580. this.choosePort = value.port;
  581. this.showPort = false;
  582. this.getInfo()
  583. },
  584. initSocket(key){
  585. let self = this;
  586. },
  587. toSet(){
  588. // this.closeSocket();
  589. uni.navigateTo({
  590. url: '/pages/weitiandi/bluetooth/setting'
  591. });
  592. },
  593. toPlan(){
  594. let arr = [];
  595. let date = new Date();
  596. let min = date.getMinutes();
  597. let hour = date.getHours();
  598. let arr1 = ["今日", "明日"];
  599. let arr2 = []
  600. let arr3 = [];
  601. let arr4 = [];
  602. for (let i = 0; i < hour; i++) {
  603. arr2.push(i+"时")
  604. }
  605. this.columnData[0] = arr2;
  606. for (let i = hour+1; i < 24; i++) {
  607. arr3.push(i+"时")
  608. }
  609. this.columnData[1] = arr3;
  610. for (let i = 0; i <= 59; i++) {
  611. arr4.push(i+"分")
  612. }
  613. this.planCols = [arr1, arr3, arr4]
  614. this.showPlan = true;
  615. },
  616. trigger(){
  617. let portStatus = this.portDetail.portStatus;
  618. if(portStatus == 2){//需要停止充电
  619. this.$modal.confirm("需要停止充电么?").then(res=>{
  620. this.stopCharge();
  621. })
  622. }else{
  623. if(portStatus == 1){
  624. this.$modal.msg("请先将充电枪插入后再点击充电");
  625. }
  626. if(portStatus == 5){
  627. this.$modal.confirm("确认开始充电么?").then(res=>{
  628. this.startCharge();
  629. })
  630. }else {
  631. this.$modal.msg("端口无法开始充电");
  632. }
  633. }
  634. },
  635. getInfo(flag) {
  636. let self = this;
  637. // setTimeout(function (){
  638. // self.messageCallback({"type":103,"real_data":{"port_first_status":1,"power":0,"elec":0,"money":0,"time":0,"port_second_status":2,"power_1":0,"elec_1":3,"money_1":50000,"time_1":367,"dev_temper":17,"voltage":228,"":249,"portStatus":1,"currentValue":"0.0"}})
  639. //
  640. // },50);
  641. //
  642. // setTimeout(function (){
  643. // self.messageCallback({"type":103,"real_data":{"port_first_status":1,"power":0,"elec":0,"money":0,"time":0,"port_second_status":2,"power_1":0,"elec_1":3,"money_1":50000,"time_1":367,"dev_temper":17,"voltage":228,"":249,"portStatus":1,"currentValue":"0.0"}})
  644. //
  645. // },150);
  646. //
  647. // setTimeout(function (){
  648. // self.messageCallback({"type":103,"real_data":{"port_first_status":1,"power":0,"elec":0,"money":0,"time":0,"port_second_status":2,"power_1":0,"elec_1":3,"money_1":50000,"time_1":367,"dev_temper":17,"voltage":228,"":249,"portStatus":1,"currentValue":"0.0"}})
  649. //
  650. // },250);
  651. this.$modal.loading("正在获取状态,请稍等...");
  652. if(flag){
  653. setTimeout(function (){
  654. sendPortDetailCmd().then(res => {
  655. })
  656. },500)
  657. }else{
  658. sendPortDetailCmd().then(res => {
  659. })
  660. }
  661. },
  662. stopCharge(){
  663. let self = this;
  664. this.deviceInfo.port = this.choosePort;
  665. stopCharge(this.deviceInfo).then(()=>{
  666. self.$modal.loading("停止成功");
  667. setTimeout((()=>{
  668. self.getInfo();
  669. }),1000);
  670. })
  671. },
  672. startCharge(){
  673. let self = this;
  674. this.deviceInfo.port = this.choosePort;
  675. startCharge(this.deviceInfo).then(res=>{
  676. self.$modal.loading("启动成功");
  677. setTimeout((()=>{
  678. self.getInfo();
  679. }),1000);
  680. })
  681. },
  682. getPortInfo(){
  683. this.startPortDetailTimer();
  684. },
  685. startPortDetailTimer(){
  686. let self = this;
  687. this.timer = setTimeout(function (){
  688. getPortDetail(self.deviceInfo,self.visitTime).then(res=>{
  689. let data = res.data;
  690. if(data != null){
  691. self.portDetail = data;
  692. self.checkStatusCheck();
  693. self.$modal.closeLoading();
  694. }else{
  695. self.startPortDetailTimer();
  696. }
  697. });
  698. },1000);
  699. },
  700. checkStatusCheck(){
  701. this.statusChangeTimer();
  702. },
  703. checkOnPage(){
  704. var pages = getCurrentPages() // 获取栈实例
  705. let currentRoute = pages[pages.length - 1].route; // 获取当前页面路由
  706. if("pages/weitiandi/device/index" != currentRoute){
  707. return false;
  708. }
  709. return true;
  710. },
  711. goBack(){
  712. this.closeSocket();
  713. uni.navigateBack({
  714. });
  715. },
  716. closeSocket(){
  717. ecBLE.onBLEConnectionStateChange(() => {})
  718. ecBLE.onBLECharacteristicValueChange(() => {})
  719. ecBLE.closeBLEConnection()
  720. uni.removeStorageSync('blueid');
  721. },
  722. statusChangeTimer(){
  723. let self = this;
  724. this.statusTimer = setTimeout(function(){
  725. if(!this.checkOnPage()){
  726. return;
  727. }
  728. checkStatusChange(self.deviceInfo,self.visitTime).then(res=>{
  729. let data = res.data;
  730. if(data != null){
  731. self.getInfo();
  732. }else{
  733. self.statusChangeTimer();
  734. }
  735. });
  736. },3000);
  737. }
  738. }
  739. }
  740. </script>
  741. <style>
  742. .container {
  743. background: rgb(249, 252, 255);
  744. inset: 0;
  745. position: absolute;
  746. }
  747. .header {
  748. position: relative;
  749. margin-top:4vw;
  750. }
  751. .header-status-desc {
  752. position: absolute;
  753. text-align: center;
  754. width: 100%;
  755. bottom:1vh;
  756. font-size: 5vw;
  757. font-weight: bold;
  758. color: #0E9F9B;
  759. margin-bottom: 5vw;
  760. }
  761. .header-status {
  762. font-weight: bold;
  763. text-align: center;
  764. }
  765. .chong-active {
  766. color: #0E9F9B
  767. }
  768. .header-img {
  769. width: 100%;
  770. padding: 5% 10%;
  771. text-align: center;
  772. }
  773. .header-img image {
  774. width: 100%;
  775. height: 23vh;
  776. }
  777. .info-body{
  778. background: #0E9F9B;
  779. height: 20vh;
  780. margin: 0 2%;
  781. border-radius: 1vw;
  782. margin-top:2vh;
  783. color: #F8FCFF;
  784. line-height: 3vh;
  785. }
  786. .info-content{
  787. display: inline-block;
  788. width: 23%;
  789. text-align: center;
  790. margin: 1%;
  791. margin-top:2.5vh;
  792. }
  793. .info-content-value{
  794. font-weight: bold;
  795. }
  796. .info-content-text{
  797. }
  798. .info-summary{
  799. display: flex;
  800. flex-direction: row;
  801. text-align: center;
  802. margin:3vh 0;
  803. }
  804. .summary{
  805. width: 33%;
  806. line-height: 2.5vh;
  807. }
  808. .charge-num{
  809. color: #0E9F9B;
  810. font-weight: bold;
  811. font-size: 4.5vw;
  812. }
  813. .charge-title{
  814. color: #B2B2B2;
  815. font-weight: 400;
  816. }
  817. .btn-image{
  818. width: 90%;
  819. height: 100%;
  820. }
  821. .info-bottom-btn{
  822. display: flex;
  823. flex-direction: row;
  824. text-align: center;
  825. position: relative;
  826. margin-top: 10vh
  827. ;
  828. }
  829. .btn-area{
  830. width: 50%;
  831. height: 50px;
  832. }
  833. .left{
  834. position: relative;
  835. left: 10px;
  836. text-align: right;
  837. }
  838. .right{
  839. text-align: left;
  840. position: relative;
  841. right: 10px;
  842. }
  843. .info-plan{
  844. text-align: center;
  845. color: #0E9F9B;
  846. margin-top:1vh;
  847. font-weight: 400;
  848. }
  849. .setting{
  850. position: fixed;
  851. right: -1px;
  852. top: 10vh;
  853. z-index: 999;
  854. background: rgb(227,243,245);
  855. color: #0E9F9B;
  856. font-size: 10px;
  857. border-radius: 5px;
  858. padding: 3px;
  859. }
  860. .port{
  861. height: 70px;
  862. background: #F8FCFF;
  863. border: 0px solid #F8FCFF;
  864. box-shadow: 0px 0px 6px 1px rgba(101,101,101,0.29);
  865. border-radius: 4px;
  866. margin:0 10px;
  867. position: relative;
  868. margin-top:10px;
  869. }
  870. .plan{
  871. height: 70px;
  872. background: #F8FCFF;
  873. border: 0px solid #F8FCFF;
  874. box-shadow: 0px 0px 6px 1px rgba(101,101,101,0.29);
  875. border-radius: 4px;
  876. margin:0 10px;
  877. position: relative;
  878. margin-top:15px;
  879. }
  880. .port-image{
  881. height: 40px;
  882. width: 40px;
  883. position: absolute;
  884. top:15px;
  885. left:20px;
  886. }
  887. .port-text{
  888. position: absolute;
  889. top:13px;
  890. left:75px;
  891. font-weight: bold;
  892. }
  893. .port-num{
  894. position: absolute;
  895. top:38px;
  896. left:75px;
  897. color: #B2B2B2;
  898. }
  899. .port-icon{
  900. position: absolute;
  901. top:30px;
  902. right:5px;
  903. width: 10px;
  904. height: 16px;
  905. }
  906. .port-icon image{
  907. width: 90%;
  908. }
  909. .body-bottom{
  910. padding:0 22px;
  911. }
  912. .body-bottom .info-content{
  913. width: 30%;
  914. }
  915. .bottom-control{
  916. height: 22vh;
  917. margin: 0 2%;
  918. margin-top:2vh;
  919. line-height: 3vh;
  920. background: #F8FCFF;
  921. border: 0px solid #F8FCFF;
  922. box-shadow: 0px 0px 6px 1px rgba(101,101,101,0.29);
  923. border-radius: 4px;
  924. padding:3%;
  925. }
  926. .control-btn{
  927. display: inline-block;;
  928. height: 60px;
  929. width: 25%;
  930. padding:10px 20px;
  931. text-align: center;
  932. font-size: 12px;
  933. color: black;
  934. }
  935. .control-btn .btn-image{
  936. }
  937. #box {
  938. /* width: 300px; */
  939. height: 280px;
  940. position: relative;
  941. /* 背景色 */
  942. /* background: #f7f6f6; */
  943. overflow: hidden;
  944. /* padding: 50px 0; */
  945. box-sizing: border-box;
  946. ;
  947. }
  948. .box {
  949. width: 100%;
  950. height: 100%;
  951. position: absolute;
  952. display: flex;
  953. justify-content: center;
  954. /* 此处尽量不要设置背景色,可以选择在父标签上设置背景色,否则没有黏黏的效果 */
  955. filter: url("#goo");
  956. }
  957. /* 电量文字 */
  958. .text {
  959. font-weight: 200;
  960. font-size: 20px;
  961. margin-top: 5px;
  962. text-align: center;
  963. color: #ff6600;
  964. }
  965. /* 电量文字 */
  966. .text span {
  967. font-size: 15px;
  968. }
  969. .three {
  970. width: 170px;
  971. height: 170px;
  972. border-radius: 300px;
  973. opacity: 1;
  974. position: absolute;
  975. top: 20px;
  976. z-index: 10;
  977. /* 从中心向外剪切圆,相当于掏空 */
  978. /* -webkit-mask: radial-gradient(transparent 95px, white 0px); */
  979. background: #ffffff;
  980. /* animation: ballZhuan 9s linear infinite; */
  981. overflow: hidden;
  982. box-shadow: 0px 0px 19px 1px #2196f3;
  983. }
  984. .four {
  985. width: 200px;
  986. height: 200px;
  987. border-radius: 80px;
  988. opacity: 0.3;
  989. position: absolute;
  990. top: 10px;
  991. z-index: 10;
  992. /* 从中心向外剪切圆,相当于掏空 */
  993. /* -webkit-mask: radial-gradient(transparent 95px, white 0px); */
  994. background: #2196f3;
  995. animation: ballZhuan1 linear infinite;
  996. animation-duration: 11s;
  997. }
  998. .five {
  999. width: 270px;
  1000. height: 270px;
  1001. border-radius: 99px;
  1002. opacity: 0.6;
  1003. position: absolute;
  1004. top: 30px;
  1005. z-index: 10;
  1006. /* 从中心向外剪切圆,相当于掏空 */
  1007. /* -webkit-mask: radial-gradient(transparent 95px, white 0px); */
  1008. background: #2196f3;
  1009. animation: ballZhuan1 linear infinite;
  1010. /* transform: rotate(120deg); */
  1011. animation-duration: 9s;
  1012. left: -67px;
  1013. }
  1014. .six {
  1015. width: 270px;
  1016. height: 270px;
  1017. border-radius: 99px;
  1018. opacity: 0.6;
  1019. position: absolute;
  1020. top:30px;
  1021. z-index: 10;
  1022. /* 从中心向外剪切圆,相当于掏空 */
  1023. /* -webkit-mask: radial-gradient(transparent 95px, white 0px); */
  1024. background: #2196f3;
  1025. animation: ballZhuan1 7s linear infinite;
  1026. /* transform: rotate(120deg); */
  1027. right: -67px;
  1028. }
  1029. @keyframes ballZhuan {
  1030. 100% {
  1031. transform: rotate(360deg);
  1032. }
  1033. }
  1034. @keyframes ballZhuan1 {
  1035. 100% {
  1036. transform: rotate(360deg);
  1037. }
  1038. }
  1039. /* 底部的小球 */
  1040. .dot {
  1041. display: block;
  1042. width: 20px;
  1043. height: 20px;
  1044. border-radius: 50%;
  1045. background: rgba(101,192,255,0.28);
  1046. position: absolute;
  1047. z-index: 1000;
  1048. bottom: -50px;
  1049. }
  1050. .dot:nth-of-type(1) {
  1051. width: 40px;
  1052. height: 40px;
  1053. right: 116px;
  1054. animation: dotMove 5s linear infinite;
  1055. }
  1056. .dot:nth-of-type(2) {
  1057. width: 50px;
  1058. height: 50px;
  1059. left: 120px;
  1060. animation: dotMove 4s linear infinite;
  1061. }
  1062. .dot:nth-of-type(3) {
  1063. animation: dotMove 2s linear infinite;
  1064. }
  1065. .dot:nth-of-type(4) {
  1066. width: 15px;
  1067. height: 15px;
  1068. left: 130px;
  1069. animation: dotMove 2s linear infinite;
  1070. }
  1071. .dot:nth-of-type(5) {
  1072. width: 30px;
  1073. height: 30px;
  1074. animation: dotMove 3s linear infinite;
  1075. }
  1076. @keyframes dotMove {
  1077. 0% {
  1078. transform: translateY(0px);
  1079. opacity: 1;
  1080. }
  1081. 98% {
  1082. opacity: 1;
  1083. }
  1084. 100% {
  1085. transform: translateY(-260px);
  1086. opacity: 0;
  1087. }
  1088. }
  1089. .w-flex {
  1090. display: -webkit-box;
  1091. display: -webkit-flex;
  1092. display: flex;
  1093. padding: 0px 25px;
  1094. }
  1095. .w-flex__item {
  1096. -webkit-box-flex: 1;
  1097. -webkit-flex: 1;
  1098. flex: 1;
  1099. }
  1100. .w-item{
  1101. text-align: center;
  1102. padding: 5px;
  1103. }
  1104. .w-item-tit{
  1105. font-size: 14px;
  1106. color: #888;
  1107. }
  1108. .w-item-num{
  1109. font-size: 18px;
  1110. color: #111;
  1111. }
  1112. .can{
  1113. position: relative;
  1114. z-index: 0;
  1115. width: 211px;
  1116. height: 211px;
  1117. background-image: url(/static/images/new/quan.png);
  1118. background-size: cover;
  1119. display: flex;
  1120. justify-content: center;
  1121. align-items: center;
  1122. }
  1123. .dtop{
  1124. background: url(/static/images/new/box1.png);
  1125. background-size: cover;
  1126. width: 260px;
  1127. height: 236px;
  1128. display: flex;
  1129. justify-content: center;
  1130. align-items: center;
  1131. left: 15%;
  1132. position: relative;
  1133. }
  1134. .dstatus{
  1135. margin-top: 0.1rem;
  1136. display: flex;
  1137. flex-wrap: wrap;
  1138. justify-content: space-evenly;
  1139. align-content: center;
  1140. }
  1141. .ditem{
  1142. width: 30%;
  1143. display: flex;
  1144. flex-direction: column;
  1145. align-items: center;
  1146. margin-bottom: 0.3rem;
  1147. margin-top: 10px;
  1148. }
  1149. .itemimg{
  1150. width: 50px;
  1151. height: 50px;
  1152. }
  1153. .item-value{
  1154. font-weight: bold;
  1155. font-size: 19px;
  1156. margin:4px 0;
  1157. }
  1158. .item-text{
  1159. font-size: 13px;
  1160. margin:1px 0;
  1161. color: #999999;
  1162. }
  1163. .start{
  1164. background: #1A87FF;
  1165. color: #fff;
  1166. width: 45%;
  1167. height: 50px;
  1168. min-height: 40px;
  1169. border-radius: 50px;
  1170. display: flex;
  1171. justify-content: center;
  1172. align-items: center;
  1173. font-size: 20px;
  1174. font-weight: bold;
  1175. }
  1176. .dbtns{
  1177. display: flex;
  1178. margin-top:10px;
  1179. justify-content: space-between;
  1180. padding: 0 30px;
  1181. }
  1182. .get{
  1183. background: #fff;
  1184. border: 1px solid #1A87FF;
  1185. color: #1A87FF;
  1186. width: 45%;
  1187. height: 50px;
  1188. min-height: 40px;
  1189. border-radius: 50px;
  1190. display: flex;
  1191. justify-content: center;
  1192. align-items: center;
  1193. font-size: 20px;
  1194. font-weight: bold;
  1195. }
  1196. .dtip{
  1197. margin: 20px 20px;
  1198. padding: 10px;
  1199. background: rgba(127,200,251,0.1);
  1200. border: 1px solid #7FC8FB;
  1201. box-shadow: 0 2px 8px 0 rgba(0,0,0,0.19);
  1202. border-radius: 5px;
  1203. font-size: 17px;
  1204. font-weight: 400;
  1205. color: #B8B9BA;
  1206. margin-bottom: 10px;
  1207. }
  1208. .p1{
  1209. font-size: 20px;
  1210. color: white;
  1211. font-weight: bold;
  1212. margin-top:10px;
  1213. }
  1214. .stip{
  1215. text-align: center;
  1216. z-index: 9999;
  1217. }
  1218. .port_item{
  1219. color: #1A87FF;
  1220. padding: 5px;
  1221. border: 1px solid #1A87FF;
  1222. }
  1223. .selected_item{
  1224. color: white !important;
  1225. padding: 5px;
  1226. background: #1A87FF !important;
  1227. }
  1228. </style>