<template>
	<view class="page">
		<u-navbar title="车辆详情 " :border-bottom="false" :background="background" title-color='#000' title-size='36'
			height='45' back-icon-color='#000'></u-navbar>
		<view class="info_li" style="display: flex;justify-content: center;">
			<image src="https://lxnapi.ccttiot.com/bike/img/static/uErfy6HXzkp9Dq0gYpLy" mode=""></image>
			<view class="infos">
				<view class="txt1">
					{{deviceInfos.model}}
				</view>
				<view class="txt2">
					车辆编号：{{deviceInfos.sn}}
				</view>
				<view class="types">
					<view class="type" v-for="(item,index) in deviceInfos.accessorys" :key="index">
						{{item.name}}
					</view>
				</view>
			</view>
		</view>
		<view class="info_li">
			<view class="txt3">
				车辆状态
			</view>
			<view class="types1">
				<view class="type1">
					{{status(deviceInfos)}}
				</view>
				<!-- <view class="type2">
					租赁中
				</view> -->

			</view>
			<view class="btn" @click="btn(3)">
				下架
			</view>
		</view>
		<view class="info_li">
			<view class="txt3">
				车牌号
			</view>
			<view class="txt4">
			{{deviceInfos.vehicleNum}}
			</view>
			<view class="btn" @click="showvehicle=true">
				编辑车牌号
			</view>
		</view>
		<view class="info_li" v-if="false">
			<view class="txt3">
				配件
			</view>
			<view class="types1">
				<view class="type">
					含电池
				</view>
				<view class="type">
					含充电器
				</view>
				<view class="type">
					含头盔
				</view>
			</view>
			<view class="btn">
				选择配件
			</view>
		</view>
		<view class="info_li">
			<view class="txt3">
				电量
			</view>
			<view class="txt4">
				当前电量{{deviceInfos.remainingPower}}%
			</view>

		</view>
		<view class="info_li">
			<view class="txt3">
				行驶距离
			</view>
			<view class="txt4">
				当前状态可行驶{{deviceInfos.remainingMileage}}km
			</view>

		</view>
		<view class="info_li" style="display: flex; align-items: flex-start;">
			<view class="txt3" style="white-space: nowrap;">
				所属门店
			</view>
			<view class="txt4" style=" flex-wrap: wrap;">
				{{deviceInfos.storeName}}- {{deviceInfos.storeLocation}}
			</view>
		</view>
		<view class="info_li" style="display: flex; align-items: flex-start;">
			<view class="txt3" style="white-space: nowrap;">
				车辆位置
			</view>
			<view class="txt4" style=" flex-wrap: wrap;" @click="mapFuns()">
				点击查看 <image src="https://lxnapi.ccttiot.com/bike/img/static/usfoBTRsd4Tnr8x8TnFF" mode="" style="width: 32rpx;height: 32rpx;margin-left: 15rpx;"></image>
			</view>
		</view>
		<view class="btn_li">
			<view class="btn" @click="btn(0)">
				开锁
			</view>
			<view class="btn" @click="btn(1)">
				关锁
			</view>
			<view class="btn" @click="btn(2)">
				响铃
			</view>
		</view>
		<u-mask :show="showvehicle" @click="closevehicle()" :z-index='100' />\
		
		<view class="tip_box" v-if="showvehicle">
			<view class="top" v-if="showvehicle">
				<view class="tip">
					设备信息修改
				</view>
		
				<view class="ipt_box">
					<view class="text">
						
						
						
						车牌号
					</view>
					<view class="ipt">
						<input type="text" v-model="vehicleNum" placeholder=" " class="input"
							placeholder-style="color:#C7CDD3">
		
					</view>
				</view>
		
			</view>
			<view class="bots">
				<view class="bot_left" @click="closevehicle()">
					取消
				</view>
				<view class="bot_right" @click="putvehicle()">
					确定
				</view>
			</view>
		</view>
		<u-mask :show="showpart" @click="closevehicle()" :z-index='100' />
		<view class="choose_part" v-if="showpart">
			<view class="tit">
				选择配件
			
			</view>
			<view class="part_box">
				<view class="part">
					充电器
				</view>
				<view class="part act">
					充电器
					<image src="https://lxnapi.ccttiot.com/bike/img/static/uJNlGEGmN0F4AuPJmOZn" mode=""></image>
				</view>
			</view>
			<view class="btn">
				确定
			</view>
		</view>
	</view>
