Prechádzať zdrojové kódy

feature: 添加曲谱顶部被选择图片

Damon 1 rok pred
rodič
commit
a8400c8790

+ 55 - 44
app.js

@@ -17,18 +17,18 @@ App({
     pwdData: "",
     userData: null,
     userInfo: null,
-    newDeviceId: null, 
+    newDeviceId: null,
     is_debug: 2, // 1 测试环境 // 2正式环境
     client: null,
     oneInitBluetooth: true,
-        systemInfo:null,
+    systemInfo: null,
     //MQTT连接的配置
     options: {
       clientId: "wx_" + parseInt(Math.random() * 100 + 800, 10),
       reconnectPeriod: 1000, //1000毫秒,两次重新连接之间的间隔
       connectTimeout: 30 * 1000, //1000毫秒,两次重新连接之间的间隔
       resubscribe: true, //如果连接断开并重新连接,则会再次自动订阅已订阅的主题(默认true
-      keepalive: 3,//每3秒发送一次心跳
+      keepalive: 3, //每3秒发送一次心跳
     },
   },
   eventBus: eventBus,
@@ -39,51 +39,60 @@ App({
   connect() {
     this.globalData.client = mqtt.connect(host, this.globalData.options);
     // 连接成功
-    this.globalData.client.on('connect', ()=> {
+    this.globalData.client.on('connect', () => {
       const pageinfo = getCurrentPages()[getCurrentPages().length - 1];
-      if(pageinfo.mqttCallback) {
+      if (pageinfo.mqttCallback) {
         pageinfo.mqttCallback("connect")
       };
-      
+
     });
     // 接收消息
-    this.globalData.client.on("message", function(topic, payload) {
+    this.globalData.client.on("message", function (topic, payload) {
       wx.hideLoading();
       const pageinfo = getCurrentPages()[getCurrentPages().length - 1];
       const thisPageIsIndex = getCurrentPages().length === 1;
-      if(pageinfo.mqttCallback) {
-        if(topic.indexOf("status/onoffline") !== -1) {
-          pageinfo.mqttCallback("message_onoffline", {topic, payload});
-          if(!thisPageIsIndex) {
-            getCurrentPages()[0].mqttCallback("message_onoffline", {topic, payload})
+      if (pageinfo.mqttCallback) {
+        if (topic.indexOf("status/onoffline") !== -1) {
+          pageinfo.mqttCallback("message_onoffline", {
+            topic,
+            payload
+          });
+          if (!thisPageIsIndex) {
+            getCurrentPages()[0].mqttCallback("message_onoffline", {
+              topic,
+              payload
+            })
           }
-        } else if(topic.indexOf("user/pub_response") !== -1) {
-          pageinfo.mqttCallback("message", {topic, payload});
+        } else if (topic.indexOf("user/pub_response") !== -1) {
+          pageinfo.mqttCallback("message", {
+            topic,
+            payload
+          });
         }
       };
     });
     //服务器连接异常的回调
-    this.globalData.client.on("error", function(error) {
+    this.globalData.client.on("error", function (error) {
       console.log(" 服务器 error 的回调" + error)
       const pageinfo = getCurrentPages()[getCurrentPages().length - 1];
-      if(pageinfo.mqttCallback) {
+      if (pageinfo.mqttCallback) {
         pageinfo.mqttCallback("error")
       };
     })
 
     // 服务器重连
-    this.globalData.client.on("reconnect", function(errr) {
+    this.globalData.client.on("reconnect", function (errr) {
       console.log(" 服务器 reconnect的回调", errr);
       const pageinfo = getCurrentPages()[getCurrentPages().length - 1];
-      if(pageinfo.mqttCallback) {
+      if (pageinfo.mqttCallback) {
         pageinfo.mqttCallback("reconnect")
       };
     })
     //服务器断开连接
-    this.globalData.client.on("offline", function(errr) {
+    this.globalData.client.on("offline", function (errr) {
       console.log(" 服务器 offline的回调", errr)
       const pageinfo = getCurrentPages()[getCurrentPages().length - 1];
-      if(pageinfo.mqttCallback) {
+      if (pageinfo.mqttCallback) {
         pageinfo.mqttCallback("offline")
       };
     })
@@ -98,13 +107,13 @@ App({
 
 
   // 订阅主题
-  subscribe: function(topic, callback) {
+  subscribe: function (topic, callback) {
 
     if (this.globalData.client && this.globalData.client.connected) {
       //订阅主题
-      this.globalData.client.subscribe(topic, function(err, granted) {
+      this.globalData.client.subscribe(topic, function (err, granted) {
         if (!err) {
-          if(callback) {
+          if (callback) {
             callback();
           }
           console.log("订阅成功");
@@ -122,7 +131,7 @@ App({
     }
   },
   // 取消订阅
-  unsubscribe: function(Topic) {
+  unsubscribe: function (Topic) {
     if (this.globalData.client && this.globalData.client.connected) {
       this.globalData.client.unsubscribe(Topic);
     } else {
@@ -149,11 +158,15 @@ App({
       wx.showLoading({
         title: '请稍后',
       });
-      const data = {"DstDeviceName": option.DstDeviceName,"SrcDeviceName": `ALY_${this.globalData.userInfo.userId}`,"type": option.type};
-      if(option.other) {
+      const data = {
+        "DstDeviceName": option.DstDeviceName,
+        "SrcDeviceName": `ALY_${this.globalData.userInfo.userId}`,
+        "type": option.type
+      };
+      if (option.other) {
         data.other = option.other;
       };
-      this.globalData.client.publish(`/${option.DstDeviceName}/user/sub_control`, `${JSON.stringify(data)}`,(err) => {
+      this.globalData.client.publish(`/${option.DstDeviceName}/user/sub_control`, `${JSON.stringify(data)}`, (err) => {
         if (err) {
           console.log("发布消息失败");
         }
@@ -169,18 +182,18 @@ App({
   },
   onLaunch() {
     var _this = this;
-    wx.onAppHide(()=> {
-      if(_this.globalData.client && _this.globalData.client.connected){
+    wx.onAppHide(() => {
+      if (_this.globalData.client && _this.globalData.client.connected) {
         _this.globalData.client.end(true);
         _this.globalData.client.end(true);
         console.log("断开");
       };
     });
 
-    wx.onAppShow(()=> {
+    wx.onAppShow(() => {
       console.log("加载")
-      if(_this.globalData.userInfo !== null){
-        if(_this.globalData.client) {
+      if (_this.globalData.userInfo !== null) {
+        if (_this.globalData.client) {
           _this.globalData.client.end(true);
           _this.globalData.client.end(true);
         }
@@ -193,27 +206,25 @@ App({
     wx.getSystemInfo({
       success: (res) => {
         let custom = wx.getMenuButtonBoundingClientRect();
-       _this.globalData.systemInfo = res;
+        _this.globalData.systemInfo = res;
         _this.globalData.navBarHeight = res.statusBarHeight + custom.height + (custom.top - res.statusBarHeight) * 2;
         _this.globalData.MenuButtonheight = custom.height;
         _this.globalData.MenuButtonTop = custom.top;
-        
       }
-      
     })
   },
   // 获取蓝牙权限
-  getBluetoothStatus(){
+  getBluetoothStatus() {
     const _this = this;
     wx.getSetting({
-      success (res) {
-        if(res.authSetting["scope.bluetooth"]) {
+      success(res) {
+        if (res.authSetting["scope.bluetooth"]) {
           _this.globalData.scopeBluetooth = true;
-        } else if(res.authSetting["scope.bluetooth"] === undefined) {
+        } else if (res.authSetting["scope.bluetooth"] === undefined) {
           _this.globalData.scopeBluetooth = false;
-          wx.authorize({ 
+          wx.authorize({
             scope: "scope.bluetooth",
-            complete () {
+            complete() {
               _this.getBluetoothStatus();
             }
           });
@@ -222,11 +233,11 @@ App({
           wx.showModal({
             title: '请打开系统蓝牙进行配网',
             content: '如已打开蓝牙仍然弹框,请尝试重启小程序',
-            success (res) {
+            success(res) {
               if (res.confirm) {
                 console.log('用户点击确定')
                 wx.openSetting({
-                  complete () {
+                  complete() {
                     // _this.getBluetoothStatus();
                   }
                 })
@@ -236,7 +247,7 @@ App({
             }
           })
         };
-        if(getCurrentPages()[getCurrentPages().length - 1].getBluetoothStatusCallck) {
+        if (getCurrentPages()[getCurrentPages().length - 1].getBluetoothStatusCallck) {
           getCurrentPages()[getCurrentPages().length - 1].getBluetoothStatusCallck(_this.globalData.scopeBluetooth);
         }
         // res.authSetting = {

+ 13 - 0
pages/piano/musicscore/musicscore.js

@@ -10,6 +10,19 @@ Page({
       showCapsule: 1, //是否显示左上角图标   1表示显示    0表示不显示
       title: '曲谱', //导航栏 中间的标题
     },
+    topList: [{
+      name: "图片4",
+      image: "./../../../img/min.png",
+    }, {
+      name: "图片1",
+      image: "./../../../img/min.png",
+    }, {
+      name: "图片2",
+      image: "./../../../img/min.png",
+    }, {
+      name: "图片3",
+      image: "./../../../img/min.png",
+    }, ],
   },
 
   /**

+ 13 - 0
pages/piano/musicscore/musicscore.wxml

@@ -1,4 +1,17 @@
 <view>
   <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="public">
+    <image class="image_top" src="./../../../img/min.png"></image>
+    <view class="top_item_public_add">
+      <view class="top_item_public" wx:for="{{topList}}" wx:key="key" wx:for-item="item" wx:for-index="index">
+        <view bind:tap="clickTopItem" data-index="{{index}}">
+          <image class="top_image" mode="heightFix" src="{{item.image}}"></image>
+          <view>{{item.name}}</view>
+        </view>
+      </view>
+    </view>
+  </view>
+
 </view>

+ 35 - 1
pages/piano/musicscore/musicscore.wxss

@@ -1 +1,35 @@
-/* pages/piano/musicscore/musicscore.wxss */
+.public {
+  display: flex;
+  flex-direction: column;
+  align-items: center;
+}
+
+.image_top {
+  margin-top: 40rpx;
+  height: 40vw;
+  width: 60vw;
+}
+
+.top_item_public_add {
+  display: -webkit-flex;
+  display: flex;
+  margin-top: 40rpx;
+  align-items: center;
+  justify-content: flex-start;
+  flex-wrap: wrap;
+  width: 100%;
+}
+
+.top_item_public {
+  justify-content: center;
+  flex: 0 0 auto;
+  width: 50%;
+  text-align: center;
+  color: #797979;
+  padding: 40rpx 0;
+  font-size: 30rpx;
+}
+
+.top_image {
+  height: 20vw;
+}

+ 0 - 1
pages/piano/wallpaper/wallpaper.wxml

@@ -4,7 +4,6 @@
 
   <view class="public">
     <image class="image_top" src="./../../../img/min.png"></image>
-
     <view class="top_item_public_add">
       <view class="top_item_public" wx:for="{{topList}}" wx:key="key" wx:for-item="item" wx:for-index="index">
         <view bind:tap="clickTopItem" data-index="{{index}}">

+ 9 - 1
project.private.config.json

@@ -9,6 +9,13 @@
     "miniprogram": {
       "list": [
         {
+          "name": "曲谱",
+          "pathName": "pages/piano/musicscore/musicscore",
+          "query": "",
+          "launchMode": "default",
+          "scene": null
+        },
+        {
           "name": "壁纸",
           "pathName": "pages/piano/wallpaper/wallpaper",
           "query": "",
@@ -52,5 +59,6 @@
         }
       ]
     }
-  }
+  },
+  "libVersion": "2.26.2"
 }