status.vue 29 KB

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