<template>
	<view class="maincontent contentBg">

		<uni-nav-bar :border="false" @clickLeft="prevPage" fixed="true" statusBar="true" background-color="#121212"
			color="#FFFFFF" :title="Status.navbar.title">
			<template v-slot:left>
				<view>
					<uni-icons type="left" size="24" color="#FFFFFF"></uni-icons>
				</view>
			</template>
			<block slot="right">
				<view class="navbarRight center">
					<image @click.stop="handleRightClick(index,item)" v-for="item,index in Status.navbar.icons"
						class="img" :src="item.src" mode="aspectFit"></image>
				</view>

			</block>
		</uni-nav-bar>

		<view class="eq" :style="{marginTop:Status.navbar.height+'px'}">
			<view class="leftImg" @click.stop="previewImg(device.devicePic?device.devicePic:formData.img)">
				<image class="img" :src="device.devicePic?device.devicePic:formData.img" mode="aspectFit"></image>
			</view>
			<view class="rightTxt">
				<view class="row">
					<image class="img" src="/static/images/common/battry.png" mode="aspectFit"></image>
					<view class="txt">
						<view class="bigTxt">{{formData.sta_PowerPercent}}%</view>
						<view class="smallTxt">电量</view>
					</view>
				</view>
				<view class="row">
					<image class="img" src="/static/images/common/time.png" mode="aspectFit"></image>
					<view class="txt">
						<view class="bigTxt">{{formData.sta_PowerTime}}</view>
						<view class="smallTxt">续航时间</view>
					</view>
				</view>
			</view>
		</view>





		<view class="eqinfo">
			<view class="item">
				<text class="lbl">设备名称</text>
				<text class="value valueFont">{{device.deviceName}}</text>
			</view>
			<view class="item">
				<text class="lbl">设备IMEI</text>
				<text class="value valueFont">{{device.deviceImei}}</text>
			</view>

			<view class="item">
				<text class="lbl">Mac地址</text>
				<text class="value">{{device.deviceMac}}</text>
			</view>
			<view class="item">
				<text class="lbl">蓝牙名称</text>
				<text class="value valueFont">{{device.bluetoothName}}</text>
			</view>
			<view class="item" @click.top="bleStatuToggle">
				<text class="lbl">蓝牙状态</text>
				<text class="value" :class="formData.bleStatu?'green':'red'">{{getbleStatu}}</text>
			</view>
			<view class="item">
				<text class="lbl">设备状态</text>
				<text class="value valueFont">{{sta_system}}</text>
			</view>
			<view class="item">
				<text class="lbl">环境温度</text>
				<text class="value " :class="heatStyle">{{formData.sta_Heat}}</text>
			</view>
			<view class="item">
				<text class="lbl">定位信息</text>
				<view class="multiValue" @click.stop="gotoMap()">
					<view class="valueItem valueFont">
						{{formData.sta_longitude}}

					</view>
					<view class="valueItem valueFont">

						{{formData.sta_latitude}}

					</view>
					<view class="valueItem">

						<view style="width:80%;float: right;text-align: right;" class="valueFont">
							<uni-icons type="location" size="17" color="rgba(255, 255, 255, 0.8)"
								style="vertical-align: bottom;" />
							{{formData.address}}
						</view>
						<view class="clear"></view>
					</view>
				</view>


			</view>
		</view>

		<view class="eqinfo">
			<view class="item">
				<view>
					<text class="lbl">海拔高度</text>
					<view class="value valueFont leftIndent">{{formData.sta_Height}}m</view>
				</view>
				<view>
					<text class="lbl">相对高度</text>
					<view class="value valueFont leftIndent">{{formData.sta_releaHeight}}m</view>
				</view>
			</view>
		</view>
		<view class="warnnig" :class="formData.sta_ShakeBit!=0  ?'':'displayNone'">
			<view>{{formData.sta_ShakeBit==3?'设备疑似受到外力碰撞':'设备声光报警中'}}！</view>
			<view @click.stop="SOSToggle()">
				<uni-icons type="closeempty" color="#FFFFFFde" size="16"></uni-icons>
			</view>


		</view>

		<view class="lamp">
			<view class="title">
				<text>灯光亮度</text>
				<text>{{formData.sta_brightness}}%</text>
			</view>

			<view class="slider-container">
				<slider min="10" max="100" step="10" :disabled="false" :value="formData.sta_brightness"
					activeColor="#bbe600" backgroundColor="#00000000" block-size="20" block-color="#ffffffde"
					@change="sliderChange" @changing="sliderChanging" class="custom-slider" />

			</view>
		</view>
		<view class="lampMode">
			<view class="mode " v-on:click.stop="showAction('main')">
				<view class="leftImg">
					<image class="img" src="/static/images/6155/DeviceDetail/mainLamp.png" mode="aspectFit"></image>
				</view>
				<view class="rightTxt">
					<text class="bigTxt">主灯模式</text>
					<text class="smallTxt">{{MainLight}}</text>
				</view>
			</view>
			<view class="mode  " v-on:click.stop="showAction('fu')">
				<view class="leftImg">
					<image class="img" src="/static/images/6155/DeviceDetail/fuLamp.png" mode="aspectFit"></image>
				</view>
				<view class="rightTxt">
					<text class="bigTxt">辅灯模式</text>
					<text class="smallTxt">{{FuLight}}</text>
				</view>
			</view>
			<view class="mode  " :class="{active:formData.sta_laser==1}" v-on:click.stop="laserToggle">
				<view class="leftImg">

					<image class="img" src="/static/images/common/jig.png" v-show="formData.sta_laser!=1"
						mode="aspectFit"></image>
					<image class="img" src="/static/images/common/jigA.png" v-show="formData.sta_laser==1"
						mode="aspectFit"></image>
				</view>
				<view class="rightTxt">
					<text class="bigTxt">激光模式</text>
				</view>
			</view>
			<view class="mode  " :class="{active:formData.sta_ShakeBit!=0}" v-on:click.stop="SOSToggle">
				<view class="leftImg">
					<image class="img" src="/static/images/common/sg.png" v-show="formData.sta_ShakeBit==0"
						mode="aspectFit"></image>
					<image class="img" src="/static/images/common/sgActive.png" v-show="formData.sta_ShakeBit!=0"
						mode="aspectFit"></image>
				</view>
				<view class="rightTxt">
					<text class="bigTxt">声光报警</text>

				</view>
			</view>
			<view class="mode  " v-on:click.stop="showUploadMedia">
				<view class="leftImg">
					<image class="img" src="/static/images/6155/DeviceDetail/open.png" mode="aspectFit"></image>
				</view>
				<view class="rightTxt">
					<text class="bigTxt">开机画面</text>
					<text class="smallTxt">上传</text>
				</view>
			</view>


		</view>

		<view class="usrinfo">
			<view @click="Status.usrToggle=!Status.usrToggle">
				<text class="usrtitle fleft">人员信息登记</text>
				<view class="image fright" :style="{transform:Status.usrToggle?'rotate(0deg)':'rotate(180deg)' }">

					<image class="img" src="/static/images/6155/DeviceDetail/slideToggle.png" mode="aspectFit"></image>

				</view>

				<view class="clear"></view>
			</view>
			<view :class="Status.usrToggle?'':'displayNone'">
				<view style="margin: 20rpx 0rpx;">

					<view class="btnSend fright" v-on:click.stop="sendUsr(null)">发送</view>

					<TextToHexV1 class="TextToHex" ref="textToHex" :txts="formData.textLines" :bgColor="'#FFFFFF'"
						:color="'#000000'" :fontSize="16" />

					<view class="clear"></view>
				</view>
				<view class="item">
					<text class="lbl">单位：</text>
					<input class="value" v-model="formData.company" placeholder="请输入单位" placeholder-class="usrplace" />
				</view>
				<view class="item">
					<text class="lbl">姓名：</text>
					<input class="value" v-model="formData.usrname" placeholder="请输入姓名" placeholder-class="usrplace" />
				</view>
				<view class="item">
					<text class="lbl">职位：</text>
					<input class="value" v-model="formData.job" placeholder="请输入职位" placeholder-class="usrplace" />
				</view>

			</view>
		</view>

		<view class="usrinfo">
			<view>
				<text class="usrtitle fleft">发送信息</text>
				<view class="btnSend fright" v-on:click.stop="sendMsg(null)">发送</view>
				<view class="clear"></view>
			</view>
			<view>

				<view class="item">
					<input maxlength="16" class="value" style="text-indent: 20rpx;" v-model="formData.sendMsg"
						placeholder="请输入文字" placeholder-class="usrplace" />
				</view>

			</view>
		</view>

		<ProParams :id="device.id"></ProParams>

		<MsgBox ref="msgPop" />
		<global-loading ref="loading" />
		<BottomSlideMenuPlus v-for="item,index in dic.actionSheets" :config="item" @close="item.closeMenu"
			@itemClick="item.handleItemClick" @btnClick="item.btnClick">
		</BottomSlideMenuPlus>
	</view>
