Browse Source

客户端 增加后台输出组件

Changpeng Duan 4 years ago
parent
commit
ab82e770b7
3 changed files with 48 additions and 19 deletions
  1. 6 0
      online/src/page/index.vue
  2. 40 17
      online/src/page/mainpage.vue
  3. 2 2
      tv/src/components/Headside.vue

+ 6 - 0
online/src/page/index.vue

@@ -19,4 +19,10 @@
         padding-bottom: 40px;
         overflow-y: scroll;
     }
+    #__vconsole {
+        display: none;
+    }
+    #__vconsole.show {
+        display: block;
+    }
 </style>

+ 40 - 17
online/src/page/mainpage.vue

@@ -39,7 +39,7 @@
                             <s class="noValue">--</s>
                         </div>
                     </div>
-                    <span>瞬时心率</span>
+                    <span @click="showConsole()">瞬时心率</span>
                 </div>
             </div>
         </div>
@@ -137,7 +137,7 @@
     export default {
         data() {
             return {
-                runMode: 'mock',//'' 为正常模式 mock 为模拟操作模式
+                runMode: '',//'' 为正常模式 mock 为模拟操作模式
                 isClassTime: 5000,//上课状态检测频率
                 isAddHeartTime: 1000,//心率上报检测频率
                 dataLabels: [],
@@ -200,17 +200,17 @@
                     // 不上课就不报
                     console.log('下课中,不汇报');
                 }
-
-                if (this.runMode == 'mock') {
-                    this.InClass = 1;
-                    this.duId = 775;
-                    this.sn = '22735';
-                    this.HrId = 87;
-                    this.AutoAddAppHeartRate();
-                } else {
-                    // 不上课就不报
-                    console.log('下课中,不汇报test');
-                }
+                //
+                // if (this.runMode == 'mock') {
+                //     this.InClass = 1;
+                //     this.duId = 775;
+                //     this.sn = '22735';
+                //     this.HrId = 87;
+                //     this.AutoAddAppHeartRate();
+                // } else {
+                //     // 不上课就不报
+                //     console.log('下课中,不汇报test');
+                // }
             }, this.isAddHeartTime);
         },
         beforeDestroy() {
@@ -285,12 +285,35 @@
                     });
                 }
             },
+            showConsole() {
+                let vconDom = document.getElementById('__vconsole');
+                this.toggleClass(vconDom, 'show')
+            },
+            toggleClass(obj, cls) {
+                if (this.hasClass(obj, cls)) {
+                    this.removeClass(obj, cls);
+                } else {
+                    this.addClass(obj, cls);
+                }
+            },
+            hasClass(obj, cls) {
+                return obj.className.match(new RegExp('(\\s|^)' + cls + '(\\s|$)'));
+            },
+            addClass(obj, cls) {
+                if (!this.hasClass(obj, cls)) obj.className += " " + cls;
+            },
+            removeClass(obj, cls) {
+                if (this.hasClass(obj, cls)) {
+                    var reg = new RegExp('(\\s|^)' + cls + '(\\s|$)');
+                    obj.className = obj.className.replace(reg, ' ');
+                }
+            },
             // 生成心率数据
             mockCreateDate() {
                 let that = this;
                 clearInterval(this.timermockCreateDate);
                 this.timermockCreateDate = setInterval(() => {
-                    that.battery =  '85%';
+                    that.battery = '85%';
                     // 成功获取心跳
                     that.heartRate = parseInt(Math.random() * 100 + 90);
                     that.watchText = '心率带已连接';
@@ -324,7 +347,7 @@
                         that.InClass = json.InClass;//0下课,1上课
                         // 记录duid
                         that.duId = parseInt(json.DuInfo.DuId);
-                        console.log('that.duId:' +  that.duId);
+                        console.log('that.duId:' + that.duId);
                     } else {
                         that.$message.error(json.Memo);
                     }
@@ -346,7 +369,7 @@
             connectWatch() {
                 // 打开蓝牙适配器
                 let that = this;
-                if(typeof plus == 'undefined'){
+                if (typeof plus == 'undefined') {
                     that.Toast('当前设备不支持蓝牙心率带', 'error');
                     return false
                 }
@@ -677,7 +700,7 @@
                         console.log('心率数据上传成功!');
                     } else {
                         // that.Toast( '心率数据上传失败' + json.Memo);
-                        console.log( '心率数据上传失败' + json.Memo);
+                        console.log('心率数据上传失败' + json.Memo);
                     }
                 })
             },

+ 2 - 2
tv/src/components/Headside.vue

@@ -23,8 +23,8 @@
       </div>
       <table>
         <th>
-        <td>版本</td>
-        <td>热点IP</td>
+            <td>版本</td>
+            <td>热点IP</td>
         </th>
         <tr>
           <td>{{currunVersion}}</td>