Sfoglia il codice sorgente

feature:增加钢琴音箱的蓝牙连接界面

zeng.chen 1 anno fa
parent
commit
f825ebac1f

+ 22 - 14
app.json

@@ -14,22 +14,25 @@
     "pages/download/download",
     "pages/wakeList/wakeList",
     "pages/aboutInfo/aboutInfo",
-    "pages/home/home"
+    "pages/home/home",
+    "pages/bluConnect/bleconnect"
   ],
-
-  "subPackages": [{
-    "root": "pages/piano/",
-    "pages": [
-      "detail/detail",
-      "woodenfish/woodenfish",
-      "wallpaper/wallpaper",
-      "musicscore/musicscore"
-    ]
-  }],
-
+  "subPackages": [
+    {
+      "root": "pages/piano/",
+      "pages": [
+        "detail/detail",
+        "woodenfish/woodenfish",
+        "wallpaper/wallpaper",
+        "musicscore/musicscore"
+      ]
+    }
+  ],
+  
   "tabBar": {
     "borderStyle": "black",
-    "list": [{
+    "list": [
+      {
         "pagePath": "pages/index/index",
         "text": "首页",
         "iconPath": "./img/index_unaction.png",
@@ -67,5 +70,10 @@
   "sitemapLocation": "sitemap.json",
   "requiredPrivateInfos": [
     "getFuzzyLocation"
-  ]
+  ],
+  "permission": {
+    "scope.userFuzzyLocation": {
+      "desc": "用于获取wifi名称" 
+    }
+  }
 }

+ 107 - 0
pages/bluConnect/bleconnect.js

@@ -0,0 +1,107 @@
+// pages/bluConnect/bleconnect.js
+Page(
+  {
+  /**
+   * 页面的初始数据
+   */
+  data: {
+    scopeBluetooth: false,
+    isScaning: false,
+    connectStatus: 0,
+    connectText: "连接中",
+    connectTips: "确保蓝牙已经打开",
+
+    
+    userFuzzyLocation: true,
+    nvabarData: {
+      showCapsule: 1, //是否显示左上角图标   1表示显示    0表示不显示
+      title: '设备连接', //导航栏 中间的标题
+      callback() {
+        wx.navigateBack({
+          delta: 1,
+        })
+      }
+    },
+  },  getBluetoothStatusCallck(v) {
+    this.setData({
+      scopeBluetooth: v
+    })
+  },
+  setBluetooth(){
+    wx.openSetting({
+      complete () {
+        // app.getBluetoothStatus();
+      }
+    })
+  },
+
+  /**
+   * 生命周期函数--监听页面加载
+   */
+  onLoad(options) {
+
+    if(options.isLognlink) {
+      this.setData({
+        isNotruter: true,
+        nvabarData: {
+          showCapsule: 1,
+          title: '设备连接',
+          callback: ()=> {
+            wx.switchTab({
+              url: '../home/home',
+            })
+          }
+        },
+      })
+    }
+  },
+
+  /**
+   * 生命周期函数--监听页面初次渲染完成
+   */
+  onReady() {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面显示
+   */
+  onShow() {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面隐藏
+   */
+  onHide() {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面卸载
+   */
+  onUnload() {
+
+  },
+
+  /**
+   * 页面相关事件处理函数--监听用户下拉动作
+   */
+  onPullDownRefresh() {
+
+  },
+
+  /**
+   * 页面上拉触底事件的处理函数
+   */
+  onReachBottom() {
+
+  },
+
+  /**
+   * 用户点击右上角分享
+   */
+  onShareAppMessage() {
+
+  }
+})

+ 5 - 0
pages/bluConnect/bleconnect.json

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

+ 18 - 0
pages/bluConnect/bleconnect.wxml

@@ -0,0 +1,18 @@
+<!-- pages/bluConnect/bleconnect.wxml -->
+<view class="container">
+  <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>
+  <!-- <scroll-view class="scrollClass" scroll-y="true"> -->
+  <image class="device_pic_class" src="../../img/a.png" mode="scaleToFill" />
+  <view class="text_class">
+    <text class="scanDeviceClass">搜索钢琴音箱</text>
+    <view wx:if="{{isScaning}}">{{connectTips}}</view>
+    <span wx:if="{{connectStatus == 4}}" class="scan_device_status_class">
+      <image class="scan_device_status_img_class" src="../../img/a.png" mode="scaleToFill" />
+      <text class="scan_device_status_text_class">{{connectText}}</text>
+    </span>
+  </view>
+  <view style="flex: 1;  "></view>
+<view style="justify-content: center;  display: flex;">  <button class="connect_btn_class">连接</button>
+</view>
+  <!-- </scroll-view> -->
+</view>

+ 64 - 0
pages/bluConnect/bleconnect.wxss

@@ -0,0 +1,64 @@
+/* pages/bluConnect/bleconnect.wxss */
+
+.container {
+  /* background: red; */
+  position: fixed;  
+  display: flex;
+  flex-direction: column;
+  width: 100%;
+  height: 100%;
+}
+
+.container .device_pic_class {
+  height: 300rpx;
+  /* width: 300rpx; */
+  margin-top: 56rpx;
+  margin-left: 60rpx;
+  margin-right: 60rpx;
+
+}
+
+.container .text_class {
+  width: 100%;
+  align-items: center;
+  display: flex;
+  flex-direction: column;
+}
+
+.container .scanDeviceClass {
+  margin-top: 16rpx;
+  margin-left: 16rpx;
+  margin-right: 16rpx;
+
+}
+
+
+.container .scan_device_status_class {
+  /* align-items: center; */
+  margin-top: 16rpx;
+  margin-left: 16rpx;
+  margin-right: 16rpx;
+  flex-direction: row;
+}
+
+
+.container .scan_device_status_img_class {
+  margin-right: 16rpx;
+  width: 16rpx;
+  height: 16rpx;
+}
+
+.container .scan_device_status_text_class {
+  margin-right: 16rpx;
+  width: 16rpx;
+  height: 16rpx;
+}
+
+
+.container .connect_btn_class {
+  margin-left: 56rpx;
+  margin-right: 56rpx;
+  margin-bottom: 56rpx;
+  margin-top: 70rpx;
+
+}

+ 7 - 0
project.private.config.json

@@ -9,6 +9,13 @@
     "miniprogram": {
       "list": [
         {
+          "name": "pages/bluConnect/bleconnect",
+          "pathName": "pages/bluConnect/bleconnect",
+          "query": "",
+          "launchMode": "default",
+          "scene": null
+        },
+        {
           "name": "pages/piano/detail/detail",
           "pathName": "pages/piano/detail/detail",
           "query": "",