1
0
forked from dyf/APP
Files
APP/pages/6075J/BJQ6075J.vue
2026-03-05 10:06:37 +08:00

2939 lines
69 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<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/6155/DeviceDetail/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/6155/DeviceDetail/time.png" mode="aspectFit"></image>
<view class="txt">
<view class="bigTxt">{{battery}}</view>
<view class="smallTxt">续航时间</view>
</view>
</view>
</view>
</view>
<view class="warnnig" :class="formData.sta_ShakeBit!==0 && formData.showShakeBit ?'':'displayNone'">
<view>{{formData.sta_ShakeBit==1?'设备疑似受到外力碰撞':'设备声光报警中'}}</view>
<view @click.stop="SOSToggle()">
<uni-icons type="closeempty" color="#FFFFFFde" size="16"></uni-icons>
</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>
<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="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 class="item">
<text class="lbl">ID号</text>
<input class="value" v-model="formData.usrid" placeholder="请输入ID" 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.msgTxt"
placeholder="请输入文字" placeholder-class="usrplace" />
</view>
</view>
</view>
<view class="proinfo lamp">
<text class="title">产品信息</text>
<view class="itemcontent">
<view class="item" @click="proDetail('productDes')">
<image class="img" src="/static/images/6155/DeviceDetail/param.png" mode="aspectFit"></image>
<text class="txt">产品参数</text>
</view>
<view class="item" @click="proDetail('operatingInstruct')">
<image class="img" src="/static/images/6155/DeviceDetail/remark.png" mode="aspectFit"></image>
<text class="txt">操作说明</text>
</view>
<view class="item" @click="proDetail('operationVideo')">
<image class="img" src="/static/images/6155/DeviceDetail/video.png" mode="aspectFit"></image>
<text class="txt">操作视频</text>
</view>
</view>
</view>
<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'
var eventChannel = null;
var these = null;
var ble = null;
var rec = null;
var mq = null;
var pagePath = "pages/6075J/BJQ6075J";
var brightnessTimer = 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_LightGrade: "", //副灯档位
sta_ShakeBit: "1", //报警状态
sta_4gSinal: "", //4G信号强度
sta_laser: "", //激光状态
sta_brightness: 100, //亮度
sta_SOSGrade: "1", //强制报警状态
showSosGrade:false,
showShakeBit:false,
sta_height:'',//海拔
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
}
}
},
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;
},
battery(){
let hours = Math.floor(this.formData.sta_PowerTime / 60);
let remainingMinutes = this.formData.sta_PowerTime % 60;
let xuhang = '0分';
// 处理不同情况的显示
if (hours === 0) {
xuhang = `${remainingMinutes}`;
} else if (remainingMinutes === 0) {
xuhang = `${hours}小时`;
} else {
xuhang = `${hours}小时${remainingMinutes}`;
}
return xuhang;
}
},
created() {
this.Status.navbar.height = uni.getSystemInfoSync().statusBarHeight + 20;
},
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;
},
onHide: function() {
this.Status.pageHide = true;
},
onLoad() {
these = this;
this.initActionData();
this.initWatch();
rec = 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();
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;
});
});
},
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;
this.formData.sta_SOSGrade = json.staSOSGrade;
}
});
},
initWatch(){
this.$watch("formData.sta_SOSGrade", (newVal, oldVal) => {
console.log("报警状态发生变化");
if (newVal == 1) {
this.formData.showSosGrade = true;
}
});
this.$watch("formData.sta_ShakeBit", (newVal, oldVal) => {
console.log("碰撞状态发生变化");
if (newVal != 0) {
this.formData.showShakeBit = true;
}
});
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: '#232323de',
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();
let timeDelayCloseLoading = () => {
setTimeout(() => {
hideLoading(these);
}, 1500);
}
let sendVideoPackets = (ReSendNo) => {
console.log("开始发送分片数据");
return new Promise((resolve, reject) => {
if (f) {
// 总数据包数
var totalPackets = 1536; //36;
let currentPacket = 1;
console.log("发送数据准备中,总共" + totalPackets);
if (ReSendNo) {
totalPackets = ReSendNo;
currentPacket = ReSendNo;
}
this.totalPackets = totalPackets;
// 发送单个数据包
const sendNextVideoPacket = () => {
// console.log("准备发送一段数据");
if (currentPacket > totalPackets) {
if (!ReSendNo) {
setTimeout(() => {
ble.sendString(f.deviceId, "transmit complete", f
.writeServiceId, f.wirteCharactId, 20)
.then(
() => {
console.log("全部发送完毕")
}).catch((ex) => {
console.log("出现异常", ex);
});
}, 500);
}
hideLoading(these);
showPop({
showPop: true,
message: "上传成功",
iconUrl: "/static/images/common/success.png"
}, these);
these.videoHexArray = null;
resolve();
return;
}
// 计算当前包的数据
let packetSize = 500;
// 创建数据包
const startIndex = (currentPacket - 1) * packetSize;
const endIndex = Math.min(startIndex + packetSize, these.videoHexArray
.length);
if (startIndex > endIndex) {
resolve();
return;
}
////console.log("111111");
const packetData = these.videoHexArray.slice(startIndex, endIndex);
// 构建数据包
////console.log("packetData.length"+packetData.length);
const bufferSize = 504; // 头部5字节 + 数据部分
const buffer = new ArrayBuffer(bufferSize);
const dataView = new DataView(buffer);
let sortNo = currentPacket.toString(16).padStart(4, '0');
// 填充头部
dataView.setUint8(0, 0x55); // 帧头
dataView.setUint8(1, 0x04); // 帧类型:开机画面
dataView.setUint8(2, '0x' + sortNo.substring(0, 2)); // 包序号
dataView.setUint8(3, '0x' + sortNo.substring(2, 4)); // 包序号
// dataView.setUint8(4, 0x01);
// dataView.setUint8(5, 0xF4);
for (let i = 0; i < packetData.length; i++) {
dataView.setUint8(4 + i, '0x' + packetData[i]);
}
let inteval = 40;
ble.sendData(f.deviceId, buffer, f.writeServiceId, f
.wirteCharactId, 10).then(() => {
updateLoading(these, {
text: "正在发送:" + currentPacket + "/" +
totalPackets
})
currentPacket++;
// console.log("发送一段成功,发送下一段");
setTimeout(sendNextVideoPacket, inteval);
}).catch(err => {
console.log("发送失败了", err);
if (err.code == '10007') { //遇到这个错误自动重新发送
console.log(err.errMsg + ",发送失败了,正在补偿:" +
currentPacket);
setTimeout(sendNextVideoPacket, inteval);
} else {
hideLoading(these);
showPop({
showPop: true,
message: err.msg + ",发送失败了",
borderColor: "#e034344d",
buttonBgColor: "#E03434",
buttonText: "确定",
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png"
}, these);
reject(err);
these.videoHexArray = null;
return;
}
});
};
sendNextVideoPacket();
} else {
console.log("Fail.......")
}
});
}
var sendVideo = (videoPath) => {
let uploadVideo = () => {
these.videoHexArray = [];
console.log("开始处理,正在上传");
showLoading(these, {
text: "上传中"
});
let p1 = new Promise((resolve, reject) => {
ble.sendString(f.deviceId, "video transmit start", f
.writeServiceId, f.wirteCharactId).then(res => {
setTimeout(() => {
console.log("握手成功了");
resolve(true);
}, 2200)
}).catch(ex => {
reject(ex);
});
});
let p2 = new Promise((succ, err) => {
const token = uni.getStorageSync('token');
const clientid = uni.getStorageSync('clientID');
if (!token) {
err({
code: 401,
msg: "请先登陆后再试"
});
hideLoading(these);
return;
}
console.log("baseURL=", baseURL);
console.log("token", token);
console.log("clientID", clientid);
uni.uploadFile({
// url: 'http://114.55.111.217/video/upload',
url: baseURL + "/app/video/upload",
filePath: videoPath,
name: 'file',
header: {
"Method": "POST",
"Content-Type": "multipart/form-data",
"Authorization": 'Bearer ' + token,
"clientid": clientid
},
timeout: 600000,
fail: (ex) => {
console.log("上传视频失败" + JSON.stringify(ex));
err(ex);
},
success: (res) => {
console.log("上传完成,向蓝牙设备发送");
succ(res);
}
});
});
Promise.all([p1, p2]).then((arr) => {
if (arr[0].status == 'rejected') {
showPop({
message: "设备准备未就绪",
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
borderColor: "#e034344d",
buttonBgColor: "#E03434",
}, these);
return;
}
let res = arr[1];
// console.log("11111111111111111111111",res);
res = JSON.parse(res.data);
// console.log("22222222222222222222");
if (res.data) {
these.videoHexArray = res.data;
updateLoading(these, {
text: "正在发送:0/1536"
});
shotVideoClick(res.data);
} else {
console.log("服务器未返回正确的数据");
showPop({
message: "与服务器连接出现异常,请检查网络设置",
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
borderColor: "#e034344d",
buttonBgColor: "#E03434",
}, these);
}
}).catch((ex) => {
console.log("出现异常,", ex)
hideLoading(these);
showPop({
message: "出现异常," + ex.msg,
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
borderColor: "#e034344d",
buttonBgColor: "#E03434",
}, these);
})
}
let shotVideoClick = () => {
console.log("正在开始发送");
sendVideoPackets().then(() => {
console.log("发送完成");
}).catch((ex1) => {
//console.log("出现了异常", ex1)
}).finally(() => {
hideLoading(these);
});
}
uploadVideo();
}
uni.chooseVideo({
sourceType: ['album'],
compressed: false, // 关闭视频压缩,确保上传原始文件
success: function(res) {
console.log("res=", res);
let path = res.tempFilePath;
// iOS可能返回浮点数需要转换为整数进行比较
let width = Math.round(res.width);
let height = Math.round(res.height);
let duration = res.duration;
// 获取平台信息
const systemInfo = uni.getSystemInfoSync();
const platform = systemInfo.platform;
const isIOS = platform === 'ios';
console.log("平台:", platform, "uni.chooseVideo返回 - 宽度:", width, "高度:", height,
"时长:", duration);
// iOS特殊处理如果返回的是80*40很可能是160*80的一半iOS的bug
if (isIOS && width === 80 && height === 40) {
console.log("检测到iOS特殊情况返回80*40实际应该是160*80进行修正");
width = 160;
height = 80;
}
// 检查分辨率是否符合要求
let checkResolution = (w, h) => {
// 使用容差比较允许1像素的误差
return Math.abs(w - 160) <= 1 && Math.abs(h - 80) <= 1;
};
let err = [];
if (duration < 2) {
err.push("视频时长至少2秒");
}
if (!checkResolution(width, height)) {
err.push("视频宽高必须是160*80当前分辨率" + width + "*" + height);
}
if (err.length > 0) {
err = err.join(";");
showPop({
message: err,
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
borderColor: "#e034344d",
buttonBgColor: "#E03434",
}, these);
return;
}
showLoading(these, {
text: '正在上传'
});
setTimeout(() => {
sendVideo(path);
}, 0);
}
});
},
sendImg() {
if (!this.permissions.includes('3') && this.Status.apiType !== 'listA') {
MsgError('无操作权限', '确定', these);
return;
}
let f = this.getDevice();
// 处理像素数据并发送
var processAndSendImageData = function(pixels) {
return new Promise((resolve, reject) => {
// 创建RGB565格式的像素数据
const arr = Common.convertToRGB565(pixels, 'bgr');
var list = [];
let index = 0; // 用于追踪arr的当前位置
let packetSize = 2048;
let cSize = 248;
// 外层循环7个主要元素i从1到7
for (let i = 1; i < 8; i++) {
let secondLevel = [];
let secondCnt = 0;
// 中层循环每个主要元素包含9个子数组j从1到9
for (let j = 1; j < 10; j++) {
// 确定当前子数组的长度前8个是254第9个是64
let thirdLevel = [];
// 从arr中提取相应数量的元素
for (let k = 0; k < cSize && index < arr.length; k++) {
if (secondCnt == packetSize) {
break;
}
thirdLevel.push(arr[index]);
secondCnt++;
index++;
}
secondLevel.push(thirdLevel);
}
list.push(secondLevel);
}
console.log("list=", list);
let length = 0;
for (let i = 0; i < list.length; i++) {
const item = list[i];
let clength = 0;
for (let j = 0; j < item.length; j++) {
const element = item[j];
console.log("第" + i + "包,第" + j + "小包,长度:" + element.length)
length += element.length;
clength += element.length;
}
}
// 分包发送
sendImagePackets(list).then(resolve).catch(reject);
});
}
// 分包发送图片数据
var sendImagePackets = function(imageData) {
return new Promise((resolve, reject) => {
// 总数据包数
const totalPackets = 7;
let currentPacket = 1;
let childPacket = 1;
let totalChildPacket = 9;
// 发送单个数据包
const sendNextPacket = () => {
if (currentPacket > totalPackets) {
setTimeout(() => {
hideLoading(these);
MsgSuccess("上传成功", "确定", these);
resolve();
}, 3000)
return;
}
var packetData = imageData[currentPacket - 1][childPacket - 1];
let start = 0;
let bufferSize = packetData.length * 2;
if (currentPacket == 7) {
if (childPacket > 2 && childPacket < 9) {
bufferSize = 496;
} else if (childPacket == 9) {
bufferSize = 128;
}
}
if (childPacket == 1) {
bufferSize = bufferSize + 8
start = 8;
}
if (childPacket == 9) { //|| (currentPacket==7 && childPacket==3
bufferSize = bufferSize + 1
}
//FA 09 10 04 FC 09 [00] [01] + 4096字节+FF 数据格式
var buffer = new ArrayBuffer(bufferSize);
var dataView = new DataView(buffer);
if (childPacket == 1) {
dataView.setUint8(0, 0xFA); // 帧头
dataView.setUint8(1, 0x09); // 帧头
dataView.setUint8(2, 0x10); // 帧头
dataView.setUint8(3, 0x04); // 帧头
dataView.setUint8(4, 0xFC); // 帧头
dataView.setUint8(5, 0x09); // 帧头
dataView.setUint8(6, 0x00); // 图序号,图片固定0视频的话要写序号
dataView.setUint8(7, currentPacket); //子包序号
}
for (let i = 0; i < packetData.length; i++) {
dataView.setUint16(start + i * 2, packetData[i], false); //本包数据,大端字节序
}
console.log("packetData.length=", packetData.length);
console.log("bufferSize=", bufferSize)
if (childPacket == 9) { // || (currentPacket==7 && childPacket==3
dataView.setUint8(bufferSize - 1, 0xFF);
}
//发送数据包
ble.sendData(f.deviceId, buffer, f.writeServiceId, f.wirteCharactId,
30)
.then(() => {
let curr = childPacket + (currentPacket - 1) *
totalChildPacket;
console.log("第" + currentPacket + "大包,第" + childPacket +
"小包发送完成,总计:" + curr);
updateLoading(these, {
text: "正在发送" + curr + "/63"
})
if (childPacket == 9) {
currentPacket++;
childPacket = 1;
} else {
childPacket++;
}
setTimeout(sendNextPacket, 100);
}).catch(err => {
if (err.code == 10007) {
setTimeout(sendNextPacket, 100);
return;
}
console.log("发送数据包失败了", err);
showPop({
message: "发送数据包失败了" + err.msg,
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
borderColor: "#e034344d",
buttonBgColor: "#E03434",
});
hideLoading(these);
reject(err);
});
}
// 开始发送数据
sendNextPacket();
});
}
uni.chooseImage({
count: 1,
sizeType: ['original', 'compressed'],
sourceType: ['album'],
success: function(res) {
uni.navigateTo({
url: "/pages/6155/ImgCrop",
events: {
ImgCutOver: function(data) {
showLoading(these, {
text: "正在发送0/52"
});
setTimeout(function() {
processAndSendImageData(data.piexls).catch((
ex) => {
console.log("出现异常", ex);
});
}, 0)
}
},
success(ev) {
ev.eventChannel.emit('checkImg', {
data: res.tempFiles[0].path
})
},
fail(ex) {
console.log("跳转页面失败" + JSON.stringify(ex));
}
});
}
});
},
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 index = null;
if (type === 'main') {
index = 0;
item = this.dic.actionSheets[0];
} else {
index = 1;
item = this.dic.actionSheets[1];
}
let f = item.menuItems.find(v => {
if (v.value == this.dic.actionSheets[index].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.name = 'media';
item3.title = '选择媒体';
item3.menuItems = [{
text: '照片',
icon: '/static/images/lightImg/qiang.png',
value: 'img',
key: 'media'
},
{
text: '动画',
icon: '/static/images/lightImg/qiang.png',
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() {
if (!this.permissions.includes('42') && this.Status.apiType !== 'listA') {
MsgError('无操作权限', '确定', these);
return;
}
let val = 1;
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: '#232323de',
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.setBleFormData();
}).catch(ex => {
console.error("出现错误", ex)
});
}
if (val === 1) {
showPop({
message: "注意事项\n1.禁止直视光源或反向面! \n2.避免直射人或易燃物! \n3.需佩戴相应专业防护眼镜!",
borderColor: "#e034344d",
buttonBgColor: "#E03434",
buttonText: '确定',
buttonTextColor: '#232323de',
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;
this.setBleFormData();
}).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;
}
let toByteValue = (value) => {
if (typeof value === 'number') {
return value;
}
if (typeof value === 'string') {
if (value.startsWith('0x') || value.startsWith('0X')) {
return parseInt(value, 16);
}
return parseInt(`0x${value}`, 16);
}
return 0;
}
this.formData.textLines = [this.formData.company, this.formData.usrname, this.formData.job, this.formData
.usrid
];
console.log("data=", this.formData.textLines);
showLoading(these, {
text: "发送中"
});
//握手
let holdHand = (hexs, time) => {
return new Promise((resolve, reject) => {
this.sendData(hexs, 'ble', "string").then(res => {
setTimeout(() => {
resolve(res)
}, time);
}).catch(ex => {
reject(ex)
});
});
}
//画图
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 < 4; i++) {
let linePixels = (allPixels[i] || []).flat(Infinity).map(item =>
typeof item === 'string' ? toByteValue(item) : item
);
for (var j = linePixels.length; j < 256; j++) {
linePixels.push(0x00);
}
linePixels = [0xFA, 0x06, 0x03, i + 1].concat(linePixels);
linePixels.push(0xFF)
combinedData.push(linePixels);
}
let curr = 1;
let len = combinedData.length;
//分包发送
let sendPacket = () => {
if (combinedData.length === curr - 1) {
holdHand('transmit complete', 200).then(res => {
MsgSuccess("人员信息发送成功", "确定", these);
hideLoading(these);
this.setBleFormData();
});
hideLoading();
return;
}
let array = combinedData[curr - 1];
console.log("array=", array);
ble.sendHexs(f.deviceId, array, null, null, 15).then(
res => {
curr++;
console.log("发送成功", curr);
updateLoading(these, {
text: '发送中,' + (curr - 1) + '/' + 4
})
setTimeout(sendPacket, 250);
}).catch(err => {
console.err("发送失败", err);
if (err.code == '10007') {
setTimeout(sendPacket, 250);
} else {
console.log("err:", err);
MsgError('发送失败' + (err.msg || err.code), '确定', these);
hideLoading();
}
});
}
setTimeout(sendPacket, 0);
// 5. 发送成功处理
} catch (ex) {
MsgError('发送失败' + (ex.msg || ex.code), '确定', these);
}
}
setTimeout(() => {
Promise.allSettled([holdHand('word transmit start', 2200), drawText()]).then(results => {
if (results[0].status == 'rejected') {
setTimeout(() => {
hideLoading(these)
}, 500);
return;
}
if (results[1].status == 'rejected') {
return;
}
task(results[1].value);
})
}, 0);
},
sendMsg() {
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) {
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, 500);
}).catch(err => {
if (err.code == '10007') {
setTimeout(sendPacket, 500);
} 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() {
console.log("LinkedList=", ble.data.LinkedList);
console.log("this.device=", this.device);
let f = ble.data.LinkedList.find((v) => {
if(v.macAddress == these.device.deviceMac){
if(!this.formData.deviceId){this.formData.deviceId=v.deviceId};
return true;
}
});
return f;
},
showBleUnConnect() {
showPop({
message: "蓝牙未连接过该设备,请使用蓝牙重新添加该设备",
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
borderColor: "#e034344d",
buttonBgColor: "#E03434",
buttonText: '去连接',
buttonTextColor: '#232323de',
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.setBleFormData();
},
setBleFormData() {
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;
setTimeout(() => {
hideLoading(these, 1000);
});
uni.showToast({
icon: 'success',
title: '蓝牙连接成功'
});
}
},
deviceDispose(res) {
if (this.Status.pageHide) {
return;
}
if (res.deviceId == these.formData.deviceId) {
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
})
}).finally(() => {
setTimeout(() => {
hideLoading(these);
}, 1000);
});
},
gotoMap() {
let promise = 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
});
}
})
});
},
proDetail: function(pgetpe) {
let url = '/pages/common/' + pgetpe + '/index?id=' + (this.device.id ? this.device.id : 0);
uni.navigateTo({
url: url,
fail(ex) {
console.error(ex);
}
});
},
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;
}
.proinfo .itemcontent {
display: flex;
display: flex;
flex-direction: row;
flex-wrap: nowrap;
align-content: center;
justify-content: space-evenly;
}
.proinfo .item {
width: 180rpx;
height: 180rpx;
box-sizing: border-box;
padding: 40rpx;
border-radius: 16rpx;
background: rgba(26, 26, 26, 1);
display: flex;
flex-direction: column;
flex-wrap: nowrap;
align-content: center;
justify-content: center;
align-items: center;
}
.proinfo .item .img {
width: 50rpx;
height: 50rpx;
}
.proinfo .item .txt {
color: rgba(255, 255, 255, 0.6);
font-family: PingFang SC;
font-size: 24rpx;
font-weight: 400;
margin-top: 20rpx;
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: 20rpx;
}
.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;
}
</style>