status.vue 30 KB

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