houjie 4 years ago
parent
commit
3d95fcc24d

+ 3 - 3
Lib/BleConfigNet.js

@@ -149,16 +149,16 @@ function notifyBLECharacteristicValueChange(characteristicId) {
                 setTimeout(() => {
                     let buf = Buffer.from('AIrSMArT_CLOSE')
                     sendCongifCmd(characteristicId, buf.buffer)
-                }, 2000)
+                }, 1000)
             }
             else if (receiveStr.indexOf('recv_finish') >= 0) {
                 //todo 设备这里流程没有统一,目前唯一的设备MW-V是收到recv_finish就配网结束了
-                setTimeout(() => {
+                //setTimeout(() => {
                     closeBLEConnection()
                     if (callback && iccid && iccid.length > 0) {
                         callback({ errCode: 0, iccid })
                     }
-                }, 1000)
+                //}, 1000)
             } else if (receiveStr.indexOf('without_WiFi_OK') >= 0) {
                 //配网成功
                 closeBLEConnection()

+ 145 - 0
components/device-manager/deviceItem/deviceItem.vue

@@ -0,0 +1,145 @@
+<template>
+  <view class="content" @click="goDeviceInfo">
+    <image
+      class="device-img"
+      :src="'https://airsmart-photo1.oss-cn-shanghai.aliyuncs.com/wx/productModel/2X/'+device.ProdModel+'.png'"
+      mode="aspectFit"
+    />
+    <battery :battery="device.Power" class="battery"></battery>
+    <view class="text-view">
+      <view class="product">
+        <text class="product-font">型号 {{device.ProdModel}}</text>
+        <text class="product-font" :class="{online:device.online}">{{device.online ? '在线':'离线'}}</text>
+      </view>
+      <text class="name-font">{{device.devName}}</text>
+    </view>
+    <view class="bottom-line"></view>
+    <view class="right-view">
+      <image
+        class="right-img"
+        src="../../../static/common/right.svg"
+        mode="aspectFit"
+      />
+      <view class="red-point" v-if="false"/>
+    </view>
+  </view>
+</template>
+
+<script>
+import battery from "../../battery/battery.vue";
+//MW-V(4G)
+export default {
+  components: { battery },
+  props: {
+    device:{
+      type:Object,
+      default:function(){
+        return {
+          devName:'猫王· 旅行者1号',
+          ProdModel:'MW-X',
+          Power:50,
+          
+        }
+      }
+    }
+  },
+  data: () => ({}),
+  computed: {},
+  methods: {
+	  goDeviceInfo() {
+	    this.$emit('onclick')
+	  },
+  },
+  watch: {},
+
+  // 组件周期函数--监听组件挂载完毕
+  mounted() {},
+
+  // 组件周期函数--监听组件激活(显示)
+  activated() {},
+  // 组件周期函数--监听组件停用(隐藏)
+  deactivated() {},
+  // 组件周期函数--监听组件销毁之前
+  beforeDestroy() {},
+};
+</script>
+
+<style>
+.content {
+  width: 100vw;
+  height: 236rpx;
+  display: flex;
+  flex-direction: row;
+  justify-content: flex-start;
+  align-items: center;
+  position: relative;
+}
+.device-img {
+  width: 120rpx;
+  height: 111rpx;
+  margin-left: 32rpx;
+}
+.battery {
+  margin-left: 6rpx;
+  margin-bottom: 62rpx;
+  align-self: flex-end;
+}
+.text-view {
+  margin-left: 42rpx;
+  margin-bottom: 62rpx;
+  align-self: flex-end;
+  display: flex;
+  flex-direction: column-reverse;
+}
+.product {
+  width: 40vw;
+  display: flex;
+  flex-direction: row;
+  justify-content: space-between;
+}
+
+.product-font {
+  font-size: 24rpx;
+  font-weight: 400;
+  color: #999999;
+}
+.online{
+  color: #684BBE;
+}
+
+.name-font {
+  font-size: 30rpx;
+  font-weight: 600;
+  color: #353535;
+  margin-bottom: 6rpx;
+}
+.bottom-line {
+  position: absolute;
+  bottom: 0;
+  left: 4vw;
+  width: 92vw;
+  height: 1px;
+  opacity: 0.2;
+  background-image: linear-gradient(to right, #c8c8c8, #484848, #979797);
+}
+.right-view {
+  position: absolute;
+  right: 0;
+  height: 100%;
+  display: flex;
+  flex-direction: row-reverse;
+  align-items: center;
+}
+.right-img {
+  width: 13rpx;
+  height: 21rpx;
+  margin-right: 34rpx;
+}
+.red-point {
+  width: 12rpx;
+  height: 12rpx;
+  background: #fb0202;
+  border-radius: 8rpx;
+  margin-right: 30rpx;
+}
+</style>

+ 1 - 0
pages/addDevice/connectDevice/connectDevice.vue

@@ -126,6 +126,7 @@ export default {
             device: {
               devName: this.productName,
               uuid: this.device.uuid,
+              ProdModel:this.model
             },
           });
           //返回上上一级页面

+ 17 - 0
pages/index/index.vue

@@ -1,11 +1,14 @@
 <template>
   <view class="content">
     <button type="primary" @click="addDevice">添加设备</button>
+    <device-item v-for="(device,index) in deviceList" :key="index" :device="device" @onclick='goDeviceInfo'></device-item>
   </view>
 </template>
 
 <script>
+import deviceItem from '../../components/device-manager/deviceItem/deviceItem.vue';
 export default {
+  components: { deviceItem },
   data() {
     return {
       title: "Hello",
@@ -18,7 +21,21 @@ export default {
         url: "../addDevice/selectDevice/selectDevice",
       });
     },
+	goDeviceInfo() {
+	  console.log("goDeviceInfo");
+	  uni.navigateTo({
+	    url: "../demo/mqtt/deviceInfo",
+	    complete(res){
+	      console.warn(res);
+	    }
+	  });
+	},
   },
+  computed:{
+	  deviceList(){
+		  return this.$store.state.moduleMqtt.deviceList;
+	  }
+  }
 };
 </script>
 

