瀏覽代碼

feature: 加入设备唤醒音设置分包

332777428@qq.com 4 月之前
父節點
當前提交
dbabaa08b1

+ 3 - 3
app.json

@@ -4,7 +4,6 @@
     "pages/pageA/login/login",
     "pages/pageA/deviceList/deviceList",
     "pages/channelDetail/channelDetail",
-    "pages/wakeList/wakeList",
     "pages/connectBle/connectBle",
     "pages/setWifi/setWifi",
     "pages/vipPurchase/vipPurchase",
@@ -15,6 +14,8 @@
     {
       "root": "pages/pageB/",
       "pages": [
+        "repeat/repeat",
+        "wakeList/wakeList",
         "deviceMode/deviceMode",
         "deviceWake/deviceWake",
         "deviceConnect0/deviceConnect0",
@@ -28,8 +29,7 @@
       "root": "pages/pageC/",
       "pages": [
         "about/about",
-        "aboutInfo/aboutInfo",
-        "repeat/repeat"
+        "aboutInfo/aboutInfo"
       ]
     },
     {

+ 0 - 554
pages/deviceWake/deviceWake.js

@@ -1,554 +0,0 @@
-const app = getApp();
-const {
-  formatNumber
-} = require('../../../utils/requestUtil.js');
-const {
-  deviceWakedetail
-} = require('../../../utils/apiUtil.js');
-
-import lexin_util from '../../../utils/lexin/util.js';
-import routePath from '../../../utils/routePath.js';
-import routeUtil from '../../../utils/routeUtil.js';
-
-Page({
-  data: {
-    nvabarData: {
-      showCapsule: 1, //是否显示左上角图标   1表示显示    0表示不显示
-      title: '定时设置', //导航栏 中间的标题
-    },
-    switch1Checked: false,
-    alarm_id_0_time: "00:00:00",
-    switch2Checked: false,
-    deviceMac: null,
-    alarm_id_0: {}, // 休眠
-    alarm_id_1: {}, // 唤醒
-    timeindex: 1,
-    timeArray: [{
-        id: 600,
-        name: '10分钟'
-      },
-      {
-        id: 1800,
-        name: '30分钟'
-      },
-      {
-        id: 3600,
-        name: '60分钟'
-      },
-      {
-        id: 5400,
-        name: '90分钟'
-      }
-    ],
-    clientType: "",
-    time0: '00:00:00',
-    time: '07:00:00',
-    repeat: "",
-    repeat0: "",
-    week: ["周日", "周一", "周二", "周三", "周四", "周五", "周六"],
-    week_actives: [],
-    isOne: true,
-    wakeName: "",
-    toastData: {
-      titlePicUrl: "./../../../img/gt.png",
-      titlePicUrlWidth: 140,
-      title: ["温馨提醒"],
-      info: ["当前设备电量低"],
-      isShowTwoBut: true,
-      twoButText: "好的",
-      footTop: 10,
-    },
-    twoButCallback: () => {},
-    toast_visible: false,
-    // 后续新加需求
-    deviceOther: null,
-    updataDeviceInfo: false,
-    repeatIndex: 0,
-    deviceId: "",
-  },
-
-  onLoad(options) {
-    var that = this;
-
-    var deviceId = options.deviceId;
-    var clientType = options.clientType;
-    var deviceMac = lexin_util.getDeviceMacId(deviceId);
-
-    that.data.deviceId = deviceId;
-    that.data.deviceMac = deviceMac;
-    that.data.clientType = clientType;
-
-    deviceWakedetail({
-      clientType: clientType,
-      deviceMac: deviceMac,
-    }).then((res) => {
-      if (res && res.length > 0) {
-        that.setData({
-          wakeName: res[0].audioName || null
-        });
-      }
-    })
-    app.PubMsg({
-      type: "get_dev_info",
-      DstDeviceName: deviceMac
-    });
-
-    // 赋值按钮回调
-    that.setData({
-      twoButCallback: () => {
-        that.setData({
-          toast_visible: false
-        })
-      }
-    })
-  },
-
-  onShow(options) {
-    var that = this;
-    var deviceMac = that.data.deviceMac;
-    app.PubMsg({
-      type: "get_dev_info",
-      DstDeviceName: deviceMac,
-    });
-  },
-
-  mqttCallback(type, option) {
-    var that = this;
-    let payloads = null;
-    if (option) {
-      payloads = JSON.parse(option.payload);
-    };
-
-    switch (type) {
-      case "message_onoffline":
-        if (payloads.state !== "online") {
-          // option.payload: {"uuid":"AIrSMArT_7cdfa1fcbb24","state":"offline","userid":"1"}
-          var deviceMacId = payloads.uuid;
-          if (deviceMacId == that.data.deviceMac) {
-            wx.showToast({
-              title: '设备已断开连接',
-              icon: 'none',
-              duration: 2000
-            });
-          }
-        }
-        break;
-      case "message":
-        // 设备信息
-        if (payloads.type === "get_dev_info") {
-          that.setData({
-            deviceOther: payloads.other,
-            updataDeviceInfo: true,
-          });
-          if (payloads.other.alarm) {
-            payloads.other.alarm.map((v) => {
-              if (v.alarm_id === "0") {
-                v.action = "update";
-                // 休眠
-                that.setData({
-                  alarm_id_0: v
-                });
-
-                // 定时时间
-                if (v.on_off_timestamp !== "") {
-                  that.setData({
-                    alarm_id_0_time: v.on_off_timestamp
-                  })
-                }
-
-                // 是否启用
-                if (v.enable === "1") {
-                  that.setData({
-                    switch1Checked: true
-                  })
-                } else {
-                  that.setData({
-                    switch1Checked: false
-                  })
-                }
-
-                // 重复
-                if (v.week_actives) {
-                  that.setData({
-                    repeat0: that.repeatText(v.week_actives),
-                  })
-                }
-
-              } else if (v.alarm_id === "1") {
-                // 唤醒
-                that.setData({
-                  alarm_id_1: v
-                });
-                // 定时时间
-                if (v.on_off_timestamp !== "") {
-                  that.setData({
-                    time: v.on_off_timestamp
-                  })
-                }
-                // 是否启用
-                if (v.enable === "1") {
-                  that.setData({
-                    switch2Checked: true
-                  })
-                } else {
-                  that.setData({
-                    switch2Checked: false
-                  })
-                }
-                // 重复
-                if (v.week_actives) {
-                  that.setData({
-                    repeat: that.repeatText(v.week_actives),
-                  })
-                }
-              }
-            })
-          }
-        } else if (payloads.type === "alert_set") {
-          if (payloads.code === 200) {
-            app.PubMsg({
-              type: "get_dev_info",
-              DstDeviceName: that.data.deviceMac
-            });
-          } else {
-            wx.showModal({
-              title: '保存失败',
-              content: '请保持设备网络通畅并检查是否已连接电源?',
-              success(res) {
-                if (res.confirm) {
-                  console.log('用户点击确定')
-                } else if (res.cancel) {
-                  console.log('用户点击取消')
-                }
-              }
-            })
-          }
-        }
-        default:
-    }
-  },
-
-  // 休眠-选择时间
-  switch1Change(e) {
-    var that = this;
-    let other = that.data.alarm_id_0;
-    if (e.detail.value) {
-      that.setData({
-        switch1Checked: e.detail.value
-      });
-      const thisTime = Math.round(new Date() / 1000);
-      other = that.setOther(other, 1);
-      other.on_off_timestamp = that.data.alarm_id_0_time;
-
-      // 有重复
-      if (other.week_actives && other.week_actives.filter((v) => v === 1).length > 0) {
-        // other.week_actives = [0,1,1,1,1,1,0],
-        other.weekly_repeat = "1";
-      } else {
-        other.weekly_repeat = "0";
-      };
-      // 如果跨天了
-      if (!that.compareDate(that.data.alarm_id_0_time, that.formatTime(thisTime, "h:m:s"))) {
-        const date = new Date((that.formatTime(thisTime, "Y-M-D") + " 00:00:00").replace(/-/g, '/'));
-        other.current_timestamp = that.formatTime(date.getTime() / 1000 + 86400, "Y-M-D h:m:s");
-      };
-      app.PubMsg({
-        type: "alert_set",
-        DstDeviceName: that.data.deviceMac,
-        other
-      });
-    } else {
-      that.setData({
-        switch1Checked: e.detail.value
-      });
-      other = that.setOther(other, 0);
-      app.PubMsg({
-        type: "alert_set",
-        DstDeviceName: that.data.deviceMac,
-        other
-      });
-    }
-  },
-
-  switch2Change(e) {
-    var that = this;
-    that.data.updataDeviceInfo = false;
-    let other = that.data.alarm_id_1;
-    if (e.detail.value) {
-      if (that.data.deviceOther && that.data.deviceOther.Power < 20) {
-        that.setData({
-          toast_visible: true,
-        });
-      };
-      // app.PubMsg({
-      //   type: "get_dev_info",
-      //   DstDeviceName: that.data.deviceMac
-      // });
-      if (!other) {
-        wx.showToast({
-          title: '设备已断开连接',
-          icon: "none"
-        })
-        return
-      }
-      other.on_off_timestamp = that.data.time;
-      other = that.setOther(other, 1);
-      let week_actives = other.week_actives ?? []
-      if (week_actives.filter((v) => v === 1).length > 0) {
-        // other.week_actives = [0,1,1,1,1,1,0],
-        other.weekly_repeat = "1";
-      } else {
-        other.weekly_repeat = "0";
-      };
-
-      app.PubMsg({
-        type: "alert_set",
-        DstDeviceName: that.data.deviceMac,
-        other
-      });
-
-      // 不要循环发送,也不要改alarm_id_0.enable
-      // 循环查询
-      // const Interval = setInterval(() => {
-      //   if (that.data.updataDeviceInfo) {
-      //     clearInterval(Interval);
-      // other.on_off_timestamp = that.data.time;
-      // other = that.setOther(other, 1);
-      // if (other.week_actives.filter((v) => v === 1).length > 0) {
-      //   // other.week_actives = [0,1,1,1,1,1,0],
-      //   other.weekly_repeat = "1";
-      // } else {
-      //   other.weekly_repeat = "0";
-      // };
-      // app.PubMsg({
-      //   type: "alert_set",
-      //   DstDeviceName: that.data.deviceMac,
-      //   other
-      // });
-      // 需打开休眠
-      // if (that.data.alarm_id_0.enable === "0") {
-
-      //   const thisTime = Math.round(new Date() / 1000);
-      //   const alarm_id_0 = that.setOther(that.data.alarm_id_0, 1);
-      //   alarm_id_0.on_off_timestamp = that.data.alarm_id_0_time;
-
-      //   // 有重复
-      //   if (alarm_id_0.week_actives.filter((v) => v === 1).length > 0) {
-      //     alarm_id_0.weekly_repeat = "1";
-      //   } else {
-      //     alarm_id_0.weekly_repeat = "0";
-      //   };;
-      //   // 如果跨天了
-      //   if (!that.compareDate(that.data.alarm_id_0_time, that.formatTime(thisTime, "h:m:s"))) {
-      //     const date = new Date((that.formatTime(thisTime, "Y-M-D") + " 00:00:00").replace(/-/g, '/'));
-      //     alarm_id_0.current_timestamp = that.formatTime(date.getTime() / 1000 + 86400, "Y-M-D h:m:s");
-      //   };
-      //   app.PubMsg({
-      //     type: "alert_set",
-      //     DstDeviceName: that.data.deviceMac,
-      //     other: alarm_id_0
-      //   });
-      // }
-
-      //   }
-      // }, 500);
-    } else {
-      other = that.setOther(other, 0);
-      app.PubMsg({
-        type: "alert_set",
-        DstDeviceName: that.data.deviceMac,
-        other
-      });
-    }
-  },
-
-  // bindPickerChange(e) {
-  // var that = this;
-  //   let other = that.data.alarm_id_0;
-  //   const thisTime = Math.round(new Date() / 1000);
-  //   other = that.setOther(other, 1);
-  //   other.on_off_timestamp = that.formatTime(thisTime + that.data.timeArray[e.detail.value].id, "h:m:s");
-  //   // 如果跨天了
-  //   if(parseInt(that.formatTime(thisTime + that.data.timeArray[e.detail.value].id, "D")) > parseInt(that.formatTime(thisTime, "D"))) {
-  //     const date = new Date(that.formatTime(thisTime, "Y-M-D") + " 00:00:00");
-  //     other.current_timestamp = that.formatTime(date.getTime() / 1000 + 86400, "Y-M-D h:m:s");
-  //   };
-  //   app.PubMsg({type: "alert_set", DstDeviceName: that.data.deviceMac, other});
-  // },
-
-  bindTimeChange0: function (e) {
-    var that = this;
-    that.setData({
-      alarm_id_0_time: e.detail.value + ":00"
-    });
-    let other = that.data.alarm_id_0;
-    other.on_off_timestamp = e.detail.value + ":00";
-    other = that.setOther(other, 1);
-    // 有重复
-    if (other.week_actives.filter((v) => v === 1).length > 0) {
-      // other.week_actives = [0,1,1,1,1,1,0],
-      other.weekly_repeat = "1";
-    } else {
-      other.weekly_repeat = "0";
-    };
-    // 如果跨天了
-    const thisTime = Math.round(new Date() / 1000);
-    if (!that.compareDate(that.data.alarm_id_0_time, that.formatTime(thisTime, "h:m:s"))) {
-      const date = new Date((that.formatTime(thisTime, "Y-M-D") + " 00:00:00").replace(/-/g, '/'));
-      other.current_timestamp = that.formatTime(date.getTime() / 1000 + 86400, "Y-M-D h:m:s");
-    };
-    app.PubMsg({
-      type: "alert_set",
-      DstDeviceName: that.data.deviceMac,
-      other
-    });
-  },
-
-  bindTimeChange: function (e) {
-    var that = this;
-    that.setData({
-      time: e.detail.value + ":00"
-    });
-    let other = that.data.alarm_id_1;
-    other.on_off_timestamp = e.detail.value + ":00";
-    other = that.setOther(other, 1);
-    app.PubMsg({
-      type: "alert_set",
-      DstDeviceName: that.data.deviceMac,
-      other
-    });
-  },
-
-  setRepeat(arr) {
-    var that = this;
-    let other = that.data.repeatIndex === "0" ? that.data.alarm_id_0 : that.data.alarm_id_1;
-    other = that.setOther(other, 1);
-    other.week_actives = arr;
-    other.weekly_repeat = arr.filter((v) => v === 1).length > 0 ? "1" : "0";
-    // 倒计时
-    if (that.data.repeatIndex === "0") {
-      // 如果跨天了
-      const thisTime = Math.round(new Date() / 1000);
-      if (!that.compareDate(that.data.alarm_id_0_time, that.formatTime(thisTime, "h:m:s"))) {
-        const date = new Date((that.formatTime(thisTime, "Y-M-D") + " 00:00:00").replace(/-/g, '/'));
-        other.current_timestamp = that.formatTime(date.getTime() / 1000 + 86400, "Y-M-D h:m:s");
-      };
-    }
-    app.PubMsg({
-      type: "alert_set",
-      DstDeviceName: that.data.deviceMac,
-      other
-    });
-  },
-
-  goWakeList() {
-    var that = this;
-    var deviceId = that.data.deviceId;
-    var clientType = that.data.clientType;
-    ///唤醒的设置特殊,智能这样用
-    var deviceMac = lexin_util.getMacByDeviceId(deviceId);
-    wx.navigateTo({
-      url: './../wakeList/wakeList?clientType=' + clientType + "&deviceMac=" + deviceMac,
-    })
-  },
-
-  gorepeat(e) {
-    var that = this;
-    that.data.repeatIndex = e.currentTarget.dataset.index;
-    that.data.week_actives = e.currentTarget.dataset.index === "0" ? that.data.alarm_id_0.week_actives : that.data.alarm_id_1.week_actives;
-
-    var param = '?week_actives=' + that.data.week_actives;
-    routeUtil.jumpParam(routePath.repeat, param);
-  },
-
-
-  setdeviceWakedetail() {
-    var that = this;
-    deviceWakedetail({
-      clientType: that.data.clientType,
-      deviceMac: that.data.deviceMac,
-    }).then((res) => {
-      that.setData({
-        wakeName: res[0].audioName
-      })
-    })
-  },
-
-  /** 
-   * 时间戳转化为年 月 日 时 分 秒 
-   * number: 传入时间戳 
-   * format:返回格式,支持自定义,但参数必须与formateArr里保持一致 
-   */
-  formatTime(number, format) {
-
-    var formateArr = ['Y', 'M', 'D', 'h', 'm', 's'];
-    var returnArr = [];
-
-    var date = new Date(number * 1000);
-    returnArr.push(date.getFullYear());
-    returnArr.push(formatNumber(date.getMonth() + 1));
-    returnArr.push(formatNumber(date.getDate()));
-
-    returnArr.push(formatNumber(date.getHours()));
-    returnArr.push(formatNumber(date.getMinutes()));
-    returnArr.push(formatNumber(date.getSeconds()));
-
-    for (var i in returnArr) {
-      format = format.replace(formateArr[i], returnArr[i]);
-    }
-    return format;
-  },
-
-  // type: 0 关闭  1 开启
-  setOther(other, type) {
-    var that = this;
-    if (type === 0) {
-      other.enable = "0";
-      other.alarm_name = "close";
-      other.operation = "off";
-    } else if (type === 1) {
-      other.enable = "1";
-      other.alarm_name = "open";
-      other.operation = "on";
-    }
-    const thisTime = Math.round(new Date() / 1000);
-    other.current_timestamp = that.formatTime(thisTime, "Y-M-D h:m:s");
-    other.action = "update",
-      other.song_uri = "-1";
-    other.version = 3;
-    other.is_debug = app.globalData.is_debug
-    return other
-  },
-  // 判断当天时间前后
-  compareDate(t1, t2) {
-    var date = new Date();
-    var a = t1.split(":");
-    var b = t2.split(":");
-    return date.setHours(a[0], a[1]) > date.setHours(b[0], b[1]);
-  },
-
-  repeatText(arr) {
-    var that = this;
-    let text = "";
-    if (arr.toString() === [0, 1, 1, 1, 1, 1, 0].toString()) {
-      text = "工作日";
-    } else if (arr.toString() === [1, 0, 0, 0, 0, 0, 1].toString()) {
-      text = "周末";
-    } else {
-      arr.map((v, index) => {
-        if (v === 1) {
-          if (text === "") {
-            text = text + that.data.week[index]
-          } else {
-            text = text + "、" + that.data.week[index];
-          }
-        }
-      });
-      if (text === "") {
-        text = "不重复";
-      };
-    }
-    return text.length < 20 ? text : "每日";
-  }
-
-})

+ 3 - 3
pages/pageB/deviceWake/deviceWake.js

@@ -445,11 +445,11 @@ Page({
     var that = this;
     var deviceId = that.data.deviceId;
     var clientType = that.data.clientType;
+
     ///唤醒的设置特殊,智能这样用
     var deviceMac = lexin_util.getMacByDeviceId(deviceId);
-    wx.navigateTo({
-      url: './../wakeList/wakeList?clientType=' + clientType + "&deviceMac=" + deviceMac,
-    })
+    var param = '?clientType=' + clientType + "&deviceMac=" + deviceMac;
+    routeUtil.jumpParam(routePath.wakeList, param);
   },
 
   gorepeat(e) {

+ 1 - 3
pages/pageC/repeat/repeat.js

@@ -49,9 +49,7 @@ Page({
       };
     })
   },
-  /**
-   * 生命周期函数--监听页面加载
-   */
+
   onLoad(options) {
     const week_actives = [];
     options.week_actives.split(",").map((v) => {

pages/pageC/repeat/repeat.json → pages/pageB/repeat/repeat.json


pages/pageC/repeat/repeat.wxml → pages/pageB/repeat/repeat.wxml


pages/pageC/repeat/repeat.wxss → pages/pageB/repeat/repeat.wxss


+ 2 - 2
pages/wakeList/wakeList.js

@@ -1,5 +1,5 @@
 const app = getApp();
-import routeRoot from '../../utils/routeRoot.js';
+import routeRoot from '../../../utils/routeRoot.js';
 
 let PreselectionIndex = null; // 记录选中的频道
 const {
@@ -9,7 +9,7 @@ const {
   listByDevice,
   pageByDevice,
   radioList
-} = require('../../utils/apiUtil.js');
+} = require('../../../utils/apiUtil.js');
 
 Page({
   data: {

+ 5 - 0
pages/pageB/wakeList/wakeList.json

@@ -0,0 +1,5 @@
+{
+  "usingComponents": {
+    "nav-bar": "./../../../components/navbar/navbar"
+  }
+}

+ 3 - 3
pages/wakeList/wakeList.wxml

@@ -1,7 +1,7 @@
 <view class="wakeList">
   <nav-bar bind:goBack="_goBack" nav-bgc-class="ex-nav-bgc-class" nav-title-class="ex-nav-title-class" ex-back-pre="ex-back-pre" navbar-data='{{nvabarData}}'></nav-bar>
   <view class="ps">
-    <image mode="heightFix" src="./../../img/vaa.png"></image>
+    <image mode="heightFix" src="./../../../img/vaa.png"></image>
     <text>设备网络异常时,将会使用默认闹铃声</text>
   </view>
   <view class="list" style="height: calc(100vh - {{navBarHeight}}px - 36rpx);">
@@ -15,7 +15,7 @@
           {{deviceWake.length > 0 ? deviceWake[0].audioName : ""}}
         </text>
       </view>
-      <image wx:if="{{actionIndex === index}}" class="action" style="height:28rpx; width:28rpx;" src="./../../img/gg.png" mode="aspectFit"></image>
+      <image wx:if="{{actionIndex === index}}" class="action" style="height:28rpx; width:28rpx;" src="./../../../img/gg.png" mode="aspectFit"></image>
     </view>
   </view>
   <view wx:if="{{isShowWakeDetail}}" class="wakeDetail">
@@ -25,7 +25,7 @@
         <view class="li {{actionWakeIndex === index ? 'action' : ''}}" wx:for="{{detailList}}" data-index="{{index}}" bindtap="actionWakeDetail">
           <text>{{index + 1}}</text>
           <text>{{item.audioName}}</text>
-          <image wx:if="{{actionWakeIndex === index}}" src="./../../img/gg.png" style="height:28rpx; width:28rpx;" mode="aspectFit"></image>
+          <image wx:if="{{actionWakeIndex === index}}" src="./../../../img/gg.png" style="height:28rpx; width:28rpx;" mode="aspectFit"></image>
         </view>
       </view>
       <view class="foot">

+ 0 - 1
pages/wakeList/wakeList.wxss

@@ -1,4 +1,3 @@
-/* pages/wakeList/wakeList.wxss */
 .wakeList{
   position: relative;
   height: 100%;

+ 0 - 5
pages/wakeList/wakeList.json

@@ -1,5 +0,0 @@
-{
-  "usingComponents": {
-    "nav-bar": "./../../components/navbar/navbar"
-  }
-}

+ 4 - 2
utils/routePath.js

@@ -6,6 +6,8 @@ const login = "../../pageA/login/login";
 const deviceList = "../../pageA/deviceList/deviceList";
 
 /// B
+const repeat = "../../pageB/repeat/repeat";
+const wakeList = "../../pageB/wakeList/wakeList";
 const deviceMode = "../../pageB/deviceMode/deviceMode";
 const deviceWake = "../../pageB/deviceWake/deviceWake";
 const deviceConnect0 = "../../pageB/deviceConnect0/deviceConnect0";
@@ -17,7 +19,6 @@ const deviceConnect4 = "../../pageB/deviceConnect4/deviceConnect4";
 /// C
 const about = "../../pageC/about/about";
 const aboutInfo = "../../pageC/aboutInfo/aboutInfo";
-const repeat = "../../pageC/repeat/repeat";
 
 /// pageD
 const ota = "../../pageD/ota/ota";
@@ -40,6 +41,8 @@ module.exports = {
   login: login,
   deviceList: deviceList,
   /// B
+  repeat: repeat,
+  wakeList: wakeList,
   deviceMode: deviceMode,
   deviceWake: deviceWake,
   deviceConnect0: deviceConnect0,
@@ -50,7 +53,6 @@ module.exports = {
   /// C
   about: about,
   aboutInfo: aboutInfo,
-  repeat: repeat,
   /// D
   ota: ota,
   webview: webview,