</template>


<script>
	
	const app = getApp();
	var xBlufi = require("@/utils/blufi/xBlufi.js");
	let _this = null;
	export default {
		data() {
			return {
				devicesList: [
					// {name:'110000',
					// mac:'11111'}
				],
				searching: false,
				texts: '正在扫描蓝牙设备...',
				btnflag: true,
				tishiflag: false,
				option: '',
				bluthlist: [], //蓝牙数组
				// status: 'loading',
				statusflag: false,
				Bluetoothmac: '',
				mac: '',
				ishave: false,
				ver_data: null,
				deviceInfoss: {},
				gps: {},
				isband: false,
				// status: false,
				deviceIds: '',
				name: '',
				
				dl: 0,
				czmoney: true,
				iscz: true,


			
				
				show: true,
				showgj: true,
				searchKeyword: '11',
				latitude: 39.916527,
				longitude: 116.397128,
				isMap: false,
				zoomSize: 15,
				markers: [],
				polyline: [],
				polygons: [],
				cardId: '001区域',
				sn: '',
				deviceInfos: {},
				carstause: false,

				maskloading: false,
				toploadtxt: "开锁中0%",
				loadimg: 'https://lxnapi.ccttiot.com/bike/img/static/urJQJnOI1DEjWatFqHYh',
				tiptxt: '请定点停放，规范用车',
				maskepage: 0,
				backgps: {},
				buletxt: '',

				buleclose: false,
				buleopen: false,
				bulering: false,
				bulerebort: false,
				
				orderinfo:{},
				storeInfo:{},
				
				
				bgc: {
					backgroundColor: "#F7FAFE",
				},
				showvehicle:false,
				showpart:false,
				pickertime:'',
				vehicleNum:''
				

			}
		},
		onLoad(e) {
			this.sn = e.sn
			this.deviceInfo()
			// this.getorderInfo()

		},
		onUnload: function() {
			xBlufi.listenDeviceMsgEvent(false, this.funListenDeviceMsgEvent);
			xBlufi.notifyStartDiscoverBle({
				'isStart': false
			});
		},
		onHide() {
			xBlufi.listenDeviceMsgEvent(false, this.funListenDeviceMsgEvent);
			xBlufi.notifyStartDiscoverBle({
				'isStart': false
			});
		},
		onBeforeUnmount() {
			xBlufi.listenDeviceMsgEvent(false, this.funListenDeviceMsgEvent);
			xBlufi.notifyStartDiscoverBle({
				'isStart': false
			});
		},
		watch: {



		},
		methods: {
			mapFuns(item){
				console.log('点击了');
				uni.openLocation({
					latitude: Number(this.deviceInfos.latitude), // 确保纬度为数字类型
					longitude: Number(this.deviceInfos.longitude), // 确保经度为数字类型
					address: '车辆定位'
				});
			},
			putvehicle(){
				
				this.$u.put('/appVerify/device/edit?sn=' + this.sn+'&vehicleNum='+this.vehicleNum).then((res) => {
					console.log(res, 'rererer');
					if (res.code === 200) {
						// console.log(this.areaId,);
						this.showvehicle=false
						this.deviceInfo()
					} else {
						uni.showToast({
							title: res.msg,
							icon: 'none',
							duration: 2000
						});
					}
				})
			},
			closevehicle(){
				this.showvehicle=false
			},
			status(item) {
				if (item.status == 0) {
					return '未上架'
				} else if (item.status == 1) {
					return '待租'
				} else if (item.status == 2) {
					return '预约中'
				} else if (item.status == 3) {
					return '使用中'
				} else if (item.status == 4) {
					return '临时锁车中'
				} else if (item.status == 6) {
					return '调度中'
				} else if (item.status == 7) {
					return '未绑定'
				} else if (item.status == 8) {
					return '禁用中'
				}
			},
			deviceInfo(){
				this.$u.get('app/getDeviceBySn?sn=' + this.sn).then((res) => {
					console.log(res, 'rererer');
					if (res.code === 200) {
						// console.log(this.areaId,);
						this.deviceInfos = res.data
						this.vehicleNum=res.data.vehicleNum
					} else {
						uni.showToast({
							title: res.msg,
							icon: 'none',
							duration: 2000
						});
					}
				})
				
			},
			bulebtn(num) {
				if (num == 1) {
					if (this.carstause) {
						this.ring()
					} else {
						this.bulering = true
						this.Binddevice()
					}
				} else if (num == 2) {
					if (this.carstause) {
						this.open()
					} else {
						this.buleopen = true
						this.Binddevice()
					}
				} else if (num == 3) {
					if (this.carstause) {
						this.close()
					} else {
						this.buleclose = true
						this.Binddevice()
					}
				} else if (num == 4) {
					if (this.carstause) {
						this.reboot()
					} else {
						this.bulerebort = true
						this.Binddevice()
					}
				}
			},
			btn(num) {
				// this.showbtntip = false
				if (num == 0) {
					uni.showLoading({
						title: '加载中...'
					})
					console.log('点击了....1');
					this.$u.post('/appVerify/device/unlock?sn=' + this.sn).then((res) => {

						if (res.code == 200) {
							// 处理接口返回的数据，将边界数据转换为地图组件需要的折线结构
							this.deviceInfo()
							uni.showToast({
								title: '操作成功',
								icon: 'none',
								duration: 2000
							});
						} else {
							uni.hideLoading()
							this.bulebtn(2)
						}
					}).catch(error => {
						console.error("Error fetching area data:", error);
					});
				} else if (num == 1) {
					uni.showLoading({
						title: '加载中...'
					})
					console.log('点击了....2');
					this.$u.post('/appVerify/device/lock?sn=' + this.sn).then((res) => {
						if (res.code == 200) {
							// 处理接口返回的数据，将边界数据转换为地图组件需要的折线结构
							this.deviceInfo()
							uni.showToast({
								title: '操作成功',
								icon: 'none',
								duration: 2000
							});
						} else {
							uni.hideLoading()
							this.bulebtn(3)
						}
					}).catch(error => {
						console.error("Error fetching area data:", error);
					});
				} else if (num == 2) {
					uni.showLoading({
						title: '加载中...'
					})
					this.$u.post('/app/device/ring?sn=' + this.sn).then((res) => {
						if (res.code == 200) {
							uni.hideLoading()
							uni.showToast({
								title: '操作成功',
								icon: 'none',
								duration: 2000
							});
						} else {
							uni.hideLoading()
							uni.showToast({
								title: res.msg,
								icon: 'none',
								duration: 2000
							});
							this.bulebtn(1)
						}
					})
				} else if (num == 3) {
					uni.showLoading({
						title: '加载中...'
					})
					this.$u.post('/appAdmin/device/offline?sn=' + this.sn).then((res) => {
						if (res.code == 200) {
							this.deviceInfo()
							uni.showToast({
								title: '操作成功',
								icon: 'none',
								duration: 2000
							});
						} else {
							// uni.hideLoading()
							// this.bulebtn(4)
						}
					})
				} else if (num == 4) {
					

				} else if (num == 5) {
					
				} else if (num == 6) {
					

				} else if (num == 7) {

					
				} else if (num == 8) {
					uni.showLoading({
						title: '加载中...'
					})
					this.$u.post('/appVerify/device/reboot?sn=' + this.sn).then((res) => {
						if (res.code == 200) {
							this.deviceInfo()
							uni.showToast({
								title: '操作成功',
								icon: 'none',
								duration: 2000
							});
						} else {
							// uni.hideLoading()
							// this.bulebtn(4)
						}
					})


				} else if (num == 9) {
					uni.showLoading({
						title: '加载中...'
					})
					this.$u.post('/appVerify/device/seatCushionLock?sn=' + this.sn).then((res) => {
						if (res.code == 200) {
							this.deviceInfo()
							uni.showToast({
								title: '操作成功',
								icon: 'none',
								duration: 2000
							});
						} else {
							uni.showToast({
								title: res.msg,
								icon: 'none',
								duration: 2000
							});
						}
					})
				} else if (num == 10) {
					uni.showLoading({
						title: '加载中...'
					})
					this.$u.post('/appVerify/refreshDevice?sn=' + this.sn).then((res) => {
						if (res.code == 200) {
							this.deviceInfo()
							uni.showToast({
								title: '操作成功',
								icon: 'none',
								duration: 2000
							});
						} else {
							uni.showToast({
								title: res.msg,
								icon: 'none',
								duration: 2000
							});
						}
					})
				}
			},
			Binddevice() {
				uni.getBluetoothAdapterState({
					success: function(res) {
						console.log('蓝牙状态：', res.available)
					},
					fail: function(res) {
						console.log('获取蓝牙状态失败')
					}
				})
				this.maskloading = true
				this.devicesList = []
				this.maskepage = 4
				this.buletxt = '蓝牙连接中'
				// uni.showLoading({
				// 	title: '蓝牙扫描中..'
				// })
				xBlufi.initXBlufi(1);
				console.log("xBlufi", xBlufi.XMQTT_SYSTEM);
				xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvent);
				xBlufi.notifyStartDiscoverBle({
					'isStart': true
				});


				// 两秒后停止蓝牙搜索
				setTimeout(() => {
					xBlufi.notifyStartDiscoverBle({
						'isStart': false
					});
					setTimeout(() => {
						// uni.hideLoading()
						if (this.devicesList.length == 0) {
							// uni.showToast({
							// 	title: '暂无发现对应设备,请靠近设备',
							// 	icon: 'none',
							// 	duration: 1500
							// });
							this.maskepage = 5
						} else {
							let uniqueDevicesList = Array.from(new Set(this.devicesList));

							// 将去重后的数组重新赋值给 this.devicesList
							this.devicesList = uniqueDevicesList;
							console.log(this.devicesList, 'this.devicesListthis.devicesList');
							let istrue = false
							this.devicesList.forEach(device => {
								// 从设备名称中提取 MAC 地址（假设 MAC 地址是设备名称的后6个字符）
								let macFromName = device.name.substring(device.name.length - 12);
								console.log(macFromName, 'macFromNamemacFromName');
								// 与 this.mac 进行比较
								if (macFromName == this.mac) {
									// 如果相同，则将 this.ishave 设置为 true
									console.log(device);
									this.deviceInfoss = device
									// this.ishave = true;
									istrue = true
									this.createBLEConnection(device)

									console.log('对比正确1111111111');
								} else {
									console.log('对比错误');

								}
							});
							setTimeout(() => {
								if (!istrue) {
									this.buletxt = '蓝牙连接失败'


									setTimeout(() => {
										this.maskepage = 5
									}, 500)
								}

							}, 500)
						}


					}, 200)
					// 判断是否存在浇花器设备

					// this.status = true
				}, 5000)

			},

			reboot() {
				let vm = this; // 将外部的 this 绑定到 vm 上
				uni.getNetworkType({
					success(res) {
						if (res.networkType !== 'none') {
							uni.getConnectedBluetoothDevices({
								success(res) {
									console.log('已连接的蓝牙设备信息：', res);
									// vm.dl = (vm.orderinfo.deviceAmount / vm.orderinfo.unitPrice).toFixed(2); // 使用 vm 访问 Vue 实例的属性
									xBlufi.notifySendCustomData({
										customData: "11reboot"
									});
									vm.maskloading = false
									// uni.hideLoading()
									// vm.remakr()
								},
								fail(err) {
									uni.hideLoading()
									console.error('获取已连接蓝牙设备信息失败：', err);
								}
							});
						} else {
							console.log('手机未连接网络');
						}
					}
				});
			},
			open() {
				let vm = this; // 将外部的 this 绑定到 vm 上
				uni.getNetworkType({
					success(res) {
						if (res.networkType !== 'none') {
							uni.getConnectedBluetoothDevices({
								success(res) {
									console.log('已连接的蓝牙设备信息：', res);
									// vm.dl = (vm.orderinfo.deviceAmount / vm.orderinfo.unitPrice).toFixed(2); // 使用 vm 访问 Vue 实例的属性
									xBlufi.notifySendCustomData({
										customData: "11open"
									});
									vm.maskloading = false
									vm.deviceInfo()
									// uni.hideLoading()
									// vm.remakr()
								},
								fail(err) {
									uni.hideLoading()
									console.error('获取已连接蓝牙设备信息失败：', err);
								}
							});
						} else {
							console.log('手机未连接网络');
						}
					}
				});
			},
			close() {
				let vm = this; // 将外部的 this 绑定到 vm 上
				uni.getNetworkType({
					success(res) {
						if (res.networkType !== 'none') {
							uni.getConnectedBluetoothDevices({
								success(res) {
									console.log('已连接的蓝牙设备信息：', res);
									// vm.dl = (vm.orderinfo.deviceAmount / vm.orderinfo.unitPrice).toFixed(2); // 使用 vm 访问 Vue 实例的属性
									xBlufi.notifySendCustomData({
										customData: "11close"
									});
									vm.maskloading = false
									vm.deviceInfo()
									// uni.hideLoading()
									// vm.remakr()
								},
								fail(err) {
									uni.hideLoading()
									console.error('获取已连接蓝牙设备信息失败：', err);
								}
							});
						} else {
							console.log('手机未连接网络');
						}
					}
				});
			},
		
		
			ring() {
				let vm = this; // 将外部的 this 绑定到 vm 上
				uni.getNetworkType({
					success(res) {
						if (res.networkType !== 'none') {
							uni.getConnectedBluetoothDevices({
								success(res) {
									console.log('已连接的蓝牙设备信息：', res);
									// vm.dl = (vm.orderinfo.deviceAmount / vm.orderinfo.unitPrice).toFixed(2); // 使用 vm 访问 Vue 实例的属性
									xBlufi.notifySendCustomData({
										customData: "11play1@"
									});
									vm.maskloading = false
									vm.deviceInfo()
									// uni.hideLoading()
									// vm.remakr()
								},
								fail(err) {
									uni.hideLoading()
									console.error('获取已连接蓝牙设备信息失败：', err);
								}
							});
						} else {
							console.log('手机未连接网络');
						}
					}
				});
			},
			
			
			funListenDeviceMsgEvent: function(options) {
				switch (options.type) {
					case xBlufi.XBLUFI_TYPE.TYPE_GET_DEVICE_LISTS:
						if (options.result) {
							let devicesarr = options.data
							// this.devicesList = options.data

							devicesarr.forEach(device => {


								// this.$u.get(`/app/device/${mac}/isBind`, data).then((res) => {
								// if (res.data == false) {
								this.devicesList.push(device);

								let uniqueDevicesList = Array.from(new Set(this.devicesList));

								// 将去重后的数组重新赋值给 this.devicesList
								this.devicesList = uniqueDevicesList;

							});
						}
						break;

					case xBlufi.XBLUFI_TYPE.TYPE_CONNECTED:
						console.log("连接回调：" + JSON.stringify(options));
						if (options.result) {
							// uni.hideLoading();


							xBlufi.notifyInitBleEsp32({
								deviceId: options.data.deviceId
							});

							// xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvents);

							// this.deviceIds = options.data.deviceId
							// this.name = options.data.name
							// 连接成功绑定设备
							// let params = {
							// 	mac: this.Bluetoothmac,
							// 	userId: this.$store.state.user.userId
							// }
							let systemInfo = uni.getSystemInfoSync();
							if (systemInfo.platform === 'android') {
								// 当前设备是 Android  

							} else if (systemInfo.platform === 'ios') {
								// 当前设备是 iOS  
								// uni.navigateTo({
								// 	url: '/pages/wifilist/index?deviceId=' + options
								// 		.data.deviceId + '&name=' + options.data.name
								// })
							}
						}
						if (options.result == false) {
							// this.loadingmask=false
							this.carstause = false
							if (this.maskepage == 4) {
								this.buletxt = '设备连接失败'


								setTimeout(() => {
									this.maskepage = 5
								}, 800)
							}

							// uni.showModal({
							// 	title: '很抱歉提醒你！',
							// 	content: '小程序与设备异常断开',
							// 	showCancel: false,
							// 	success: function(res) {
							// 		// uni.navigateBack({
							// 		// 	url: '../search/search'
							// 		// });
							// 	}
							// });
							// this.statusflag = false
							// uni.hideLoading();
						}
						break;
					case xBlufi.XBLUFI_TYPE.TYPE_RECIEVE_CUSTON_DATA:

						// this.ver_data = this.parseCustomData(options.data)
						if (options.data) {
							this.carstause = true


							if (this.maskloading && this.maskepage == 4) {
								// setTimeout(() => {
								// 	this.maskloading = false
								// }, 700)
								if (this.buleclose == false && this.buleopen == false && this.bulerebort == false &&
									this
									.bulering == false) {
									if (this.buletxt == '蓝牙连接中') {
										this.buletxt = '蓝牙连接成功！'
									}

								}
								if (this.buleclose) {
									this.buleclose = false
									this.close()
								}
								if (this.buleopen) {
									this.buleopen = false
									this.open()
								}
								if (this.bulerebort) {
									this.buleopen = false
									this.reboot()
								}
								if (this.bulering) {
									this.bulering = false
									this.ring()
								}


							}






						} else {
							this.carstause = false
							if (this.maskepage == 4) {
								this.buletxt = '设备连接失败'


								setTimeout(() => {
									this.maskepage = 5
								}, 800)
							}
						}
						console.log("1收到设备发来的自定义数据结果：", options.data);
						break;
					case xBlufi.XBLUFI_TYPE.TYPE_STATUS_CONNECTED: {
						console.log('状态', options.result)
						if (options.result == false) {
							this.carstause = false
							if (this.maskepage == 4) {
								this.buletxt = '设备连接失败'


								setTimeout(() => {
									this.maskepage = 5
								}, 800)
							}
							// uni.showToast({
							// 	title: '设备断开链接，请重新点击蓝牙链接',
							// 	icon: 'none'
							// });
							// uni.showModal({
							// 	title: '很抱歉提醒你！',
							// 	content: '小程序与设备异常断开',
							// 	showCancel: false,
							// 	success: function(res) {
							// 		// uni.navigateBack({
							// 		// 	url: '../search/search'
							// 		// });
							// 	}
							// });
							// this.statusflag = false
							// uni.hideLoading();
						}
					}
					break;
					case xBlufi.XBLUFI_TYPE.TYPE_GET_DEVICE_LISTS_STOP:
						if (options.result) {
							let uniqueDevicesList = Array.from(new Set(this.devicesList));

							// 过滤出名称字段的前五个字母为 "CTPOW" 的项
							let filteredDevices = uniqueDevicesList.filter(device => device.name.substring(0,
									4) ===
								"BBLE");

							// 将过滤后的数组重新赋值给 this.devicesList
							this.devicesList = filteredDevices;

							// console.log('蓝牙停止搜索ok',this.devicesList);
						} else {
							//蓝牙停止搜索失败
							// console.log('蓝牙停止搜索失败');
						}
						this.searching = false
						// _this.setData({
						// 	searching: false
						// });

						break;
				}
			},



			//4、建立连接
			createBLEConnection(e) {
				console.log('调用了');
				xBlufi.notifyStartDiscoverBle({
					'isStart': false
				});
				console.log(e, '蓝牙信息')
				const deviceId = e.deviceId
				this.Bluetoothmac = e.localName.substring(5) //从第七位开始截取 只取后面的mac号
				console.log(this.Bluetoothmac, '11111');
				let name = e.name;
				console.log('点击了，蓝牙准备连接的deviceId:' + e.deviceId);
				xBlufi.notifyConnectBle({
					isStart: true,
					deviceId: e.deviceId,
					name
				});
				// for (var i = 0; i < this.devicesList.length; i++) {
				// 	if (e.deviceId === this.devicesList[i].deviceId) {

				// 		uni.showLoading({
				// 			title: '连接蓝牙设备中...'
				// 		});
				// 	}
				// }
			},

			funListenDeviceMsgEvents: function(options) {
				let that = this;
				switch (options.type) {
					case xBlufi.XBLUFI_TYPE.TYPE_STATUS_CONNECTED: {
						console.log('状态', options.result)
						if (options.result == false) {
							this.carstause = false
							uni.showToast({
								title: '设备断开链接，请重新点击蓝牙链接',
								icon: 'none'
							});
							// uni.showModal({
							// 	title: '很抱歉提醒你！',
							// 	content: '小程序与设备异常断开',
							// 	showCancel: false,
							// 	success: function(res) {
							// 		// uni.navigateBack({
							// 		// 	url: '../search/search'
							// 		// });
							// 	}
							// });
							// this.statusflag = false
							uni.hideLoading();
						}
					}
					break;

					case xBlufi.XBLUFI_TYPE.TYPE_RECIEVE_MY_DATA:
						this.loadPercent = options.data;
						this.loadText = '文件读取中'
						console.log("文件读取中", options.data);
						break;
					case xBlufi.XBLUFI_TYPE.TYPE_RECIEVE_CUSTON_DATA:
						// this.isband = true
						// this.ver_data = this.parseCustomData(options.data)
						console.log("1收到设备发来的自定义数据结果：", options.data);
						if (options.data) {
							this.carstause = true
						}
						break;

					case xBlufi.XBLUFI_TYPE.TYPE_INIT_ESP32_RESULT:
						uni.hideLoading();
						if (options.result) {
							console.log('初始化成功');
						} else {
							console.log('初始化失败');


						}
						break;
				}
			},	
		}
	}
