index.vue 29 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036
  1. <template>
  2. <view class="container">
  3. <!-- <view class="dboxs dport">
  4. <view class="dboxtitle"><image class="portimg" src="/static/images/new/start/port.png"/>
  5. <view class="dboxtitle-text"> {{ i18('设备端口') }}</view>
  6. </view>
  7. <view class="dportitems">
  8. <view class="dportitem " v-for="item in curPort" @click="selectPort(item.id);">
  9. <p class="dpropitem-title "> {{ i18(item.text )}}</p>
  10. <view style="position: absolute;right: 0px;z-index: 9999" v-if="item.id == choosePort">
  11. <image class="dportitem-img" style="width: 15px;height: 15px" src="/static/images/new/start/choose.png"/>
  12. </view>
  13. <view class="dpropitem-block dportitem-block-2" v-if="item.status == 2">
  14. <image class="dportitem-img" src="/static/images/new/start/using.png"/>
  15. <view class="dpropitem-status">{{ i18('充电中') }}</view>
  16. </view>
  17. <view class="dpropitem-block dportitem-block-1" v-if="item.status == 1 || item.status == 7">
  18. <image class="dportitem-img" src="/static/images/new/start/free.png"/>
  19. <view class="dpropitem-status">{{ i18('空闲中') }}</view>
  20. </view>
  21. <view class="dpropitem-block dportitem-block-3" style="background: rgb(247,238,240);color:#FF6868" v-if="item.status == 3">
  22. <image class="dportitem-img" src="/static/images/new/start/ban.png"/>
  23. <view class="dpropitem-status">{{ i18('禁用中') }}</view>
  24. </view>
  25. <view class="dpropitem-block dportitem-block-3" style="background: rgb(248,244,230);color:#FFAA00" v-if="item.status == 4">
  26. <image class="dportitem-img" src="/static/images/new/start/bad.png"/>
  27. <view class="dpropitem-status">{{ i18('故障中') }}</view>
  28. </view>
  29. <view class="dpropitem-block dportitem-block-3" style=";" v-if="item.status == 5">
  30. <image class="dportitem-img" src="/static/images/new/start/lianjie.png"/>
  31. <view class="dpropitem-status">{{ i18('已连接') }}</view>
  32. </view>
  33. <view class="dpropitem-block dportitem-block-3" style="background: rgb(239,235,254);color:#A552FF" v-if="item.status == 6">
  34. <image class="dportitem-img" src="/static/images/new/start/yuyue.png"/>
  35. <view class="dpropitem-status">{{ i18('已预约') }}</view>
  36. </view>
  37. </view>
  38. </view>
  39. </view>
  40. <view class="dboxs dport" style="height: 100px" @click="planCharge">
  41. <view class="dboxtitle"><image class="portimg" src="/static/images/new/start/clock.png"/>
  42. <view class="dboxtitle-text">{{ i18('预约充电') }}</view>
  43. </view>
  44. <view class="port-text" v-if="planInfo != null" style="left:40px;top:48px;font-size: 14px">
  45. {{ i18('已预约') }} <view class="port-text" style="top:30px;">
  46. <text style="font-size: 10px">{{ planInfo.runTime }}</text>
  47. </view>
  48. </view>
  49. <view class="port-text" style="left:40px;top:55px;font-size: 14px" v-else>
  50. {{ i18('点击预约充电') }}
  51. </view>
  52. <view class="port-num" style="left:40px;top:70px;font-size: 12px" v-if="portDetail.portStatus == 6">
  53. {{ i18('可点击取消预约') }}
  54. </view>
  55. <view class="port-icon" v-if="portDetail.portStatus !=6" style="width: 50px;height: 50px;right:10px;top:28%">
  56. <image class="btn-image" src="/static/images/new/start/clock.png" >
  57. </image>
  58. </view>
  59. <view class="port-icon" v-if="portDetail.portStatus == 6" style="width: 50px;height: 50px;right:10px;top:28%">
  60. <image class="btn-image" src="/static/images/new/start/del.png" >
  61. </image>
  62. </view>
  63. </view>
  64. <u-picker @cancel="showPort=false" @confirm="confirmPort" :show="showPort" :columns="portList" keyName="text"></u-picker>
  65. <view class="dboxs dport" style="height: 200px">
  66. <view class="dboxtitle"><image class="portimg" src="/static/images/new/start/oper.png"/>
  67. <view class="dboxtitle-text"> {{ i18('设备操作') }}</view>
  68. </view>
  69. <view class="control-btn" @click="trigger()" v-if="portDetail.portStatus == 2">
  70. <image class="btn-image" src="/static/images/new/start/stop.png" >
  71. </image>
  72. <view>{{ i18('停止充电') }}</view>
  73. </view>
  74. <view class="control-btn" @click="trigger()" v-if="portDetail.portStatus != 2">
  75. <image class="btn-image" src="/static/images/new/start/using.png" >
  76. </image>
  77. <view>{{ i18('立即充电') }}</view>
  78. </view>
  79. <view class="control-btn" @click="getInfo">
  80. <image class="btn-image" src="/static/images/new/start/get.png" >
  81. </image>
  82. <view>{{ i18('获取状态') }}</view>
  83. </view>
  84. <view class="control-btn" @click="toSet">
  85. <image class="btn-image" src="/static/images/new/start/oper.png" >
  86. </image>
  87. <view>{{ i18('设备控制') }}</view>
  88. </view>
  89. <view class="control-btn" @click="goBack">
  90. <image class="btn-image" src="/static/images/new/start/back.png" >
  91. </image>
  92. <view>{{ i18('查看状态') }}</view>
  93. </view>
  94. <view class="control-btn" @click="restart">
  95. <image class="btn-image" src="/static/images/new/start/reset.png" >
  96. </image>
  97. <view>{{ i18('重置设备') }}</view>
  98. </view> -->
  99. <view class="dboxs dport">
  100. <view class="dboxtitle">
  101. <image class="portimg" src="../../../static/images/new/starts/mine/symbol (1).png" />
  102. <view class="dboxtitle-text"> {{ i18('设备端口') }}</view>
  103. </view>
  104. <view class="dportitems">
  105. <view class="dportitem " v-for="item in curPort" @click="selectPort(item.id);">
  106. <p class="dpropitem-title "> {{ item.text }}</p>
  107. <view style="position: absolute;right: 0px;z-index: 9999" v-if="item.id == choosePort">
  108. <image class="dportitem-img" style="width: 15px;height: 15px"
  109. src="/static/images/new/start/choose.png" />
  110. </view>
  111. <view class="dpropitem-block dportitem-block-2" v-if="item.status == 2">
  112. <image class="dportitem-img" src="/static/images/new/starts/charnging.png" />
  113. <view class="dpropitem-status">{{ i18('充电中') }}</view>
  114. </view>
  115. <view class="dpropitem-block dportitem-block-1" v-if="item.status == 1 || item.status == 7">
  116. <image class="dportitem-img" src="/static/images/new/starts/free.png" />
  117. <view class="dpropitem-status">{{ i18('空闲中') }}</view>
  118. </view>
  119. <view class="dpropitem-block dportitem-block-3" style="background: rgb(247,238,240);color:#FF6868"
  120. v-if="item.status == 3">
  121. <image class="dportitem-img" src="/static/images/new/starts/ban.png" />
  122. <view class="dpropitem-status">{{ i18('禁用中') }}</view>
  123. </view>
  124. <view class="dpropitem-block dportitem-block-3" style="background: rgb(248,244,230);color:#FFAA00"
  125. v-if="item.status == 4">
  126. <image class="dportitem-img" src="/static/images/new/starts/bad.png" />
  127. <view class="dpropitem-status">{{ i18('故障中') }}</view>
  128. </view>
  129. <view class="dpropitem-block dportitem-block-3" style=";" v-if="item.status == 5">
  130. <image class="dportitem-img" src="/static/images/new/port.png" />
  131. <view class="dpropitem-status">{{ i18('已连接') }}</view>
  132. </view>
  133. <view class="dpropitem-block dportitem-block-3" style="background: rgb(239,235,254);color:#A552FF"
  134. v-if="item.status == 6">
  135. <image class="dportitem-img" src="/static/images/new/start/yuyue.png" />
  136. <view class="dpropitem-status">{{ i18('已预约') }}</view>
  137. </view>
  138. </view>
  139. </view>
  140. </view>
  141. <view class="dboxs dport" style="height: 100px" @click="planCharge">
  142. <view class="dboxtitle">
  143. <image class="portimg" src="../../../static/images/new/starts/index/yuyue.png" />
  144. <view class="dboxtitle-text">{{ i18('预约充电') }}</view>
  145. </view>
  146. <view class="port-text" v-if="planInfo != null" style="left:40px;top:48px;font-size: 14px">
  147. {{ i18('已预约') }} {{planInfo.runTime}}
  148. </view>
  149. <view class="port-text" style="left:40px;top:55px;font-size: 14px" v-else>
  150. {{ i18('点击预约充电') }}
  151. </view>
  152. <view class="port-num" style="left:40px;top:70px;font-size: 12px" v-if="planInfo != null">
  153. {{ i18('可点击取消预约') }}
  154. </view>
  155. <!-- <view class="port-icon" v-if="planInfo == null" style="width: 50px;height: 50px;right:10px;top:28%">
  156. <image class="btn-image" src="../../../static/images/new/starts/index/yuyue.png">
  157. </image>
  158. </view>
  159. <view class="port-icon" v-if="planInfo != null" style="width: 50px;height: 50px;right:10px;top:28%">
  160. <image class="btn-image" src="/static/images/new/start/del.png">
  161. </image>
  162. </view> -->
  163. </view>
  164. <view class="dboxs dport" style="height: 200px">
  165. <view class="dboxtitle">
  166. <image class="portimg" src="/static/images/new/starts/mine/list.png" />
  167. <view class="dboxtitle-text"> {{ i18('设备操作') }}</view>
  168. </view>
  169. <view class="control-btn" @click="trigger()" v-if="portDetail.portStatus == 2">
  170. <image class="btn-image" src="/static/images/new/start/stop.png">
  171. </image>
  172. <view>{{ i18('停止充电') }}</view>
  173. </view>
  174. <view class="control-btn" @click="trigger()" v-if="portDetail.portStatus != 2">
  175. <image class="btn-image" src="/static/images/new/starts/index/using.png">
  176. </image>
  177. <view>{{ i18('立即充电') }}</view>
  178. </view>
  179. <view class="control-btn" @click="getInfo">
  180. <image class="btn-image" src="../../../static/images/new/starts/index/icon_pull.png">
  181. </image>
  182. <view>{{ i18('获取状态') }}</view>
  183. </view>
  184. <view class="control-btn" @click="toSet">
  185. <image class="btn-image" src="../../../static/images/new/starts/index/list.png">
  186. </image>
  187. <view>{{ i18('设备控制') }}</view>
  188. </view>
  189. <!-- <view class="control-btn" @click="goBack">
  190. <image class="btn-image" src="../../../static/images/new/starts/index/return.png">
  191. </image>
  192. <view>{{ i18('查看状态') }}</view>
  193. </view> -->
  194. <view class="control-btn" @click="restart">
  195. <image class="btn-image" src="/static/images/new/starts/index/return.png">
  196. </image>
  197. <view>{{ i18('重置设备') }}</view>
  198. </view>
  199. <!-- <view class="control-btn">-->
  200. <!-- <image class="btn-image" :src="imgUrl+'/control/record.png'" >-->
  201. <!-- </image>-->
  202. <!-- <view>使用记录</view>-->
  203. <!-- </view>-->
  204. </view>
  205. <u-picker ref="uPicker" @cancel="cancelPicker" @confirm="confirm" :show="showPlan" :columns="planCols" @change="changeHandler"></u-picker>
  206. <u-modal :show="showPwd" :confirmText="i18('确认')" @confirm="inputPwd" @cancel="cancel" :showCancelButton="true" title="修改密码" >
  207. <view class="slot-content">
  208. <view>
  209. <u--input
  210. type="number"
  211. :placeholder="i18('原密码')"
  212. border="surround"
  213. v-model="oldPwd"
  214. ></u--input>
  215. </view>
  216. <view style="margin-top:5px">
  217. <u--input
  218. type="number"
  219. :placeholder="i18('6位数字新密码')"
  220. border="surround"
  221. v-model="pwd"
  222. ></u--input>
  223. </view>
  224. </view>
  225. </u-modal>
  226. </view>
  227. </template>
  228. <script>
  229. import { restart,getDeviceInfo,getPortDetail,startCharge,stopCharge,sendPortDetailCmd,checkStatusChange,getPlanInfo,cancelPlan,parseDataObj,planCharge,getPwd,setPwd} from "@/utils/weitiandi/device/device.js";
  230. // #ifdef APP
  231. import ecUI from '@/utils/ecUI.js'
  232. import ecBLE from '@/utils/ecBLE/ecBLE.js'
  233. // #endif
  234. // #ifdef MP
  235. const ecUI = require('@/utils/ecUI.js')
  236. const ecBLE = require('@/utils/ecBLE/ecBLE.js')
  237. // #endif
  238. import i18 from '@/utils/i18.js'
  239. let ctx
  240. let isCheckScroll = true
  241. let isCheckRevHex = false
  242. let isCheckSendHex = false
  243. let sendData = ''
  244. export default {
  245. data() {
  246. return {
  247. oldPwd:"",
  248. pwd:"",
  249. showPwd:false,
  250. planCols:[ ],
  251. columnData:[],
  252. showPlan:false,
  253. deviceInfo:{},
  254. visitTime:"",
  255. timer:null,
  256. showPort:false,
  257. portDetail:{portStatus:0,POWER:0,voltage:0},
  258. statusTimer:"",
  259. connected:false,
  260. scriptTask:null,
  261. choosePort:1,
  262. portList:[[{port:1,text:"端口一"}]],
  263. planInfo:null,
  264. days:["","周一","周二","周三","周四","周五","周六","周日"],
  265. textRevData: '',
  266. picker:null,
  267. firstInit:false,
  268. hasRight:false,
  269. startAutoCharge:true,
  270. curPort:[]
  271. }
  272. },
  273. computed: {
  274. imgUrl() {
  275. return getApp().globalData.config.imgUrl;
  276. }
  277. },
  278. onLoad(opt) {
  279. this.deviceInfo.deviceId = opt.id;
  280. this.deviceInfo.ccid = opt.ccid;
  281. this.deviceInfo.qrcode = opt.qrcode;
  282. this.checkPassword();
  283. },
  284. onShow(){
  285. uni.setNavigationBarTitle({
  286. title: this.$t('page.control')
  287. })
  288. this.buletooth();
  289. },
  290. onUnload (){
  291. this.closeSocket();
  292. },
  293. methods: {
  294. restart(){
  295. let self = this;
  296. this.$modal.loading("正在重置,请稍等...");
  297. restart().then(res => {
  298. setTimeout(function(){
  299. self.getInfo();
  300. },5000)
  301. })
  302. setTimeout(function (){
  303. self.$modal.loading("正在重置,请稍等...");
  304. },1000);
  305. },
  306. i18(text){
  307. return i18(text)
  308. },
  309. selectPort(id){
  310. this.choosePort = id;
  311. console.log(this.choosePort)
  312. this.getInfo();
  313. },
  314. cancel(){
  315. this.showPwd = false;
  316. },
  317. modifyPwd(){
  318. this.showPwd = true;
  319. },
  320. inputPwd(){
  321. let rightPwd = uni.getStorageSync("pwd");
  322. if(!this.oldPwd){
  323. this.$modal.showToast("原密码不能为空");
  324. return;
  325. }
  326. if(rightPwd != this.oldPwd){
  327. this.$modal.showToast("原密码不对");
  328. return;
  329. }
  330. if(!this.pwd){
  331. this.$modal.showToast("密码不能为空");
  332. }else {
  333. setPwd(this.pwd);
  334. this.$modal.showToast("密码修改成功");
  335. this.goBack();
  336. }
  337. },
  338. confirm(e) {
  339. if(this.portDetail.portStatus == 7){
  340. this.$modal.showToast("当前无法预约。请再次插枪后操作");
  341. return;
  342. }
  343. let value = e.value;
  344. console.log('confirm', value)
  345. let day = value[0];
  346. let date = new Date();
  347. let nowDay = date.getDate();
  348. let hour = value[1]+"";
  349. hour = parseInt(hour,10);
  350. let min = value[2]+"";
  351. min = parseInt(min,10);
  352. let todayTotalMin = 0;
  353. let planDate = {min:min,hour:hour};
  354. let nowHour = date.getHours();
  355. let nowMin = date.getMinutes();
  356. let nowDate ={min:nowMin,hour:nowHour};
  357. if(i18("今日") == day){
  358. todayTotalMin = this.getGapMin(planDate,nowDate)
  359. }else {
  360. let nowHour = date.getHours();
  361. let min = date.getMinutes();
  362. let maxDate ={min:59,hour:23};
  363. todayTotalMin = this.getGapMin(maxDate,nowDate);
  364. let minDate = {min:0,hour:0};
  365. todayTotalMin +=this.getGapMin(planDate,minDate);
  366. }
  367. console.log(todayTotalMin);
  368. this.cancelPicker();
  369. if(todayTotalMin<=0 || todayTotalMin>1440){
  370. this.$modal.showToast("最大预约时间为24小时");
  371. }else{
  372. planCharge(this.choosePort,todayTotalMin).then(res=>{
  373. this.getInfo(true);
  374. });
  375. }
  376. },
  377. getGapMin(date1,date2){
  378. let min1 = date1.min;
  379. let hour1 = date1.hour;
  380. let min2 = date2.min;
  381. let hour2 = date2.hour;
  382. let total1 = min1+hour1*60;
  383. let total2 = min2+hour2*60;
  384. return total1-total2;
  385. },
  386. cancelPicker(e) {
  387. this.showPlan = false
  388. },
  389. changeHandler(e){
  390. const {
  391. columnIndex,
  392. value,
  393. values, // values为当前变化列的数组内容
  394. index,
  395. // 微信小程序无法将picker实例传出来,只能通过ref操作
  396. picker = this.$refs.uPicker
  397. } = e
  398. let day = e.value[0];
  399. // 当第一列值发生变化时,变化第二列(后一列)对应的选项
  400. this.picker = picker;
  401. if (columnIndex === 0) {
  402. // picker为选择器this实例,变化第二列对应的选项
  403. if(day == i18("今日")){
  404. picker.setColumnValues(1, this.columnData[1])
  405. }else{
  406. picker.setColumnValues(1, this.columnData[0])
  407. }
  408. }
  409. },
  410. checkPassword(){
  411. },
  412. recon(){
  413. let self = this;
  414. ecUI.showLoading('设备连接中')
  415. let blueid = uni.getStorageSync('blueid');
  416. ecBLE.onBLEConnectionStateChange(res => {
  417. ecUI.hideLoading()
  418. if (res.ok) {
  419. self.buletooth();
  420. } else {
  421. uni.removeStorageSync('blueid');
  422. ecUI.showModal(
  423. '提示',
  424. '连接失败,errCode=' + res.errCode + ',errMsg=' + res.errMsg
  425. )
  426. }
  427. })
  428. ecBLE.createBLEConnection(blueid);
  429. },
  430. buletooth(){
  431. let self = this;
  432. ctx = this
  433. isCheckScroll = true
  434. isCheckRevHex = false
  435. isCheckSendHex = false
  436. sendData = ''
  437. //on disconnect
  438. ecBLE.onBLEConnectionStateChange(() => {
  439. uni.showModal({
  440. title: '提示',
  441. content: '蓝牙断开连接',
  442. confirmText:"点击重连",
  443. showCancel:false,
  444. success: function (res) {
  445. if (res.confirm) {
  446. uni.reLaunch({
  447. url: '/pages/bluetooth/index/index'
  448. });
  449. // self.recon()
  450. } else if (res.cancel) {
  451. console.log('用户点击取消');
  452. }
  453. }
  454. });
  455. })
  456. //receive data
  457. ecBLE.onBLECharacteristicValueChange((str, strHex) => {
  458. isCheckRevHex = true;
  459. let data =
  460. (isCheckRevHex ? strHex.replace(/[0-9a-fA-F]{2}/g, ' $&') : str)
  461. // console.log(data)
  462. self.$modal.closeLoading();
  463. console.log("收到消息:"+data);
  464. //AA 67 0D 05 00 00 00 00 00 00 00 00 00 25 E2 00 80
  465. data = parseDataObj(data);
  466. self.messageCallback(data);
  467. })
  468. self.getInfo();
  469. },
  470. messageCallback(data){
  471. let self = this;
  472. console.log(data);
  473. let type = data.type;
  474. let real_data = data.real_data;
  475. if(type == 103){
  476. self.portDetail = real_data
  477. self.portList = [[]];
  478. self.curPort = [];
  479. let port_first_status = self.portDetail["port_first_status"];
  480. let port_second_status = self.portDetail["port_second_status"]
  481. if(port_first_status){
  482. self.portList[0].push({port:1,text:i18("端口一")});
  483. self.curPort.push({
  484. text: i18("端口一"),
  485. status:port_first_status,
  486. id:1,
  487. })
  488. }
  489. if(port_second_status){
  490. self.portList[0].push({port:2,text:i18("端口二")});
  491. self.curPort.push({
  492. text:i18("端口二"),
  493. status:port_second_status,
  494. id:2
  495. })
  496. }
  497. let choosePort = self.choosePort
  498. if(choosePort == 1){
  499. self.portDetail.portStatus = port_first_status;
  500. }else if(choosePort == 2){
  501. self.portDetail.portStatus = port_second_status;
  502. }
  503. self.$modal.closeLoading();
  504. }
  505. if(type == 116){
  506. self.$modal.closeLoading();
  507. self.getInfo();
  508. }
  509. if(type == 113){
  510. self.$modal.closeLoading();
  511. self.getInfo();
  512. }
  513. if(type == 96){
  514. }
  515. self.$forceUpdate();
  516. console.log('收到服务器内容:' + JSON.stringify(data));
  517. },
  518. planCharge(){
  519. if(this.portDetail.portStatus == 6){
  520. this.$modal.confirm("确认取消预约?").then(res=>{
  521. this.cancelPlan();
  522. })
  523. }else{
  524. this.toPlan()
  525. }
  526. },
  527. sendBlueData(){
  528. ecBLE.writeBLECharacteristicValue(tempSendData, false)
  529. },
  530. cancelPlan(){
  531. cancelPlan(this.choosePort).then(res=>{
  532. this.$modal.msg("取消成功");
  533. this.getInfo(true);
  534. })
  535. },
  536. getPlanInfo(){
  537. getPlanInfo(this.deviceInfo.deviceId,this.choosePort).then(res=>{
  538. let data = res.data;
  539. if(data != null){
  540. let planType = data.planType;
  541. if(planType == 1){//单次预约
  542. let planInfo = {};
  543. planInfo.runTime = data.runTime;
  544. this.planInfo = planInfo;
  545. this.planInfo.id = data.id;
  546. }else{
  547. let planInfo = {};
  548. planInfo.runTime = data.runTime;
  549. let repeatDays = data.repeatDays;
  550. let days = repeatDays.split(",")
  551. let strs = "";
  552. for (let i = 0; i < days.length; i++) {
  553. if(strs.length>0){
  554. strs+=",";
  555. }
  556. strs +=this.days[days[i]];
  557. }
  558. this.planInfo = planInfo;
  559. this.planInfo.runTime = strs+" "+data.repeatTime;
  560. this.planInfo.id = data.id;
  561. }
  562. }
  563. })
  564. },
  565. confirmPort(e){
  566. let value = e.value[0]
  567. this.choosePort = value.port;
  568. this.showPort = false;
  569. this.getInfo()
  570. },
  571. initSocket(key){
  572. let self = this;
  573. },
  574. toSet(){
  575. // this.closeSocket();
  576. uni.navigateTo({
  577. url: '/pages/weitiandi/bluetooth/setting'
  578. });
  579. },
  580. toPlan(){
  581. let arr = [];
  582. let date = new Date();
  583. let min = date.getMinutes();
  584. let hour = date.getHours();
  585. let arr1 = [i18("今日"), i18("明日")];
  586. let arr2 = []
  587. let arr3 = [];
  588. let arr4 = [];
  589. for (let i = 0; i < hour; i++) {
  590. arr2.push(i)
  591. }
  592. this.columnData[0] = arr2;
  593. for (let i = hour+1; i < 24; i++) {
  594. arr3.push(i)
  595. }
  596. this.columnData[1] = arr3;
  597. for (let i = 0; i <= 59; i++) {
  598. arr4.push(i)
  599. }
  600. this.planCols = [arr1, arr3, arr4]
  601. this.showPlan = true;
  602. },
  603. trigger(){
  604. let portStatus = this.portDetail.portStatus;
  605. if(portStatus == 2){//需要停止充电
  606. this.$modal.confirm("需要停止充电么?").then(res=>{
  607. this.stopCharge();
  608. })
  609. }else{
  610. if(portStatus == 1){
  611. this.$modal.msg("请先将充电枪插入后再点击充电");
  612. }
  613. if(portStatus == 5){
  614. this.$modal.confirm("确认开始充电么?").then(res=>{
  615. this.startCharge();
  616. })
  617. }else {
  618. this.$modal.msg("端口无法开始充电");
  619. }
  620. }
  621. },
  622. getInfo(flag) {
  623. // let str = "AA 67 0D 01 00 00 00 00 00 00 00 00 00 25 E2 00 80";
  624. // let data = parseDataObj(str);
  625. // this.messageCallback(data);
  626. //
  627. //
  628. this.$modal.loading("正在获取状态,请稍等...");
  629. if(flag){
  630. setTimeout(function (){
  631. sendPortDetailCmd().then(res => {
  632. })
  633. },500)
  634. }else{
  635. sendPortDetailCmd().then(res => {
  636. })
  637. }
  638. },
  639. stopCharge(){
  640. let self = this;
  641. this.deviceInfo.port = this.choosePort;
  642. stopCharge(this.deviceInfo).then(()=>{
  643. self.$modal.loading("停止成功");
  644. setTimeout((()=>{
  645. self.getInfo();
  646. }),1000);
  647. })
  648. },
  649. startCharge(){
  650. let self = this;
  651. this.deviceInfo.port = this.choosePort;
  652. startCharge(this.deviceInfo).then(res=>{
  653. self.$modal.loading("启动成功");
  654. setTimeout((()=>{
  655. self.getInfo();
  656. }),1000);
  657. })
  658. },
  659. getPortInfo(){
  660. this.startPortDetailTimer();
  661. },
  662. startPortDetailTimer(){
  663. let self = this;
  664. this.timer = setTimeout(function (){
  665. getPortDetail(self.deviceInfo,self.visitTime).then(res=>{
  666. let data = res.data;
  667. if(data != null){
  668. self.portDetail = data;
  669. self.checkStatusCheck();
  670. self.$modal.closeLoading();
  671. }else{
  672. self.startPortDetailTimer();
  673. }
  674. });
  675. },1000);
  676. },
  677. checkStatusCheck(){
  678. this.statusChangeTimer();
  679. },
  680. checkOnPage(){
  681. var pages = getCurrentPages() // 获取栈实例
  682. let currentRoute = pages[pages.length - 1].route; // 获取当前页面路由
  683. if("pages/weitiandi/device/index" != currentRoute){
  684. return false;
  685. }
  686. return true;
  687. },
  688. goBack(){
  689. this.closeSocket();
  690. uni.navigateBack({
  691. });
  692. },
  693. closeSocket(){
  694. ecBLE.onBLEConnectionStateChange(() => {})
  695. ecBLE.onBLECharacteristicValueChange(() => {})
  696. },
  697. statusChangeTimer(){
  698. let self = this;
  699. this.statusTimer = setTimeout(function(){
  700. if(!this.checkOnPage()){
  701. return;
  702. }
  703. checkStatusChange(self.deviceInfo,self.visitTime).then(res=>{
  704. let data = res.data;
  705. if(data != null){
  706. self.getInfo();
  707. }else{
  708. self.statusChangeTimer();
  709. }
  710. });
  711. },3000);
  712. }
  713. }
  714. }
  715. </script>
  716. <style>
  717. .container {
  718. background-image: url('../../../static/images/new/starts/bg2.jpg');
  719. inset: 0;
  720. position: absolute;
  721. background-size: cover;
  722. background-repeat: no-repeat;
  723. }
  724. .header {
  725. position: relative;
  726. margin-top:4vw;
  727. }
  728. .header-status-desc {
  729. position: absolute;
  730. text-align: center;
  731. width: 100%;
  732. bottom:1vh;
  733. font-size: 5vw;
  734. font-weight: bold;
  735. color: #0E9F9B;
  736. margin-bottom: 5vw;
  737. }
  738. .header-status {
  739. font-weight: bold;
  740. text-align: center;
  741. }
  742. .chong-active {
  743. color: #0E9F9B
  744. }
  745. .header-img {
  746. width: 100%;
  747. padding: 5% 10%;
  748. text-align: center;
  749. }
  750. .header-img image {
  751. width: 100%;
  752. height: 23vh;
  753. }
  754. .info-body{
  755. background: #0E9F9B;
  756. height: 20vh;
  757. margin: 0 2%;
  758. border-radius: 1vw;
  759. margin-top:2vh;
  760. color: #F8FCFF;
  761. line-height: 3vh;
  762. }
  763. .info-content{
  764. display: inline-block;
  765. width: 23%;
  766. text-align: center;
  767. margin: 1%;
  768. margin-top:2.5vh;
  769. }
  770. .info-content-value{
  771. font-weight: bold;
  772. }
  773. .info-content-text{
  774. }
  775. .info-summary{
  776. display: flex;
  777. flex-direction: row;
  778. text-align: center;
  779. margin:3vh 0;
  780. }
  781. .summary{
  782. width: 33%;
  783. line-height: 2.5vh;
  784. }
  785. .charge-num{
  786. color: #0E9F9B;
  787. font-weight: bold;
  788. font-size: 4.5vw;
  789. }
  790. .charge-title{
  791. color: #B2B2B2;
  792. font-weight: 400;
  793. }
  794. .btn-image{
  795. width: 90%;
  796. height: 100%;
  797. }
  798. .info-bottom-btn{
  799. display: flex;
  800. flex-direction: row;
  801. text-align: center;
  802. position: relative;
  803. margin-top: 10vh
  804. ;
  805. }
  806. .btn-area{
  807. width: 50%;
  808. height: 50px;
  809. }
  810. .left{
  811. position: relative;
  812. left: 10px;
  813. text-align: right;
  814. }
  815. .right{
  816. text-align: left;
  817. position: relative;
  818. right: 10px;
  819. }
  820. .info-plan{
  821. text-align: center;
  822. color: #0E9F9B;
  823. margin-top:1vh;
  824. font-weight: 400;
  825. }
  826. .setting{
  827. position: fixed;
  828. right: -1px;
  829. top: 10vh;
  830. z-index: 999;
  831. background: rgb(227,243,245);
  832. color: #0E9F9B;
  833. font-size: 10px;
  834. border-radius: 5px;
  835. padding: 3px;
  836. }
  837. .port{
  838. height: 70px;
  839. background: #F8FCFF;
  840. border: 0px solid #F8FCFF;
  841. box-shadow: 0px 0px 6px 1px rgba(101,101,101,0.29);
  842. border-radius: 4px;
  843. margin:0 10px;
  844. position: relative;
  845. margin-top:10px;
  846. }
  847. .plan{
  848. height: 70px;
  849. background: #F8FCFF;
  850. border: 0px solid #F8FCFF;
  851. box-shadow: 0px 0px 6px 1px rgba(101,101,101,0.29);
  852. border-radius: 4px;
  853. margin:0 10px;
  854. position: relative;
  855. margin-top:15px;
  856. }
  857. .port-image{
  858. height: 40px;
  859. width: 40px;
  860. position: absolute;
  861. top:15px;
  862. left:20px;
  863. }
  864. .port-text{
  865. position: absolute;
  866. top:13px;
  867. left:75px;
  868. font-weight: bold;
  869. }
  870. .port-num{
  871. position: absolute;
  872. top:38px;
  873. left:75px;
  874. color: #B2B2B2;
  875. }
  876. .port-icon{
  877. position: absolute;
  878. top:30px;
  879. right:5px;
  880. width: 10px;
  881. height: 16px;
  882. }
  883. .port-icon image{
  884. width: 90%;
  885. }
  886. .body-bottom{
  887. padding:0 22px;
  888. }
  889. .body-bottom .info-content{
  890. width: 30%;
  891. }
  892. .bottom-control{
  893. height: 22vh;
  894. margin: 0 2%;
  895. margin-top:2vh;
  896. line-height: 3vh;
  897. background: #F8FCFF;
  898. border: 0px solid #F8FCFF;
  899. box-shadow: 0px 0px 6px 1px rgba(101,101,101,0.29);
  900. border-radius: 4px;
  901. padding:3%;
  902. }
  903. .control-btn{
  904. display: inline-block;;
  905. height: 60px;
  906. width: 25%;
  907. padding:10px 20px;
  908. text-align: center;
  909. font-size: 12px;
  910. color: white;
  911. }
  912. .control-btn .btn-image{
  913. }
  914. .dportitem{
  915. color: #60af7b
  916. }
  917. .dboxs{
  918. /* background: #F8FCFF; */
  919. background: linear-gradient(#303030, #050609);
  920. border: 0px solid #F8FCFF;
  921. box-shadow: 0px 0px 6px 1px rgba(101,101,101,0.29);
  922. border-radius: 4px;
  923. padding: 20px;
  924. font-size: 0.24rem;
  925. color: #57B03D;
  926. margin:20px;
  927. position: relative;
  928. }
  929. .portimg{
  930. width: 20px;
  931. height: 20px;
  932. }
  933. .dportitem-img{
  934. width: 50px;
  935. height: 50px;
  936. }
  937. .dpropitem-block{
  938. /* padding: 0.12rem 0.37rem;
  939. background: #e6f6f1; */
  940. display: flex;
  941. width: 70px;
  942. height: 70px;
  943. flex-direction: column;
  944. justify-content: center;
  945. align-items: center;
  946. position: relative;
  947. }
  948. .dportitem{
  949. margin:10px;
  950. width: 70px;
  951. position: relative;
  952. display: inline-block;
  953. }
  954. .dportitem-block-2{
  955. /* background: #f9f4e5; */
  956. color: #FFAA00;
  957. }
  958. .dpropitem-title{
  959. text-align: center;
  960. margin-bottom: 5px;
  961. font-size: 16px;
  962. }
  963. .dpropitem-status{
  964. font-size: 14px;
  965. }
  966. .dboxtitle{
  967. font-size: 18px;
  968. position: relative;
  969. }
  970. .dboxtitle-text{
  971. display: inline-block;
  972. position: absolute;
  973. top: -2px;
  974. left: 25px;
  975. color: #b0b0b0;
  976. }
  977. .btn-image{
  978. width: 30px;
  979. height: 30px;
  980. }
  981. .control-btn{
  982. font-size: 14px;
  983. }
  984. </style>