소스 검색

同步小程序蓝牙的问题

wzh 2 년 전
부모
커밋
a03d9aa84d
5개의 변경된 파일151개의 추가작업 그리고 107개의 파일을 삭제
  1. 2 1
      locale/en.json
  2. 3 2
      locale/zh-Hans.json
  3. 103 99
      pages/weitiandi/bluetooth/index.vue
  4. 39 2
      pages/weitiandi/bluetooth/status.vue
  5. 4 3
      utils/weitiandi/device/device.js

+ 2 - 1
locale/en.json

@@ -118,7 +118,7 @@
     "检测到有新版本,请点击下载": "A new version has been detected. Please click to download",
     "立即下载": "Download now",
     "文件下载中,请稍后......": "The file is downloading. Please wait...",
-	"版本":"Version",
+    "版本":"Version",
     "连接失败":"Connected fail",
     "密码不能设置为000000": "The  password cannot be '000000'",
     "密码不能设置为123456": "The  password cannot be '123456'",
@@ -200,6 +200,7 @@
     "voltage": "Voltage",
     "current": "Current",
     "chargetime": "Charging time",
+    "lefttime": "Left Time",
     "power": "Power",
 
 

+ 3 - 2
locale/zh-Hans.json

@@ -46,7 +46,8 @@
 		"devtemper": "设备温度",
 		"voltage": "设备电压",
 		"current": "设备电流",
-		"chargetime": "已冲时间",
+		"chargetime": "已充时间",
+		"lefttime": "剩余时间",
 		"power": "充电功率",
 		"nocharge": "空闲中",
 
@@ -54,7 +55,7 @@
 		"getinfo": "获取状态",
 		"oldpwd": "原密码",
 		"newpwd": "6位数字新密码",
