status.vue 33 KB

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