Quellcode durchsuchen

feat: 路由切换

332777428@qq.com vor 2 Monaten
Ursprung
Commit
07e33df377

+ 2 - 2
app.json

@@ -1,7 +1,7 @@
 {
-  "entryPagePath": "pages/pageA/index/index",
+  "entryPagePath": "pages/index/index",
   "pages": [
-    "pages/pageA/index/index",
+    "pages/index/index",
     "pages/pageA/login/login",
     "pages/pageA/deviceList/deviceList"
   ],

+ 3 - 3
devices/ble_manager.js

@@ -342,16 +342,16 @@ class bleManager {
     const routeUtil = require('../utils/routeUtil');
     const routeRoot = require('../utils/routeRoot');
 
-    const indexRoot = routeRoot.index;
+    const index = routeRoot.index;
     const connectBleRoot = routeRoot.connectBle;
     var lastPageRoute = routeUtil.getLastPageRoute();
-    if (lastPageRoute != indexRoot && lastPageRoute != connectBleRoot) {
+    if (lastPageRoute != index && lastPageRoute != connectBleRoot) {
       console.log("搜索蓝牙设备失败,请返回首页0");
       return;
     }
 
     ///蓝牙连接 做限制
-    if (lastPageRoute == indexRoot) {
+    if (lastPageRoute == index) {
       if (that.doStartScaning == true) {
         console.log("搜索蓝牙设备失败,请返回首页1");
         return;

+ 12 - 13
pages/pageA/index/index.js

@@ -1,12 +1,12 @@
-const constant = require('../../../utils/constant.js');
+const constant = require('../../utils/constant.js');
 import {
   BtHelper
-} from '../../../devices/bt_helper.js';
+} from '../../devices/bt_helper.js';
 
 import {
   EnumCmdEvent,
   CmdEvent
-} from '../../../devices/cmd_key_event';
+} from '../../devices/cmd_key_event';
 
 Page({
   data: {
@@ -50,7 +50,7 @@ Page({
     ////我的界面
     loginStatus: true,
     nickName: "未登录",
-    userPic: './../../../img/head_pic.png',
+    userPic: './../../img/head_pic.png',
     intervalId: null,
     /// 是否第一次自动连接过
     autoConnected: false,
@@ -74,7 +74,7 @@ Page({
     that.onBannerLoad();
   },
 
-  onShow() { },
+  onShow() {},
 
   onLoginLoad() {
     var that = this;
@@ -157,7 +157,7 @@ Page({
       ///监听蓝牙设备
       BtHelper.getInstance().initBluetoothAdapter();
       BtHelper.getInstance().getBluetoothDevices();
-      BtHelper.getInstance().startScan(null, null, function (res) { });
+      BtHelper.getInstance().startScan(null, null, function (res) {});
       var isFirst = true;
       that.startBleTimer(isFirst, true);
       that.addNotification()
@@ -235,8 +235,7 @@ Page({
           let hasOtherOnline = false;
           that.data.deviceList.forEach(item => {
             if (item.state === 'online') {
-              if (item.deviceId == device.deviceId) {
-              } else {
+              if (item.deviceId == device.deviceId) {} else {
                 hasOtherOnline = true;
                 return;
               }
@@ -288,7 +287,7 @@ Page({
         case "connect":
           constant.lexinSubscribe.subscribeAllDevice();
           break;
-        ///再走有在线
+          ///再走有在线
         case "message_onoffline":
           constant.lexinConnect.searchOnlineDevice(payloads, function (list) {
             that.updateDeviceList(list, false, false);
@@ -296,10 +295,10 @@ Page({
               return item.state === 'online';
             });
             if (hasOnline) {
-              console.log("停止蓝牙监听1:",)
+              console.log("停止蓝牙监听1:", )
               that.stopIntervalId1()
             } else {
-              console.log("开启蓝牙监听1:",)
+              console.log("开启蓝牙监听1:", )
               that.startBleTimer(true, false);
             }
           }, function () {
@@ -358,7 +357,7 @@ Page({
           break;
         default:
       }
-    } catch (e) { }
+    } catch (e) {}
   },
 
   ///去连接设备数据
@@ -495,7 +494,7 @@ Page({
       isLogin: false,
       greeting: greeting,
       nickName: nickName,
-      userPic: "./../../../img/head_pic.png",
+      userPic: "./../../img/head_pic.png",
     });
 
     var device = that.getCurrentDevice();

+ 5 - 0
pages/index/index.json

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

+ 24 - 24
pages/pageA/index/index.wxml

@@ -17,7 +17,7 @@
       </view>
 
       <view class="add_device_public" bind:tap="jumpToAddDevice">
-        <image mode="heightFix" src="./../../../img/add_device.png" style="width: 48rpx;height: 48rpx;"></image>
+        <image mode="heightFix" src="./../../img/add_device.png" style="width: 48rpx;height: 48rpx;"></image>
         <view style="color: white; margin-left: 8rpx; font-size: 32rpx;">添加设备</view>
       </view>
 
@@ -41,14 +41,14 @@
                     </view>
 
                     <view style="width: 48rpx; height: 48rpx;">
-                      <image mode="aspectFit" src="./../../../img/add_device_arrow.png" style="width: 48rpx; height: 48rpx; opacity: {{item.state && item.state === 'online'&&deviceListSelect === index ? '1' : '0'}}; "></image>
+                      <image mode="aspectFit" src="./../../img/add_device_arrow.png" style="width: 48rpx; height: 48rpx; opacity: {{item.state && item.state === 'online'&&deviceListSelect === index ? '1' : '0'}}; "></image>
                     </view>
 
                   </view>
 
                   <view style="display: flex; flex-direction: row;">
                     <view style="color: #666666; font-size: 24rpx;display: flex; flex-direction: row; align-items: center;">
-                      <image mode="heightFix" src="{{item.connectType==3?'./../../../images/device/wifi_black.png':'./../../../images/device/blue_black.png'}}" style="width: 28rpx;height: 28rpx; padding-right: 10rpx; opacity: {{item.state && item.state === 'online' ? '1' : '0.7'}};"></image>
+                      <image mode="heightFix" src="{{item.connectType==3?'./../../images/device/wifi_black.png':'./../../images/device/blue_black.png'}}" style="width: 28rpx;height: 28rpx; padding-right: 10rpx; opacity: {{item.state && item.state === 'online' ? '1' : '0.7'}};"></image>
                       <view style="white-space: nowrap;"> {{item.state && item.state === "online" ? (item.connectType==3?"Wifi在线":"蓝牙在线") : "离线"}} </view>
                     </view>
 
@@ -77,13 +77,13 @@
       <view wx:if="{{indexPage==1&&deviceListSelect!=null&&deviceList.length>deviceListSelect&&deviceList[deviceListSelect].connectType===3}}" class="mair" style="height: calc(100vh - 105rpx - {{safeBottomHeight}}rpx - 22rpx - {{navBarHeight}}px);">
         <view class="play-info">
           <view class="info">
-            <image src="./../../../img/blak.png" class="black" mode="scaleToFill"></image>
-            <image src="./../../../img/mm.png" class="mode" mode="widthFix"></image>
-            <image class="logo" mode="heightFix" src="./../../../img/logo.png"></image>
+            <image src="./../../img/blak.png" class="black" mode="scaleToFill"></image>
+            <image src="./../../img/mm.png" class="mode" mode="widthFix"></image>
+            <image class="logo" mode="heightFix" src="./../../img/logo.png"></image>
             <view wx:if="{{actionIndex !== null}}" style="opacity: 0.8; text-shadow:0px 0px 4px #6D00FF;" class="fm">
               FM.{{actionIndex !== null ? (actionIndex + 1 < 10 ? "0" + (actionIndex + 1) : actionIndex + 1) : 00}} </view>
                 <view wx:if="{{actionIndex !== null}}" style="opacity: 1;" class="fm">
-                  FM.{{actionIndex !== null ? (actionIndex + 1 < 10 ? "0" + (actionIndex + 1) : actionIndex + 1) : 00}} <image class="gochnnalList" mode="heightFix" src="./../../../img/a6.png">
+                  FM.{{actionIndex !== null ? (actionIndex + 1 < 10 ? "0" + (actionIndex + 1) : actionIndex + 1) : 00}} <image class="gochnnalList" mode="heightFix" src="./../../img/a6.png">
                     </image>
                 </view>
                 <view class="fmMod" bindtap="onTapToChannel"></view>
@@ -95,25 +95,25 @@
                     </view>
                   </view>
                 </view>
-                <image src="{{'./../../../img/dl' + battery + '.png'}}" class="battery" mode="scaleToFill"></image>
+                <image src="{{'./../../img/dl' + battery + '.png'}}" class="battery" mode="scaleToFill"></image>
             </view>
             <view class="wakeMode" bindtap="goWake">
-              <image src="./../../../img/woak.png" class="mode" mode="scaleToFill"></image>
-              <image class="wake" mode="heightFix" src="{{isSetWake ? './../../../img/n24.png' : './../../../img/n23.png' }}"></image>
+              <image src="./../../img/woak.png" class="mode" mode="scaleToFill"></image>
+              <image class="wake" mode="heightFix" src="{{isSetWake ? './../../img/n24.png' : './../../img/n23.png' }}"></image>
               <text>定时</text>
             </view>
           </view>
           <scroll-view class="pd" scroll-y="true">
             <view class="conm" wx:if="{{channelData && channelData.length > 0}}">
-              <image mode="scaleToFill" class="cz" src="./../../../img/cz.png"></image>
+              <image mode="scaleToFill" class="cz" src="./../../img/cz.png"></image>
               <view class="musicList">
                 <view wx:for="{{channelData}}" class="li {{index === actionIndex ? 'action' : ' '}}">
-                  <image mode="scaleToFill" wx:if="{{index === actionIndex}}" class="zz" src="./../../../img/zz.png"></image>
+                  <image mode="scaleToFill" wx:if="{{index === actionIndex}}" class="zz" src="./../../img/zz.png"></image>
                   <text class="lm">{{luoma[index]}}</text>
                   <view class="musicInfo" data-index="{{index}}" bindtap="onTapChannelIndex">
-                    <image mode="scaleToFill" class="pic" src="{{item.channelPic ? item.channelPic : './../../../img/head_pic.png'}}"></image>
+                    <image mode="scaleToFill" class="pic" src="{{item.channelPic ? item.channelPic : './../../img/head_pic.png'}}"></image>
                     <text>{{item.channelName}}</text>
-                    <image mode="scaleToFill" wx:if="{{index === actionIndex}}" class="svg" src="./../../../svg/audio.svg"></image>
+                    <image mode="scaleToFill" wx:if="{{index === actionIndex}}" class="svg" src="./../../svg/audio.svg"></image>
                   </view>
                 </view>
               </view>
@@ -127,7 +127,7 @@
               </view>
               <view style="position: none; height: calc(100% - 224rpx); overflow: auto;" class="BG_PD">
                 <view>
-                  <image style="margin: 0; width: 100vw;" mode="widthFix" src="./../../../img/BG_PD.png"></image>
+                  <image style="margin: 0; width: 100vw;" mode="widthFix" src="./../../img/BG_PD.png"></image>
                 </view>
               </view>
             </view>
@@ -135,11 +135,11 @@
           <view class="gologin goruter" wx:if="{{!showLogin && deviceList && deviceList.length === 0}}">
             <view class="model">
               <view bindtap="goDeviceConnect" style="position: none; height: auto;" class="loginPic">
-                <image style="margin: 20rpx 0 20rpx 0; width: 100vw;" mode="widthFix" src="./../../../img/BG_LJ.png"></image>
+                <image style="margin: 20rpx 0 20rpx 0; width: 100vw;" mode="widthFix" src="./../../img/BG_LJ.png"></image>
               </view>
               <view style="position: none; height: calc(100% - 224rpx); overflow: auto;" class="BG_PD">
                 <view>
-                  <image style="margin: 0; width: 100vw;" mode="widthFix" src="./../../../img/BG_PD.png"></image>
+                  <image style="margin: 0; width: 100vw;" mode="widthFix" src="./../../img/BG_PD.png"></image>
                 </view>
               </view>
             </view>
@@ -158,22 +158,22 @@
           <view class="list">
             <view class="li">
               <view class="icon">
-                <image mode="widthFix" style="width: 40rpx; height: 40rpx;" src="./../../../img/o.png"></image>
+                <image mode="widthFix" style="width: 40rpx; height: 40rpx;" src="./../../img/o.png"></image>
               </view>
               <view class="button">
                 <button class="between_text" open-type="feedback">建议与反馈</button>
                 <button class="between_image" open-type="feedback">
-                  <image class="j" src="./../../../img/b.png"></image>
+                  <image class="j" src="./../../img/b.png"></image>
                 </button>
               </view>
             </view>
             <view class="li">
               <view class="icon">
-                <image mode="widthFix" style="width: 40rpx; height: 40rpx;" src="./../../../img/q.png"></image>
+                <image mode="widthFix" style="width: 40rpx; height: 40rpx;" src="./../../img/q.png"></image>
               </view>
               <view class="button" bindtap="jumpToAboutUs">
                 <text>关于我们</text>
-                <image class="j" src="./../../../img/b.png"></image>
+                <image class="j" src="./../../img/b.png"></image>
               </view>
             </view>
           </view>
@@ -193,7 +193,7 @@
       <view style="flex: 1; text-align: center; display: flex;align-items: center;">
         <!-- 首页 -->
         <view class="bottom_view" data-index="0" bind:tap="onTapIndex">
-          <image class="bottom_image" mode="widthFix" src="{{indexPage==0?'./../../../img/index_action.png':'./../../../img/index_unaction.png'}}"></image>
+          <image class="bottom_image" mode="widthFix" src="{{indexPage==0?'./../../img/index_action.png':'./../../img/index_unaction.png'}}"></image>
           <view style="font-size: 20rpx;color: {{indexPage==0?'#A4D099':'black'}}; padding-top: 0rpx;margin-top: 0rpx;">
             首页
           </view>
@@ -201,13 +201,13 @@
 
         <!-- 频道 -->
         <view wx:if="{{deviceListSelect!=null&&deviceList.length>deviceListSelect&&deviceList[deviceListSelect].connectType===3}}" class="bottom_view" data-index="1" bind:tap="onTapIndex">
-          <image class="bottom_image" mode="widthFix" src="{{indexPage==1?'./../../../img/channel_action.png':'./../../../img/channel_unaction.png'}}"></image>
+          <image class="bottom_image" mode="widthFix" src="{{indexPage==1?'./../../img/channel_action.png':'./../../img/channel_unaction.png'}}"></image>
           <view style="font-size: 20rpx;color: {{indexPage==1?'#A4D099':'black'}};">频道</view>
         </view>
 
         <!-- 我的 -->
         <view class="bottom_view" data-index="2" bind:tap="onTapIndex">
-          <image class="bottom_image" mode="widthFix" src="{{indexPage==2?'./../../../img/me_action.png':'./../../../img/me_unaction.png'}}"></image>
+          <image class="bottom_image" mode="widthFix" src="{{indexPage==2?'./../../img/me_action.png':'./../../img/me_unaction.png'}}"></image>
           <view style="font-size: 20rpx;color: {{indexPage==2?'#A4D099':'black'}};">我的</view>
         </view>
       </view>

pages/pageA/index/index.wxss → pages/index/index.wxss


+ 0 - 5
pages/pageA/index/index.json

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

+ 2 - 2
pages/pageB/deviceConnect0/deviceConnect0.js

@@ -43,7 +43,7 @@ Page({
           showCapsule: 1,
           title: '连接配网',
           callback: () => {
-            constant.routeUtil.goBackRoute(constant.routeRoot.indexRoot);
+            constant.routeUtil.goBackRoute(constant.routeRoot.index);
           }
         },
       })
@@ -141,7 +141,7 @@ Page({
 
   ///返回到首页
   notRoter() {
-    constant.routeUtil.goBackRoute(constant.routeRoot.indexRoot);
+    constant.routeUtil.goBackRoute(constant.routeRoot.index);
   },
 
   onUnload() {

+ 1 - 1
pages/pageB/deviceConnect3/deviceConnect3.js

@@ -204,7 +204,7 @@ Page({
   },
 
   goIndex() {
-    routeUtil.goBackRoute(routeRoot.indexRoot);
+    routeUtil.goBackRoute(routeRoot.index);
   },
 
   onUnload: function () {

+ 1 - 1
pages/pageB/deviceConnect4/deviceConnect4.js

@@ -125,6 +125,6 @@ Page({
   },
 
   goIndex() {
-    routeUtil.goBackRoute(routeRoot.indexRoot);
+    routeUtil.goBackRoute(routeRoot.index);
   },
 })

+ 3 - 3
utils/blue_ble/manager.js

@@ -214,15 +214,15 @@ class Manager {
 
     const routeUtil = require('../../utils/routeUtil');
     const routeRoot = require('../../utils/routeRoot');
-    const indexRoot = routeRoot.indexRoot;
+    const index = routeRoot.index;
     const connectBleRoot = routeRoot.connectBleRoot;
     var lastPageRoute = routeUtil.getLastPageRoute();
-    if (lastPageRoute != indexRoot && lastPageRoute != connectBleRoot) {
+    if (lastPageRoute != index && lastPageRoute != connectBleRoot) {
       return;
     }
 
     ///蓝牙连接 做限制
-    if (lastPageRoute == indexRoot) {
+    if (lastPageRoute == index) {
       if (that.doStartScaning == true) {
         return;
       }

+ 1 - 1
utils/routePath.js

@@ -1,7 +1,7 @@
 ///这里是跳转的路径
 
 /// A
-const index = "../../pageA/index/index";
+const index = "../../index/index";
 const login = "../../pageA/login/login";
 const deviceList = "../../pageA/deviceList/deviceList";
 

+ 1 - 1
utils/routeRoot.js

@@ -1,7 +1,7 @@
 ///路由
 
 /// A
-const index = "pages/pageA/index/index";
+const index = "pages/index/index";
 const login = "pages/pageA/login/login";
 
 /// B