</template>

<script>
	import api from '@/api/670/HBY670.js';
	import TextToHexV1 from '@/components/TextToHex/TextToHexV1.vue';
	import request, {
		baseURL
	} from '@/utils/request.js';
	import {
		showLoading,
		hideLoading,
		updateLoading
	} from '@/utils/loading.js';

	import {
		MsgSuccess,
		MsgError,
		MsgClose,
		MsgWarning,
		showPop
	} from '@/utils/MsgPops.js';
	import Common from '@/utils/Common.js';
	import BleTool from '@/utils/BleHelper.js'
	import BleReceive from '@/utils/BleReceive';
	import MqttClient from '@/utils/mqtt.js';
	import lnglatConvert from '@/utils/wgs84_to_gcj02.js';
	import SendBatchData from '@/utils/SendBatchData.js';
	var batchTool = null;
	var eventChannel = null;
	var these = null;
	var ble = null;

	var recei = null;
	var mq = null;
	var pagePath = "pages/6075J/BJQ6075J";
	var brightnessTimer = null;
	var reGeoTime = null;

	export default {
		components: {
			TextToHexV1
		},
		data() {
			return {
				Status: {


					pageHide: false,
					apiType: "listA",
					navbar: {
						icons: [
							// {
							// 	src: '/static/images/common/msg.png'
							// },
							{
								src: '/static/images/common/shape.png'
							}
						],
						title: 'BJQ6075',
						showBack: true,
						height: 90
					},
					usrToggle: true,

				},
				formData: {
					img: '/static/images/common/BJQ6075.png',
					sta_PowerPercent: "", //电量
					sta_PowerTime: "", //续航
					sta_imei: "", //sta_imei
					sta_longitude: "", //经度
					sta_latitude: "", //纬度 
					address: '',

					textLines: [],
					company: "湖北星汉文化", //单位
					usrname: "有限公司", //姓名 
					job: "工程师", //职位
					usrid: "11223344", //id
					sendMsg: "",

					deviceId: "",
					sta_system: "", //设备状态，0关机，1仅充电，2开机未充电,3，开机且充电
					bleStatu: false,

					sta_LightGrade: "", //主灯档位
					sta_Side_Light: "", //副灯档位
					sta_ShakeBit: 0, //报警状态
					sta_4gSinal: "", //4G信号强度
					sta_laser: "", //激光状态
					sta_brightness: 100, //亮度
					sta_SOSGrade: "1", //强制报警状态



					sta_Height: '', //海拔
					sta_Heat: '', //温度
					sta_releaHeight: '',
					sta_BreakNews: '',
					deviceId: ''
				},
				device: {
					id: "",
					deviceName: "",
					deviceImei: "",
					deviceMac: "",
					communicationMode: 0,
					devicePic: "",
					typeName: "",
					bluetoothName: null,
					deviceStatus: null,
					bindingTime: "",
					onlineStatus: 0,
					battery: "0",
					latitude: null,
					longitude: null,
					alarmStatus: null,
					detailPageUrl: "/pages/670/HBY670",
					showConfirm: false
				},

				permissions: [],

				dic: {
					actionSheets: [


					]
				},
				detailData: {
					deviceId: null,
					deviceName: null,
					deviceImei: null,
					deviceMac: null,
					communicationMode: null,
					devicePic: null,
					typeName: null,
					bluetoothName: null,
					deviceStatus: null,
					personnelInfo: null,
					onlineStatus: null,
					longitude: null,
					latitude: null,
					address: null,
					staDetectGrade: null,
					staLightGrade: null,
					staSOSGrade: null,
					staPowerTime: null,
					staPowerPercent: null,
					staDetectResult: null
				},
				inteval: 80
			}
		},
		computed: {
			getbleStatu() {

				if (this.formData.bleStatu === true) {
					return '已连接';
				}
				if (this.formData.bleStatu === 'connecting') {
					return '连接中';
				}
				if (this.formData.bleStatu === 'dicconnect') {
					return '正在断开';
				}
				if (this.formData.bleStatu === 'err') {
					return '连接异常';
				}
				return '未连接';
			},
			MainLight() {
				return this.getLightMode('main');
			},
			FuLight() {
				return this.getLightMode('fu');
			},
			sta_system() {
				let state = '关机';
				if (this.formData.sta_system == 3) {
					state = '开机充电中';
				} else if (this.formData.sta_system == 2) {
					state = '开机未充电';
				} else if (this.formData.sta_system == 1) {
					state = "仅充电";
				}
				return state;
			},

			heatStyle() {
				if (this.formData.sta_Heat < 0) {
					return 'hanleng';
				}
				if (this.formData.sta_Heat >= 0 && this.formData.sta_Heat <= 30) {
					return 'green';
				}
				if (this.formData.sta_Heat > 30 && this.formData.sta_Heat <= 40) {
					return 're'
				}
				if (this.formData.sta_Heat > 40 && this.formData.sta_Heat <= 60) {
					return 'yanRe'
				}
				if (this.formData.sta_Heat > 60) {
					return 'kuRe'
				}
				return '';
			}
		},
		created() {
			this.Status.navbar.height = uni.getSystemInfoSync().statusBarHeight + 44;
		},
		onUnload() {
			console.log("页面卸载,释放资源");
			let statusTopic = `A/${this.formData.sta_imei?this.formData.sta_imei:this.device.deviceImei}`;

			if (ble) {
				ble.removeAllCallback(pagePath);
				ble.removeReceiveCallback(pagePath);
			}

			if (mq) {
				mq.unsubscribe(statusTopic);
				mq.disconnect();
				mq = null;
			}
			clearTimeout(brightnessTimer);
		},
		onShow() {
			this.Status.pageHide = false;

			let f = this.getDevice();
			if (f) {
				these.formData.bleStatu = 'connecting';
				ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId).then(res => {
					console.log("连接成功")
					these.formData.bleStatu = true;
				}).catch(ex => {
					these.formData.bleStatu = 'err';
					MsgError("连接错误:" + ex.msg, "确定", these);
				});;
			}
		},
		onHide: function() {
			this.Status.pageHide = true;
		},

		onLoad() {

			these = this;
			this.initActionData();





			recei = BleReceive.getBleReceive();
			ble = BleTool.getBleTool();


			ble.addReceiveCallback(these.bleValueNotify, pagePath);
			ble.addStateBreakCallback(these.bleStateBreak, pagePath);
			ble.addStateRecoveryCallback(these.bleStateRecovry, pagePath);
			ble.addDisposeCallback(these.deviceDispose, pagePath);
			ble.addRecoveryCallback(these.deviceRecovry, pagePath);

			let eventChannel = this.getOpenerEventChannel();

			eventChannel.on('detailData', (data) => {
				debugger;
				console.log("收到父页面的参数：" + JSON.stringify(data));
				var device = data.data;
				these.Status.apiType = data.apiType;
				these.device = device;

				these.formData.sta_imei = device.deviceImei;
				if (these.formData.sta_imei) {
					these.initMQ();
				}

				these.formData.usrid = device.deviceImei;
				if (data.apiType !== 'listA') {
					Common.getdeviceShareId(data.data.id).then(res => {
						if (res.code == 200) {
							if (res.data.permission) {
								these.permissions = res.data.permission.split(',');
							}
						}
					});
				}

				let f = these.getDevice();
				if (!f) {
					these.showBleUnConnect();
					these.getDetail();
					these.initWatch();
					return;
				}
				let form = f.formData;
				if (form) {
					let keys = Object.keys(form);
					for (var i = keys.length; i >= 0; i--) {
						let key = keys[i];
						these.formData[key] = form[key];
					}
				}
				these.formData.bleStatu = 'connecting';
				ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId).then(res => {
					these.formData.bleStatu = true;
				}).catch(ex => {
					these.formData.bleStatu = 'err';
					MsgError("连接错误:" + ex.msg, "确定", these);
				});

				these.getDetail();
				these.initWatch();
			});


		},
		methods: {
			getDetail() {

				api.getDetail(this.device.id).then(res => {

					if (res && res.code == 200) {
						res = res.data;
						let json = res;
						this.detailData = json;
						console.log("res=", res);
						this.formData.sta_longitude = res.longitude;
						this.formData.sta_latitude = res.latitude;
						this.formData.address = res.address;
						let personnelInfo = res.personnelInfo;
						if (personnelInfo) {
							this.formData.company = personnelInfo.unitName;
							this.formData.usrname = personnelInfo.name;
							this.formData.job = personnelInfo.position;
							this.formData.usrid = personnelInfo.code
						}

						this.formData.sta_PowerPercent = json.staPowerPercent
						this.formData.sta_PowerTime = json.staPowerTime;
					}
				});
			},
			initWatch() {

				this.$watch("formData.sta_Heat", (newVal, oldVal) => {
					if (newVal) {
						if (newVal < -30) {
							MsgError("危险:环境温度过低,当前温度" + newVal + ",请立即撤离", "确定");
						}
						if (newVal >= 40 && newVal < 60) {
							MsgWarning("注意:环境温度过高,当前温度" + newVal, "确定");
						} else if (newVal >= 60 && newVal < 80) {
							MsgWarning("警告:环境温度过高,当前温度" + newVal + ",注意停留时间", "确定");
						} else if (newVal >= 80) {
							MsgError("危险:环境温度过高,当前温度" + newVal + ",请立即撤离", "确定");
						}
					}
				});

				this.$watch("formData.sta_BreakNews", (newVal, oldVal) => {
					if (newVal) {
						MsgSuccess("用户已确认收到紧急通知", "确定", these);
						setTimeout(() => {
							these.formData.sta_BreakNews = "";
						}, 10);
					}
				});

				this.$watch("formData.sta_PowerPercent", (newVal, oldVal) => {
					console.log("电量发生变化");
					if (newVal <= 20 && (this.formData.sta_system === 2 || this.formData.sta_system === 0)) {
						//电量在20%及以及下，且是未充电状态提醒
						showPop({
							message: "设备电量低于20%,请充电",
							borderColor: "#e034344d",
							buttonBgColor: "#E03434",
							buttonText: '确定',
							buttonTextColor: '#FFFFFFde',
							showCancel: false,
							showHeader: false,
							visibleClose: true,
							textColor: '#E03434',
							iconUrl: '/static/images/common/path.png'
						}, this);
					}
				});

			},
			checkSendVideo() {

				if (!this.permissions.includes('3') && this.Status.apiType !== 'listA') {

					MsgError('无操作权限', '确定', these);
					return;
				}

				let f = this.getDevice();

				if (!f) {
					this.showBleUnConnect();
					return;
				}

				if (!batchTool) {
					batchTool = new SendBatchData(these, f, ble);
				}
				batchTool.SendVideo(504);
			},
			sendImg() {
				if (!this.permissions.includes('3') && this.Status.apiType !== 'listA') {

					MsgError('无操作权限', '确定', these);
					return;
				}

				let f = this.getDevice();
				if (!f) {
					this.showBleUnConnect();
					return;
				}

				if (!batchTool) {
					batchTool = new SendBatchData(these, f, ble);
				}


				batchTool.SendImg();

				return;

			},
			sliderChanging(e) {
				this.formData.sta_brightness = e.detail.value;
			},
			sliderChange(e) {
				this.formData.sta_brightness = e.detail.value;

				// 清除之前的定时器
				if (brightnessTimer) {
					clearTimeout(brightnessTimer);
				}

				// 设置新的定时器，控制发送频率
				brightnessTimer = setTimeout(() => {

					let json = {
						ins_brightness: e.detail.value
					}

					this.sendData(json, null, 'string').then(res => {
						this.setBleFormData();
					}).catch(ex => {

					});
				}, 200);
			},

			showUploadMedia() {


				this.showAction('media')
			},
			getLightMode(type) {
				let item = null;
				let value = null;
				if (type === 'main') {
					value = this.formData.sta_LightGrade;
					item = this.dic.actionSheets[0];

				} else {
					value = this.formData.sta_Side_Light;
					item = this.dic.actionSheets[1];
				}

				let f = item.menuItems.find(v => {
					if (v.value == value) {
						return true;
					}
				});
				if (!f) {
					return "关闭";
				}
				return f.text;

			},
			initActionData() { //初始化ActionSheet菜单

				let json = {
					name: '',
					show: false,
					showHeader: true,
					menuItems: [],
					activeIndex: -1,
					bgColor: '#2a2a2a',
					itemBgColor: '#3a3a3a',
					textColor: '#ffffffde',
					textAlign: 'flex-start',
					title: '请选择',
					value: '',
					valueMember: 'value',
					showDivider: false,
					dividerColor: '#00000000',
					dividerThickness: '0rpx',
					dividerMargin: '10rpx',
					itemHeight: '80rpx',
					type: '',
					showBtn: true,
					btnBgColor: "#bbe600",
					btnText: "确定",
					btnTextColor: "#232323de",
					showMask: true,
					maskBgColor: '#00000066',
					showClose: false,

					closeMenu: these.closeAction,
					btnClick: (li, i) => {
						debugger;
					},
					handleItemClick: (li, i) => {
						debugger;
					}

				};

				let item = Object.assign({}, json);
				item.name = 'main';
				item.title = '主灯模式'
				item.menuItems = [{
						text: '强光',
						icon: '/static/images/lightImg/qiang.png',
						value: 1,
						key: 'ins_LightGrade'
					},
					{
						text: '工作光',
						icon: '/static/images/lightImg/work.png',
						value: 2,
						key: 'ins_LightGrade'
					},
					{
						text: '节能光',
						icon: '/static/images/lightImg/jieN.png',
						value: 3,
						key: 'ins_LightGrade'
					},
					{
						text: '爆闪',
						icon: '/static/images/lightImg/shan.png',
						value: 4,
						key: 'ins_LightGrade'
					},
					{
						text: 'SOS',
						icon: '/static/images/lightImg/sos.png',
						value: 5,
						key: 'ins_LightGrade'
					},
					{
						text: '关闭',
						icon: '/static/images/lightImg/closeLight.png',
						value: 6,
						key: 'ins_LightGrade'
					}
				];



				let item1 = Object.assign({}, json);
				item1.name = 'fu';
				item1.title = '辅光模式';
				item1.menuItems = [{
						text: '泛光',
						icon: '/static/images/lightImg/fan.png',
						value: 2,
						key: 'ins_Side_Light'
					},
					{
						text: '泛光爆闪',
						icon: '/static/images/lightImg/fan.png',
						value: 3,
						key: 'ins_Side_Light'
					},
					{
						text: '警示灯',
						icon: '/static/images/lightImg/warn.png',
						value: 1,
						key: 'ins_Side_Light'
					},
					{
						text: '警示灯/泛光',
						icon: '/static/images/lightImg/warn.png',
						value: 4,
						key: 'ins_Side_Light'
					},
					{
						text: '关闭',
						icon: '/static/images/lightImg/closeLight.png',
						value: 5,
						key: 'ins_Side_Light'
					}
				];

				let item3 = Object.assign({}, json);
				item3.textAlign = 'center';
				item3.name = 'media';
				item3.title = '选择媒体';
				item3.menuItems = [{
						text: '照片',
						value: 'img',
						key: 'media'
					},
					{
						text: '动画',
						value: 'flash',
						key: 'media'
					}
				];


				item.handleItemClick = (li, i) => {
					this.$set(this.dic.actionSheets[0], 'value', li.value);

				};
				item.btnClick = (li, i) => {
					this.lightSettiong(li, i);
					this.$set(this.dic.actionSheets[0], 'show', false);
				}

				item1.handleItemClick = (li, i) => {
					this.$set(this.dic.actionSheets[1], 'value', li.value);
				}
				item1.btnClick = (li, i) => {
					this.lightSettiong(li, i);
					this.$set(this.dic.actionSheets[1], 'show', false);
				}

				item3.handleItemClick = (li, i) => {
					this.$set(this.dic.actionSheets[2], 'value', li.value);
				};
				item3.btnClick = (li, i) => {
					this.$set(this.dic.actionSheets[2], 'show', false);

					let f = this.getDevice();
					if (!f) {
						this.showBleUnConnect();
						return;
					}

					if (li.value == 'img') {
						//照片
						these.sendImg();
					} else {
						//视频
						these.checkSendVideo();
					}

				}

				this.dic.actionSheets = [item, item1, item3];
			},
			SOSToggle() {
				debugger;
				if (!this.permissions.includes('42') && this.Status.apiType !== 'listA') {

					MsgError('无操作权限', '确定', these);
					return;
				}
				let val = 1;
				if (this.formData.sta_ShakeBit == 3) {
					val = 0;
				} else if (this.formData.sta_ShakeBit == 1) {
					val = 0;
				}

				let send = () => {
					let json = {
						ins_ShakeBit: val
					};
					this.sendData(json, null, 'string').then(res => {
						this.formData.sta_ShakeBit = val;
					}).catch(ex => {
						console.error("出现错误", ex)
					});
				}
				let msg = val == 1 ? '确定开启声光报警' : '确定解除声光报警';

				showPop({
					message: msg,
					iconUrl: "/static/images/670/sgActive.png",
					borderColor: "#e034344d",
					buttonBgColor: "#E03434",
					buttonText: '确定',
					buttonTextColor: '#FFFFFFde',
					showCancel: true,
					buttonCancelText: '取消',
					okCallback: send
				}, these);



			},
			laserToggle() {
				if (!this.permissions.includes('2') && this.Status.apiType !== 'listA') {

					MsgError('无操作权限', '确定', these);
					return;
				}
				let val = 1;
				if (this.formData.sta_laser === 1) {
					val = 0;
				}
				let json = {
					ins_laser: val
				};
				let sendLaser = () => {
					this.sendData(json, null, 'string').then(res => {
						this.formData.sta_laser = val;
						this.formData.sta_LightGrade = 6;
						this.setBleFormData();
					}).catch(ex => {
						console.error("出现错误", ex)
					});
				}

				if (val === 1) {
					showPop({
						message: "注意事项\n1.禁止直视光源或反向面！   \n2.避免直射人或易燃物！        \n3.需佩戴相应专业防护眼镜！",
						borderColor: "#e034344d",
						buttonBgColor: "#E03434",
						buttonText: '确定',
						buttonTextColor: '#FFFFFFde',
						showCancel: true,
						showHeader: true,
						visibleClose: false,
						headerTxt: "确定开启激光模式？",
						textColor: '#E03434',
						okCallback: sendLaser,
					}, this);
				} else {
					sendLaser();
				}

			},
			lightSettiong(li, index) {
				if (!this.permissions.includes('1') && this.Status.apiType !== 'listA') {

					MsgError('无操作权限', '确定', these);
					return;
				}
				let json = {};
				json[li.key] = li.value;
				this.sendData(json, null, 'string').then((res) => {
					let key = li.key.replace(/ins_/g, 'sta_');
					this.formData[key] = li.value;
					if (li.value != 6) {
						this.formData.sta_laser = 0;
					}
					this.setBleFormData();
					this.formData.sta_brightness = 100;
				}).catch((ex) => {
					console.error("出现错误", ex)
				});
			},
			sendUsr() {

				if (!this.permissions.includes('4') && this.Status.apiType !== 'listA') {

					MsgError('无操作权限', '确定', these);
					return;
				}

				let f = this.getDevice();
				if (!f) {
					this.showBleUnConnect();
					return;
				}


				if (!batchTool) {
					batchTool = new SendBatchData(these, f, ble);
				}
				batchTool.SendUsr(3);
			},
			sendMsg() {
				debugger;
				if (!this.permissions.includes('4') && this.Status.apiType !== 'listA') {
					MsgError('无操作权限', '确定', these);

					return;
				}


				this.formData.sendMsg.padStart(16, ' ');

				this.formData.textLines = [this.formData.sendMsg.slice(0, 8), this.formData.sendMsg.slice(8, 16)];



				showLoading(this, {
					text: "发送中"
				});
				//握手
				let holdHand = (hexs, time) => {
					return new Promise((resolve, reject) => {
						setTimeout(() => {
							resolve(true)
						}, time);
					});
				}
				//画图
				let drawText = () => {
					return new Promise((resolve, reject) => {
						this.$refs.textToHex.drawAndGetPixels().then(allPixels => {
							if (!allPixels) {
								reject("文本初始化失败");
								return;
							}
							console.log("画图成功");
							resolve(allPixels);
						}).catch(compEx => {
							reject(compEx);
						});

					});
				}
				//发送3个分包的数据
				let task = (allPixels) => {
					try {
						let combinedData = [];
						for (let i = 0; i < 2; i++) {
							let linePixels = (allPixels[i] || []).flat(Infinity).map(item =>

								item.replace('0x', '')
							);

							for (var j = linePixels.length; j < 256; j++) {
								linePixels.push("00");

							}


							combinedData.push(['0' + (i + 1), '01'].concat(linePixels.slice(0, 128)));
							combinedData.push(['0' + (i + 1), '02'].concat(linePixels.slice(128, 256)));
						}


						let curr = 1;
						let len = combinedData.length;


						console.log("包数量", len)
						//分包发送
						let sendPacket = () => {

							if (combinedData.length === curr - 1) {

								Common.saveDeviceLog({
									deviceId: this.device.id,
									name: '发送紧急通知',
									sendMsg: this.formData.sendMsg.trim()
								}).catch(ex => {

								});
								holdHand('transmit complete', 200).then(res => {

									MsgSuccess("消息发送成功", "确定", these);
								});
								hideLoading(these);
								return;
							}

							let array = combinedData[curr - 1];

							let json = {
								ins_msg: array.join("")
							}

							this.sendData(json, '4g', 'string').then(
								res => {
									curr++;
									console.log("发送成功", curr);
									setTimeout(sendPacket, 1000);


								}).catch(err => {
								if (err.code == '10007') {

									setTimeout(sendPacket, 1000);
								} else {
									console.log("err:", err);
									MsgError('发送失败' + (err.msg || err.code), '确定', these);
								}

							});
						}

						setTimeout(sendPacket, 0);
						// 5. 发送成功处理


					} catch (ex) {
						uni.showModal({
							title: '提示',
							content: '发送失败' + (ex.msg || ex.code)
						})
					}


				}

				setTimeout(() => {
					Promise.allSettled([holdHand('word transmit start', 2200), drawText()]).then(results => {
						console.log("PromiseAll=", results);
						if (results[0].status == 'rejected') {

							setTimeout(() => {
								hideLoading(these)
							}, 500);
							return;
						}
						if (results[1].status == 'rejected') {
							console.log("任务1失败了", results[1].reason);
							return;
						}
						console.log("开始发送数据包");
						task(results[1].value);
					})

				}, 0);
			},
			sendData(json, sendType, dataType) {

				return new Promise((resolve, reject) => {
					if (json instanceof Object) {
						json = JSON.stringify(json)
					}
					let fourGSend = () => {
						return new Promise((succ, err) => {
							let flag = mq.publish("B/" + this.formData.sta_imei, json);
							if (flag) {
								succ();
							} else {
								err({
									code: 500,
									msg: "操作失败,请检查网络连接"
								});
							}
						});

					}
					let bleSend = () => {
						return new Promise((succ, err) => {
							let f = these.getDevice();

							if (f) {
								if (dataType == 'string') {
									ble.sendString(f.deviceId, json).then(res => {

										succ(res);
									}).catch(ex => {

										err(ex);
									});
								} else if (dataType == 'hex') {
									ble.sendHexs(f.deviceId, json).then(res => {

										succ(res);
									}).catch(ex => {

										err(ex);
									});

								} else {
									ble.sendData(f.deviceId, json).then(res => {

										succ(res);
									}).catch(ex => {

										err(ex);
									});
								}

							} else {
								these.showBleUnConnect();
								err({
									code: 0,
									msg: '蓝牙未连接'
								});
							}
						});

					}
					if (sendType === '4g') {
						fourGSend().then(res => {
							resolve(res);
						}).catch(ex => {
							console.error("ex=", ex);
							reject(ex)
						});
						return;
					}
					if (sendType === 'ble') {
						bleSend().then(res => {
							resolve(res);
						}).catch((ex) => {
							console.error("ex=", ex);
							reject(ex);
						});
						return;
					}


					bleSend().then(res => {
						resolve(res);
					}).catch((err) => {
						fourGSend().then((res) => {
							resolve(res);
						}).catch(ex => {
							console.error("ex=", ex);
							reject(ex);
						})
					});
				});


			},
			getDevice: function() {

				let f = ble.data.LinkedList.find((v) => {
					let flag = v.macAddress == these.device.deviceMac;
					if (!flag && v.device) {
						flag = v.device.id == these.device.id;
					}
					if (flag) {
						these.formData.deviceId = v.deviceId;
					}
					return flag;
				});

				// #ifdef WEB
				f = {
					deviceId: '123'
				}
				// #endif

				return f;
			},
			showBleUnConnect() {

				showPop({
					message: "蓝牙未连接过该设备,请使用蓝牙重新添加该设备",
					iconUrl: "/static/images/common/uploadErr.png",
					borderColor: "#e034344d",
					buttonBgColor: "#E03434",
					buttonText: '去连接',
					buttonTextColor: '#FFFFFFde',
					showCancel: true,
					okCallback: function() {
						console.log("1111");
						uni.navigateTo({
							url: "/pages/common/addBLE/addEquip",
							events: {
								BindOver: function(data) {
									console.log(data)
									these.formData.bleStatu = true;
								}
							},
							success: function(res) {
								// 通过eventChannel向被打开页面传送数据
								res.eventChannel.emit('detailData', {
									data: these.device
								})
							}
						})
					}
				}, these);
			},
			initMQ() {


				return new Promise((resolve, reject) => {
					if (mq) {

						resolve();
						return;
					}
					console.log("正在初始化MQtt")
					mq = new MqttClient();
					mq.connect(() => {
						console.log("MQTT连接成功，开始订阅消息")
						// 订阅来自设备的状态更新
						const statusTopic =
							`A/${this.formData.sta_imei?this.formData.sta_imei:this.device.deviceImei}`;
						mq.subscribe(statusTopic, (payload, receive) => {
							console.log("mq收到消息", payload)
							let json = JSON.parse(payload);
							this.receivData(json);
						});
						resolve();
					});
				});

			},
			bleValueNotify: function(receive, device, path, recArr) { //订阅消息
				if (receive.deviceId !== this.formData.deviceId) {
					return;
				}
				let data = recei.ReceiveData(receive, device, pagePath, recArr);
				console.log("蓝牙收到消息", data)
				this.receivData(data);
			},
			receivData(data) { //处理蓝牙/MQ的数据
				let keys = Object.keys(data);
				keys.forEach(key => {
					this.formData[key] = data[key];
				});

				this.$set(this.dic.actionSheets[0], 'value', this.formData.sta_LightGrade);
				this.$set(this.dic.actionSheets[1], 'value', this.formData.sta_Side_Light);

				if ('sta_longitude' in data) {
					this.reGeo();
				}
				this.setBleFormData();
			},
			reGeo() {
				console.log("经纬度发生变化,执行逆地理")
				let task = () => {
					if (this.formData.sta_longitude && this.formData.sta_latitude) {
						let promise = lnglatConvert.wgs84_to_gcj02(this.formData.sta_longitude, this.formData
							.sta_latitude);
						promise.then(lnglat => {

							this.device.longitude = lnglat[0];
							this.device.latitude = lnglat[1];
							this.formData.sta_longitude = lnglat[0];
							this.formData.sta_latitude = lnglat[1];


							Common.regeo(lnglat[0], lnglat[1]).then(res => {
								this.formData.address = res.regeocode.formatted_address
								this.setBleFormData();
							}).catch(ex => {
								console.error("逆地理失败了")
							});
						}).catch(err => {
							console.error("坐标转换失败了");
						});
					} else {
						console.error("经纬度缺失");
					}

				}

				clearTimeout(reGeoTime);
				reGeoTime = setTimeout(task, 500);
			},
			setBleFormData() {
				if (!ble) {
					return;
				}
				let f = ble.data.LinkedList.find((v) => {
					if (v.deviceId == these.formData.deviceId) {
						v.formData = these.formData;

						return true;
					}
					return false;
				});
				if (f) {
					uni.setStorageSync(ble.StorageKey, ble.data.LinkedList);
				}

			},
			deviceRecovry(res) {
				if (this.Status.pageHide) {
					return;
				}
				if (res.deviceId == these.formData.deviceId) {
					this.formData.bleStatu = true;

					batchTool = new SendBatchData(this, res, ble);

				}

			},
			deviceDispose(res) {
				// if (this.Status.pageHide) {
				// 	return;
				// }
				if (res.deviceId == these.formData.deviceId) {
					batchTool = null;
					if (res.device) {
						these.formData.bleStatu = 'connecting';
					} else {
						this.formData.bleStatu = false;
					}
					setTimeout(() => {
						hideLoading(these, 1000);
					});
					uni.showToast({
						icon: 'fail',
						title: '蓝牙连接已断开'
					});
				}

			},
			bleStateBreak() {
				if (this.Status.pageHide) {
					return;
				}
				//蓝牙适配器不可用
				this.formData.bleStatu = false;
				uni.showToast({
					icon: 'fail',
					title: '蓝牙已不可用'
				})
				hideLoading(this);
			},
			bleStateRecovry() {
				console.log("蓝牙可用");
				if (this.Status.pageHide) {
					return;
				}
				console.log("蓝牙可用");
				//蓝牙适配器再次可用,尝试恢复连接
				showLoading(this, {
					text: "蓝牙恢复可用,正在连接设备"
				});
				this.formData.bleStatu = 'connecting';
				ble.LinkBlue(these.formData.deviceId).then(() => {
					these.formData.bleStatu = true;
					updateLoading(these, {
						text: '连接成功'
					});
				}).catch(ex => {
					updateLoading(these, {
						text: ex.msg
					});
					these.formData.bleStatu = 'err';
				}).finally(() => {
					setTimeout(() => {
						hideLoading(these);
					}, 1000);

				});
			},
			bleStatuToggle() {
				let f = this.getDevice();
				if (!f) {
					this.showBleUnConnect();
					return;
				}
				if (this.formData.bleStatu === true) {
					this.formData.bleStatu = 'dicconnect';
					ble.disconnectDevice(f.deviceId).finally(r => {
						this.formData.bleStatu = false;
					});
					return;
				}

				if (this.formData.bleStatu === false || this.formData.bleStatu === 'err') {
					this.formData.bleStatu = 'connecting';
					ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId).then(res => {
						these.formData.bleStatu = true;
					}).catch(ex => {
						these.formData.bleStatu = 'err';
						MsgError("连接错误:" + ex.msg, "确定", these);
					});
					return;
				}


			},
			gotoMap() {
				let promise = Promise.resolve([this.formData.sta_longitude, this.formData
					.sta_latitude
				]); //lnglatConvert.wgs84_to_gcj02(this.formData.sta_longitude, this.formData.sta_latitude);
				promise.then(lnglat => {

					this.detailData.longitude = lnglat[0];
					this.detailData.latitude = lnglat[1];
					uni.navigateTo({
						url: '/pages/common/map/index',
						events: {
							ack: function(data) {}
						},
						success: (res) => {
							res.eventChannel.emit('Map', {
								data: this.detailData
							});
						}
					})
				});

			},

			prevPage() {
				uni.navigateBack({

				});
			},
			handleRightClick: function(s, e) {

				if (s === 0) {

					return;
				} else if (s === 1) {
					console.log("分享");
					uni.navigateTo({
						url: '/pages/common/share/index',
						events: {
							ack: function(data) {}
						},
						success: (res) => {
							let json = {
								persissonType: '6075'
							};
							Object.assign(json, this.device);
							res.eventChannel.emit('share', {
								data: json
							});
						}
					})
				}
			},
			closeAction() {
				for (let index = 0; index < this.dic.actionSheets.length; index++) {
					let menu = this.dic.actionSheets[index];
					if (menu.show) {
						this.$set(this.dic.actionSheets[index], 'show', false);
						break;
					}
				}
			},
			showAction(name) {

				for (let index = 0; index < this.dic.actionSheets.length; index++) {
					let menu = this.dic.actionSheets[index];
					if (menu.name == name) {
						this.$set(this.dic.actionSheets[index], 'show', true);
						if (index == 2) {
							this.$set(this.dic.actionSheets[index], 'value', '');
							this.$set(this.dic.actionSheets[index], 'activeIndex', -1);
						}
					} else {
						this.$set(this.dic.actionSheets[index], 'show', false);
					}
				}
			}
		}
	}
