index.vue 29 KB

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