소스 검색

feature: 处理连接成功后回调用到首页

Damon 8 달 전
부모
커밋
57e04811dc
6개의 변경된 파일126개의 추가작업 그리고 208개의 파일을 삭제
  1. 22 9
      pages/connectBle/connectBle.js
  2. 24 71
      pages/deviceConMode/index.js
  3. 0 47
      pages/deviceList/deviceList.js
  4. 6 7
      pages/deviceList/deviceList.wxml
  5. 5 6
      pages/index/index.js
  6. 69 68
      utils/route_util.js

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 22 - 9
pages/connectBle/connectBle.js


+ 24 - 71
pages/deviceConMode/index.js

@@ -16,27 +16,40 @@ Page({
       title: '连接配网', //导航栏 中间的标题
     },
     isNotruter: false,
-    model: "",
+    model: 0,
     connectDevice: {},
-    typeList: [
-
+    typeList: [{
+        "icon": "../../images/device/mode_wifi.png",
+        "text": "WiFi模式",
+        "type": 2,
+      },
+      {
+        "icon": "../../images/device/mode_ble.png",
+        "text": "蓝牙模式",
+        "type": 1,
+      },
+      {
+        "icon": "../../images/device/mode_g4.png",
+        "text": "4G模式",
+        "type": 4,
+      },
     ],
   },
   getModeName(curItem) {
     // 设备类型:1-蓝牙,2-Wifi,3-传统蓝牙,4-4G
     var str = "";
-    if (curItem.type == 4) {
+    if (curItem.deviceMode == 4) {
       str = "移动数据模式";
-    } else if (curItem.type == 2) {
+    } else if (curItem.deviceMode == 2) {
       str = "WiFi模式";
-    } else if (curItem.type == 1) {
+    } else if (curItem.deviceMode == 1) {
       str = "蓝牙模式";
     }
     return str;
   },
   nextTap(e) {
     let device = this.data.typeList[0];
-    let type = device.connectType ?? 0;
+    let type = device.type ?? 0;
     console.log("选择模式", type)
     if (type == 1) {
       // let device = e.currentTarget.dataset.data
@@ -55,7 +68,7 @@ Page({
   async selectDeviceModelTap(e) {
     let device = e.currentTarget.dataset.device;
     // console.log(e)
-    let type = device.connectType;
+    let type = device.type;
     if (type == 1) {
       // this.getConnectedDevices()
     } else if (type == 2) {
@@ -68,13 +81,12 @@ Page({
     var list = []
     list.push(device)
     this.data.typeList.forEach(element => {
-      if (element.connectType != type) {
+      if (element.type != type) {
         list.push(element)
       }
     });
     this.setData({
       typeList: list,
-      model: this.getModeName(device.typeList)
     })
 
   },
@@ -83,72 +95,13 @@ Page({
     let json = JSON.parse(options.param)
     console.log(json)
     let device = json
-
-    let typeList = json.typeList.map(e => {
-      return {
-        icon: "../../images/device/mode_" + e.connectType + ".png",
-        text: this.getModeName(e),
-        connectType: e.connectType
-      }
-    })
-
     this.setData({
-      connectDevice: device,
-      typeList: typeList
+      connectDevice: device
     })
 
     if (getApp().globalData.isIOS) {
 
-    } else {
-    }
-  },
-
-  /**
-   * 生命周期函数--监听页面初次渲染完成
-   */
-  onReady() {
-
-  },
-
-  /**
-   * 生命周期函数--监听页面显示
-   */
-  onShow() {
-
-  },
-
-  /**
-   * 生命周期函数--监听页面隐藏
-   */
-  onHide() {
-
-  },
-
-  /**
-   * 生命周期函数--监听页面卸载
-   */
-  onUnload() {
-
-  },
-
-  /**
-   * 页面相关事件处理函数--监听用户下拉动作
-   */
-  onPullDownRefresh() {
-
-  },
-
-  /**
-   * 页面上拉触底事件的处理函数
-   */
-  onReachBottom() {
-
+    } else {}
   },
 
-  /**
-   * 用户点击右上角分享
-   */
-  onShareAppMessage() {
-
-  }
 })

+ 0 - 47
pages/deviceList/deviceList.js

@@ -62,52 +62,5 @@ Page({
     // })
 
   },
-  /**
-   * 生命周期函数--监听页面初次渲染完成
-   */
-  onReady() {
-
-  },
-
-  /**
-   * 生命周期函数--监听页面显示
-   */
-  onShow() {
-
-  },
-
-  /**
-   * 生命周期函数--监听页面隐藏
-   */
-  onHide() {
-
-  },
-
-  /**
-   * 生命周期函数--监听页面卸载
-   */
-  onUnload() {
-
-  },
-
-  /**
-   * 页面相关事件处理函数--监听用户下拉动作
-   */
-  onPullDownRefresh() {
-
-  },
-
-  /**
-   * 页面上拉触底事件的处理函数
-   */
-  onReachBottom() {
-
-  },
-
-  /**
-   * 用户点击右上角分享
-   */
-  onShareAppMessage() {
 
-  }
 })

+ 6 - 7
pages/deviceList/deviceList.wxml

@@ -1,10 +1,9 @@
-
 <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="container grid-container">
-    <block wx:for="{{deviceList}}" wx:key="index" wx:for-item="item" wx:for-index="index">
-        <view class="cell" bind:tap="deviceTap" data-device="{{item}}">
-            <image class="device_img" src="{{item.img}}" mode="aspectFill" />
-            <text class="device_text main_black">{{item.name}}</text>
-        </view>
-    </block>
+  <block wx:for="{{deviceList}}" wx:key="index" wx:for-item="item" wx:for-index="index">
+    <view class="cell" bind:tap="deviceTap" data-device="{{item}}">
+      <image class="device_img" src="{{item.img}}" mode="aspectFill" />
+      <text class="device_text main_black">{{item.name}}</text>
+    </view>
+  </block>
 </view>

+ 5 - 6
pages/index/index.js

@@ -58,7 +58,6 @@ Page({
 
   onLoad(options) {
     var that = this;
-
     var bannerList = wx.getStorageSync("homeBanner") || [];
     if (that.data.bannerList.length == 0) {
       that.setData({
@@ -72,7 +71,7 @@ Page({
   onShow() {
     var that = this;
     that.onHomeShow();
-    that.onMeShow();
+    that.onMeLoad();
     var nickname = that.data.nickname;
     var greeting = that.updateGreeting();
     if (nickname != "" && nickname != "未登录") {
@@ -202,10 +201,6 @@ Page({
     };
   },
 
-  onMeShow() {
-    this.onLoad();
-  },
-
   ////开始是home的
   login() {
     wx.login({
@@ -799,4 +794,8 @@ Page({
     });
   },
 
+  addConnectDevice(connectDevice) {
+    console.log("dfadsfasdfasdfa==111==" + JSON.stringify(connectDevice))
+  },
+
 })

+ 69 - 68
utils/route_util.js

@@ -3,77 +3,78 @@
 //返回页面个数
 async function goBack(pages) {
 
-    const cPages = getCurrentPages();
-    const currentPage = cPages[cPages.length - 1];
+  const cPages = getCurrentPages();
+  const currentPage = cPages[cPages.length - 1];
 
-    if (currentPage.route.lastIndexOf("detail/detail")) {
-        setTimeout(() => {
-            wx.switchTab({
-                url: '../pages/index/index'
-            });
-        }, 300);
-    } else {
-        // 执行返回操作
-        if (pages == null) pages = 1;
-        await wx.navigateBack({
-            delta: pages,
-        });
-    }
+  if (currentPage.route.lastIndexOf("detail/detail")) {
+    setTimeout(() => {
+      wx.switchTab({
+        url: '../pages/index/index'
+      });
+    }, 300);
+  } else {
+    // 执行返回操作
+    if (pages == null) pages = 1;
+    await wx.navigateBack({
+      delta: pages,
+    });
+  }
 
 };
 
 ///跳转界面
 async function jump(url) {
-    await wx.navigateTo({
-        url: url,
-    })
+  await wx.navigateTo({
+    url: url,
+  })
 };
 
 async function jumpParam(url, param) {
-    if (param) {
-        await wx.navigateTo({
-            url: url + "?param=" + param,
-        });
-    } else {
-        await jump(url);
-    }
+  if (param) {
+    await wx.navigateTo({
+      url: url + "?param=" + param,
+    });
+  } else {
+    await jump(url);
+  }
 };
 
 //界面跳转
 async function jumpLogin(url, isNeedLogin) {
-    if (isNeedLogin) {
-        // if (loginUtil.getUserBean() == null) {
-        //     return;
-        // }
-    }
-    await wx.navigateTo({
-        url: url,
-    });
+  if (isNeedLogin) {
+    // if (loginUtil.getUserBean() == null) {
+    //     return;
+    // }
+  }
+  await wx.navigateTo({
+    url: url,
+  });
 };
 
 //跳转到Tab页面
 async function switchTo(url) {
-    console.log(url)
-    await wx.switchTab({
-        //跳转目标
-        url: url,
-        //跳转成功后
-        success: function () {
-            //让多个tabl显示出来
-            // wx.showTabBar({
-            //     animation: false,
-            // });
-        }, fail: function (res) {
-            console.log(res)
-        }
-    })
+  console.log(url)
+  await wx.switchTab({
+    //跳转目标
+    url: url,
+    //跳转成功后
+    success: function () {
+      //让多个tabl显示出来
+      // wx.showTabBar({
+      //     animation: false,
+      // });
+    },
+    fail: function (res) {
+      console.log(res)
+    }
+  })
 };
 
 //跳转摧毁当前界面
 async function redirectTo(url) {
-    await wx.redirectTo({
-        url: url,
-    });
+  await wx.redirectTo({
+    url: url,
+  });
 };
 
 /**
@@ -81,25 +82,25 @@ async function redirectTo(url) {
  * @param {*} item
  */
 function jump2Other(item) {
-    wx.navigateToMiniProgram({
-        appId: item.app_id,
-        path: item.page_path,
-        // extraData: {
-        //   foo: 'bar'
-        // },
-        // envVersion: 'develop',
-        envVersion: 'release',
-        success() { },
-        fail() { }
-    });
+  wx.navigateToMiniProgram({
+    appId: item.app_id,
+    path: item.page_path,
+    // extraData: {
+    //   foo: 'bar'
+    // },
+    // envVersion: 'develop',
+    envVersion: 'release',
+    success() {},
+    fail() {}
+  });
 };
 
 module.exports = {
-    jump: jump,
-    jumpParam: jumpParam,
-    goBack: goBack,
-    switchTo: switchTo,
-    jump2Other: jump2Other,
-    redirectTo: redirectTo,
-    jumpLogin: jumpLogin,
+  jump: jump,
+  jumpParam: jumpParam,
+  goBack: goBack,
+  switchTo: switchTo,
+  jump2Other: jump2Other,
+  redirectTo: redirectTo,
+  jumpLogin: jumpLogin,
 }