</script>



<style lang="scss">
	page {
		background-color: #F7F7F7;
	}

	.page {
		width: 750rpx;
		.choose_part{
			position: fixed;
			top: 530rpx;
			left: 54rpx;
			z-index: 110;
			width: 644rpx;
			padding: 40rpx 48rpx;
			background: #FFFFFF;
			border-radius: 26rpx 26rpx 26rpx 26rpx;
			.part_box{
				margin-top: 40rpx;
				display: flex;
				flex-wrap: wrap;
				
				.part{
					position: relative;
					margin-right: 36rpx;
					display: flex;
					align-items: center;
					justify-content: center;
					width: 160rpx;
					height: 60rpx;
					background: #F0F0F0;
					border-radius: 6rpx 6rpx 6rpx 6rpx;
					border: 1rpx solid #F0F0F0;
					font-weight: 500;
					font-size: 32rpx;
					
					color: #3D3D3D;
					image{
						position: absolute;
						right: 0;
						bottom: 0;
						width: 34rpx;
						height: 34rpx;
					}
				}
				.act{
					background: #DCEDFF;
					border: 1rpx solid #4297F3;
					color: #4297F3;
				}
			}
			.tit{
				width: 100%;
				text-align: center;
				font-weight: 600;
				font-size: 36rpx;
				color: #3D3D3D;
			}
				
			.btn{
				margin-top: 60rpx;
				display: flex;
				align-items: center;
				justify-content: center;
				width: 552rpx;
				height: 88rpx;
				background: #4C97E7;
				border-radius: 10rpx 10rpx 10rpx 10rpx;
				font-weight: 600;
				font-size: 36rpx;
				color: #FFFFFF;
			}
		}
		
		
		.tip_box {
			position: fixed;
			left: 72rpx;
			top: 628rpx;
			width: 610rpx;
			// height: 282rpx;
			background: #FFFFFF;
			border-radius: 30rpx 30rpx 30rpx 30rpx;
			z-index: 110;
			padding-bottom: 100rpx;
			.saveQr{
				margin: 0 auto;
				margin-top: 30rpx;
				display: flex;
				align-items: center;
				justify-content: center;
				width: 502rpx;
				height: 68rpx;
				background: #4C97E7;
				border-radius: 10rpx 10rpx 10rpx 10rpx;
				font-weight: 500;
				font-size: 36rpx;
				color: #FFFFFF;
			}
			.top {
				padding: 52rpx 38rpx 42rpx 36rpx;
		
				.ipt_box {
					margin-top: 22rpx;
					display: flex;
					flex-wrap: nowrap;
					align-items: center;
		
					.text {
						width: 350rpx;
						font-weight: 400;
						font-size: 32rpx;
						color: #3D3D3D;
					}
		
					.ipt {
						padding: 10rpx 18rpx;
						display: flex;
						align-items: center;
						justify-content: space-between;
						margin-left: 26rpx;
						width: 420rpx;
						height: 64rpx;
						border-radius: 0rpx 0rpx 0rpx 0rpx;
						border: 2rpx solid #979797;
		
						.input {
							width: 80%;
						}
					}
				}
		
				.tip {
					width: 100%;
					text-align: center;
					font-weight: 700;
					font-size: 32rpx;
					color: #3D3D3D;
				}
		
				.txt {
					margin-top: 32rpx;
					width: 100%;
					text-align: center;
					font-weight: 500;
					font-size: 32rpx;
					color: #3D3D3D;
				}
			}
		
			.bots {
				position: absolute;
		
				width: 610rpx;
				// border-top: 2rpx solid #D8D8D8;
				display: flex;
				flex-wrap: nowrap;
				// height: 100%;
				bottom: -20rpx;
		
				.bot_left {
					border-radius: 0rpx 0rpx 0rpx 30rpx;
					width: 50%;
					height: 86rpx;
					display: flex;
					align-items: center;
					justify-content: center;
					font-weight: 500;
					font-size: 32rpx;
					color: #3D3D3D;
					background: #EEEEEE;
				}
		
				.bot_right {
					border-radius: 0rpx 0rpx 30rpx 0rpx;
					width: 50%;
					height: 86rpx;
					background: #4C97E7;
					display: flex;
					align-items: center;
					justify-content: center;
					color: #FFFFFF;
					// border-left: 2rpx solid #D8D8D8;
					font-weight: 500;
					font-size: 32rpx;
					// color: #4C97E7;
		
				}
		
			}
		}
		
		
		.btn_li{
			margin-top: 70rpx;
			display: flex;
			flex-wrap: nowrap;
			align-items: center;
			justify-content: space-around;
			.btn{
				display: flex;
				align-items: center;
				justify-content: center;
				width: 186rpx;
				height: 82rpx;
				background: #4297F3;
				border-radius: 14rpx 14rpx 14rpx 14rpx;
				font-weight: 600;
				font-size: 36rpx;
				color: #FFFFFF;
			}
		}
		.info_li {
			width: 750rpx;
			padding: 30rpx 0;
			display: flex;
			flex-wrap: nowrap;
			align-items: center;
			border-bottom: 1rpx solid #D8D8D8;

			.txt4 {
				font-weight: 400;
				font-size: 32rpx;
				color: #3D3D3D;
			}

			.btn {
				margin-left: auto;
				margin-right: 36rpx;
				padding: 4rpx 16rpx;
				border-radius: 6rpx 6rpx 6rpx 6rpx;
				border: 1rpx solid #4297F3;
				font-weight: 400;
				font-size: 32rpx;
				color: #4297F3;
			}

			.txt3 {
				margin-right: 24rpx;
				margin-left: 32rpx;
				width: 126rpx;
				font-weight: 400;
				font-size: 32rpx;
				color: #6F6F6F;
			}

			.types1 {
				display: flex;

				.type {
					padding: 4rpx 12rpx;
					background: #DCEDFF;
					border-radius: 6rpx 6rpx 6rpx 6rpx;
					font-weight: 400;
					font-size: 24rpx;
					color: #4297F3;
					margin-right: 12rpx;
				}

				.type1 {
					padding: 4rpx 12rpx;
					background: #E8FFE5;
					border-radius: 6rpx 6rpx 6rpx 6rpx;
					font-weight: 400;
					font-size: 24rpx;
					color: #16BC32;
					margin-right: 34rpx;
				}

				.type2 {
					padding: 4rpx 12rpx;
					background: #FFDBDB;
					border-radius: 6rpx 6rpx 6rpx 6rpx;
					font-weight: 400;
					font-size: 24rpx;
					color: #FF1C1C;
				}


			}

			image {
				width: 222rpx;
				height: 170rpx;
			}

			.infos {

				margin-left: 36rpx;

				.tex1 {
					font-weight: 600;
					font-size: 32rpx;
					color: #3D3D3D;
				}

				.txt2 {
					margin-top: 6rpx;
					font-weight: 400;
					font-size: 28rpx;
					color: #3D3D3D;
				}

				.types {
					display: flex;
					margin-top: 24rpx;

					.type {
						margin-right: 8rpx;
						padding: 4rpx 12rpx;
						background: #DCEDFF;
						border-radius: 6rpx 6rpx 6rpx 6rpx;
						font-weight: 400;
						font-size: 24rpx;
						color: #4297F3;
					}
				}
			}
		}

	}
</style>