</script>

<style>
	.content {
		padding: 30rpx;
		box-sizing: border-box;
	}

	.eq {
		width: 100%;
		height: 250rpx;
		border-radius: 8px;
		background: rgba(26, 26, 26, 1);
		box-sizing: border-box;
		padding: 24rpx 28rpx;
		display: flex;
		flex-direction: row;
		flex-wrap: nowrap;
		align-content: center;
		justify-content: center;
		align-items: center;
		margin-bottom: 24rpx;
	}

	.eq .leftImg {
		box-sizing: border-box;
		padding: 36rpx;
		border-radius: 16rpx;
		background: rgba(42, 42, 42, 0.5);
	}

	.eq .leftImg,
	.eq .rightTxt {
		width: 50%;
		height: 100%;
	}

	.eq .rightTxt {
		display: flex;
		flex-direction: column;
		flex-wrap: nowrap;
		align-content: flex-start;
		justify-content: space-evenly;
		align-items: flex-start;
	}

	.eq .leftImg .img {
		width: 100%;
		height: 100%;
	}

	.eq .rightTxt .img {
		width: 52rpx;
		height: 52rpx;
	}

	.eq .rightTxt .row {
		width: 100%;
		display: flex;
		flex-direction: row;
		flex-wrap: nowrap;
		align-content: center;
		justify-content: flex-start;
		align-items: center;
		box-sizing: border-box;
		padding-left: 50rpx;
	}

	.eq .rightTxt .row .txt {
		padding-left: 20rpx;
	}

	.eq .bigTxt {
		color: rgba(255, 255, 255, 0.87);
		font-family: PingFang SC;
		font-size: 28rpx;
		font-weight: 400;
	}

	.eq .smallTxt {
		color: rgba(255, 255, 255, 0.6);
		font-family: PingFang SC;
		font-size: 24rpx;
		font-weight: 400;
	}


	.eqinfo {
		border-radius: 16rpx;
		background: rgba(26, 26, 26, 1);
		box-sizing: border-box;
		padding: 14rpx 0rpx;
		margin-bottom: 20rpx;
	}

	.eqinfo .item {
		width: 100%;
		min-height: 60rpx;
		height: auto;
		line-height: 60rpx;
		padding: 0rpx 28rpx;
		box-sizing: border-box;
		display: flex;
		flex-direction: row;
		flex-wrap: nowrap;
		align-content: center;
		justify-content: space-between;
		align-items: center;
	}

	.eqinfo .lbl {
		color: rgba(255, 255, 255, 0.87);
		font-family: PingFang SC;
		font-size: 28rpx;
		font-weight: 400;
		width: 140rpx;
		letter-spacing: 0.07px;
		text-align: left;
	}

	.eqinfo .value {
		color: rgba(255, 255, 255, 0.6);
		font-family: 'PingFang SC';
		font-size: 28rpx !important;
		font-weight: 400;

		letter-spacing: 0.07px;
		text-align: left;
	}


	.eqinfo .valueFont {
		font-family: 'PingFang SC';
		font-size: 28rpx !important;
		font-weight: 400;
		color: rgba(255, 255, 255, 0.6);
	}

	.eqinfo .multiValue {
		display: flex;
		flex-direction: column;
		flex-wrap: wrap;
		align-content: flex-end;
		align-items: flex-end;
		justify-content: flex-start;
		width: calc(100% - 140rpx)
	}

	.eqinfo .valueItem {
		height: auto;
		line-height: 40rpx;
		color: rgba(255, 255, 255, 0.6);
		font-family: PingFang SC;
		font-size: 14px;
		font-weight: 400;
		letter-spacing: 0.07px;
	}

	.lamp {
		margin-top: 24rpx;
	}

	.lamp .title {
		width: 100%;
		height: 60rpx;
		line-height: 60rpx;
		padding: 0rpx 28rpx;
		box-sizing: border-box;
		display: flex;
		flex-direction: row;
		flex-wrap: nowrap;
		align-content: center;
		justify-content: space-between;
		align-items: center;
		font-size: 28rpx;
	}

	.lampMode {
		padding: 30rpx 0rpx;
		width: 100%;
		box-sizing: border-box;
		display: flex;
		align-content: space-around;
		justify-content: space-between;
		align-items: center;
		justify-items: stretch;
		flex-direction: row;
		flex-wrap: wrap;
	}

	.lampMode .mode {
		width: calc(calc(100% - 34rpx) / 2);
		border-radius: 8px;
		margin-top: 20rpx;
		background: rgba(26, 26, 26, 1);
		display: flex;
		flex-direction: row;
		flex-wrap: nowrap;
		align-content: center;
		align-items: center;
		justify-content: flex-start;
		padding: 30rpx;
		box-sizing: border-box;
	}

	.lampMode .mode.active {

		border: 1px solid rgba(174, 214, 0, 1);
	}

	.lampMode .mode.active .bigTxt {

		color: rgba(174, 214, 0, 1) !important;
	}

	.mode.marginLeft {
		margin-left: 34rpx !important;
	}

	.mode .leftImg .img {
		width: 70rpx;
		height: 70rpx;
	}

	.mode .rightTxt {
		display: flex;
		flex-direction: column;
		flex-wrap: nowrap;
		align-content: flex-start;
		justify-content: center;
		align-items: flex-start;
		padding-left: 20rpx;
	}

	.mode .bigTxt {
		color: rgba(255, 255, 255, 0.87);
		font-family: PingFang SC;
		font-size: 28rpx;
		font-weight: 400;

		letter-spacing: 0.07px;

	}

	.mode .smallTxt {
		color: rgba(255, 255, 255, 0.6);
		font-family: PingFang SC;
		font-size: 24rpx;
		font-weight: 400;

		letter-spacing: 0.07px;

	}

	.usrinfo {
		border-radius: 8px;
		width: 100%;
		box-sizing: border-box;
		padding: 24rpx 28rpx;
		background: rgba(26, 26, 26, 1);
		margin-bottom: 20rpx;
	}

	.usrtitle {
		color: rgba(255, 255, 255, 0.87);
		font-family: PingFang SC;
		font-size: 28rpx;
		font-weight: 400;
		height: 40rpx;
		line-height: 40rpx;
		letter-spacing: 0.07px;

	}

	.usrinfo .btnSend {
		line-height: 65rpx;
		border-radius: 8px;
		width: 120rpx;
		height: 65rpx;
		color: rgba(35, 35, 35, 0.87);
		font-family: PingFang SC;
		font-size: 24rpx;
		font-weight: 400;
		letter-spacing: 0.15rpx;
		text-align: center;
		background-color: #BBE600;
	}

	.usrinfo .item {
		border-radius: 8px;
		width: 100%;
		box-sizing: border-box;
		line-height: 90rpx;
		height: 90rpx;
		background: rgba(42, 42, 42, 1);
		margin-top: 24rpx;
		display: flex;
		flex-direction: row;
		flex-wrap: nowrap;
		align-content: center;
		justify-content: flex-start;
		align-items: center;
	}

	.usrinfo .lbl {
		width: 120rpx;
		height: 100%;
		padding-left: 24rpx;
		box-sizing: border-box;

		text-align: right;

		color: rgba(255, 255, 255, 0.87);
		font-family: PingFang SC;
		font-size: 28rpx;
		font-weight: 400;

		letter-spacing: 0.07px;

	}

	.usrinfo .value {
		width: calc(100% - 120rpx);
		height: 100%;

		font-size: 28rpx;
		font-weight: 400;

		letter-spacing: 0.07px;
		text-align: left;

	}

	.usrinfo .value .uni-input-input {
		color: rgba(255, 255, 255, 0.87);
		font-family: PingFang SC;

	}


	.usrplace {
		color: rgba(255, 255, 255, 0.4);
		font-family: PingFang SC;
		font-size: 28rpx;
		font-weight: 400;
		letter-spacing: 0.07px;
		text-align: left;
	}



	.slider-container {
		padding: 0px;
	}




	.addIco {
		width: 100%;
		height: 360rpx;
		display: flex;
		flex-direction: row;
		flex-wrap: nowrap;
		align-content: center;
		justify-content: center;
		align-items: center;
	}

	.icoContent {
		width: 240rpx;
		height: 240rpx;
		border-radius: 8rpx;


		background: rgba(58, 58, 58, 1);
	}

	.icoContent .img {
		width: 70rpx;
		height: 70rpx;
	}

	.modeSetting {
		display: flex;
		flex-direction: row;
		flex-wrap: nowrap;
		align-content: center;
		justify-content: space-around;
		align-items: center;
		border-radius: 8px;
		background: rgba(26, 26, 26, 1);
		box-sizing: border-box;
		padding: 30rpx 0rpx;
	}

	.modeSetting .item {
		width: 120rpx;
		height: 120rpx;
		background: rgba(42, 42, 42, 1);
		border-radius: 50%;

		color: rgba(255, 255, 255, 0.87);

		font-family: PingFang SC;
		font-size: 28rpx;
		font-weight: 400;
		line-height: 0px;

		box-sizing: border-box;
	}

	.modeSetting .item.active {
		border: 4rpx solid rgba(174, 214, 0, 1);
		background: rgba(26, 26, 26, 1);
		padding: 6rpx;
		color: rgba(26, 26, 26, 0.87);
	}

	.modeSetting .item.active .p100 {
		background: rgba(174, 214, 0, 1);
		border-radius: 50%;

	}


	.usrinfo .image {
		width: 30rpx;
		height: 40rpx;
	}

	.usrinfo .img {
		width: 30rpx;
		height: 40rpx;
	}

	.content {

		box-sizing: border-box;
		width: 100%;
		min-height: 100vh;
		height: auto;
	}

	.contentBg {
		background-color: #121212;
		color: #ffffffde;
	}

	.fleft {
		float: left;
	}

	.fright {
		float: right;
	}

	.clear {
		clear: both;
	}

	.displayNone {
		display: none !important;
	}

	.p100 {
		width: 100%;
		height: 100%;
	}

	.center {
		display: flex;
		flex-direction: row;
		flex-wrap: nowrap;
		align-content: center;
		justify-content: center;
		align-items: center;
	}

	.centerLeft {
		display: flex;
		flex-direction: row;
		flex-wrap: nowrap;
		align-content: center;
		justify-content: flex-start;
		align-items: center;
	}

	.warnnig {
		border-radius: 16rpx;
		width: 100%;
		height: 70rpx;
		line-height: 70rpx;
		background: rgba(224, 52, 52, 1);
		box-sizing: border-box;
		padding: 0rpx 30rpx;
		margin: 20rpx 0rpx;
		color: rgba(255, 255, 255, 0.87);
		font-family: 'PingFang SC';
		font-size: 28rpx;
		font-weight: 400;
		display: flex;
		flex-direction: row;
		flex-wrap: nowrap;
		align-content: center;
		justify-content: space-between;
		align-items: center;
	}

	.optTitle {
		color: rgba(255, 255, 255, 0.87);

		font-family: 'PingFang SC';
		font-size: 28rpx;
		font-weight: 400;

		letter-spacing: 0.14rpx;
		text-align: left;
		width: 100%;
		box-sizing: border-box;
		padding: 30rpx 0rpx 10rpx 30rpx;
	}

	.sosContent {
		width: 100%;
		height: 130rpx;

		display: flex;
		flex-direction: row;
		flex-wrap: nowrap;
		align-content: center;
		justify-content: space-between;
		align-items: center;
	}

	.sosContent .item {
		width: calc(calc(100% - 80rpx) / 2);
		height: 100%;
		box-sizing: border-box;
		border-radius: 16rpx;
		background: rgba(26, 26, 26, 1);
		color: rgba(255, 255, 255, 0.87);
		font-family: 'PingFang SC';
		font-size: 28rpx;
		font-weight: 400;
		letter-spacing: 0.14rpx;
		display: flex;
		flex-direction: row;
		flex-wrap: nowrap;
		align-content: center;
		justify-content: center;
		align-items: center;
	}

	.sosContent .item.active {
		border: 1px solid rgba(224, 52, 52, 1);
		color: rgba(224, 52, 52, 1);
	}

	.sosContent .imgContent {
		width: 55rpx;
		height: 55rpx;
		background-color: #232323;
		border-radius: 4rpx;
		margin-right: 30rpx;
	}

	.sosContent .imgContent .img {
		width: 70%;
		height: 70%;

	}

	.sosContent .item.active .imgContent {
		background-color: #E034340F;
	}

	.lightMode {
		width: 100%;
		height: 180rpx;
		border-radius: 16rpx;
		background: rgba(26, 26, 26, 1);
		margin-bottom: 30rpx;
		display: flex;
		flex-direction: row;
		flex-wrap: nowrap;
		align-content: center;
		justify-content: space-between;
		align-items: center;
	}


	.lightMode .item {
		width: calc(calc(100% - 90rpx) / 3);
		height: 100%;
		box-sizing: border-box;
		border-radius: 16rpx;

		color: rgba(255, 255, 255, 0.87);
		font-family: 'PingFang SC';
		font-size: 28rpx;
		font-weight: 400;
		letter-spacing: 0.14rpx;
		display: flex;
		flex-direction: column;
		flex-wrap: nowrap;
		align-content: center;
		justify-content: space-evenly;
		align-items: center;
	}

	.lightMode .item.active {

		color: #AED600;
	}

	.lightMode .imgContent {
		width: 80rpx;
		height: 100rpx;
	}

	.lightMode .imgContent .img {
		width: 100%;
		height: 100%;

	}

	.picVideo .btnImg {
		width: 100%;
		height: 100rpx;
		border-radius: 16rpx;
		background: rgba(42, 42, 42, 1);
	}

	.picVideo .btnImg .img {
		width: 40rpx;
		height: 40rpx;
	}


	.netContent {
		display: flex;
		flex-direction: row;
		flex-wrap: nowrap;
		align-content: flex-end;
		justify-content: space-around;
		align-items: flex-end;
		width: 50rpx;
	}

	.net {
		width: 7rpx;
		background: rgba(255, 255, 255, 0.3);
	}

	.net.netone {
		height: 11rpx;
	}

	.net.nettwo {
		height: 17rpx;
	}

	.net.netsiri {
		height: 23rpx;
	}

	.net.netfour {
		height: 29rpx;
	}

	.net.netfive {
		height: 35rpx;
	}

	.net.active {
		background: #FFFFFF !important;
	}

	.navbarRight .img {
		width: 35rpx;
		height: 35rpx;
		margin-right: 30rpx;
	}

	.uni-navbar--fixed {
		top: 0rpx;
	}

	/deep/ .uni-navbar--fixed {
		top: 0px;
	}

	/deep/ .uni-navbar__placeholder {
		display: none !important;
	}

	.TextToHex {
		position: fixed;
		top: -99999rpx;
		left: -99999rpx;
		visibility: hidden;
	}

	.leftIndent {
		text-indent: 10rpx;
		display: inline-block;
	}

	.hanleng {
		color: #66CCFF;
	}

	.re {
		color: #FFB74D
	}

	.yanRe {
		color: #F57C00;
	}

	.kuRe {
		color: #B71C1C;
	}
</style>