Explorar o código

修改体质调查问卷和睡眠调查问卷不能提交bug
修改体制报告数值为nan和null bug
修改体制报告列表数值为nan和null bug
体质调查问卷增加点击 以上没有 js特效

suixueyan hai 5 meses
pai
achega
ba3cfbf7d8
Modificáronse 53 ficheiros con 1896 adicións e 262 borrados
  1. 36 6
      app.js
  2. 2 0
      app.json
  3. 9 3
      componets/authorized-login-dialog/authorizedLoginDialog.js
  4. 36 132
      pages/index/index.js
  5. 1 2
      pages/index/index.json
  6. 2 24
      pages/index/index.wxml
  7. 0 58
      pages/index/index.wxss
  8. BIN=BIN
      static/index/bg/bg_wdcd.png
  9. BIN=BIN
      static/index/bg/ic_wdd_bg.png
  10. BIN=BIN
      static/index/icon/ic_wdcd.png
  11. BIN=BIN
      static/index/icon/ic_wdd.png
  12. BIN=BIN
      static/painter/hua.png
  13. 180 6
      subpages/data/data.js
  14. 1 0
      subpages/data/data.json
  15. 26 2
      subpages/data/data.wxml
  16. 59 1
      subpages/data/data.wxss
  17. 11 11
      subpages/data/getPosterObj.js
  18. 0 0
      subpages/images/painter/bc-1.png
  19. 0 0
      subpages/images/painter/bg-1.png
  20. 0 0
      subpages/images/painter/dy-1.png
  21. 0 0
      subpages/images/painter/icon-1.png
  22. 0 0
      subpages/images/painter/icon-2.png
  23. 0 0
      subpages/images/painter/qr-code.png
  24. 23 12
      subpages/scan/scan.js
  25. 1 1
      subpages/scan/scan.wxml
  26. 4 0
      subpages/scan/scan.wxss
  27. 2 0
      subpagesTwo/components/navBar/app.js
  28. 228 0
      subpagesTwo/components/navBar/navBar.js
  29. 4 0
      subpagesTwo/components/navBar/navBar.json
  30. 41 0
      subpagesTwo/components/navBar/navBar.wxml
  31. 173 0
      subpagesTwo/components/navBar/navBar.wxss
  32. 23 0
      subpagesTwo/components/navBar/package.json
  33. 346 0
      subpagesTwo/dropfoot/dropfoot.js
  34. 5 0
      subpagesTwo/dropfoot/dropfoot.json
  35. 97 0
      subpagesTwo/dropfoot/dropfoot.wxml
  36. 103 0
      subpagesTwo/dropfoot/dropfoot.wxss
  37. BIN=BIN
      subpagesTwo/images/zmdevice/bluetooth.png
  38. BIN=BIN
      subpagesTwo/images/zmdevice/current.png
  39. BIN=BIN
      subpagesTwo/images/zmdevice/current1.png
  40. BIN=BIN
      subpagesTwo/images/zmdevice/minus.png
  41. BIN=BIN
      subpagesTwo/images/zmdevice/plus.png
  42. BIN=BIN
      subpagesTwo/images/zmdevice/start.png
  43. BIN=BIN
      subpagesTwo/images/zmdevice/stop.png
  44. BIN=BIN
      subpagesTwo/images/zmdevice/target.png
  45. BIN=BIN
      subpagesTwo/images/zmdevice/target1.png
  46. BIN=BIN
      subpagesTwo/images/zmdevice/wake.png
  47. 345 0
      subpagesTwo/search/search.js
  48. 6 0
      subpagesTwo/search/search.json
  49. 18 0
      subpagesTwo/search/search.wxml
  50. 30 0
      subpagesTwo/search/search.wxss
  51. 4 1
      subpagesTwo/seeAisoList/seeAicoList.wxml
  52. 19 3
      subpagesTwo/seeAisoList/seeAicoList.wxss
  53. 61 0
      utils/api2.js

+ 36 - 6
app.js