-		"elec": "已电量"
+		"elec": "已电量"
 	},
 	"page": {
 		"login": "登录",

+ 103 - 99
pages/weitiandi/bluetooth/index.vue

@@ -4,7 +4,7 @@
       <view class="dboxtitle"><image class="portimg" src="/static/images/new/start/port.png"/>
         <view class="dboxtitle-text"> {{ i18('设备端口') }}</view>
 
-        </view>
+      </view>
 
 
       <view class="dportitems">
@@ -53,19 +53,19 @@
 
     <view class="dboxs dport" style="height: 100px" @click="planCharge">
       <view class="dboxtitle"><image class="portimg" src="/static/images/new/start/clock.png"/>
-      <view class="dboxtitle-text">{{ i18('预约充电') }}</view>
+        <view class="dboxtitle-text">{{ i18('预约充电') }}</view>
       </view>
 
       <view class="port-text" v-if="planInfo != null"  style="left:40px;top:48px;font-size: 14px">
-       {{ i18('已预约') }}    <view  class="port-text" style="top:30px;">
+        {{ i18('已预约') }}    <view  class="port-text" style="top:30px;">
         <text style="font-size: 10px">{{ planInfo.runTime }}</text>
       </view>
       </view>
       <view class="port-text" style="left:40px;top:55px;font-size: 14px" v-else>
-          {{ i18('点击预约充电') }}
+        {{ i18('点击预约充电') }}
       </view>
       <view class="port-num" style="left:40px;top:70px;font-size: 12px" v-if="portDetail.portStatus == 6">
-         {{ i18('可点击取消预约') }}
+        {{ i18('可点击取消预约') }}
       </view>
       <view class="port-icon"  v-if="portDetail.portStatus !=6" style="width: 50px;height: 50px;right:10px;top:28%">
         <image class="btn-image" src="/static/images/new/start/clock.png" >
@@ -117,13 +117,13 @@
         <view>{{ i18('重置设备') }}</view>
       </view>
 
-<!--      <view class="control-btn">-->
-<!--        <image class="btn-image" :src="imgUrl+'/control/record.png'" >-->
-<!--        </image>-->
-<!--        <view>使用记录</view>-->
-<!--      </view>-->
+      <!--      <view class="control-btn">-->
+      <!--        <image class="btn-image" :src="imgUrl+'/control/record.png'" >-->
+      <!--        </image>-->
+      <!--        <view>使用记录</view>-->
+      <!--      </view>-->
     </view>
-    <u-picker @cancel="cancelPicker" @confirm="confirm" :show="showPlan" :columns="planCols" @change="changeHandler"></u-picker>
+    <u-picker ref="uPicker" @cancel="cancelPicker" @confirm="confirm" :show="showPlan" :columns="planCols" @change="changeHandler"></u-picker>
     <u-modal :show="showPwd" :confirmText="i18('确认')" @confirm="inputPwd" @cancel="cancel" :showCancelButton="true"  title="修改密码" >
       <view class="slot-content">
         <view>
@@ -166,45 +166,45 @@ let isCheckRevHex = false
 let isCheckSendHex = false
 let sendData = ''
 export default {
- data() {
-   return {
-     oldPwd:"",
-     pwd:"",
-     showPwd:false,
-     planCols:[ ],
-     columnData:[],
-     showPlan:false,
-     deviceInfo:{},
-     visitTime:"",
-     timer:null,
-     showPort:false,
-     portDetail:{portStatus:0,POWER:0,voltage:0},
-     statusTimer:"",
-     connected:false,
-     scriptTask:null,
-     choosePort:1,
-     portList:[[{port:1,text:"端口一"}]],
-     planInfo:null,
-     days:["","周一","周二","周三","周四","周五","周六","周日"],
-     textRevData: '',
-     picker:null,
-     firstInit:false,
-     hasRight:false,
-     startAutoCharge:true,
-     curPort:[]
-   }
- },
- computed: {
-   imgUrl() {
-     return getApp().globalData.config.imgUrl;
-   }
- },
- onLoad(opt) {
-   this.deviceInfo.deviceId = opt.id;
-   this.deviceInfo.ccid = opt.ccid;
-   this.deviceInfo.qrcode = opt.qrcode;
-   this.checkPassword();
- },
+  data() {
+    return {
+      oldPwd:"",
+      pwd:"",
+      showPwd:false,
+      planCols:[ ],
+      columnData:[],
+      showPlan:false,
+      deviceInfo:{},
+      visitTime:"",
+      timer:null,
+      showPort:false,
+      portDetail:{portStatus:0,POWER:0,voltage:0},
+      statusTimer:"",
+      connected:false,
+      scriptTask:null,
+      choosePort:1,
+      portList:[[{port:1,text:"端口一"}]],
+      planInfo:null,
+      days:["","周一","周二","周三","周四","周五","周六","周日"],
+      textRevData: '',
+      picker:null,
+      firstInit:false,
+      hasRight:false,
+      startAutoCharge:true,
+      curPort:[]
+    }
+  },
+  computed: {
+    imgUrl() {
+      return getApp().globalData.config.imgUrl;
+    }
+  },
+  onLoad(opt) {
+    this.deviceInfo.deviceId = opt.id;
+    this.deviceInfo.ccid = opt.ccid;
+    this.deviceInfo.qrcode = opt.qrcode;
+    this.checkPassword();
+  },
   onShow(){
     uni.setNavigationBarTitle({
       title: this.$t('page.control')
@@ -213,7 +213,7 @@ export default {
 
   },
   onUnload (){
-   this.closeSocket();
+    this.closeSocket();
   },
   methods: {
     restart(){
@@ -224,23 +224,23 @@ export default {
           self.getInfo();
         },5000)
       })
-     setTimeout(function (){
-       self.$modal.loading("正在重置,请稍等...");
-     },1000);
+      setTimeout(function (){
+        self.$modal.loading("正在重置,请稍等...");
+      },1000);
     },
     i18(text){
       return i18(text)
     },
-   selectPort(id){
-     this.choosePort = id;
-     console.log(this.choosePort)
-     this.getInfo()
-   },
+    selectPort(id){
+      this.choosePort = id;
+      console.log(this.choosePort)
+      this.getInfo();
+    },
     cancel(){
       this.showPwd = false;
     },
     modifyPwd(){
-        this.showPwd = true;
+      this.showPwd = true;
     },
     inputPwd(){
       let rightPwd = uni.getStorageSync("pwd");
@@ -252,16 +252,20 @@ export default {
         this.$modal.showToast("原密码不对");
         return;
       }
-        if(!this.pwd){
-          this.$modal.showToast("密码不能为空");
-        }else {
-          setPwd(this.pwd);
-          this.$modal.showToast("密码修改成功");
-          this.goBack();
-        }
+      if(!this.pwd){
+        this.$modal.showToast("密码不能为空");
+      }else {
+        setPwd(this.pwd);
+        this.$modal.showToast("密码修改成功");
+        this.goBack();
+      }
 
     },
     confirm(e) {
+      if(this.portDetail.portStatus == 7){
+        this.$modal.showToast("当前无法预约。请再次插枪后操作");
+        return;
+      }
       let value = e.value;
       console.log('confirm', value)
       let day = value[0];
@@ -461,10 +465,10 @@ export default {
         if(data != null){
           let planType = data.planType;
           if(planType == 1){//单次预约
-              let planInfo = {};
-              planInfo.runTime = data.runTime;
-              this.planInfo = planInfo;
-              this.planInfo.id = data.id;
+            let planInfo = {};
+            planInfo.runTime = data.runTime;
+            this.planInfo = planInfo;
+            this.planInfo.id = data.id;
           }else{
             let planInfo = {};
             planInfo.runTime = data.runTime;
@@ -472,10 +476,10 @@ export default {
             let days = repeatDays.split(",")
             let strs = "";
             for (let i = 0; i < days.length; i++) {
-                if(strs.length>0){
-                  strs+=",";
-                }
-                strs +=this.days[days[i]];
+              if(strs.length>0){
+                strs+=",";
+              }
+              strs +=this.days[days[i]];
             }
             this.planInfo = planInfo;
             this.planInfo.runTime = strs+" "+data.repeatTime;
@@ -527,7 +531,7 @@ export default {
       let portStatus = this.portDetail.portStatus;
       if(portStatus == 2){//需要停止充电
         this.$modal.confirm("需要停止充电么?").then(res=>{
-              this.stopCharge();
+          this.stopCharge();
         })
       }else{
         if(portStatus == 1){
@@ -543,27 +547,27 @@ export default {
 
       }
     },
-   getInfo(flag) {
+    getInfo(flag) {
 
       // let str = "AA 67 0D 01 00 00 00 00 00 00 00 00 00 25 E2 00 80";
       // let data = parseDataObj(str);
       // this.messageCallback(data);
-     //
-     //
-     this.$modal.loading("正在获取状态,请稍等...");
-     if(flag){
+      //
+      //
+      this.$modal.loading("正在获取状态,请稍等...");
+      if(flag){
         setTimeout(function (){
           sendPortDetailCmd().then(res => {
 
           })
         },500)
-     }else{
-       sendPortDetailCmd().then(res => {
+      }else{
+        sendPortDetailCmd().then(res => {
 
-       })
-     }
+        })
+      }
 
-  },
+    },
     stopCharge(){
       let self = this;
       this.deviceInfo.port = this.choosePort;
@@ -588,17 +592,17 @@ export default {
       this.startPortDetailTimer();
     },
     startPortDetailTimer(){
-     let self = this;
+      let self = this;
       this.timer = setTimeout(function (){
         getPortDetail(self.deviceInfo,self.visitTime).then(res=>{
-         let data = res.data;
-         if(data != null){
-           self.portDetail = data;
-           self.checkStatusCheck();
-           self.$modal.closeLoading();
-         }else{
-           self.startPortDetailTimer();
-         }
+          let data = res.data;
+          if(data != null){
+            self.portDetail = data;
+            self.checkStatusCheck();
+            self.$modal.closeLoading();
+          }else{
+            self.startPortDetailTimer();
+          }
         });
       },1000);
     },
@@ -625,9 +629,9 @@ export default {
     statusChangeTimer(){
       let self = this;
       this.statusTimer = setTimeout(function(){
-       if(!this.checkOnPage()){
-         return;
-       }
+        if(!this.checkOnPage()){
+          return;
+        }
         checkStatusChange(self.deviceInfo,self.visitTime).then(res=>{
           let data = res.data;
           if(data != null){
@@ -820,7 +824,7 @@ export default {
   width: 90%;
 }
 .body-bottom{
-padding:0 22px;
+  padding:0 22px;
 }
 .body-bottom .info-content{
   width: 30%;

+ 39 - 2
pages/weitiandi/bluetooth/status.vue

@@ -84,7 +84,8 @@
       <view class="ditem">
         <image class="itemimg" src="/static/images/new/shjian.png"/>
         <view class="item-value" >{{ chargeTime }}{{ i18('分钟') }}</view>
-        <span class="item-text">{{$t('charge.chargetime')}}</span>
+        <span class="item-text" v-if="portStatus == 6">{{$t('charge.lefttime')}}</span>
+        <span class="item-text" v-else>{{$t('charge.chargetime')}}</span>
       </view>
 
       <view class="ditem">
@@ -148,7 +149,7 @@
       </view>
     </u-modal>
 
-    <u-modal :show="showInitPwd" :confirmText="i18('确认')" :cancelText="i18('取消')" @confirm="inputPwd" @cancel="cancel" :showCancelButton="true"  :title="i18('当前密码为初始密码,请修改')" >
+    <u-modal :show="showInitPwd" :confirmText="i18('确认')" :cancelText="i18('取消')" @confirm="inputPwd" @cancel="cancelInitDlg" :showCancelButton="true"  :title="i18('当前密码为初始密码,请修改')" >
       <view class="slot-content">
         <view style="margin-bottom:10px;">
           {{i18('请保存好设备序列号。可用于找回密码')}}
@@ -234,6 +235,7 @@ export default {
       uuid:"",
       curPort:[],
       firstRender:false,
+      refreshTimer:null,
     }
   },
   computed: {
@@ -259,8 +261,14 @@ export default {
   },
   onUnload (){
     this.closeSocket();
+    if(this.refreshTimer != null){
+      clearTimeout(this.refreshTimer)
+    }
   },
   methods: {
+    cancelInitDlg(){
+      this.showInitPwd = false;
+    },
     selectPort(id){
       this.choosePort = id;
       console.log(this.choosePort)
@@ -454,6 +462,17 @@ export default {
         self.messageCallback(data);
       })
       self.getInfo();
+      self.startTimer();
+    },
+    startTimer(){
+      let self = this;
+      if(this.refreshTimer != null){
+        clearTimeout(this.refreshTimer);
+      }
+      self.refreshTimer = setTimeout(function(){
+        self.getInfo();
+        self.startTimer();
+      },30000);
     },
     messageCallback(data,flag){
       let self = this;
@@ -513,12 +532,30 @@ export default {
           self.gonglv = self.portDetail.power;
           self.dianliang = self.portDetail.elec/100;
           self.currentValue =  self.portDetail.currentValue;
+          if(port_first_status != 2){
+            self.chargeTime = 0;
+            if(port_first_status == 6){
+              self.chargeTime = self.portDetail.time;
+            }
+            self.gonglv = 0;
+            self.dianliang = 0;
+            self.currentValue =  0;
+          }
         }else if(choosePort == 2){
           self.portDetail.portStatus = port_second_status;
           self.chargeTime = self.portDetail.time_1;
           self.gonglv = self.portDetail.power_1;
           self.dianliang = self.portDetail.elec_1/100;
           self.currentValue =  self.portDetail.currentValue_1;
+          if(port_second_status != 2){
+            self.chargeTime = 0;
+            if(port_first_status == 6){
+              self.chargeTime = self.portDetail.time_1;
+            }
+            self.gonglv = 0;
+            self.dianliang = 0;
+            self.currentValue =  0;
+          }
         }
         self.portStatus = self.portDetail.portStatus;
         self.deviceTemp = self.portDetail.dev_temper;

+ 4 - 3
utils/weitiandi/device/device.js

@@ -201,9 +201,9 @@ const dataParser = {
             'ELEC 2\n' +
             'MONEY 2\n' +
             'TIME 2\n' +
-            'VOLTAGE\n' +
+            'WIRE_TEMPER\n' +
             'DEV_TEMPER\n' +
-            'WIRE_TEMPER',
+            'VOLTAGE',
         morlsingle2:'PORT_FIRST_STATUS\n' +
             'POWER 2\n' +
             'ELEC 2\n' +
@@ -559,7 +559,7 @@ function doResetTime(delay){
 
 
 function test(){
-    let data = 'AA,67,0B,02,00,00,15,00,4E,C3,2B,00,1C,E8,C9';
+    let data = 'AA,67,0D,02,00,00,00,00,00,00,06,00,00,14,E7,00,77';
     data = data.trim();
     data = data.split(",");
 
@@ -567,6 +567,7 @@ function test(){
     for (let i = 0; i < data.length; i++) {
         arr.push(parseInt(data[i],16)) ;
     }
+    arr =[170,103,13,1,0,0,0,0,0,0,0,0,0,23,233,0,117];
     console.log(arr)
     console.log( parseData(arr))
 }