status.vue 29 KB

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