Ver código fonte

优化设备

yuhao 1 ano atrás
pai
commit
db7a2bccca
1 arquivos alterados com 79 adições e 93 exclusões
  1. 79 93
      pages/edit/edit.vue

+ 79 - 93
pages/edit/edit.vue

@@ -9,53 +9,54 @@
9 9
 			<view class="facilityType">
10 10
 				<p>设备类型</p>
11 11
 				<view class="buttonOP" v-if="typeList">
12
-						<view class="item" @click="selectOne('type_sn',index,item)" :class="{selectType:index==selectTypeIndex}" v-for="(item,index) in typeList" :key="index">
13
-							<img :src="item.cover_url" alt="">
14
-							<span>{{item.name}}</span>
15
-						</view>
12
+					<view class="item" @click="selectOne('type_sn',index,item)"
13
+						:class="{selectType:index==selectTypeIndex}" v-for="(item,index) in typeList" :key="index">
14
+						<img :src="item.cover_url" alt="">
15
+						<span>{{item.name}}</span>
16
+					</view>
16 17
 				</view>
17 18
 			</view>
18 19
 			<view class="facilityType">
19 20
 				<p>探头</p>
20 21
 				<view class="buttonOP" v-if="typeList!=''">
21
-						<view class="item" @click="selectOne('detectors',index,item)" :class="{selectType:index==selectDetectorsIndexA}" v-for="(item,index) in typeList[selectTypeIndex].detectors"
22
-						:key="index">
23
-							<img :src="item.cover_url" alt="">
24
-							<span>{{item.detector_name}}</span>
25
-						</view>
22
+					<view class="item" @click="selectOne('detectors',index,item)"
23
+						:class="{selectType:index==selectDetectorsIndexA}"
24
+						v-for="(item,index) in typeList[selectTypeIndex].detectors" :key="index">
25
+						<img :src="item.cover_url" alt="">
26
+						<span>{{item.detector_name}}</span>
27
+					</view>
26 28
 				</view>
27 29
 			</view>
28 30
 			<!-- mode中的模式 -->
29 31
 			<view class="pattern">
30
-			<view class="facilityType"
31
-				v-if="typeList!=''&&typeList[selectTypeIndex].detectors[selectDetectorsIndex].config.mode&&typeList[selectTypeIndex].detectors[selectDetectorsIndex].config.mode.list">
32
-				<p>模式</p>
33
-				<view class="buttonOP">
34
-					<button @click="selectOne('mode',index,item)" :class="{selectType:index==selectModeIndexA}"
35
-						v-for="(item,index) in typeList[selectTypeIndex].detectors[selectDetectorsIndex].config.mode.list">{{item.name}}</button>
32
+				<view class="facilityType"
33
+					v-if="typeList!=''&&typeList[selectTypeIndex].detectors[selectDetectorsIndex].config.mode&&typeList[selectTypeIndex].detectors[selectDetectorsIndex].config.mode.list">
34
+					<p>模式</p>
35
+					<view class="buttonOP">
36
+						<button @click="selectOne('mode',index,item)" :class="{selectType:index==selectModeIndexA}"
37
+							v-for="(item,index) in typeList[selectTypeIndex].detectors[selectDetectorsIndex].config.mode.list">{{item.name}}</button>
38
+					</view>
36 39
 				</view>
37
-			</view>
38
-			<!-- power中的模式 -->
39
-			<view class="facilityType"
40
-				v-else-if="typeList!=''&&typeList[selectTypeIndex].detectors[selectDetectorsIndex].config.power.list">
41
-				<p>模式</p>
42
-				<view class="buttonOP">
43
-					<button @click="selectOne('mode',index,item)" :class="{selectType:index==selectModeIndexA}"
44
-						v-for="(item,index) in typeList[selectTypeIndex].detectors[selectDetectorsIndex].config.power.list">{{item.name}}</button>
45
-					<button style="margin-left: 100px; background-color: #374b5f;" @click="pqCLick">点击排气</button>
40
+				<!-- power中的模式 -->
41
+				<view class="facilityType"
42
+					v-else-if="typeList!=''&&typeList[selectTypeIndex].detectors[selectDetectorsIndex].config.power.list">
43
+					<p>模式</p>
44
+					<view class="buttonOP">
45
+						<button @click="selectOne('mode',index,item)" :class="{selectType:index==selectModeIndexA}"
46
+							v-for="(item,index) in typeList[selectTypeIndex].detectors[selectDetectorsIndex].config.power.list">{{item.name}}</button>
47
+						<button style="margin-left: 100px; background-color: #374b5f;" @click="pqCLick">点击排气</button>
48
+					</view>
46 49
 				</view>
