Bläddra i källkod

蓝牙版配网优化

htc 21 timmar sedan
förälder
incheckning
c4f6f65e38
4 ändrade filer med 33 tillägg och 12 borttagningar
  1. 13 7
      components/deviceBox/index.vue
  2. 9 3
      pagesMy/scanResult.vue
  3. 1 1
      pagesMy/wifiSearch.vue
  4. 10 1
      pagesMy/wifiSet.vue

+ 13 - 7
components/deviceBox/index.vue

@@ -80,12 +80,17 @@ export default {
 							})
 							.then(async (res) => {
 								if (res.data.code !== 0) return this.$showToast(res.data.msg);
-								this.$showToast('解绑成功');
+								this.$showToast('解绑成功');
+								
+								xBlufi.notifyStartDiscoverBle({
+									'isStart': false
+								})
 								xBlufi.notifyConnectBle({
 									isStart: false,
 									deviceId: item.id,
 								});
-								xBlufi.listenDeviceMsgEvent(false, this.funListenDeviceMsgEvent);
+								xBlufi.listenDeviceMsgEvent(false, this.funListenDeviceMsgEvent);
+								
 								this.connectedId = item.id;
 								console.log(this.connectedId, 'this.connectedId');
 								const ready = await this.ensureBtReady();
@@ -125,14 +130,15 @@ export default {
 		},
 		closeBluetooth() {
 			// 2.1 断开设备
-			if (this.connectedId) {
+			if (this.connectedId) {
+				console.log('断开连接', this.connectedId);
 				uni.closeBLEConnection({
 					deviceId: this.connectedId,
 					success: () => {
 						console.log('断开连接成功');
 					},
-					fail: () => {
-						/* 已断开或其它异常不用提示 */
+					fail: (err) => {
+						console.log('断开连接失败',err);
 					}
 				});
 				this.connectedId = '';
@@ -144,8 +150,8 @@ export default {
 					success: () => {
 						console.log('关闭蓝牙适配器成功');
 					},
-					fail: () => {
-						/* 同样可吞掉 */
+					fail: (err) => {
+						console.log('关闭适配器',err)
 					}
 				});
 				this.isBluetoothOpen = false;

+ 9 - 3
pagesMy/scanResult.vue

@@ -1,8 +1,8 @@
 <template>
 	<view class="page" :style="{'min-height':h+'px', 'padding-top':mt+'px'}">
-		<cus-header title='扫码结果'></cus-header>
+		<cus-header :title='htitle'></cus-header>
 		<image src="https://transcend.ringzle.com/xiaozhi-app/profile/2025/06/03/ea285d8f-ad96-447e-8f4a-77d495f2fac6.png"></image>
-		<p>扫码成功</p>
+		<p>{{title}}</p>
 		<p class="tip">设备已就绪,需添加角色才能使用<br>快去创建角色吧~</p>
 		<div class="zt_btn" @tap="addRole">为设备添加角色</div>
 	</view>
@@ -12,11 +12,17 @@
 	export default {
 		data(){
 			return {
-				scanParams:''
+				scanParams:'',
+				htitle:'扫码结果',
+				title:'扫码成功'
 			}
 		},
 		onLoad(option) {
 			if(option.scanParams) this.scanParams = JSON.parse(option.scanParams);
+			if(option.type&&option.type=='lanya'){
+				this.htitle = '配网结果';
+				this.title = '配网成功';
+			}
 		},
 		methods:{
 			addRole(){

+ 1 - 1
pagesMy/wifiSearch.vue

@@ -128,7 +128,7 @@
 							})
 							wx.navigateTo({
 								url: '/pagesMy/wifiSet?deviceId=' + options.data.deviceId + '&name=' + options
-									.data.name,
+									.data.name
 							});
 						} else {
 							wx.hideLoading()

+ 10 - 1
pagesMy/wifiSet.vue

@@ -122,8 +122,17 @@
 						else {
 							if (options.data.progress == 100) {
 								uni.setStorageSync(that.wifiSSID,that.wifiPWD)
+								// uni.navigateTo({
+								// 	url:'/pagesMy/wifiSuccess'
+								// })
+								
+								let result = { 
+									"macAddress": this.connectedDeviceId||'', 
+									"board": this.name||"cx-mxb-wifi", 
+									"appVersion": "1.8.2" ,
+								};
 								uni.navigateTo({
-									url:'/pagesMy/wifiSuccess'
+									url:'/pagesMy/scanResult?scanParams='+JSON.stringify(result)+'&type=lanya'
 								})
 							}
 						}