status.vue 29 KB

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