Pārlūkot izejas kodu

feature: 添加页面路由路径

332777428@qq.com 4 mēneši atpakaļ
vecāks
revīzija
2c20dda364

+ 4 - 4
devices/ble_manager.js

@@ -318,7 +318,7 @@ class bleManager {
       }
 
       ///做搜索蓝牙适配器权限
-      const permission_util = require('../utils/permission_util');
+      const permissionUtil = require('../utils/permission_util');
       // var location = await permission_util.getSetting()
       // if (!location) {
       //   if (boolean != null) {
@@ -327,7 +327,7 @@ class bleManager {
       //   }
       //   return
       // }
-      var available = await permission_util.openBluetoothAdapter();
+      var available = await permissionUtil.openBluetoothAdapter();
       that.isAvailable = available;
       if (!available) {
         that.doStartScaning = false;
@@ -340,7 +340,7 @@ class bleManager {
     }
 
     const route_util = require('../utils/route_util');
-    const routePath = require('../utils/route_path');
+    const routePath = require('../utils/routePath');
     const indexRoot = routePath.indexRoot;
     const connectBleRoot = routePath.connectBleRoot;
     var lastPageRoute = route_util.getLastPageRoute();
@@ -502,7 +502,7 @@ class bleManager {
           wx.setBLEMTU({
             deviceId: device.deviceId,
             mtu: 128,
-            success:(mtuRes) => {
+            success: (mtuRes) => {
               console.log("设置mtu成功")
             },
             fail: (mtuErr) => {

+ 1 - 1
pages/deviceConnect4/deviceConnect4.js

@@ -1,7 +1,7 @@
 const app = getApp();
 import strings from '../../utils/strings.js';
 import route_util from '../../utils/route_util.js';
-import routePath from '../../utils/route_path.js'
+import routePath from '../../utils/routePath.js'
 const {
   BleUtil
 } = require('../../utils/blue_ble/util');

+ 1 - 1
pages/index/index.js

@@ -8,7 +8,7 @@ const {
 import time_util from '../../utils/time_util.js';
 import strings from '../../utils/strings.js';
 import store from '../../utils/store.js';
-import routePath from '../../utils/route_path.js';
+import routePath from '../../utils/routePath.js';
 import route_util from '../../utils/route_util.js';
 
 /// 乐鑫相关

+ 1 - 1
pages/ota/ota.js

@@ -2,7 +2,7 @@ const { BtHelper } = require("../../devices/bt_helper");
 import { EnumCmdEvent, CmdEvent } from '../../devices/cmd_key_event';
 import EventManager from '../../utils/event_bus'
 import route_util from '../../utils/route_util';
-import routePath from '../../utils/route_path.js';
+import routePath from '../../utils/routePath.js';
 import { BtCmd } from '../../devices/bluetooth/bt_cmd.js';
 import strings from '../../utils/strings.js';
 const {

+ 8 - 0
utils/api.js

@@ -15,48 +15,56 @@ module.exports = {
       "content-type": "application/json"
     }, false)
   },
+
   // 注册
   register: (data) => {
     return request("/mini/wx/user/registerV2", data, "POST", {
       "content-type": "application/json"
     }, false)
   },
+
   // 频道列表
   listByDevice: (data) => {
     return request("/mini/wx/channelDefault/listByDevice", data, "GET", {
       "content-type": "application/x-www-form-urlencoded"
     })
   },
+
   // 一级频道详情列表
   pageByDevice: (data) => {
     return request("/mini/wx/channelDefault/pageByDevice", data, "GET", {
       "content-type": "application/x-www-form-urlencoded"
     })
   },
+
   // 查询设备绑定的唤醒音信息
   deviceWakedetail: (data) => {
     return request("/mini/wx/deviceWake/detail", data, "GET", {
       "content-type": "application/x-www-form-urlencoded"
     })
   },
+
   // 查询设备的唤醒音音频列表
   deviceWakeList: (data) => {
     return request("/mini/wx/deviceWake/list", data, "GET", {
       "content-type": "application/x-www-form-urlencoded"
     })
   },
+
   // 设备设置唤醒音
   deviceWakeadd: (data) => {
     return request("/mini/wx/deviceWake/add", data, "POST", {
       "content-type": "application/x-www-form-urlencoded"
     })
   },
+
   // 查询设备的唤醒音下的音频列表
   radioList: (data) => {
     return request("/mini/wx/deviceWake/radioList", data, "GET", {
       "content-type": "application/json"
     })
   },
+
   // 初始化
   init: () => {
     return request("/mini/wx/user/init", {}, "GET", {

+ 123 - 123
utils/event_bus.js

@@ -21,22 +21,22 @@ var isDebug = true;
  * observer: 注册对象,指Page对象
  */
 function addNotification(name, selector, observer) {
-    if (name && selector) {
-        if (!observer) {
-            // console.log("addNotification Warning: no observer will can't remove notice");
-        }
-        // console.log("addNotification:" + name);
-        var newNotice = {
-            name: name,
-            selector: selector,
-            observer: observer
-        };
-
-        addNotices(newNotice);
-
-    } else {
-        // console.log("addNotification error: no selector or name");
+  if (name && selector) {
+    if (!observer) {
+      // console.log("addNotification Warning: no observer will can't remove notice");
     }
+    // console.log("addNotification:" + name);
+    var newNotice = {
+      name: name,
+      selector: selector,
+      observer: observer
+    };
+
+    addNotices(newNotice);
+
+  } else {
+    // console.log("addNotification error: no selector or name");
+  }
 }
 
 /**
@@ -48,39 +48,39 @@ function addNotification(name, selector, observer) {
  * observer: 注册对象,指Page对象
  */
 function addOnceNotification(name, selector, observer) {
-    if (__notices.length > 0) {
-        for (var i = 0; i < __notices.length; i++) {
-            var notice = __notices[i];
-            if (notice.name === name) {
-                if (notice.observer === observer) {
-                    return;
-                }
-            }
+  if (__notices.length > 0) {
+    for (var i = 0; i < __notices.length; i++) {
+      var notice = __notices[i];
+      if (notice.name === name) {
+        if (notice.observer === observer) {
+          return;
         }
+      }
     }
-    this.addNotification(name, selector, observer)
+  }
+  this.addNotification(name, selector, observer)
 }
 
 function addNotices(newNotice) {
-    // if (__notices.length > 0) {
-    //     for (var i = 0; i < __notices.length; i++) {
-    //         var hisNotice = __notices[i];
-    //         //当名称一样时进行对比,如果不是同一个 则放入数组,否则跳出
-    //         if (newNotice.name === hisNotice.name) {
-    //             if (!cmp(hisNotice, newNotice)) {
-    //                 __notices.push(newNotice);
-    //             }
-    //             return;
-    //         }else{
-    //             __notices.push(newNotice);
-    //         }
-
-    //     }
-    // } else {
-
-    // }
-
-    __notices.push(newNotice);
+  // if (__notices.length > 0) {
+  //     for (var i = 0; i < __notices.length; i++) {
+  //         var hisNotice = __notices[i];
+  //         //当名称一样时进行对比,如果不是同一个 则放入数组,否则跳出
+  //         if (newNotice.name === hisNotice.name) {
+  //             if (!cmp(hisNotice, newNotice)) {
+  //                 __notices.push(newNotice);
+  //             }
+  //             return;
+  //         }else{
+  //             __notices.push(newNotice);
+  //         }
+
+  //     }
+  // } else {
+
+  // }
+
+  __notices.push(newNotice);
 }
 
 /**
@@ -93,16 +93,16 @@ function addNotices(newNotice) {
  */
 
 function removeNotification(name, observer) {
-    // console.log("removeNotification:" + name);
-    for (var i = 0; i < __notices.length; i++) {
-        var notice = __notices[i];
-        if (notice.name === name) {
-            if (notice.observer === observer) {
-                __notices.splice(i, 1);
-                return;
-            }
-        }
+  // console.log("removeNotification:" + name);
+  for (var i = 0; i < __notices.length; i++) {
+    var notice = __notices[i];
+    if (notice.name === name) {
+      if (notice.observer === observer) {
+        __notices.splice(i, 1);
+        return;
+      }
     }
+  }
 
 
 }
@@ -116,94 +116,94 @@ function removeNotification(name, observer) {
  * info: 携带的参数
  */
 function fire(cmdEvent) {
-    let name = "cmdEventNotification";
-    let info = cmdEvent;
-    // console.log("fire:" + name);
-    if (__notices.length == 0) {
-        console.log("fire error: u hadn't add any notice.");
-        return;
-    }
-
-    for (var i = 0; i < __notices.length; i++) {
-        var notice = __notices[i];
-        if (notice.name === name) {
-            notice.selector(info);
-        }
+  let name = "cmdEventNotification";
+  let info = cmdEvent;
+  // console.log("fire:" + name);
+  if (__notices.length == 0) {
+    console.log("fire error: u hadn't add any notice.");
+    return;
+  }
+
+  for (var i = 0; i < __notices.length; i++) {
+    var notice = __notices[i];
+    if (notice.name === name) {
+      notice.selector(info);
     }
+  }
 }
 
 function fireName(name, cmdEvent) {
-    let info = cmdEvent;
-    // console.log("fire:" + name);
-    if (__notices.length == 0) {
-        console.log("fire error: u hadn't add any notice.");
-        return;
-    }
-
-    for (var i = 0; i < __notices.length; i++) {
-        var notice = __notices[i];
-        if (notice.name === name) {
-            notice.selector(info);
-        }
+  let info = cmdEvent;
+  // console.log("fire:" + name);
+  if (__notices.length == 0) {
+    console.log("fire error: u hadn't add any notice.");
+    return;
+  }
+
+  for (var i = 0; i < __notices.length; i++) {
+    var notice = __notices[i];
+    if (notice.name === name) {
+      notice.selector(info);
     }
+  }
 }
 
 // 用于对比两个对象是否相等
 function cmp(x, y) {
-    // If both x and y are null or undefined and exactly the same  
-    if (x === y) {
-        return true;
-    }
-
-    // If they are not strictly equal, they both need to be Objects  
-    if (!(x instanceof Object) || !(y instanceof Object)) {
+  // If both x and y are null or undefined and exactly the same  
+  if (x === y) {
+    return true;
+  }
+
+  // If they are not strictly equal, they both need to be Objects  
+  if (!(x instanceof Object) || !(y instanceof Object)) {
+    return false;
+  }
+
+  // They must have the exact same prototype chain, the closest we can do is  
+  // test the constructor.  
+  if (x.constructor !== y.constructor) {
+    return false;
+  }
+
+  for (var p in x) {
+    // Inherited properties were tested using x.constructor === y.constructor  
+    if (x.hasOwnProperty(p)) {
+      // Allows comparing x[ p ] and y[ p ] when set to undefined  
+      if (!y.hasOwnProperty(p)) {
         return false;
-    }
+      }
 
-    // They must have the exact same prototype chain, the closest we can do is  
-    // test the constructor.  
-    if (x.constructor !== y.constructor) {
+      // If they have the same strict value or identity then they are equal  
+      if (x[p] === y[p]) {
+        continue;
+      }
+
+      // Numbers, Strings, Functions, Booleans must be strictly equal  
+      if (typeof (x[p]) !== "object") {
         return false;
-    }
+      }
 
-    for (var p in x) {
-        // Inherited properties were tested using x.constructor === y.constructor  
-        if (x.hasOwnProperty(p)) {
-            // Allows comparing x[ p ] and y[ p ] when set to undefined  
-            if (!y.hasOwnProperty(p)) {
-                return false;
-            }
-
-            // If they have the same strict value or identity then they are equal  
-            if (x[p] === y[p]) {
-                continue;
-            }
-
-            // Numbers, Strings, Functions, Booleans must be strictly equal  
-            if (typeof (x[p]) !== "object") {
-                return false;
-            }
-
-            // Objects and Arrays must be tested recursively  
-            if (!Object.equals(x[p], y[p])) {
-                return false;
-            }
-        }
+      // Objects and Arrays must be tested recursively  
+      if (!Object.equals(x[p], y[p])) {
+        return false;
+      }
     }
+  }
 
-    for (p in y) {
-        // allows x[ p ] to be set to undefined  
-        if (y.hasOwnProperty(p) && !x.hasOwnProperty(p)) {
-            return false;
-        }
+  for (p in y) {
+    // allows x[ p ] to be set to undefined  
+    if (y.hasOwnProperty(p) && !x.hasOwnProperty(p)) {
+      return false;
     }
-    return true;
+  }
+  return true;
 };
 
 module.exports = {
-    addNotification: addNotification,
-    removeNotification: removeNotification,
-    fire: fire,
-    fireName: fireName,
-    addOnceNotification: addOnceNotification
+  addNotification: addNotification,
+  removeNotification: removeNotification,
+  fire: fire,
+  fireName: fireName,
+  addOnceNotification: addOnceNotification
 }

+ 2 - 2
utils/lexin/jump.js

@@ -7,7 +7,7 @@ module.exports = {
 function toChannelIndex(index, callback) {
   var pages = getCurrentPages();
   const route_util = require('../route_util');
-  const routePath = require('../route_path');
+  const routePath = require('../routePath');
   var isLogin = pages[0].getIsLogin();
   if (!isLogin) {
     route_util.jump(routePath.login);
@@ -75,6 +75,6 @@ function toChannelIndex(index, callback) {
 ///关于我们
 function toAboutUs() {
   const route_util = require('../route_util');
-  const routePath = require('../route_path');
+  const routePath = require('../routePath');
   route_util.jump(routePath.about);
 };

+ 42 - 0
utils/routePath.js

@@ -0,0 +1,42 @@
+///路由
+const indexRoot = "pages/index/index";
+const loginRoot = "pages/login/login";
+const connectBleRoot = "pages/connectBle/connectBle";
+
+///跳转路径
+const index = "../index/index";
+const login = "../login/login";
+const about = "../about/about";
+const deviceConnect0 = "../deviceConnect0/deviceConnect0";
+const deviceConnect1 = "../deviceConnect1/deviceConnect1";
+const deviceConnect2 = "../deviceConnect2/deviceConnect2";
+
+const setWifi = "../setWifi/setWifi";
+
+/// 抽奖记录
+const deviceList = "../deviceList/deviceList";
+const connectMode = "../deviceConMode/index";
+const connectBle = "../connectBle/connectBle";
+
+
+const webview = "../webview/webview";
+
+module.exports = {
+  ///路由
+  indexRoot: indexRoot,
+  loginRoot: loginRoot,
+  connectBleRoot: connectBleRoot,
+
+  ///跳转路径
+  index: index,
+  login: login,
+  about: about,
+  deviceConnect0: deviceConnect0,
+  deviceConnect1: deviceConnect1,
+  deviceConnect2: deviceConnect2,
+  deviceList: deviceList,
+  connectMode: connectMode,
+  connectBle: connectBle,
+  setWifi: setWifi,
+  webview: webview,
+}

+ 1 - 1
utils/route_util.js

@@ -76,7 +76,7 @@ async function goBack(pages) {
 
 ///返回到首页,不关闭当前界面
 async function goBackHomePage() {
-  const route_constant = require('./route_path.js');
+  const route_constant = require('./routePath.js');
   await goBackRoute(route_constant.indexRoot);
 };
 

+ 0 - 1
utils/util.js

@@ -143,7 +143,6 @@ function isCN(str) {
   }
 }
 
-
 module.exports = {
   formatTime,
   request,