47
-			</view>
48
-			<view class="facilityType" v-else>
49
-				<p>强度</p>
50
-				<view class="buttonOPO">
51
-					<button @click="reduce">减少</button>
52
-					<view class="strength">
53
-						{{modeClass}}
54
-					</view><button @click="add">增加</button>
50
+				<view class="facilityType" v-else>
51
+					<p>强度</p>
52
+					<view class="buttonOPO">
53
+						<button @click="reduce">减少</button>
54
+						<view class="strength">
55
+							{{modeClass}}
56
+						</view><button @click="add">增加</button>
57
+					</view>
55 58
 				</view>
56 59
 			</view>
57
-			{{CODE}}
58
-			</view>
59 60
 		</view>
60 61
 		<view class="bottomBox">
61 62
 			<view class="back">
@@ -87,7 +88,6 @@
87 88
 				selectModeIndex: 0, //模式index
88 89
 				selectModeIndexA: 99, //模式index
89 90
 				TYPE_SN: 'ZK', //设备名称
90
-				CODE: 'AABB12343838373244363235444138020301010101', //设备码
91 91
 				PQCODE: "AABB12343838373244363235444138010101010101", //开始排气
92 92
 				PQCLOSECODE: "AABB12343838373244363235444138010201010101", //关闭排气
93 93
 				modeClass: 0, //强度等级
@@ -98,10 +98,9 @@
98 98
 				PAUSE: '00', //暂停
99 99
 				equipmentNum: '', //设备编号
100 100
 				modeNum: '01', //模式编号
101
-				CODE: '',
102 101
 				startTime: "", //开始时间
103 102
 				time: '00:00:00', //初始展示时间
104
-				timer: '', 
103
+				timer: '',
105 104
 				istimer: false, //是否暂停
106 105
 				hour: 0, //计时(时)
107 106
 				minutes: 0, //计时(分)
@@ -109,15 +108,15 @@
109 108
 			};
110 109
 		},