@@ -49,18 +49,22 @@ App({
                 },
                 method: 'POST',
                 success: function (intervalRes) {
-                  console.log('intervalRes=' + JSON.stringify(intervalRes));
-                  console.log('intervalRes.data=' + JSON.stringify(intervalRes.data));
+                  console.log('intervalRes222222=' + JSON.stringify(intervalRes));
+                  console.log('122222222222222')
                   //empower.js? [sm]:152 intervalRes.data={"st":"success","status":"0"}
                   if (intervalRes.data && intervalRes.data.st && intervalRes.data.status && intervalRes.data.st == 'success' && intervalRes.data.status == '1') {
                     wx.setStorageSync('hasHotelAuth', true);
-                    wx.setStorageSync('hotelEmpower', intervalRes.data.hotel);
-                    wx.setStorageSync('roomEmpower', intervalRes.data.room);
-                    wx.setStorageSync('hname', intervalRes.data.hname);
-                    wx.setStorageSync('rname', intervalRes.data.rname);
                   } else {
                     wx.setStorageSync('hasHotelAuth', false);
                   }
+                  try {
+                    wx.setStorageSync('hotelEmpower', intervalRes?.data?.hotel);
+                    wx.setStorageSync('roomEmpower', intervalRes?.data?.room);
+                    wx.setStorageSync('hname', intervalRes?.data?.hname);
+                    wx.setStorageSync('rname', intervalRes?.data?.rname);
+                  }catch ( e){
+                    console.log(e)
+                  }
                 },
                 fail: function (error) {
 
@@ -115,6 +119,32 @@ App({
     wx.setStorageSync('deviceList', []);
     wx.setStorageSync('doDevices', []);
   },
+  CRC16 :function (data) {//MODBUS_CRC16校验
+    var len = data.length;
+    if (len > 0) {
+      var crc = 0xFFFF;
+      for (var i = 0; i < len; i++) {
+        crc = (crc ^ (data[i]));
+        for (var j = 0; j < 8; j++) {
+          crc = (crc & 1) != 0 ? ((crc >> 1) ^ 0xA001) : (crc >> 1);
+        }
+      }
+      var hi = ((crc & 0xFF00) >> 8);  //高位置
+      var lo = (crc & 0x00FF);         //低位置
+
+      return [lo, hi];
+    }
+    return [0, 0];
+  },
+  ab2hex: function (buffer) {
+    let hexArr = Array.prototype.map.call(
+        new Uint8Array(buffer),
+        function (bit) {
+          return ('00' + bit.toString(16)).slice(-2)
+        }
+    )
+    return hexArr.join('');
+  },
   buf2hex: function (buffer) {
     return Array.prototype.map.call(new Uint8Array(buffer), x => ('00' + x.toString(16)).slice(-2)).join('')
   },

+ 2 - 0
app.json

@@ -33,6 +33,8 @@
       "name": "subpagesTwo",
       "pages": [
         "seeAlso/seeAico",
+        "search/search",
+        "dropfoot/dropfoot",
         "seeAisoList/seeAicoList"
       ]
     }

+ 9 - 3
componets/authorized-login-dialog/authorizedLoginDialog.js

@@ -401,15 +401,21 @@ Component({
           success: function (intervalRes) {
             that.setData({ showLoading: false });
             that.clearInterval();
-            console.log('intervalRes=' + JSON.stringify(intervalRes));
+            console.log('intervalRes11111111=' + JSON.stringify(intervalRes));
             console.log('intervalRes.data=' + JSON.stringify(intervalRes.data));
             if (intervalRes.data && intervalRes.data.st && intervalRes.data.status && intervalRes.data.st == 'success' && intervalRes.data.status == '1') {
               wx.setStorageSync('hasHotelAuth', true);
-              wx.setStorageSync('hotelEmpower', intervalRes.data.hotel);
-              wx.setStorageSync('roomEmpower', intervalRes.data.room);
             } else {
               wx.setStorageSync('hasHotelAuth', false);
             }
+            try {
+              wx.setStorageSync('hotelEmpower', intervalRes?.data?.hotel);
+              wx.setStorageSync('roomEmpower', intervalRes?.data?.room);
+              wx.setStorageSync('hname', intervalRes?.data?.hname);
+              wx.setStorageSync('rname', intervalRes?.data?.rname);
+            }catch ( e){
+              console.log(e)
+            }
           },
           fail: function (error) {
             that.setData({ showLoading: false });

+ 36 - 132
pages/index/index.js

@@ -1,5 +1,4 @@
 // pages/mine/mine.js
-import {getCheckInInfo, getDrawImg} from "./getPosterObj";
 
 const defaultAvatarUrl = "../../static/images/no-login.png"
 const homeApi_empower = "https://aipush.aidsleep.cn";
@@ -8,10 +7,7 @@ import api from '../../utils/api';
 
 
 Page({
-  imagePath: '',
-  history: [],
-  future: [],
-  isSave: false,
+
   /**
    * 页面的初始数据
    */
@@ -29,126 +25,11 @@ Page({
     latitude: null,
     longitude: null,
     menuCardList: [],
-    customActionStyle: {
-      border: {
-        borderColor: '#1A7AF8',
-      },
-      scale: {
-        textIcon: '/palette/switch.png',
-        imageIcon: '/palette/scale.png',
-      },
-      delete: {
-        icon: '/palette/close.png',
-      },
-    },
-    paintPallette: {},
-    template: {},
-    showImg:false
-  },
-  onClickShow() {
-    this.setData({ showImg: true });
-  },
 
-  onClickHide() {
-    this.setData({ showImg: false });
   },
 
 
-  handleSureDownload() {
-    this.isSave = false;
-    api.painter({
-      params: {score: 69},
-    }).then(data => {
-      if (data.code === 1) {
-
-        var DrawImg = getDrawImg(data?.data?.pic||'/static/painter/hua.png', 0);
-
-        var CheckInInfo = getCheckInInfo(data?.data?.talk|| "亲爱的,哪怕只有一分钟的平静闭眼,也是身体在努力修复的信号。新的一天,新的开始!", DrawImg.height);
-// 定义 palette 对象
-        const palette = {
-          "width": "750rpx",
-          "height": CheckInInfo.height + "rpx",
-          "background": "transparent",
-          "views": [
-            ...DrawImg.obj,
-            ...CheckInInfo.obj,
-          ]
-        };
-// 更新数据到页面
-        this.isSave = true;
-        this.setData({
-          paintPallette: palette
-        });
-      } else {
-      }
-    }).catch(err => {
-    });
 
-  },
-  saveImage() {
-    console.log("saveImage", this.imagePath)
-    if (this.imagePath && typeof this.imagePath === 'string') {
-      this.isSave = false;
-      // 存入系统相册
-      wx.saveImageToPhotosAlbum({
-        filePath: this.imagePath || '',
-        success: res => {
-          this.onClickHide()
-        },
-        fail: res => {
-          this.onClickHide()
-        }
-      })
-    }
-
-  },
-  // 生成海报点击事件
-  onImgOK(e) {
-    this.imagePath = e.detail.path;
-    this.setData({
-      image: this.imagePath,
-    });
-    if (this.isSave) {
-      this.onClickShow()
-    }
-  },
-  touchEnd({detail}) {
-    let needRefresh = detail.index >= 0 && detail.index <= this.data.template.views.length;
-    if (needRefresh) {
-      this.history.push({
-        ...detail,
-      });
-      if (this.data.template.views[detail.index].id === detail.view.id) {
-        this.data.template.views.splice(detail.index, 1);
-      } else {
-        this.data.template.views.splice(detail.index, 0, detail.view);
-      }
-    } else {
-      if (!this.data.template || !this.data.template.views) {
-        return;
-      }
-      for (let view of this.data.template.views) {
-        if (view.id === detail.view.id) {
-          this.history.push({
-            view: {
-              ...detail.view,
-              ...view,
-            },
-          });
-          view.css = detail.view.css;
-          break;
-        }
-      }
-    }
-    this.future.length = 0;
-    const props = {
-      paintPallette: this.data.template,
-    };
-    if (needRefresh) {
-      props.template = this.data.template;
-    }
-    this.setData(props);
-  },
   getLocation() {
     const that = this;
     var hasAuth = wx.getStorageSync("hasAuth");
@@ -292,7 +173,6 @@ Page({
     const type = this.data.menuList[index].type;
     const url = this.data.menuList[index].url;
     if (!url) {
-      this.handleSureDownload()
       return
     }
     if (type == 'switchTab') {
@@ -345,13 +225,17 @@ Page({
                 //empower.js? [sm]:152 intervalRes.data={"st":"success","status":"0"}
                 if (intervalRes.data && intervalRes.data.st && intervalRes.data.status && intervalRes.data.st == 'success' && intervalRes.data.status == '1') {
                   wx.setStorageSync('hasHotelAuth', true);
-                  wx.setStorageSync('hotelEmpower', intervalRes.data.hotel);
-                  wx.setStorageSync('roomEmpower', intervalRes.data.room);
-                  wx.setStorageSync('hname', intervalRes.data.hname);
-                  wx.setStorageSync('rname', intervalRes.data.rname);
                 } else {
                   wx.setStorageSync('hasHotelAuth', false);
                 }
+                try {
+                  wx.setStorageSync('hotelEmpower', intervalRes?.data?.hotel);
+                  wx.setStorageSync('roomEmpower', intervalRes?.data?.room);
+                  wx.setStorageSync('hname', intervalRes?.data?.hname);
+                  wx.setStorageSync('rname', intervalRes?.data?.rname);
+                }catch ( e){
+                  console.log(e)
+                }
                 var hasHotelAuth = wx.getStorageSync("hasHotelAuth");
                 if (!hasHotelAuth) {
                   that.setData({
@@ -386,6 +270,10 @@ Page({
           }
           this.toCardPage(index);
         } else {
+          if(index == 1){
+            this.toCardPage(index);
+            break;
+          }
           this.showDialog();
         }
         break;
@@ -559,18 +447,22 @@ Page({
         },
         method: 'POST',
         success: function (intervalRes) {
-          console.log('intervalRes=' + JSON.stringify(intervalRes));
+          console.log('intervalRes=55555555' + JSON.stringify(intervalRes));
           console.log('intervalRes.data=' + JSON.stringify(intervalRes.data));
           //empower.js? [sm]:152 intervalRes.data={"st":"success","status":"0"}
           if (intervalRes.data && intervalRes.data.st && intervalRes.data.status && intervalRes.data.st == 'success' && intervalRes.data.status == '1') {
             wx.setStorageSync('hasHotelAuth', true);
-            wx.setStorageSync('hotelEmpower', intervalRes.data.hotel);
-            wx.setStorageSync('roomEmpower', intervalRes.data.room);
-            wx.setStorageSync('hname', intervalRes.data.hname);
-            wx.setStorageSync('rname', intervalRes.data.rname);
           } else {
             wx.setStorageSync('hasHotelAuth', false);
           }
+          try {
+            wx.setStorageSync('hotelEmpower', intervalRes?.data?.hotel);
+            wx.setStorageSync('roomEmpower', intervalRes?.data?.room);
+            wx.setStorageSync('hname', intervalRes?.data?.hname);
+            wx.setStorageSync('rname', intervalRes?.data?.rname);
+          }catch ( e){
+            console.log(e)
+          }
         },
         fail: function (error) {
 
@@ -614,7 +506,8 @@ Page({
       color: "#BB6268",
       bgColor: "#FFF6F7",
       url: "/subpages/sleepReport/sleepReport"
-    }, {
+    },
+/*        {
       icon: "../../static/index/icon/ic_wdcd.png",
       bgIcon: "../../static/index/bg/bg_wdcd.png",
       title: wx.getStorageSync("isManager")?"巡检房间" : "我的床垫",
@@ -622,7 +515,18 @@ Page({
       color: "#317A9B",
       bgColor: "#E6FFFC",
       url: wx.getStorageSync("isManager")?this.data.seeAicoList+'?hotel_id='+wx.getStorageSync("isManager")[0]  : "/subpages/myMattress/myMattress"
-    }, {
+    },*/
+
+        {
+          icon: "../../static/index/icon/ic_wdd.png",
+          bgIcon: "../../static/index/bg/ic_wdd_bg.png",
+          title: wx.getStorageSync("isManager")?"巡检房间" : "我的设备",
+          type: "navigate",
+          color: "#317A9B",
+          bgColor: "#E6FFFC",
+          url: wx.getStorageSync("isManager")?this.data.seeAicoList+'?hotel_id='+wx.getStorageSync("isManager")[0]  : "/subpagesTwo/search/search"
+        },
+        {
       icon: "../../static/index/icon/ic_zxsc.png",
       bgIcon: "../../static/index/bg/bg_zxsc.png",
       title: "在线商城",

+ 1 - 2
pages/index/index.json

@@ -1,7 +1,6 @@
 {
   "usingComponents": {
-    "authorized-login-dialog": "../../componets/authorized-login-dialog/authorizedLoginDialog",
-    "painter": "../../componets/painter/painter"
+    "authorized-login-dialog": "../../componets/authorized-login-dialog/authorizedLoginDialog"
   },
   "navigationBarRightButton": {
     "hide": true

+ 2 - 24
pages/index/index.wxml

@@ -82,29 +82,7 @@
             </view>
         </view>
     </van-popup>
-    <painter
-            customActionStyle="{{customActionStyle}}"
-            palette="{{paintPallette}}"
-            bind:imgOK="onImgOK"
-            bind:touchEnd="touchEnd"
-            widthPixels="1000"
-    />
-    <van-overlay show="{{ showImg }}" bind:click="onClickHide">
-        <view class="wrapper">
-            <view class="block" >
-                <image src="{{image}}"  style="width: 630rpx; height: 100%;"/>
-            </view>
-            <view class="btns-box">
-                <view class="print-btn">
-                    <image class="btn-img"  src="/static/painter/dy-1.png" ></image>
-                    酒店打印
-                </view>
-                <view class="save-btn" bind:tap="saveImage">
-                    <image class="btn-img" src="/static/painter/bc-1.png" ></image>
-                    保存到本地
-                </view>
-            </view>
-        </view>
-    </van-overlay>
+
+
     <!--            widthPixels="1000"-->
 </view>

+ 0 - 58
pages/index/index.wxss

@@ -310,61 +310,3 @@ page {
     display: flex;
     flex-direction: column;
 }
-.wrapper {
-    display: flex;
-    flex-direction: column;
-    align-items: center;
-    justify-content: center;
-    height: 100%;
-}
-
-.block {
-    width: 630rpx;
-    height: 800rpx;
-}
-.btns-box {
-    width: 630rpx;
-    padding:80rpx 28rpx 0;
-    display: flex;
-    justify-content: space-between;
-    align-items: center;
-    box-sizing: border-box;
-}
-.print-btn{
-    width: 272rpx;
-    height: 84rpx;
-    background: #FFFFFF;
-    border-radius: 292rpx 292rpx 292rpx 292rpx;
-    font-weight: normal;
-    font-size: 28rpx;
-    color: #0BC3AA;
-    line-height: 40rpx;
-    text-align: center;
-    font-style: normal;
-    text-transform: none;
-    display: flex;
-    justify-content: center;
-    align-items: center;
-}
-.btn-img{
-    width: 28rpx;
-    height: 28rpx;
-    margin-right: 16rpx;
-}
-.save-btn{
-    width: 272rpx;
-    height: 84rpx;
-    background: linear-gradient( 315deg, #0ABCA4 0%, #0BC3AA 100%);
-    border-radius: 292rpx 292rpx 292rpx 292rpx;
-    font-weight: normal;
-    font-size: 28rpx;
-    color: #FFFFFF;
-    line-height: 40rpx;
-    text-align: center;
-    font-style: normal;
-    text-transform: none;
-    display: flex;
-    justify-content: center;
-    align-items: center;
-
-}

BIN=BIN
static/index/bg/bg_wdcd.png


BIN=BIN
static/index/bg/ic_wdd_bg.png


BIN=BIN
static/index/icon/ic_wdcd.png


BIN=BIN
static/index/icon/ic_wdd.png


BIN=BIN
static/painter/hua.png


+ 180 - 6
subpages/data/data.js

@@ -1,4 +1,7 @@
 import * as echarts from '../../ec-canvas/echarts';
+import api from "../../utils/api";
+import api2 from "../../utils/api2";
+import {getCheckInInfo, getDrawImg} from "./getPosterObj";
 
 
 // 渐变圆环
@@ -1094,7 +1097,6 @@ function setTimeWaterfallOption(chart, startTime = new Date().getTime(), data =
 }
 
 function updateTimeWaterfall(startTime = new Date().getTime(), data, that) {
-	console.log("updateTimeWaterfall========>", data);
 	if (chartTimeWaterfall) {
 		setTimeWaterfallOption(chartTimeWaterfall, startTime, data);
 	} else {
@@ -1131,11 +1133,30 @@ const token_push = "b74fd5754c5ef24cf600c39194abdaeb";
 const token_today_push = "89835e65993fee4a6a6cbbe4c271da51e5521822934e13769e61cadabaed72c3";
 
 Page({
-
+	imageaBase64Path: '',
+	imageaPath: '',
+	history: [],
+	future: [],
+	isSave: false,
 	/**
 	 * 页面的初始数据
 	 */
 	data: {
+		customActionStyle: {
+			border: {
+				borderColor: '#1A7AF8',
+			},
+			scale: {
+				textIcon: '/palette/switch.png',
+				imageIcon: '/palette/scale.png',
+			},
+			delete: {
+				icon: '/palette/close.png',
+			},
+		},
+		paintPallette: {},
+		template: {},
+		showImg:false,
 		ecCircularProgressBar: {
 			// lazyLoad: true, // 懒加载
 			onInit: initChartHumidifier
@@ -1265,6 +1286,152 @@ Page({
 		tzTitle: '',
 		tzSubTitle: '',
 	},
+	handleSureDownload() {
+		if (this.data.rscore_value && this.data.rscore_value > 0 && this.data.reportDate &&this.data.reportDate!=='' ){
+			const dateString = this.data.reportDate; // "2025-12-30"
+			const date = new Date(dateString);
+			const year = date.getFullYear();       // 2025
+			const month = date.getMonth() + 1;     // 12(注意:getMonth() 返回 0~11)
+			const day = date.getDate();
+
+			this.isSave = false;
+
+			api.painter({
+				params: {
+					score: this.data.rscore_value,
+					union_id: wx.getStorageSync('unionid'),
+					date:dateString
+				},
+			}).then(data => {
+				if (data.code === 1) {
+
+					var DrawImg = getDrawImg(data?.data?.pic||'/static/painter/hua.png', 0);
+
+					var CheckInInfo = getCheckInInfo(data?.data?.talk|| "亲爱的,哪怕只有一分钟的平静闭眼,也是身体在努力修复的信号。新的一天,新的开始!",this. data.hotelname || wx.getStorageSync('hname'),this. data.roomname,this.data.rscore_value,			year+'年'+month+'月'+day+"日", DrawImg.height);
+// 定义 palette 对象			"height": CheckInInfo.height + "rpx" 1166,
+					const palette = {
+						"width": "750rpx",
+						"height":  CheckInInfo.height+ "rpx",
+						"background": "transparent",
+						"views": [
+							...DrawImg.obj,
+							...CheckInInfo.obj,
+						]
+					};
+					console.log("paletCheckInInfo.heighte",CheckInInfo.height)
+// 更新数据到页面		l
+					this.isSave = true;
+					this.setData({
+						paintPallette: palette
+					});
+				} else {
+				}
+			}).catch(err => {
+			});
+		}
+
+
+	},
+	hotelPrinting(){
+		api2.getToken({
+			body: {
+				"tks":"cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e"
+			}
+		}).then(data => {
+			if (data?.token) {
+				api2.print({
+					body: {
+						"filename":"bk_login.png","file_content":this.imageaBase64Path
+					}
+					,headers:{
+						"X-Print-Token": data.token
+					}
+				}).then(data => {
+
+				}).catch(err => {
+				});
+			}
+		}).catch(err => {
+		});
+	},
+	saveImage() {
+		console.log("saveImage", this.imageaBase64Path)
+		if (this.imageaBase64Path && typeof this.imageaBase64Path === 'string') {
+			this.isSave = false;
+			// 存入系统相册
+			wx.saveImageToPhotosAlbum({
+				filePath:	this.imageaPath  || '',
+				success: res => {
+					this.onClickHide()
+				},
+				fail: res => {
+					console.log(res)
+					this.onClickHide()
+				}
+			})
+		}
+
+	},
+	// 生成海报点击事件
+	onImgOK(e) {
+		this.imageaBase64Path = this.convertImageToBase64(e.detail.path );
+		this.imageaPath = e.detail.path;
+		this.setData({
+			image: this.imageaBase64Path,
+		});
+		if (this.isSave) {
+			this.onClickShow()
+		}
+	},
+	convertImageToBase64(filePath) {
+		const fs = wx.getFileSystemManager();
+		try {
+			// 使用 'base64' 而不是 'binary'
+			let data = fs.readFileSync(filePath, 'base64'); // 直接以 base64 格式读取
+			return 'data:image/png;base64,' + data; // 直接返回带有 MIME 类型的 base64 字符串
+			// 你可以把 base64Url 存起来或上传服务器
+		} catch (err) {
+			console.error('读取文件失败', err);
+			return ''; // 发生错误时返回空字符串或者进行其他处理
+		}
+	},
+	touchEnd({detail}) {
+		let needRefresh = detail.index >= 0 && detail.index <= this.data.template.views.length;
+		if (needRefresh) {
+			this.history.push({
+				...detail,
+			});
+			if (this.data.template.views[detail.index].id === detail.view.id) {
+				this.data.template.views.splice(detail.index, 1);
+			} else {
+				this.data.template.views.splice(detail.index, 0, detail.view);
+			}
+		} else {
+			if (!this.data.template || !this.data.template.views) {
+				return;
+			}
+			for (let view of this.data.template.views) {
+				if (view.id === detail.view.id) {
+					this.history.push({
+						view: {
+							...detail.view,
+							...view,
+						},
+					});
+					view.css = detail.view.css;
+					break;
+				}
+			}
+		}
+		this.future.length = 0;
+		const props = {
+			paintPallette: this.data.template,
+		};
+		if (needRefresh) {
+			props.template = this.data.template;
+		}
+		this.setData(props);
+	},
 	toWarmReminder(e) {
 		const tabName = e.currentTarget.dataset.index || 1;
 		wx.navigateTo({
@@ -1531,6 +1698,14 @@ Page({
 		// console.log("睡眠数据最终=>", startTime);
 		// console.log("睡眠数据最终=>", JSON.stringify(timePeriods));
 	},
+	onClickShow() {
+		this.setData({ showImg: true });
+	},
+
+	onClickHide() {
+		this.setData({ showImg: false });
+	},
+
 	// 授权成功
 	authorizationSuccessful() {
 		// console.log("授权成功");
@@ -1913,8 +2088,6 @@ Page({
 			success(ress) {
 				try {
 					if (ress && ress.data) {
-						console.log('ress.data-getsingle=' + JSON.stringify(ress.data.results));
-
 						if (!ress.data.results || ress.data.results == '') {
 							// wx.showModal({
 							// 	title: '提示',
@@ -1926,7 +2099,6 @@ Page({
 							})
 							return;
 						}
-
 						wx.nextTick(() => {
 							setTimeout(() => {
 								//初始化数据
@@ -1939,6 +2111,8 @@ Page({
 								// that.initChartSnoring(ress.data.results);
 								// that.initChartApnea(ress.data.results);
 								that.initTimeWaterfall(ress.data.results);
+								that.handleSureDownload()
+
 							}, 1000);
 						});
 
@@ -2006,9 +2180,9 @@ Page({
 								// that.initChartSnoring(ress.data.data);
 								// that.initChartApnea(ress.data.data);
 								that.initTimeWaterfall(ress.data.data);
+								that.handleSureDownload()
 							}, 1000);
 						});
-
 						that.getSnData();//需要筛选的 要获取sn
 						that.getAllUnionidList();
 					} else {

+ 1 - 0
subpages/data/data.json

@@ -1,6 +1,7 @@
 {
   "usingComponents": {
     "ec-canvas": "../../ec-canvas/ec-canvas",
+    "painter": "../../componets/painter/painter",
     "authorized-login-dialog": "../../componets/authorized-login-dialog/authorizedLoginDialog"
   },
   "navigationBarBackgroundColor": "#ffffff",

+ 26 - 2
subpages/data/data.wxml

@@ -358,7 +358,7 @@
 				<ec-canvas id="chartRespiratoryLine-dom" canvas-id="mychart-chart-respiratory-line"
 					ec="{{ ecChartRespiratoryLine }}"></ec-canvas>
 			</view>
-			<!-- 			
+			<!--
 			<view class="separator_c00" style="margin-top: 30rpx;"></view>
 			<view class="data-row_c6">
 				<view class="data-item_c6 left_c61">打鼾</view>
@@ -403,7 +403,7 @@
 				<view class="echarts-container_c6" style="flex: 1;">
 					<ec-canvas id="chartApneaLine-dom" canvas-id="mychart-chart-apnea-line"
 						ec="{{ ecApneaLine }}"></ec-canvas>
-				</view> 
+				</view>
 			</view> -->
 			<view class="data-row_c6" style="margin-top: 30rpx;">
 				<view
@@ -576,4 +576,28 @@
 		</van-popup>  -->
 
 	</view>
+	<painter
+			customActionStyle="{{customActionStyle}}"
+			palette="{{paintPallette}}"
+			bind:imgOK="onImgOK"
+			bind:touchEnd="touchEnd"
+			widthPixels="1000"
+	/>
+	<van-overlay show="{{ showImg }}" bind:click="onClickHide">
+		<view class="wrapper">
+			<view class="block" >
+				<image src="{{image}}"  style="width: 630rpx; height: 100%;z-index: 1000;"/>
+			</view>
+			<view class="btns-box">
+				<view class="print-btn" bind:tap="hotelPrinting">
+					<image class="btn-img"  src="../images/painter/dy-1.png" ></image>
+					酒店打印
+				</view>
+				<view class="save-btn" bind:tap="saveImage">
+					<image class="btn-img" src="../images/painter/bc-1.png" ></image>
+					保存到本地
+				</view>
+			</view>
+		</view>
+	</van-overlay>
 </view>

+ 59 - 1
subpages/data/data.wxss

@@ -408,7 +408,7 @@ ec-canvas {
   /* 垂直居中 */
   text-align: center;
   /* 水平居中 */
-  z-index: 999;
+  /*z-index: 999;*/
 }
 
 .centered-text_1 {
@@ -1821,4 +1821,62 @@ ec-canvas_c6 {
   width: 100%;
   display: flex;
   flex-direction: column;
+}
+.wrapper {
+  display: flex;
+  flex-direction: column;
+  align-items: center;
+  justify-content: center;
+  height: 100%;
+}
+
+.block {
+  width: 630rpx;
+  height: 800rpx;
+}
+.btns-box {
+  width: 630rpx;
+  padding:80rpx 28rpx 0;
+  display: flex;
+  justify-content: space-between;
+  align-items: center;
+  box-sizing: border-box;
+}
+.print-btn{
+  width: 272rpx;
+  height: 84rpx;
+  background: #FFFFFF;
+  border-radius: 292rpx 292rpx 292rpx 292rpx;
+  font-weight: normal;
+  font-size: 28rpx;
+  color: #0BC3AA;
+  line-height: 40rpx;
+  text-align: center;
+  font-style: normal;
+  text-transform: none;
+  display: flex;
+  justify-content: center;
+  align-items: center;
+}
+.btn-img{
+  width: 28rpx;
+  height: 28rpx;
+  margin-right: 16rpx;
+}
+.save-btn{
+  width: 272rpx;
+  height: 84rpx;
+  background: linear-gradient( 315deg, #0ABCA4 0%, #0BC3AA 100%);
+  border-radius: 292rpx 292rpx 292rpx 292rpx;
+  font-weight: normal;
+  font-size: 28rpx;
+  color: #FFFFFF;
+  line-height: 40rpx;
+  text-align: center;
+  font-style: normal;
+  text-transform: none;
+  display: flex;
+  justify-content: center;
+  align-items: center;
+
 }

+ 11 - 11
pages/index/getPosterObj.js → subpages/data/getPosterObj.js

@@ -7,21 +7,21 @@ export function getDrawImg(url, height = 0) {
                 "css": {
                     "top": "0",
                     "width": 750 + "rpx",
-                    "height": height + 500 + "rpx",
+                    "height": height + 713 + "rpx",
                     "display": "block",
                     "borderRadius": "15rpx 15rpx 0 0"
                 }
             }],
-        height: height + 500
+        height: height + 713
     }
 }
-export function getCheckInInfo(talk, height = 0) {
+export function getCheckInInfo(talk,hotelname ="", roomname="",rscore_value= 0,dateStr='',height = 0) {
     let mr=48
     return {
         obj: [
             {
                 "type": "image",
-                "url": "/static/painter/bg-1.png",
+                "url": "../../subpages/images/painter/bg-1.png",
                 "css": {
                     "top": height+"rpx",
                     width: "750rpx",
@@ -31,7 +31,7 @@ export function getCheckInInfo(talk, height = 0) {
             },
             {
                 "type": "text",
-                "text": "银弘辰悦酒店",
+                "text": hotelname || "银弘辰悦酒店",
                 "css": {
                     "top":height+48+"rpx",
                     "left": mr+"rpx",
@@ -46,7 +46,7 @@ export function getCheckInInfo(talk, height = 0) {
             },
             {
                 "type": "image",
-                "url": "/static/painter/icon-2.png", // 确保路径正确
+                "url": "../../subpages/images/painter/icon-2.png", // 确保路径正确
                 "css": {
                     "top": height+124+"rpx",
                     "left": mr+"rpx",
@@ -57,7 +57,7 @@ export function getCheckInInfo(talk, height = 0) {
             },
             {
                 "type": "text",
-                "text": "2025年6月30日",
+                "text": dateStr,
                 "css": {
                     "top":height+119+"rpx",
                     "left": 100+"rpx",
@@ -72,7 +72,7 @@ export function getCheckInInfo(talk, height = 0) {
             },
             {
                 "type": "image",
-                "url": "/static/painter/icon-1.png", // 确保路径正确
+                "url": "../../subpages/images/painter/icon-1.png", // 确保路径正确
                 "css": {
                     "top": height+122+"rpx",
                     "left": 376+"rpx",
@@ -83,7 +83,7 @@ export function getCheckInInfo(talk, height = 0) {
             },
             {
                 "type": "text",
-                "text": "2801",
+                "text": roomname,
                 "css": {
                     "top":height+119+"rpx",
                     "left": 426+"rpx",
@@ -110,7 +110,7 @@ export function getCheckInInfo(talk, height = 0) {
             },
             {
                 "type": "text",
-                "text": "80",
+                "text": rscore_value,
                 "css": {
                     "top":height+40+"rpx",
                     "left": 595+"rpx",
@@ -168,7 +168,7 @@ export function getCheckInInfo(talk, height = 0) {
             },
             {
                 "type": "image",
-                "url": '/static/painter/qr-code.png', // 默认显示“匿名用户”
+                "url": '../../subpages/images/painter/qr-code.png', // 默认显示“匿名用户”
                 "css": {
                     "top": height+230+"rpx",
                     "left": "530rpx",

+ 0 - 0
static/painter/bc-1.png → subpages/images/painter/bc-1.png


+ 0 - 0
static/painter/bg-1.png → subpages/images/painter/bg-1.png


+ 0 - 0
static/painter/dy-1.png → subpages/images/painter/dy-1.png


+ 0 - 0
static/painter/icon-1.png → subpages/images/painter/icon-1.png


+ 0 - 0
static/painter/icon-2.png → subpages/images/painter/icon-2.png


+ 0 - 0
static/painter/qr-code.png → subpages/images/painter/qr-code.png


+ 23 - 12
subpages/scan/scan.js

@@ -21,6 +21,11 @@ Page({
       expireTimeStamp: Date.now() + 24 * 60 * 60 * 1000 // 超时时间戳,例如设置为1天后过期  
     };
   },
+  onClickLeft() {
+    wx.navigateBack({
+      delta: 1
+    })
+  },
   onChangePrivacy(event) {
     const check = event.detail;
 
@@ -115,19 +120,22 @@ Page({
         },
         method: 'POST',
         success: function (intervalRes) {
-          console.log('intervalRes=' + JSON.stringify(intervalRes));
+          console.log('intervalRes6666666666666=' + JSON.stringify(intervalRes));
           console.log('intervalRes.data=' + JSON.stringify(intervalRes.data));
           //empower.js? [sm]:152 intervalRes.data={"st":"success","status":"0"}
           if (intervalRes.data && intervalRes.data.st && intervalRes.data.status && intervalRes.data.st == 'success' && intervalRes.data.status == '1') {
             wx.setStorageSync('hasHotelAuth', true);
-            wx.setStorageSync('hotelEmpower', intervalRes.data.hotel);
-            wx.setStorageSync('roomEmpower', intervalRes.data.room);
-            wx.setStorageSync('hname', intervalRes.data.hname);
-            wx.setStorageSync('rname', intervalRes.data.rname);
-            
           } else {
             wx.setStorageSync('hasHotelAuth', false);
           }
+          try {
+            wx.setStorageSync('hotelEmpower', intervalRes?.data?.hotel);
+            wx.setStorageSync('roomEmpower', intervalRes?.data?.room);
+            wx.setStorageSync('hname', intervalRes?.data?.hname);
+            wx.setStorageSync('rname', intervalRes?.data?.rname);
+          }catch ( e){
+            console.log(e)
+          }
         },
         fail: function (error) {
 
@@ -150,16 +158,19 @@ Page({
       },
       method: 'POST',
       success: function (intervalRes) {
-        console.log('intervalRes=' + JSON.stringify(intervalRes));
+        console.log('intervalRes25252252=' + JSON.stringify(intervalRes));
         console.log('intervalRes.data=' + JSON.stringify(intervalRes.data));
         //empower.js? [sm]:152 intervalRes.data={"st":"success","status":"0"}
+        try {
+          wx.setStorageSync('hotelEmpower', intervalRes?.data?.hotel);
+          wx.setStorageSync('roomEmpower', intervalRes?.data?.room);
+          wx.setStorageSync('hname', intervalRes?.data?.hname);
+          wx.setStorageSync('rname', intervalRes?.data?.rname);
+        }catch ( e){
+          console.log(e)
+        }
         if (intervalRes.data && intervalRes.data.st && intervalRes.data.status && intervalRes.data.st == 'success' && intervalRes.data.status == '1') {
           wx.setStorageSync('hasHotelAuth', true);
-          wx.setStorageSync('hotelEmpower', intervalRes.data.hotel);
-          wx.setStorageSync('roomEmpower', intervalRes.data.room);
-          wx.setStorageSync('hname', intervalRes.data.hname);
-          wx.setStorageSync('rname', intervalRes.data.rname);
-
           wx.setStorageSync('res', res);
           wx.setStorageSync('scanResultExpiresAt', Date.now() + 2 * 60 * 60 * 1000); // 超时时间戳,例如设置为2小时后过期
           wx.reLaunch({

+ 1 - 1
subpages/scan/scan.wxml

@@ -1,7 +1,7 @@
 <view class="container">
   <image class="bg-image" src="/static/images/ic_scan_bg.png" mode="widthFix"></image>
   <view class="scan-body">
-    <van-nav-bar title="扫描二维码" left-text="" left="" custom-class="nav-bar"></van-nav-bar>
+    <van-nav-bar title="扫描二维码"   left-text="返回"  left-arrow bind:click-left="onClickLeft"  custom-class="nav-bar"></van-nav-bar>
     <view class="scan-content">
       <image class="bg-phone-image" src="/static/images/ic_phone_bg.png" mode="widthFix"></image>
       <text class="scan-tips">扫描成功后将跳转至睡眠控制主页</text>

+ 4 - 0
subpages/scan/scan.wxss

@@ -4,6 +4,10 @@
   -moz-background-size: 100% 100%;
   background-color: #333;
 } */
+.nav-bar {
+  --nav-bar-icon-color: #25CDB8;
+  --nav-bar-text-color: #25CDB8; /* 示例:将文字颜色设置为红色 */
+}
 .container {
   /* --nav-bar-icon-color: black !important; */
   display: flex;

+ 2 - 0
subpagesTwo/components/navBar/app.js

@@ -0,0 +1,2 @@
+// eslint-disable-next-line import/prefer-default-export
+export { default as navBar } from './navBar';

+ 228 - 0
subpagesTwo/components/navBar/navBar.js

@@ -0,0 +1,228 @@
+Component({
+  options: {
+    multipleSlots: true,
+    addGlobalClass: true
+  },
+  properties: {
+    extClass: {
+      type: String,
+      value: ''
+    },
+    background: {
+      type: String,
+      value: 'rgba(255, 255, 255, 1)',
+      observer: '_showChange'
+    },
+    backgroundColorTop: {
+      type: String,
+      value: 'rgba(255, 255, 255, 1)',
+      observer: '_showChangeBackgroundColorTop'
+    },
+    color: {
+      type: String,
+      value: 'rgba(0, 0, 0, 1)'
+    },
+    title: {
+      type: String,
+      value: ''
+    },
+    searchText: {
+      type: String,
+      value: '点我搜索'
+    },
+    searchBar: {
+      type: Boolean,
+      value: false
+    },
+    back: {
+      type: Boolean,
+      value: false
+    },
+    home: {
+      type: Boolean,
+      value: false
+    },
+    iconTheme: {
+      type: String,
+      value: 'black'
+    },
+    /* animated: {
+      type: Boolean,
+      value: true
+    },
+    show: {
+      type: Boolean,
+      value: true,
+      observer: '_showChange'
+    }, */
+    delta: {
+      type: Number,
+      value: 1
+    }
+  },
+  created: function() {
+    this.getSystemInfo();
+  },
+  attached: function() {
+    this.setStyle(); //设置样式
+  },
+  data: {},
+  pageLifetimes: {
+    show: function() {
+      if (getApp().globalSystemInfo.ios) {
+        this.getSystemInfo();
+        this.setStyle(); //设置样式1
+      }
+    },
+    hide: function() {}
+  },
+  methods: {
+    setStyle: function(life) {
+      const {
+        statusBarHeight,
+        navBarHeight,
+        capsulePosition,
+        navBarExtendHeight,
+        ios,
+        windowWidth
+      } = getApp().globalSystemInfo;
+      const { back, home, title } = this.data;
+      let rightDistance = windowWidth - capsulePosition.right; //胶囊按钮右侧到屏幕右侧的边距
+      let leftWidth = windowWidth - capsulePosition.left; //胶囊按钮左侧到屏幕右侧的边距
+
+      let navigationbarinnerStyle = [
+        `color: ${this.data.color}`,
+        `background: ${this.data.background}`,
+        `height:${navBarHeight + navBarExtendHeight}px`,
+        `padding-top:${statusBarHeight}px`,
+        `padding-right:${leftWidth}px`,
+        `padding-bottom:${navBarExtendHeight}px`
+      ].join(';');
+      let navBarLeft = [];
+      if ((back && !home) || (!back && home)) {
+        navBarLeft = [`width:${capsulePosition.width}px`, `height:${capsulePosition.height}px`].join(';');
+      } else if ((back && home) || title) {
+        navBarLeft = [
+          `width:${capsulePosition.width}px`,
+          `height:${capsulePosition.height}px`,
+          `margin-left:${rightDistance}px`
+        ].join(';');
+      } else {
+        navBarLeft = [`width:auto`, `margin-left:0px`].join(';');
+      }
+      if (life === 'created') {
+        this.data = {
+          navigationbarinnerStyle,
+          navBarLeft,
+          navBarHeight,
+          capsulePosition,
+          navBarExtendHeight,
+          ios
+        };
+      } else {
+        this.setData({
+          navigationbarinnerStyle,
+          navBarLeft,
+          navBarHeight,
+          capsulePosition,
+          navBarExtendHeight,
+          ios
+        });
+      }
+    },
+    _showChange: function(value) {
+      this.setStyle();
+    },
+    // 返回事件
+    back: function() {
+      this.triggerEvent('back', { delta: this.data.delta });
+    },
+    home: function() {
+      this.triggerEvent('home', {});
+    },
+    search: function() {
+      this.triggerEvent('search', {});
+    },
+    getSystemInfo() {
+      var app = getApp();
+      if (app.globalSystemInfo && !app.globalSystemInfo.ios) {
+        return app.globalSystemInfo;
+      } else {
+        let systemInfo = wx.getSystemInfoSync();
+        let ios = !!(systemInfo.system.toLowerCase().search('ios') + 1);
+        let rect;
+        try {
+          rect = wx.getMenuButtonBoundingClientRect ? wx.getMenuButtonBoundingClientRect() : null;
+          if (rect === null) {
+            throw 'getMenuButtonBoundingClientRect error';
+          }
+          //取值为0的情况  有可能width不为0 top为0的情况
+          if (!rect.width || !rect.top || !rect.left || !rect.height) {
+            throw 'getMenuButtonBoundingClientRect error';
+          }
+        } catch (error) {
+          let gap = ''; //胶囊按钮上下间距 使导航内容居中
+          let width = 96; //胶囊的宽度
+          if (systemInfo.platform === 'android') {
+            gap = 8;
+            width = 96;
+          } else if (systemInfo.platform === 'devtools') {
+            if (ios) {
+              gap = 5.5; //开发工具中ios手机
+            } else {
+              gap = 7.5; //开发工具中android和其他手机
+            }
+          } else {
+            gap = 4;
+            width = 88;
+          }
+          if (!systemInfo.statusBarHeight) {
+            //开启wifi的情况下修复statusBarHeight值获取不到
+            systemInfo.statusBarHeight = systemInfo.screenHeight - systemInfo.windowHeight - 20;
+          }
+          rect = {
+            //获取不到胶囊信息就自定义重置一个
+            bottom: systemInfo.statusBarHeight + gap + 32,
+            height: 32,
+            left: systemInfo.windowWidth - width - 10,
+            right: systemInfo.windowWidth - 10,
+            top: systemInfo.statusBarHeight + gap,
+            width: width
+          };
+          console.log('error', error);
+          console.log('rect', rect);
+        }
+
+        let navBarHeight = '';
+        if (!systemInfo.statusBarHeight) {
+          systemInfo.statusBarHeight = systemInfo.screenHeight - systemInfo.windowHeight - 20;
+          navBarHeight = (function() {
+            let gap = rect.top - systemInfo.statusBarHeight;
+            return 2 * gap + rect.height;
+          })();
+
+          systemInfo.statusBarHeight = 0;
+          systemInfo.navBarExtendHeight = 0; //下方扩展4像素高度 防止下方边距太小
+        } else {
+          navBarHeight = (function() {
+            let gap = rect.top - systemInfo.statusBarHeight;
+            return systemInfo.statusBarHeight + 2 * gap + rect.height;
+          })();
+          if (ios) {
+            systemInfo.navBarExtendHeight = 4; //下方扩展4像素高度 防止下方边距太小
+          } else {
+            systemInfo.navBarExtendHeight = 0;
+          }
+        }
+        systemInfo.navBarHeight = navBarHeight; //导航栏高度不包括statusBarHeight
+        systemInfo.capsulePosition = rect; //右上角胶囊按钮信息bottom: 58 height: 32 left: 317 right: 404 top: 26 width: 87 目前发现在大多机型都是固定值 为防止不一样所以会使用动态值来计算nav元素大小
+        systemInfo.ios = ios; //是否ios
+
+        app.globalSystemInfo = systemInfo; //将信息保存到全局变量中,后边再用就不用重新异步获取了
+
+        //console.log('systemInfo', systemInfo);
+        return systemInfo;
+      }
+    }
+  }
+});

+ 4 - 0
subpagesTwo/components/navBar/navBar.json

@@ -0,0 +1,4 @@
+{
+  "component": true,
+  "usingComponents": {}
+}

+ 41 - 0
subpagesTwo/components/navBar/navBar.wxml

@@ -0,0 +1,41 @@
+<view class="lxy-nav-bar {{extClass}}" style="background: {{backgroundColorTop}};height: {{navBarHeight+ navBarExtendHeight}}px;">
+    <view class="lxy-nav-bar__placeholder {{ios ? 'ios' : 'android'}}" style="padding-top: {{navBarHeight+ navBarExtendHeight}}px;visibility: hidden;"></view>
+    <view class="lxy-nav-bar__inner {{ios ? 'ios' : 'android'}}" style="{{navigationbarinnerStyle}}{{displayStyle}}">
+        <view class='lxy-nav-bar__left' style="{{navBarLeft}}">
+            <block wx:if="{{back&&!home}}">
+                <view bindtap="back" class="lxy-nav-bar__button lxy-nav-bar__btn_goback {{iconTheme}}"></view>
+            </block>
+            <block wx:if="{{!back&&home}}">
+                <view bindtap="home" class="lxy-nav-bar__button lxy-nav-bar__btn_gohome {{iconTheme}}"></view>
+            </block>
+            <block wx:elif="{{back&&home}}">
+                <view class="lxy-nav-bar__buttons {{ios ? 'ios' : 'android'}}" wx:if="{{home}}">
+                    <view bindtap="back" class="lxy-nav-bar__button lxy-nav-bar__btn_goback {{iconTheme}}" wx:if="{{back}}"></view>
+                    <view bindtap="home" class="lxy-nav-bar__button lxy-nav-bar__btn_gohome {{iconTheme}}"></view>
+                </view>
+            </block>
+            <block wx:else>
+                <slot name="left"></slot>
+            </block>
+        </view>
+        <view class='lxy-nav-bar__center'>
+            <block wx:if="{{title}}">
+                <text class='lxy-nav-bar__center-title'>{{title}}</text>
+            </block>
+            <view class='lxy-nav-bar-search' style="height:{{capsulePosition.height}}px;" wx:elif="{{searchBar}}" bindtap="search">
+                <view class='lxy-nav-bar-search__icon' />
+                <view class='lxy-nav-bar-search__input'>{{searchText}}</view>
+            </view>
+            <!-- 暂时不开发标题loading. 看后期需要 -->
+            <!-- <view wx:if="{{loading}}" class="lxy-nav-bar__loading">
+                <view class="lxy-loading" style="width:{{size.width}}rpx;height:{{size.height}}rpx;"></view>
+            </view> -->
+            <block wx:else>
+                <slot name="center"></slot>
+            </block>
+        </view>
+        <view class='lxy-nav-bar__right'>
+            <slot name="right"></slot>
+        </view>
+    </view>
+</view>

+ 173 - 0
subpagesTwo/components/navBar/navBar.wxss

@@ -0,0 +1,173 @@
+view,
+text,
+scroll-view,
+input,
+button,
+image,
+cover-view {
+  box-sizing: border-box;
+}
+page {
+  --height: 44px; /* 4*2+32 */
+  --right: 97px; /* 10+87 */
+  --navBarExtendHeight: 4px;
+  box-sizing: border-box;
+}
+.lxy-nav-bar .ios {
+  --height: 44px; /* 4*2+32 */
+  --right: 97px; /* 10+87 */
+  --navBarExtendHeight: 4px;
+  box-sizing: border-box;
+}
+.lxy-nav-bar .android {
+  --height: 48px; /* 8*2+32 */
+  --right: 96px; /* 10+87 */
+  --navBarExtendHeight: 4px;
+  box-sizing: border-box;
+}
+.lxy-nav-bar .devtools {
+  --height: 42px; /* 5*2+32 */
+  --right: 88px; /* 10+87 */
+  --navBarExtendHeight: 4px;
+  box-sizing: border-box;
+}
+.lxy-nav-bar__inner {
+  position: fixed;
+  top: 0;
+  left: 0;
+  z-index: 5001;
+  height: var(--height);
+  display: flex;
+  align-items: center;
+  padding-right: var(--right);
+  width: 100%;
+  padding-bottom: var(--navBarExtendHeight);
+}
+.lxy-nav-bar__inner .lxy-nav-bar__left {
+  position: relative;
+  width: var(--right);
+  height: 32px;
+  /*  padding-left: 10px; */
+  display: flex;
+  align-items: center;
+}
+.lxy-nav-bar__buttons {
+  height: 100%;
+  width: 100%;
+  display: flex;
+  align-items: center;
+  border-radius: 16px;
+  border: 1rpx solid rgba(204, 204, 204, 0.6);
+  position: relative;
+}
+.lxy-nav-bar__buttons.android {
+  border: 1rpx solid rgba(234, 234, 234, 0.6);
+}
+.lxy-nav-bar__buttons::after {
+  position: absolute;
+  content: '';
+  width: 1rpx;
+  height: 18.4px;
+  background: rgba(204, 204, 204, 0.6);
+  left: 50%;
+  top: 50%;
+  transform: translate(-50%, -50%);
+}
+.lxy-nav-bar__buttons.android::after {
+  background: rgba(234, 234, 234, 0.6);
+}
+.lxy-nav-bar__button {
+  width: 50%;
+  height: 100%;
+  display: flex;
+  font-size: 12px;
+  background-repeat: no-repeat;
+  background-position: center center;
+  background-size: 1em 2em;
+}
+
+.lxy-nav-bar__inner .lxy-nav-bar__left .lxy-nav-bar__btn_goback:active,
+.lxy-nav-bar__inner .lxy-nav-bar__left .lxy-nav-bar__btn_gohome:active {
+  opacity: 0.5;
+}
+.lxy-nav-bar__inner .lxy-nav-bar__center {
+  font-size: 17px;
+  line-height: 17px;
+  text-align: center;
+  position: relative;
+  flex: 1;
+  display: -webkit-box;
+  display: -webkit-flex;
+  display: flex;
+  align-items: center;
+  justify-content: center;
+  padding-left: 10px;
+}
+.lxy-nav-bar__inner .lxy-nav-bar__center .lxy-nav-bar__center-title {
+  margin-top: -2px;
+  font-weight: bold; /*字体加粗*/
+  font-size: 18px;/*字体大小*/
+  letter-spacing: 2rpx;/*字间距*/
+  /* color:rgb(13, 55, 243); *//*字体颜色*/
+}
+.lxy-nav-bar__inner .lxy-nav-bar__loading {
+  font-size: 0;
+}
+.lxy-nav-bar__inner .lxy-nav-bar__loading .lxy-loading {
+  margin-left: 0;
+}
+.lxy-nav-bar__inner .lxy-nav-bar__right {
+  margin-right: 10px;
+}
+.lxy-nav-bar__placeholder {
+  height: var(--height);
+  background: #f8f8f8;
+  position: relative;
+  z-index: 50;
+}
+
+.lxy-nav-bar-search {
+  width: 100%;
+  height: 100%;
+  display: flex;
+  justify-content: center;
+  align-items: center;
+  width: 100%;
+  height: 32px;
+  border-radius: 16px;
+  position: relative;
+  background: #f6f6f6;
+}
+
+.lxy-nav-bar-search__input {
+  height: 100%;
+  display: flex;
+  align-items: center;
+  color: #999;
+  font-size: 15px;
+  line-height: 15px;
+}
+.lxy-nav-bar__inner .lxy-nav-bar__left .lxy-nav-bar__btn_goback {
+  background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='24' viewBox='0 0 12 24'%3E  %3Cpath fill-opacity='.9' fill-rule='evenodd' d='M10 19.438L8.955 20.5l-7.666-7.79a1.02 1.02 0 0 1 0-1.42L8.955 3.5 10 4.563 2.682 12 10 19.438z'/%3E%3C/svg%3E");
+}
+.lxy-nav-bar__inner .lxy-nav-bar__left .lxy-nav-bar__btn_goback.white {
+  background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='24' viewBox='0 0 12 24'%3E  %3Cpath fill-opacity='.9' fill-rule='evenodd' d='M10 19.438L8.955 20.5l-7.666-7.79a1.02 1.02 0 0 1 0-1.42L8.955 3.5 10 4.563 2.682 12 10 19.438z' fill='%23ffffff'/%3E%3C/svg%3E");
+}
+.lxy-nav-bar__inner .lxy-nav-bar__left .lxy-nav-bar__btn_gohome {
+  background-image: url("data:image/svg+xml,%3Csvg t='1565752242401' class='icon' viewBox='0 0 1024 1024' version='1.1' xmlns='http://www.w3.org/2000/svg' p-id='4326' width='48' height='48'%3E%3Cpath d='M931.148 451.25L591.505 97.654c-21.106-21.953-49.313-34.034-79.551-34.034-30.235 0-58.448 12.081-79.554 34.034L92.76 451.25c-35.049 36.498-30.536 68.044-24.742 81.222 4.13 9.35 18.07 35.05 58.231 35.05h49.78v272.016c0 61.756 44.342 119.906 107.357 119.906h144.587v-287.87c0-30.866-4.675-48.062 26.848-48.062h114.268c31.52 0 26.845 17.196 26.845 48.061v287.872h144.588c63.013 0 107.358-58.15 107.358-119.906V567.523h49.782c40.16 0 54.1-25.7 58.229-35.05 5.793-13.18 10.306-44.726-24.743-81.224z m-33.486 60.28h-105.77v328.007c0 30.865-19.877 63.917-51.37 63.917h-88.6V671.572c0-61.761-19.79-104.05-82.832-104.05H454.821c-63.045 0-82.836 42.289-82.836 104.05v231.883h-88.599c-31.495 0-51.37-33.052-51.37-63.917V511.529H126.25c-0.984 0-1.888-3.852-2.708-3.907 1.94-3.388 5.276-11.975 10.825-17.743l339.671-353.35c10.142-10.578 24.467-17.057 38.353-16.924 13.888-0.133 27.342 6.346 37.483 16.923L889.54 489.88c5.549 5.768 8.885 14.355 10.825 17.743-0.818 0.055-1.72 3.907-2.704 3.907z' fill='%23000000' p-id='4327'%3E%3C/path%3E%3C/svg%3E");
+  background-size: 22px 22px;
+}
+.lxy-nav-bar__inner .lxy-nav-bar__left .lxy-nav-bar__btn_gohome.white {
+  background-image: url("data:image/svg+xml,%3Csvg t='1565752242401' class='icon' viewBox='0 0 1024 1024' version='1.1' xmlns='http://www.w3.org/2000/svg' p-id='4326' width='48' height='48'%3E%3Cpath d='M931.148 451.25L591.505 97.654c-21.106-21.953-49.313-34.034-79.551-34.034-30.235 0-58.448 12.081-79.554 34.034L92.76 451.25c-35.049 36.498-30.536 68.044-24.742 81.222 4.13 9.35 18.07 35.05 58.231 35.05h49.78v272.016c0 61.756 44.342 119.906 107.357 119.906h144.587v-287.87c0-30.866-4.675-48.062 26.848-48.062h114.268c31.52 0 26.845 17.196 26.845 48.061v287.872h144.588c63.013 0 107.358-58.15 107.358-119.906V567.523h49.782c40.16 0 54.1-25.7 58.229-35.05 5.793-13.18 10.306-44.726-24.743-81.224z m-33.486 60.28h-105.77v328.007c0 30.865-19.877 63.917-51.37 63.917h-88.6V671.572c0-61.761-19.79-104.05-82.832-104.05H454.821c-63.045 0-82.836 42.289-82.836 104.05v231.883h-88.599c-31.495 0-51.37-33.052-51.37-63.917V511.529H126.25c-0.984 0-1.888-3.852-2.708-3.907 1.94-3.388 5.276-11.975 10.825-17.743l339.671-353.35c10.142-10.578 24.467-17.057 38.353-16.924 13.888-0.133 27.342 6.346 37.483 16.923L889.54 489.88c5.549 5.768 8.885 14.355 10.825 17.743-0.818 0.055-1.72 3.907-2.704 3.907z' fill='%23ffffff' p-id='4327'%3E%3C/path%3E%3C/svg%3E");
+  background-size: 22px 22px;
+}
+.lxy-nav-bar-search__icon {
+  width: 22px;
+  height: 22px;
+  display: flex;
+  align-items: center;
+  justify-content: center;
+  background-image: url("data:image/svg+xml,%3Csvg t='1565691512239' class='icon' viewBox='0 0 1024 1024' version='1.1' xmlns='http://www.w3.org/2000/svg' p-id='1240' width='48' height='48'%3E%3Cpath d='M819.2 798.254545L674.909091 653.963636c46.545455-48.872727 74.472727-114.036364 74.472727-186.181818 0-151.272727-123.345455-274.618182-274.618182-274.618182-151.272727 0-274.618182 123.345455-274.618181 274.618182 0 151.272727 123.345455 274.618182 274.618181 274.618182 65.163636 0 128-23.272727 174.545455-62.836364l144.290909 144.290909c2.327273 2.327273 6.981818 4.654545 11.636364 4.654546s9.309091-2.327273 11.636363-4.654546c6.981818-6.981818 6.981818-18.618182 2.327273-25.6zM235.054545 467.781818c0-132.654545 107.054545-239.709091 239.709091-239.709091 132.654545 0 239.709091 107.054545 239.709091 239.709091 0 132.654545-107.054545 239.709091-239.709091 239.709091-132.654545 0-239.709091-107.054545-239.709091-239.709091z' fill='%23999999' p-id='1241'%3E%3C/path%3E%3C/svg%3E");
+  background-repeat: no-repeat;
+  background-size: cover;
+}

+ 23 - 0
subpagesTwo/components/navBar/package.json

@@ -0,0 +1,23 @@
+{
+  "name": "weapp-navigation-bar",
+  "version": "2.2.1",
+  "description": "原生封装的自定义导航栏  可自定义返回事件 返回home 搜索框 自定义左中右",
+  "main": "app.js",
+  "scripts": {
+    "test": "echo \"Error: no test specified\" && exit 1"
+  },
+  "keywords": [
+    "weapp",
+    "miniprogram",
+    "navbar",
+    "navigation-bar",
+    "navigationbar"
+  ],
+  "repository": {
+    "type": "git",
+    "url": "https://github.com/lingxiaoyi/navigation-bar"
+  },
+  "author": "lxy",
+  "license": "ISC",
+  "dependencies": {}
+}

+ 346 - 0
subpagesTwo/dropfoot/dropfoot.js

@@ -0,0 +1,346 @@
+const app = getApp()
+
+//main
+Page({
+//Data
+    data: {
+        OnlyReadOne: null,     // OnlyOneCheackStateMents
+        receiveText: '',      // explain ReciveMesage
+        connectedDeviceId: '',// BLE_List_ID
+        service_uuid: '',     // BLE_UUID
+
+        workstate: false,     // 工作状态
+        target: 1,             // 强度
+        current: 5,            // 时间
+        mode: 1,               // 模式
+
+        Rworkstate: 0,         // 工作状态
+        Rtarget: 0,             // 强度
+        Rcurrent1: 0,           // 分
+        Rcurrent2: 0,           // 秒
+        Rmode: 0,               // 模式
+        RBattery: 0,            // 电量
+        LastSendingTime: 0,
+         timeInterval:1000,
+        DisplayBLEconflag: 0,  //show ble offline
+        tisrc: "/subpagesTwo/images/zmdevice/target1.png",
+        tisrc1: "/subpagesTwo/images/zmdevice/target1.png",
+        tisrc2: "/subpagesTwo/images/zmdevice/target.png",
+        cisrc: "/subpagesTwo/images/zmdevice/current.png",
+        cisrc1: "/subpagesTwo/images/zmdevice/current1.png",
+        cisrc2: "/subpagesTwo/images/zmdevice/current.png",
+        tcisc: 1,
+        ccisc: 0,
+    },
+//响应强度按键
+    handleClick(e) {
+        var that = this;
+        const value = e.currentTarget.dataset.value;
+        this.setData({
+            mode: value,
+        });
+        if (this.data.workstate) {
+            this.setData({
+                workstate: false
+            });
+            setTimeout(() => {
+                this.setData({
+                    workstate: true
+                });
+                that.setDevdata(that,true);
+            }, 500);
+        }
+        // 这里可以添加其他逻辑
+        console.log('当前值:', value);
+    }, setDevdata(that,flag=false) {
+        var timestamp = new Date().getTime();
+        if ( !flag&&(that.data.LastSendingTime !== 0 && timestamp - that.data.LastSendingTime < that.data.timeInterval)) {
+            console.log('发送间隔小于500ms')
+            return
+        }
+        that.data.LastSendingTime = timestamp
+        // Makeup Inquire Message
+        //  0B 4D(帧头)
+        //  01(设备id)
+        //  10(写)
+        //  00 70(命令字)
+        //  00 02(命令个数)
+        //  04(数据个数)
+        //  WorkState(工作状态) Vvalue(强度) Tvalue(时间) 模式(mode)
+        //  CRCL CRCH (校验)
+        //  1C 0D(帧尾)
+        var temp_data_send = new Array(0x01, 0x10, 0x00, 0x70, 0x00, 0x02, 0x04,
+            that.data.workstate, that.data.current, that.data.target, that.data.mode);
+        let temp_crc = app.CRC16(temp_data_send)
+        temp_data_send.push(temp_crc[0]);
+        temp_data_send.push(temp_crc[1]);
+        // Add HeadTail
+        var senddata = new ArrayBuffer(17);
+        let bufferview = new DataView(senddata);
+        bufferview.setUint8(0, 0x0b);
+        bufferview.setUint8(1, 0x4d);
+        for (var i = 0; i < 13; i++) {
+            bufferview.setUint8([i + 2], temp_data_send[i]);
+        }
+        bufferview.setUint8(15, 0x1c);
+        bufferview.setUint8(16, 0x0d);
+
+        let RecoedData = senddata
+        // console.log("==========================", that.data.target)
+        wx.writeBLECharacteristicValue({
+            deviceId: that.data.connectedDeviceId,
+            serviceId: that.data.service_uuid,
+            characteristicId: "0003CDD2-0000-1000-8000-00805F9B0131",
+            value: RecoedData,
+            success: function (res) {
+                console.log('查询发送')
+            },
+            fail: function (err) {
+                console.log(err, '查询发送失败')
+            }
+        })
+    },
+// init
+    onLoad: function (options) {
+        var that = this;
+        that.setData({
+            connectedDeviceId: options.connectedDeviceId,
+            OnlyReadOne: null,
+            service_uuid: options.serviceId,
+            OnlyReadOne: setInterval(function () {
+                that.setDevdata(that);
+            }, that.data.timeInterval),
+        })
+        // 检测连接
+        wx.onBLEConnectionStateChange(function (res) {
+            console.log(res.connected)
+            if (res.connected == 0 && that.data.DisplayBLEconflag == 0) {
+                wx.showModal({
+                    title: '提示',
+                    content: '设备已断开',
+                    showCancel: false,
+                    success: function (res) {
+                        that.setData({
+                            connected: false,
+                            workstate: 0
+                        })
+                    }
+                })
+            }
+            that.setData({
+                connected: res.connected,
+            })
+        })
+        wx.onBLECharacteristicValueChange(function (res) {
+            console.log(`characteristic ${res.characteristicId} has changed, now is ${res.value}`)
+            that.setData({
+                receiveText: app.ab2hex(res.value)
+            })
+
+            let seceiver_buff = new Uint8Array(res.value);
+
+            for (let i = 0; i < seceiver_buff.length; i++) {
+                console.log(seceiver_buff[i].toString(16).padStart(2, '0') + ' ');
+            }
+
+            //开始处理蓝牙返回指令
+            for (var i = 0; i < (seceiver_buff.length - 10); i++) {
+                if (seceiver_buff[i] == 0x0b) {
+
+                    if ((seceiver_buff[i + 1] == 0x4d) && (seceiver_buff[i + 2] == 0x01) && (seceiver_buff[i + 3] == 0x10) && (seceiver_buff[i + 4] == 0x00) && (seceiver_buff[i + 5] == 0x70) && (seceiver_buff[i + 6] == 0x00) && (seceiver_buff[i + 7] == 0x03) && (seceiver_buff[i + 8] == 0x06)) {
+
+                        if ((seceiver_buff[i + 17] == 0x1C) && (seceiver_buff[i + 18] == 0x0D)) {
+                            let dataToVerify = seceiver_buff.subarray(i + 2, i + 15);   //索引2-14
+                            let calculatedCRC = app.CRC16(dataToVerify);
+                            if (calculatedCRC[0] == seceiver_buff[i + 15] && calculatedCRC[1] == seceiver_buff[i + 16]) {
+                                that.setData({
+                                    connected: true,
+                                    Rworkstate: seceiver_buff[i + 10],     // 工作状态
+                                    Rtarget: seceiver_buff[i + 11],             // 强度
+                                    target: seceiver_buff[i + 11],
+                                    Rcurrent1: seceiver_buff[i + 12],           // 分
+                                    Rcurrent2: seceiver_buff[i + 13],           // 秒
+                                    Rmode: seceiver_buff[i + 9],               // 模式
+                                    RBattery: seceiver_buff[i + 14],            // 电量
+                                })
+                              // console.log("收到数据:");
+                              // console.log("设备模式:",seceiver_buff[i+9]);
+                              // console.log("设备状态:",seceiver_buff[i+10]);
+                              // console.log("设备挡位:",seceiver_buff[i+11]);
+                              break;
+                            }
+                        } else {
+                            continue
+                        }
+                    } else {
+                        continue
+                    }
+                } else {
+                    continue
+                }
+            }
+        })
+
+
+    },
+
+//开始停止
+    Send: function () {
+        var that = this
+        if (that.data.workstate == false) {
+            that.setData({
+                workstate: true
+            })
+        } else {
+            that.setData({
+                workstate: false
+            })
+        }
+        this.setDevdata(that,true);
+    },
+
+// 强度
+    VoltagecheckboxChange: function (e) {
+        if (e.detail.value != "") {
+            this.setData({
+                tcisc: 1, ccisc: 0,
+                tisrc: this.data.tisrc1,
+                cisrc: this.data.cisrc2,
+            });
+        } else {
+            this.setData({tcisc: 0, tisrc: this.data.tisrc2});
+        }
+        this.setDevdata(this,true);
+    },
+
+// 时间
+    currentcheckboxChange: function (e) {
+        if (e.detail.value != "") {
+            this.setData({
+                ccisc: 1, tcisc: 0,
+                cisrc: this.data.cisrc1,
+                tisrc: this.data.tisrc2,
+            });
+        } else {
+            this.setData({ccisc: 0, cisrc: this.data.cisrc2});
+        }
+        this.setDevdata(this,true);
+    },
+
+//左键
+    leftTouchEnd: function (event) {
+        var that = this;
+        if (this.data.workstate == true) {
+            if (that.data.tcisc == 1) {
+                if (that.data.target > 1) {
+                    that.setData({
+                        target: that.data.target - 1,
+                    });
+                    this.setDevdata(that,true);
+                } else {
+                    console("强度越界");
+                    return;
+                }
+            } else if (that.data.ccisc == 1) {
+                if (that.data.current > 5) {
+                    that.setData({
+                        current: that.data.current - 5,
+                    });
+                    this.setDevdata(that,true);
+                } else {
+                    console.log("时间越界");
+                    return;
+                }
+            } else {
+                console.log("选择出错");
+                return;
+            }
+        } else {
+            wx.showModal({
+                title: '提示',
+                content: '设备未开始工作',
+                showCancel: false,
+                success: function (res) {
+                    that.setData({})
+                }
+            })
+        }
+
+    },
+
+
+//右键
+    rightTouchEnd: function (event) {
+        var that = this;
+        if (this.data.workstate == true) {
+            if (that.data.tcisc == 1) {
+                if (that.data.target < 30) {
+                    that.setData({
+                        target: that.data.target + 1,
+                    });
+                    this.setDevdata(that,true);
+                } else {
+                    console.log("强度越线");
+                    return;
+                }
+
+            } else if (that.data.ccisc == 1) {
+                if (that.data.current < 20) {
+                    that.setData({
+                        current: that.data.current + 5,
+                    });
+                    this.setDevdata(that,true);
+                } else {
+                    console.log("时间越线");
+                    return;
+                }
+            } else {
+                console.log("选择失败");
+                return;
+            }
+        } else {
+            wx.showModal({
+                title: '提示',
+                content: '设备未开始工作',
+                showCancel: false,
+                success: function (res) {
+                    that.setData({})
+                }
+            })
+        }
+    },
+
+    onReady: function () {
+
+    },
+
+    onShow: function () {
+        var that = this;
+        if (that.data.connected == false) {
+            clearInterval(this.data.OnlyReadOne);
+        }
+    },
+
+    onHide: function () {
+
+    },
+    onUnload: function () {
+        this.data.DisplayBLEconflag = 1,
+            // 关查询定时
+            clearInterval(this.data.OnlyReadOne)
+        // 关蓝牙连接
+        wx.closeBLEConnection({
+            deviceId: this.data.connectedDeviceId,
+            success(res) {
+                console.log(res)
+            }
+        })
+    },
+// Back to Search
+    handlerGobackClick(delta) {
+        wx.navigateBack({
+            delta: 2
+        });
+    },
+})
+

+ 5 - 0
subpagesTwo/dropfoot/dropfoot.json

@@ -0,0 +1,5 @@
+{
+  "usingComponents": {
+    "navBar": "../components/navBar/navBar"
+  }
+}

+ 97 - 0
subpagesTwo/dropfoot/dropfoot.wxml

@@ -0,0 +1,97 @@
+<view class="body">
+    <view class="body_txt" style="text-align:center">
+        <view class="weui-cells weui-cells_after-title">
+        </view>
+
+        <view style="width: 450rpx;margin: 0 auto">
+            <view class="status-text">
+                连接状态:{{connected ? "已连接" : "已断开"}}
+            </view>
+            <view style="display: flex;">
+                <view class="status-text"  style="flex: 1">
+                    模式:{{Rmode}}
+                </view >
+                <view class="status-text"  style="flex: 1">
+                    状态:{{Rworkstate === 0 ? "暂停" : "运行中"}}
+                </view>
+                <view class="status-text"  style="flex: 1">
+                    挡位:{{Rtarget}}
+                </view>
+            </view>
+            <view class="status-text">
+                计时:{{Rcurrent1}}分钟{{Rcurrent2}}秒
+            </view>
+            <view class="status-text">
+                电量:{{RBattery}}/5
+            </view>
+
+        </view>
+    </view>
+    <view class="waringimg">
+        <image src="/subpagesTwo/images/zmdevice/wake.png"
+               style="height: 520rpx; display: block; box-sizing: border-box; width: 595rpx"></image>
+    </view>
+
+
+    <view class="blocks" style="width: 677rpx; display: block; box-sizing: border-box">
+        <text style="font-size: x-small; color: gray; position: relative; left: 269rpx; top: 14rpx">
+            当前设置模式为:{{mode}}
+        </text>
+        <button type="primary"
+                style="position: relative; left: -212rpx; top: 139rpx; width: 125rpx; display: block; box-sizing: border-box; height: 87rpx"
+                data-value="1"
+                bindtap="handleClick">一
+        </button>
+        <button type="primary"
+                style="width: 125rpx; height: 87rpx; display: block; box-sizing: border-box; left: 29rpx; top: 52rpx; position: relative"
+                data-value="2"
+                bindtap="handleClick">二
+        </button>
+        <button type="primary"
+                style="position: relative; left: 272rpx; top: -35rpx; width: 125rpx; display: block; box-sizing: border-box; height: 87rpx"
+                data-value="3"
+                bindtap="handleClick">三
+        </button>
+    </view>
+    <view class="progset" style="height: 653rpx; display: flex; box-sizing: border-box">
+        <view class="clock">
+            <checkbox-group bindchange="VoltagecheckboxChange">
+                <checkbox value="targetset" checked="{{tcisc}}"/>
+            </checkbox-group>
+            <text decode="{{true}}">&nbsp;&nbsp;\n&nbsp;&nbsp;</text>
+
+            <image class="Voltage-image" src="{{tisrc}}" style="width: {{48}}px; height: {{48}}px;"></image>
+            <text decode="{{true}}">&nbsp;&nbsp;\n&nbsp;&nbsp;</text>
+
+            <view class="tainfor">
+                <text style="color: {{tcisc? '#0667f8':'#5f5f5fd7'}};">强度{{target}}\n</text>
+                <text style="color: {{ccisc? '#0667f8':'#5f5f5fd7'}};">{{current}}分钟</text>
+            </view>
+            <text decode="{{true}}">&nbsp;&nbsp;\n&nbsp;&nbsp;</text>
+
+            <image class="Voltage-image" src="{{cisrc}}" style="width: {{48}}px; height: {{48}}px;"></image>
+            <text decode="{{true}}">&nbsp;&nbsp;\n&nbsp;&nbsp;</text>
+
+            <checkbox-group bindchange="currentcheckboxChange">
+                <checkbox value="currentset" checked="{{ccisc}}"/>
+            </checkbox-group>
+        </view>
+        <view class="button">
+            <view class="circle-btn" bindtouchstart="leftTouchStart" bindtouchend="leftTouchEnd"
+                  disabled="{{leftDisabled}}">
+                <image src="/subpagesTwo/images/zmdevice/minus.png" style="width: 32px;height: 32px;"></image>
+            </view>
+            <view class="circle-work" bindtap="Send" disabled="{{stateDisabled}}">
+                <!-- <view  class="{{workstate? 'workstart':'workstop'}}"> </view> -->
+                <image wx:if="{{workstate}}" src="/subpagesTwo/images/zmdevice/start.png"
+                       style="width: 48px;height: 48px;"></image>
+                <image wx:else src="/subpagesTwo/images/zmdevice/stop.png" style="width: 32px;height: 32px;"></image>
+            </view>
+            <view class="circle-btn" bindtouchstart="rightTouchStart" bindtouchend="rightTouchEnd"
+                  disabled="{{rightDisabled}}">
+                <image src="/subpagesTwo/images/zmdevice/plus.png" style="width: 32px;height: 32px;"></image>
+            </view>
+        </view>
+
+    </view>
+</view>

+ 103 - 0
subpagesTwo/dropfoot/dropfoot.wxss

@@ -0,0 +1,103 @@
+.body
+  {
+    display:flex;
+    flex-direction: column; 
+    height: 100vh;/*这里是把标题栏的高度去掉了*/
+  }
+  
+  ._funcName
+  {
+   
+    text-align: center;
+    font-size: 20px;
+    font-weight: bold;
+    margin: 10px;   
+    border-radius: 10px;
+    color:rgba(14, 11, 11, 0.712);
+    background-color:  #cdcfcf59;
+  
+  }
+  .warning
+  {
+    flex-grow:1;/*占据body的剩余空间*/
+    margin: 10px;
+    background-color: #cdcfcf59;
+    border-radius: 15px;
+    padding-left: 10px;
+    padding-right: 10px;
+    padding-bottom: 5px;
+  }
+  .waringimg
+  {
+    display: flex;
+    justify-content: center; /* 水平居中 */
+    width: 100%;
+    height: auto;
+  }
+  .status-text
+  {
+    font-size:x-small;
+    color:gray;
+  }
+  .blocks
+  {
+    flex-grow:1;
+  }
+  .button
+  {
+    display: flex;
+    flex-direction: row;
+    justify-content: space-around;
+    align-items: center;
+    margin-top:20px;    
+  }
+  .circle-btn
+  {
+    border:5px solid #cdcfcf49;
+    width:60px;
+    height: 60px;
+    border-radius: 50%;
+    box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);  
+    display: flex;
+    flex-direction: column;
+    align-items: center;
+    justify-content: center;
+    background-color: rgba(0, 0, 0, 0.041);
+   }
+  .circle-work
+  {
+    border:5px solid #cdcfcf49;
+    width:100px;
+    height: 100px;
+    border-radius: 50%;
+    box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
+    line-height: 2.5em;
+    color: #0667f8;
+    background-color: rgba(0, 0, 0, 0.041);
+    display: flex;
+    flex-direction: column;
+    align-items: center;
+    justify-content: center;
+  }
+  .progset
+  {
+    display: flex;
+    flex-direction: column;
+    width: 100%;
+    border:1px solid #cdcfcf49;
+    border-radius: 10%;
+    padding-bottom: 10px;
+    padding-top: 15px;
+    background-color: rgba(3, 250, 65, 0.062);
+  }
+  .clock
+  {
+    display:flex;
+    align-items:center;
+    justify-content:space-between;
+    margin-left: 20px;
+    margin-right: 20px;
+    margin-top: 20px;
+    margin-bottom: 20px;  
+  }
+  

BIN=BIN
subpagesTwo/images/zmdevice/bluetooth.png


BIN=BIN
subpagesTwo/images/zmdevice/current.png


BIN=BIN
subpagesTwo/images/zmdevice/current1.png


BIN=BIN
subpagesTwo/images/zmdevice/minus.png


BIN=BIN
subpagesTwo/images/zmdevice/plus.png


BIN=BIN
subpagesTwo/images/zmdevice/start.png


BIN=BIN
subpagesTwo/images/zmdevice/stop.png


BIN=BIN
subpagesTwo/images/zmdevice/target.png


BIN=BIN
subpagesTwo/images/zmdevice/target1.png


BIN=BIN
subpagesTwo/images/zmdevice/wake.png


+ 345 - 0
subpagesTwo/search/search.js

@@ -0,0 +1,345 @@
+const app = getApp()
+app.globalData.pageid=1;
+
+Page({
+  
+  data: {
+    searching: false,
+    connectedDeviceId: '',
+    services: {},
+    characteristics: {},
+    devicesList: [],   
+    PageAddr: ["../device/device", "../dropfoot/dropfoot"],
+  },
+
+  checkUserHavePermission() 
+  {
+    getUserPermission('scope.bluetooth').then(() => {
+      // 用户已授权获取地理位置
+      this.getUserLocation(()=>{
+        // 获取位置 进行其他操作
+      })
+    }).catch(() => {
+      // 用户未授权/拒绝获取地理位置
+      // 需要提示用户手动打开设置去授权
+      this.openSettingPop(); // 打开提示弹窗
+    })
+  },
+
+  Search:function getUserPermission(permissionName) {
+    return new Promise((resolve, reject) => {
+      wx.getSetting({
+        success(res) {
+          if (res.authSetting[permissionName]) {
+            resolve(true);
+          } else if (res.authSetting[permissionName] === false) {
+            reject(false);
+          } else {
+            wx.authorize({
+              scope: permissionName,
+              success() {
+                resolve(true);
+              },
+              fail() {
+                reject(false);
+              }
+            });
+          }
+        },
+        fail() {
+          reject(false);
+        }
+      });
+    });
+  },
+  search2: function () {
+  },
+  back: function () {
+    wx.navigateBack()
+  },
+  home: function () {
+  },
+  Search: function () {
+    var that = this       
+    if (!that.data.searching) {
+      // 关闭蓝牙模块
+      wx.closeBluetoothAdapter({
+        // 接口调用结束的回调函数(调用成功、失败都会执行)
+        complete: function (res) {
+          console.log(res)
+          // 初始化蓝牙模块。iOS 上开启主机/从机(外围设备)模式时需分别调用一次,并指定对应的 mode。
+          wx.openBluetoothAdapter({
+            success: function (res) {
+              console.log(res)
+              // 获取本机蓝牙适配器状态
+              wx.getBluetoothAdapterState({
+                success: function (res) {
+                  console.log(res)
+                }
+              })
+              // 开始搜寻附近的蓝牙外围设备。
+              //此操作比较耗费系统资源,请在搜索到需要的设备后及时调用 wx.stopBluetoothDevicesDiscovery 停止搜索
+              wx.startBluetoothDevicesDiscovery({
+                allowDuplicatesKey: false,
+                success: function (res) {
+                  console.log(res)
+                  that.setData({
+                    searching: true,
+                    devicesList: []
+                  })
+                }
+              })
+            },
+            fail: function (res) {
+              console.log(res)
+              wx.showModal({
+                title: '提示',
+                content: '请检查手机蓝牙是否打开',
+                showCancel: false,
+                success: function (res) {
+                  that.setData({
+                    searching: false
+                  })
+                }
+              })
+            }
+          })
+        }
+      })
+    } else {
+      wx.stopBluetoothDevicesDiscovery({
+        success: function (res) {
+          console.log(res)
+          that.setData({
+            searching: false
+          })
+        }
+      })
+    }
+  },
+  Connect: function (e) {
+    var that = this
+    var advertisData, name
+    console.log(e.currentTarget.id)
+    for (var i = 0; i < that.data.devicesList.length; i++) {
+      if (e.currentTarget.id == that.data.devicesList[i].deviceId) {
+        name = that.data.devicesList[i].localName
+        advertisData = that.data.devicesList[i].advertisData
+      }
+    }
+    wx.stopBluetoothDevicesDiscovery({
+      success: function (res) {
+        console.log(res)
+        that.setData({
+          searching: false
+        })
+      }
+    })
+    if (name != 'WH-BLE 103') {
+      wx.showModal({
+        title: '提示',
+        content: '请选择正确设备连接',
+        showCancel: false,
+        success: function (res) {
+          that.setData({
+            searching: false
+          })
+        }
+      })
+      console.log('设备名称错误')
+    } else {
+      //显示loading提示框
+      wx.showLoading({
+        title: '连接蓝牙设备中...',
+      })
+      wx.createBLEConnection({
+
+        deviceId: e.currentTarget.id,
+        success: function (res) {
+
+          console.log("createBLEConnection success!")
+ 
+          // //ble获取蓝牙服务{获取特征值列表{开启端口监听{定时心跳发送{允许发送心跳{发送成功consloe显示}}}}} 
+          wx.getBLEDeviceServices({
+            deviceId: e.currentTarget.id,
+            /*蓝牙设备id */
+            success: function (res) {
+              /**接口调用成功的回调函数 */
+              console.log("getBLEDeviceServices success!")
+              that.setData({
+                services: res.services
+              })
+              wx.getBLEDeviceCharacteristics({
+                /**获取蓝牙低功耗设备某个服务中所有特征 */
+                deviceId: e.currentTarget.id,
+                /**蓝牙设备id */
+                serviceId: res.services[0].uuid,
+                /**蓝牙服务uuid */
+                success: function (res) {
+                  /**接口调用成功的回调函数 */
+                  console.log("getBLEDeviceCharacteristics success!")
+                  that.setData({
+                    characteristics: res.characteristics
+                  })
+                  /**启用蓝牙低功耗设备特征值变化时的notify功能 */
+                  wx.notifyBLECharacteristicValueChange({
+                    state: true, //是否启用notify
+                    deviceId: e.currentTarget.id, //蓝牙设备id
+                    serviceId: that.data.services[0].uuid, //蓝牙特征对应服务的uuid
+                    characteristicId: that.data.characteristics[0].uuid, //蓝牙特征的uuid
+                    success: function (res)   //接口调用成功的回调函数
+                    {
+                      console.log('启用notify成功')
+                                                               
+                      //*****在这跳转到device页面 url:路径?参数 参数键与参数值用 = 相连,不同参数用 & 分隔************
+                      wx.navigateTo({
+                        url: that.data.PageAddr[app.globalData.pageid] + '?' + 'connectedDeviceId=' + e.currentTarget.id + '&name=' + name +'&serviceId='+that.data.services[0].uuid,
+                      })
+                      //隐藏loading提示框
+                      wx.hideLoading()
+                    }
+                  })
+                }
+              })
+            }
+          })
+
+        },
+        fail: function (res) {
+          console.log(res)
+          wx.hideLoading()
+          wx.showModal({
+            title: '提示',
+            content: '连接失败',
+            showCancel: false
+          })
+        }
+      })
+    }
+  },
+  onLoad: function (options) {
+    var that = this
+    var list_height = ((app.globalData.SystemInfo.windowHeight - 50) * (750 / app.globalData.SystemInfo.windowWidth)) - 60
+    that.setData({
+      list_height: list_height
+    })
+    wx.onBluetoothAdapterStateChange(function (res) {
+      console.log(res)
+      that.setData({
+        searching: res.discovering
+      })
+      if (!res.available) {
+        that.setData({
+          searching: false
+        })
+      }
+    })
+    wx.onBluetoothDeviceFound(function (devices) {
+      //剔除重复设备,兼容不同设备API的不同返回值
+      var isnotexist = true
+      if (devices.devices[0].name != 'WH-BLE 103'){
+        isnotexist = false
+      }
+      else if (devices.deviceId) {
+        if (devices.advertisData) {
+          devices.advertisData = app.buf2hex(devices.advertisData)
+        } else {
+          devices.advertisData = ''
+        }
+        // console.log(devices)
+        for (var i = 0; i < that.data.devicesList.length; i++) {
+          if (devices.deviceId == that.data.devicesList[i].deviceId) {
+            isnotexist = false
+          }
+        }
+        if (isnotexist) {
+          that.data.devicesList.push(devices)
+        }
+      } else if (devices.devices) {
+        if (devices.devices[0].advertisData) {
+          devices.devices[0].advertisData = app.buf2hex(devices.devices[0].advertisData)
+        } else {
+          devices.devices[0].advertisData = ''
+        }
+        console.log(devices.devices[0])
+        for (var i = 0; i < that.data.devicesList.length; i++) {
+          if (devices.devices[0].deviceId == that.data.devicesList[i].deviceId) {
+            isnotexist = false
+          }
+        }
+        if (isnotexist) {
+          that.data.devicesList.push(devices.devices[0])
+        }
+      } else if (devices[0]) {
+        if (devices[0].advertisData) {
+          devices[0].advertisData = app.buf2hex(devices[0].advertisData)
+        } else {
+          devices[0].advertisData = ''
+        }
+        console.log(devices[0])
+        for (var i = 0; i < devices_list.length; i++) {
+          if (devices[0].deviceId == that.data.devicesList[i].deviceId) {
+            isnotexist = false
+          }
+        }
+        if (isnotexist) {
+          that.data.devicesList.push(devices[0])
+        }
+      }
+      that.setData({
+        devicesList: that.data.devicesList
+      })
+    })
+  },
+  onReady: function () {
+
+  },
+  onShow: function () {
+
+  },
+  onHide: function () {
+    var that = this
+    that.setData({
+      devicesList: []
+    })
+    if (this.data.searching) {
+      wx.stopBluetoothDevicesDiscovery({
+        success: function (res) {
+          console.log(res)
+          that.setData({
+            searching: false
+          })
+        }
+      })
+    }
+  },
+})
+wx.getSetting({
+  success(res) {
+    console.log(res.authSetting)
+    //判断是否有'scope.bluetooth'属性
+    if (res.authSetting.hasOwnProperty('scope.bluetooth')) {
+      //'scope.bluetooth'属性存在,且为false
+      if (!res.authSetting['scope.bluetooth']) {
+        //弹窗授权
+        wx.openSetting({
+          success(res) {
+            console.log(res.authSetting)
+          }
+        })
+      }
+    }
+    else
+      //'scope.bluetooth'属性不存在,需要授权
+      wx.authorize({
+        scope: 'scope.bluetooth',
+        success() {
+          // 用户已经同意小程序使用手机蓝牙功能,后续调用 蓝牙 接口不会弹窗询问
+          console.log(res.authSetting)
+        }
+      })
+
+  }
+})
+
+

+ 6 - 0
subpagesTwo/search/search.json

@@ -0,0 +1,6 @@
+{
+  "usingComponents": {
+    "navBar": "../components/navBar/navBar"
+  },
+  "navigationStyle": "custom"
+}

+ 18 - 0
subpagesTwo/search/search.wxml

@@ -0,0 +1,18 @@
+<view class='main-wraper'>
+    <navBar title='连接设备'  bindback="back"  bindhome="home"  bindsearch="search2" background='#fff' back="{{true}}" iconTheme='block' ></navBar>
+</view>
+<view class="container">
+  <scroll-view scroll-y style="width:690rpx;height:{{list_height}}rpx">
+    <block wx:for="{{devicesList}}" wx:key="deviceId">
+      <view class="list-item" id="{{item.deviceId}}" bindtap="Connect">
+        <view style="display:flex;flex-direction:column;width:80%">
+          <text style="font-size:medium;word-break:break-all">设备名称: {{item.localName}}</text>
+          <text style="font-size:x-small;color:gray;word-break:break-all">设备ID: {{item.deviceId}}</text>
+          <text style="font-size:x-small;color:gray;word-break:break-all">信号强度RSSI: {{item.RSSI}}</text>
+        </view>
+        <image style="width:36px;height:36px" mode="aspectFit" src="/subpagesTwo/images/zmdevice/bluetooth.png"></image>
+      </view>
+    </block>
+  </scroll-view>
+  <button type="primary" class="button" loading="{{searching}}" bindtap="Search">{{searching?"搜索中...":"搜索蓝牙设备"}}</button>
+</view>

+ 30 - 0
subpagesTwo/search/search.wxss

@@ -0,0 +1,30 @@
+page {
+  background-color: #f8f8f8;
+  background-repeat: no-repeat;
+  background-position:center center;
+  background-image:url(https://img14.360buyimg.com/ddimg/jfs/t1/159433/38/3955/429439/60068f12E63ab2e3b/adbd9d60b138764a.gif);
+}
+.container {
+  padding: 0 30rpx 0 30rpx;
+  align-items: center;
+}
+.list-item {
+  display: flex;
+  flex-direction: row;
+  justify-content: space-between;
+  align-items: center;
+  width: 100%;
+  padding: 10px 0 10px 0;
+  box-sizing: border-box;
+  border: 1px solid #000;
+  border-style: none none solid none;
+  border-bottom-color: lightgray;
+ }
+.list-item:last-child {
+  border-style: none;
+}
+.button {
+  position: fixed;
+  width: 690rpx;
+  bottom: 30rpx;
+}

+ 4 - 1
subpagesTwo/seeAisoList/seeAicoList.wxml

@@ -22,7 +22,10 @@
         <view class="room-status">
             <view class="room-status-title">
             </view>
-            <text class="room-status-text {{item.nuc && item.nuc.online ==='yes'? item.checked===0 ?'status-text-col-3' : 'status-text-col-1' : 'status-text-col-2'  }}">{{item.nuc && item.nuc.online ==='yes'? item.checked===0  ?'需巡检' :'正常' :  '异常'  }}  </text>
+            <view class="room-status-text-box">
+                <view class="room-status-text {{item.nuc && item.nuc.online ==='yes'? item.checked===0 ?'status-text-col-3' : 'status-text-col-1' : 'status-text-col-2'  }}">{{item.nuc && item.nuc.online ==='yes'? item.checked===0  ?'需巡检' :'正常' :  '异常'  }}  </view>
+                <view class="room-anomalies" wx:if="{{item.nuc && item.nuc.online ==='yes' && item.checked!==0 && item.checkLog}}">{{ item.checkLog.equip_abn}}个设备异常</view>
+            </view>
         </view>
     </view>
 </view>

+ 19 - 3
subpagesTwo/seeAisoList/seeAicoList.wxss

@@ -112,7 +112,7 @@ page {
     padding-bottom: 30rpx;
 }
 .room-number{
-    flex:3;
+    flex:2;
     margin-left: 40rpx;
     height: 100%;
 }
@@ -126,7 +126,7 @@ page {
     text-transform: none;
 }
 .inspection-date{
-    flex:4;
+    flex:3;
     height: 100%;
 }
 .inspection-date-text{
@@ -142,6 +142,7 @@ page {
 .room-status{
     flex:2;
     display: flex;
+    align-items: center;
     justify-content: flex-end;
     height: 100%;
 }
@@ -152,7 +153,12 @@ page {
     border-radius: 0rpx 0rpx 0rpx 0rpx;
     margin-right: 30rpx;
 }
-
+.room-status-text-box{
+    display: flex;
+    flex-direction: column;
+    align-items: center;
+    justify-content: center;
+}
 .room-status-text{
     font-weight: 400;
     font-size: 30rpx;
@@ -161,6 +167,16 @@ page {
     font-style: normal;
     text-transform: none;
 }
+.room-anomalies{
+    font-weight: 400;
+    font-size: 24rpx;
+    color: #333333;
+    line-height: 32rpx;
+    text-align: left;
+    font-style: normal;
+    text-transform: none;
+    margin-top: 12rpx;
+}
 .item-title{
     font-weight: 400;
     font-size: 24rpx;

+ 61 - 0
utils/api2.js

@@ -0,0 +1,61 @@
+// api.js
+
+const API_BASE_URL = 'https://pntst.somnisix.top';
+
+// 封装 wx.request 为 Promise 形式
+function request(url, method = 'GET', data = {}, headers = {}) {
+    return new Promise((resolve, reject) => {
+        wx.request({
+            url,
+            method,
+            data,
+            header: headers,
+            success(res) {
+                if (res.statusCode >= 200 && res.statusCode < 300) {
+                    resolve(res.data);
+                } else {
+                    reject(new Error(`HTTP error! status: ${res.statusCode}`));
+                }
+            },
+            fail(err) {
+                reject(new Error('Network error'));
+            },
+        });
+    });
+}
+
+const apiClient = {
+    get: async (endpoint, { params = {}, headers = {} } = {}) => {
+        let url = `${API_BASE_URL}/${endpoint}`;
+
+        // 手动拼接 query 参数
+        const queryString = Object.keys(params).length > 0
+            ? '?' + Object.entries(params)
+                .map(([key, value]) =>
+                    `${encodeURIComponent(key)}=${encodeURIComponent(value)}`
+                )
+                .join('&')
+            : '';
+
+        url += queryString;
+
+        return await request(url, 'GET', {}, headers);
+    },
+
+    post: async (endpoint, { body = {}, headers = {} } = {}) => {
+        const url = `${API_BASE_URL}/${endpoint}`;
+        return await request(url, 'POST', body, headers);
+    },
+
+
+    // 特定接口封装
+
+    getToken: async ({ body = {}, headers = {} } = {}) => {
+        return await apiClient.post('api/token', { body, headers });
+    },
+    print: async ({ body = {}, headers = {} } = {}) => {
+        return await apiClient.post('api/print/long', { body, headers });
+    },
+};
+
+export default apiClient;