+ 32 - 23
pages/mine/device/deviceManager/deviceManager.vue

@@ -1,32 +1,41 @@
 <template>
-	<view class="content">
-		
-		<battery :battery='battery'></battery>
-		
-	</view>
+  <view class="content">
+	  <device-item v-for="(device,index) in deviceList" :key="index" :device="device" @onclick="goDeviceInfo"></device-item>
+  </view>
 </template>
 
 <script>
-import battery from '../../../../components/battery/battery.vue'
-	export default {
-  components: { battery },
-		data() {
-			return {
-				battery:101
-			}
-		},
-		methods: {
-			
-		}
-	}
+import deviceItem from '../../../../components/device-manager/deviceItem/deviceItem.vue';
+export default {
+  components: { deviceItem },
+  data() {
+    return {
+      battery: 101,
+    };
+  },
+  methods: {
+	  goDeviceInfo() {
+	    console.log("goDeviceInfo");
+	    uni.navigateTo({
+	      url: "../../../demo/mqtt/deviceInfo",
+	      complete(res){
+	        console.warn(res);
+	      }
+	    });
+	  },
+  },
+  computed:{
+	  deviceList(){
+		  return this.$store.state.moduleMqtt.deviceList;
+	  }
+  }
+};
 </script>
 
 <style>
-.content{
-	display: flex;
-	flex-direction: column;
-	align-items: center;
-	margin: 20rpx;
-}
+.content {
+  display: flex;
+  flex-direction: column;
 
+}
 </style>

+ 6 - 0
pages/mine/mine.vue

@@ -1,5 +1,6 @@
 <template>
 	<view>
+		<button type="primary" @click="goDevice">设备管理</button>
 		<button type="primary" @click="goWebview('product/manual')">产品手册</button>
 		<button type="primary" @click="goWebview('help')">帮助与反馈</button>
 		<button type="primary" @click="goWebview('about')">关于</button>
@@ -19,6 +20,11 @@
 				uni.navigateTo({
 					url:`../webview/webview?path=${path}`
 				})
+			},
+			goDevice(){
+				uni.navigateTo({
+					url:'device/deviceManager/deviceManager'
+				})
 			}
 		}
 	}

+ 6 - 2
pages/play/play.vue

@@ -1,6 +1,6 @@
 <template>
 	<view>
-		
+		<button type="primary" @click="goControl">设备控制</button>
 	</view>
 </template>
 
@@ -12,7 +12,11 @@
 			}
 		},
 		methods: {
-			
+			goControl(){
+				uni.navigateTo({
+					url:'../demo/mqtt/mqttDemo'
+				})
+			}
 		}
 	}
 </script>

File diff suppressed because it is too large
+ 15 - 0
static/common/right.svg