111 110
 		onLoad(options) {
112
-			console.log(options, 333333);
111
+			// console.log(options, 333333);
113 112
 			this.deviceId = options.deviceId
114 113
 			this.serviceId = options.serviceId
115 114
 			this.characteristicId = options.characteristicId
116 115
 			let typeList = uni.getStorageSync('typeList')
117
-			if(!typeList){
116
+			if (!typeList) {
118 117
 				// 获取设备列表
119 118
 				this.getTypeList()
120
-			}else{
119
+			} else {
121 120
 				this.typeList = typeList
122 121
 			}
123 122
 		},
@@ -126,19 +125,6 @@
126 125
 			blueError(code) {
127 126
 				switch (code) {
128 127
 					case 10000:
129
-						// uni.openBluetoothAdapter({
130
-						// 	success(res) {
131
-						// 		uni.showToast({
132
-						// 			title: '初始化成功,请重新启动',
133
-						// 			duration: 2500,
134
-						// 			icon: 'none'
135
-						// 		})
136
-						// 	},
137
-						// 	fail(err) {
138
-						// 		uni.hideLoading()
139
-						// 		console.log('初始化蓝牙失败')
140
-						// 	}
141
-						// })
142 128
 						this.errorToast('未初始化蓝牙适配器,请返回重新连接')
143 129
 						break
144 130
 					case 10001:
@@ -199,17 +185,15 @@
199 185
 				const {
200 186
 					data: res
201 187
 				} = await uni.$http.post('v2/api-device/device/type_list')
202
-				console.log(JSON.parse(JSON.stringify(res.data.list)), '获取的数据返回');
188
+				// console.log(JSON.parse(JSON.stringify(res.data.list)), '获取的数据返回');
203 189
 				// 筛选出无创水光
204 190
 				for (let key in res.data.list) {
205
-					if (res.data.list[key].id != 1&&res.data.list[key].id != 15) {
206
-						this.typeList.push(res.data.list[key])   
191
+					if (res.data.list[key].id != 1 && res.data.list[key].id != 15) {
192
+						this.typeList.push(res.data.list[key])
207 193
 					}
208 194
 				}
209
-				// this.typeList = res.data.list
195
+				// 将数据保存到本地
210 196
 				uni.setStorageSync('typeList', this.typeList)
211
-				// console.log(JSON.parse(JSON.stringify(this.typeList[0].detectors[1])), 333333);
212
-				// console.log(JSON.parse(JSON.stringify(this.typeList)), 333333);
213 197
 			},
214 198
 			// ------------------选择设备配置
215 199
 			selectOne(type, index, item) {
@@ -222,7 +206,7 @@
222 206
 						this.selectModeIndexA = 99
223 207
 						this.equipmentNum = '' //重置探头
224 208
 						this.modeNum = '' //重置模式或强度
225
-						console.log(item)
209
+						// console.log(item)
226 210
 						//赋值哪个厂家的设备
227 211
 						if (item.type_sn.includes('ZK')) {
228 212
 							this.TYPE_SN = 'ZK'
@@ -236,24 +220,19 @@
236 220
 						this.selectModeIndexA = 99
237 221
 						this.equipmentNum = Number(item.detector_sn).toString(16) < 10 ? '0' + Number(item.detector_sn)
238 222
 							.toString(16) : Number(item.detector_sn).toString(16) //设备探头编号(16进制)
239
-						console.log(this.equipmentNum)
240
-						console.log(JSON.parse(JSON.stringify(this.typeList[this.selectTypeIndex].detectors[this
241
-							.selectDetectorsIndex])))
242
-						this.minClass = this.typeList[this.selectTypeIndex].detectors[this.selectDetectorsIndex].config
243
-							.power.min //最小值
244
-						this.maxClass = this.typeList[this.selectTypeIndex].detectors[this.selectDetectorsIndex].config
245
-							.power.max //最大值
246
-						this.incrementClass = this.typeList[this.selectTypeIndex].detectors[this.selectDetectorsIndex]
247
-							.config.power.increment //增幅
248
-						this.modeClass = this.typeList[this.selectTypeIndex].detectors[this.selectDetectorsIndex].config
249
-							.power.default //默认值
223
+						// console.log(this.equipmentNum)
224
+						// console.log(item)
225
+						this.minClass = item.config.power.min //最小值
226
+						this.maxClass = item.config.power.max //最大值
227
+						this.incrementClass = item.config.power.increment //增幅
228
+						this.modeClass = item.config.power.default //默认值
250 229
 						break
251 230
 					case 'mode':
252 231
 						this.selectModeIndex = index
253 232
 						this.selectModeIndexA = index
254 233
 						this.modeNum = Number(item.value).toString(16) < 10 ? '0' + Number(item.value).toString(16) :
255 234
 							Number(item.value).toString(16)
256
-						console.log(this.modeNum)
235
+						// console.log(this.modeNum)
257 236
 						break
258 237
 				}
259 238
 			},
@@ -301,13 +280,14 @@
301 280
 			// ----------------------操作设备开启暂停结束
302 281
 			operate(type) {
303 282
 				// 强度编号
304
-				let	modeNum = Number(this.modeClass).toString(16) < 10 ? '0' + Number(this.modeClass).toString(16) :
305
-						Number(this.modeClass).toString(16)
283
+				let modeNum = Number(this.modeClass).toString(16) < 10 ? '0' + Number(this.modeClass).toString(16) :
284
+					Number(this.modeClass).toString(16)
306 285
 				// 设备模式编号
307
-				if (this.typeList[this.selectTypeIndex].detectors[this.selectDetectorsIndex].config.mode?.list||this.typeList[this.selectTypeIndex].detectors[this.selectDetectorsIndex].config.power?.list) {
286
+				if (this.typeList[this.selectTypeIndex].detectors[this.selectDetectorsIndex].config.mode?.list || this
287
+					.typeList[this.selectTypeIndex].detectors[this.selectDetectorsIndex].config.power?.list) {
308 288
 					modeNum = this.modeNum
309 289
 				}
310
-				console.log(modeNum);
290
+				// console.log(modeNum);
311 291
 				// 蓝牙指令操作码
312 292
 				let code =
313 293
 					`AABB12343838373244363235444138${this.equipmentNum}03${type=='open'?this.START:this.PAUSE}${modeNum}0101`
@@ -322,13 +302,14 @@
322 302
 					})
323 303
 					return
324 304
 				}
325
-				if (this.typeList[this.selectTypeIndex].detectors[this.selectDetectorsIndex].config.mode?.list||this.typeList[this.selectTypeIndex].detectors[this.selectDetectorsIndex].config.power?.list) {
326
-					if(this.selectModeIndexA==99){						
327
-					uni.showToast({
328
-						title: '请选择模式',
329
-						icon: "none"
330
-					})
331
-					return
305
+				if (this.typeList[this.selectTypeIndex].detectors[this.selectDetectorsIndex].config.mode?.list || this
306
+					.typeList[this.selectTypeIndex].detectors[this.selectDetectorsIndex].config.power?.list) {
307
+					if (this.selectModeIndexA == 99) {
308
+						uni.showToast({
309
+							title: '请选择模式',
310
+							icon: "none"
311
+						})
312
+						return
332 313
 					}
333 314
 				}
334 315
 				// 操作 开始 暂停 结束
@@ -364,7 +345,6 @@
364 345
 			// -------------------发送数据
365 346
 			send(newMsg, title = '执行成功') {
366 347
 				console.log(newMsg);
367
-				this.CODE = newMsg
368 348
 				wx.showLoading({
369 349
 					title: '正在启动',
370 350
 					mask: true
@@ -380,7 +360,7 @@
380 360
 						index++
381 361
 					}
382 362
 				}
383
-				console.log(that.deviceId, that.serviceId, that.characteristicId);
363
+				// console.log(that.deviceId, that.serviceId, that.characteristicId);
384 364
 				// return
385 365
 				uni.writeBLECharacteristicValue({
386 366
 					deviceId: that.deviceId, // 设备ID
@@ -425,7 +405,7 @@
425 405
 						} else {
426 406
 							that.finishTime()
427 407
 						}
428
-						console.log(res,'发送数据成功')
408
+						console.log(res, '发送数据成功')
429 409
 					},
430 410
 					fail(err) {
431 411
 						uni.hideLoading()
@@ -468,18 +448,22 @@
468 448
 		margin-left: 100px;
469 449
 		margin-top: 40px;
470 450
 		width: 85%;
471
-		.pattern{
451
+
452
+		.pattern {
472 453
 			display: flex;
473 454
 			overflow-x: scroll;
474
-			.facilityType{
455
+
456
+			.facilityType {
475 457
 				margin-right: 80px;
476 458
 			}
477 459
 		}
460
+
478 461
 		.buttonOP {
479 462
 			display: flex;
480
-			.item{
463
+
464
+			.item {
481 465
 				padding-right: 20px;
482
-				padding-left:6px;
466
+				padding-left: 6px;
483 467
 				height: 100px;
484 468
 				background-color: #b8b8b8;
485 469
 				margin-right: 20px;
@@ -488,13 +472,15 @@
488 472
 				display: flex;
489 473
 				justify-content: center;
490 474
 				align-items: center;
491
-				img{
475
+
476
+				img {
492 477
 					width: 90px;
493 478
 					height: 90px;
494 479
 					border-radius: 24px;
495 480
 					margin-right: 20px;
496 481
 				}
497 482
 			}
483
+
498 484
 			button {
499 485
 				flex-shrink: 0;
500 486
 				margin: 0;
@@ -506,7 +492,7 @@
506 492
 			.selectType {
507 493
 				background-color: #1e98d7;
508 494
 			}
509
-			
495
+
510 496
 		}
511 497
 
512 498
 		.buttonOPO {
@@ -575,4 +561,4 @@
575 561
 			}
576 562
 		}
577 563
 	}
578
-</style>
564
+</style>