018A初步完成
This commit is contained in:
15
App.vue
15
App.vue
@ -35,6 +35,10 @@
|
||||
//以上代码仅在开发时使用,否则会出现不可预知的问题。
|
||||
|
||||
// #ifdef APP|APP-PLUS
|
||||
|
||||
let system=uni.getSystemInfoSync();
|
||||
|
||||
|
||||
let initOS = () => {
|
||||
let ble = bleTool.getBleTool();
|
||||
|
||||
@ -48,14 +52,17 @@
|
||||
}
|
||||
});
|
||||
if (!uni.setAppBadgeNumber) { //兼容鸿蒙的写法
|
||||
if(plus){
|
||||
uni.setAppBadgeNumber = plus.runtime.setBadgeNumber;
|
||||
}
|
||||
|
||||
}
|
||||
uni.onPushMessage((res) => {
|
||||
console.log("收到推送消息:", res); //监听推送消息
|
||||
if (res.type == 'click') {
|
||||
//将App角标设置为0,清空app在消息中心的所有消息
|
||||
uni.setAppBadgeNumber(0);
|
||||
plus.push.clear();
|
||||
plus && plus.push.clear();
|
||||
return;
|
||||
}
|
||||
uni.createPushMessage({
|
||||
@ -66,6 +73,7 @@
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
if (plus.os.name == 'Android') {
|
||||
if (plus.runtime.isAgreePrivacy()) {
|
||||
initOS();
|
||||
@ -75,7 +83,7 @@
|
||||
}
|
||||
|
||||
|
||||
let system=uni.getSystemInfoSync();
|
||||
|
||||
console.log("system=",system);
|
||||
// #endif
|
||||
},
|
||||
@ -206,6 +214,9 @@
|
||||
color: #ffffffde;
|
||||
}
|
||||
|
||||
.uni-app--maxwidth,.uni-body{
|
||||
background-color: #121212;
|
||||
}
|
||||
|
||||
.fleft {
|
||||
float: left;
|
||||
|
||||
@ -33,7 +33,7 @@
|
||||
<image v-if="item.icon" :src="item.icon" mode="aspectFit"></image>
|
||||
</view>
|
||||
|
||||
<text>{{ item.text }}</text>
|
||||
<text class="itemTxt">{{ item.text }}</text>
|
||||
</view>
|
||||
|
||||
|
||||
@ -139,6 +139,9 @@
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.itemTxt{
|
||||
text-indent: 20rpx;
|
||||
}
|
||||
.message-popup {
|
||||
position: relative;
|
||||
display: none;
|
||||
|
||||
@ -135,30 +135,42 @@
|
||||
},
|
||||
methods: {
|
||||
getTypeStyle(styleType) {
|
||||
debugger;
|
||||
const styles = {
|
||||
success: {
|
||||
bgColor: '#f0fff0',
|
||||
borderColor: '#52c41a',
|
||||
bgColor: '#383934cc',
|
||||
borderColor: '#52c41a4d',
|
||||
textColor: '#389e0d',
|
||||
buttonBgColor: '#52c41a',
|
||||
buttonTextColor: '#FFFFFF'
|
||||
},
|
||||
error: {
|
||||
bgColor: '#fff0f0',
|
||||
borderColor: '#ff4d4f',
|
||||
bgColor: '#383934cc',
|
||||
borderColor: '#ff4d4f4d',
|
||||
textColor: '#cf1322',
|
||||
buttonBgColor: '#ff4d4f',
|
||||
buttonTextColor: '#FFFFFF'
|
||||
},
|
||||
info: {
|
||||
bgColor: '#e6f7ff',
|
||||
bgColor: '#383934cc',
|
||||
borderColor: '#1890ff',
|
||||
textColor: '#0050b3',
|
||||
buttonBgColor: '#1890ff',
|
||||
buttonTextColor: '#FFFFFF'
|
||||
},
|
||||
customer:{
|
||||
bgColor: '#383934cc',
|
||||
borderColor: '#52c41a4d',
|
||||
textColor: '#389e0d',
|
||||
buttonBgColor: '#52c41a',
|
||||
buttonTextColor: '#232323de'
|
||||
}
|
||||
}
|
||||
return styles[this.type][styleType]
|
||||
let f= styles[this.type];
|
||||
if(f){
|
||||
return f[styleType];
|
||||
}
|
||||
|
||||
},
|
||||
handleButtonClick() {
|
||||
|
||||
|
||||
@ -140,25 +140,28 @@
|
||||
icoUrl: '/static/images/common/uploadErr.png',
|
||||
borderColor: "#e034344d",
|
||||
buttonBgColor: "#E03434",
|
||||
bgColor:'#38393466',
|
||||
bgColor:'#383934cc',
|
||||
buttonTextColor:'#FFFFFFde'
|
||||
},
|
||||
succ: {
|
||||
icoUrl: '/static/images/common/success.png',
|
||||
borderColor: "#BBE6004d",
|
||||
buttonBgColor: "#BBE600",
|
||||
bgColor:'#38393466'
|
||||
buttonTextColor:'#232323de',
|
||||
bgColor:'#383934cc'
|
||||
},
|
||||
warn: {
|
||||
icoUrl: '/static/images/common/warning.png',
|
||||
borderColor: "#FFC84E4d",
|
||||
buttonBgColor: "#FFC84E",
|
||||
bgColor:'#38393466'
|
||||
buttonTextColor:'#FFFFFFde',
|
||||
bgColor:'#383934cc'
|
||||
},
|
||||
info:{
|
||||
borderColor: "#BBE6004d",
|
||||
buttonBgColor: "#BBE600",
|
||||
bgColor:'#38393466'
|
||||
bgColor:'#383934cc',
|
||||
buttonTextColor:'#232323de'
|
||||
},
|
||||
prompt:{
|
||||
|
||||
|
||||
@ -29,7 +29,7 @@
|
||||
},
|
||||
currentCanvasWidth: {
|
||||
type: Number,
|
||||
default: 80
|
||||
default: 96
|
||||
},
|
||||
currentCanvasHeight: {
|
||||
type: Number,
|
||||
@ -147,22 +147,10 @@
|
||||
let a = imageData[k + 3];
|
||||
|
||||
|
||||
// if (r === 255 && a >= 0) {
|
||||
// r = 255;
|
||||
// } else {
|
||||
// r = 0;
|
||||
// }
|
||||
|
||||
|
||||
// if (r === 255) {
|
||||
// tmpArr.push(1);
|
||||
// } else {
|
||||
// tmpArr.push(0);
|
||||
// }
|
||||
|
||||
|
||||
// 黑色像素(R值较低)视为1,白色视为0
|
||||
let isBlack = r < 128;
|
||||
// let isBlack = r < 128;
|
||||
let gray = (r + g + b) / 3;
|
||||
let isBlack = gray < 255 ;
|
||||
|
||||
let byte1 = 0;
|
||||
|
||||
@ -216,7 +204,7 @@
|
||||
ctx.setTextBaseline('middle');
|
||||
// ctx.setTextAlign('center')
|
||||
ctx.setFontSize(this.fontSize);
|
||||
ctx.font = `${this.fontSize}px "PingFangBold", "PingFang SC", Arial, sans-serif`;
|
||||
ctx.font = `${this.fontSize}px "PingFang SC","PingFangBold", Arial, sans-serif`;
|
||||
|
||||
// 4. 绘制当前行文本
|
||||
let currentX = 0;
|
||||
|
||||
@ -167,7 +167,7 @@
|
||||
ctx.setTextBaseline('middle');
|
||||
// ctx.setTextAlign('center')
|
||||
ctx.setFontSize(this.fontSize);
|
||||
ctx.font = `${this.fontSize}px "PingFangBold", "PingFang SC", Arial, sans-serif`;
|
||||
ctx.font = `${this.fontSize}px "PingFang SC","PingFangBold", Arial, sans-serif`;
|
||||
|
||||
// 4. 绘制当前行文本
|
||||
let currentX = 0;
|
||||
|
||||
@ -171,7 +171,7 @@
|
||||
ctx.setTextBaseline('middle');
|
||||
// ctx.setTextAlign('center')
|
||||
ctx.setFontSize(this.fontSize);
|
||||
ctx.font = `${this.fontSize}px PingFangBold", "PingFang SC", Arial, sans-serif`;
|
||||
ctx.font = `${this.fontSize}px "PingFang SC",PingFangBold", Arial, sans-serif`;
|
||||
|
||||
// 4. 绘制当前行文本
|
||||
let currentX = 0;
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
const config = {
|
||||
// 开发环境
|
||||
development: {
|
||||
BASE_URL: 'http://192.168.2.34:8000',//http://139.224.253.23:8000
|
||||
BASE_URL: 'http://192.168.110.57:8000',//http://139.224.253.23:8000
|
||||
API_PREFIX: '',
|
||||
// MQTT 配置
|
||||
MQTT_HOST: '47.120.79.150',
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
"name" : "星汉物联",
|
||||
"appid" : "__UNI__A21EF43",
|
||||
"description" : "设备管控",
|
||||
"versionName" : "1.0.24",
|
||||
"versionName" : "1.0.25",
|
||||
"versionCode" : 101,
|
||||
"transformPx" : false,
|
||||
/* 5+App特有相关 */
|
||||
|
||||
21
pages.json
21
pages.json
@ -180,7 +180,14 @@
|
||||
{
|
||||
"path": "pages/common/allShare/index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "所有分享"
|
||||
"navigationBarTitleText": "所有分享",
|
||||
"app-plus": {
|
||||
"pullToRefresh": {
|
||||
"support": false, // 开启下拉刷新
|
||||
"color": "#FF5500", // 刷新图标颜色,仅 circle 样式支持
|
||||
"style": "default" // 可选 "default" 或 "circle"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@ -466,6 +473,18 @@
|
||||
"navigationStyle": "custom",
|
||||
"navigationBarTitleText": "HBY210"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/common/sosSet/TxtMsgSetting",
|
||||
"style": {
|
||||
"navigationBarTitleText": "短信设置"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/common/sosSet/LinkManSetting",
|
||||
"style": {
|
||||
"navigationBarTitleText": "紧急联系人"
|
||||
}
|
||||
}
|
||||
|
||||
],
|
||||
|
||||
@ -112,9 +112,11 @@
|
||||
apiType: "listA",
|
||||
navbar: {
|
||||
icons: [{
|
||||
type:'msg',
|
||||
src: '/static/images/common/msg.png'
|
||||
},
|
||||
{
|
||||
type:'share',
|
||||
src: '/static/images/common/shape.png'
|
||||
}
|
||||
],
|
||||
@ -318,6 +320,37 @@
|
||||
}
|
||||
|
||||
|
||||
},
|
||||
getDevice: function() {
|
||||
let f = ble.data.LinkedList.find((v) => {
|
||||
return v.macAddress == these.device.deviceMac;
|
||||
});
|
||||
|
||||
return f;
|
||||
},
|
||||
showBleUnConnect() {
|
||||
MsgError("蓝牙未连接过该设备,请使用蓝牙重新添加该设备", "去连接", these, () => {
|
||||
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
|
||||
})
|
||||
},
|
||||
fail(ex) {
|
||||
console.log("跳转失败", ex);
|
||||
}
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
},
|
||||
initMQ() {
|
||||
|
||||
|
||||
@ -13,15 +13,7 @@
|
||||
<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_charge?dic.sta_charge[formData.sta_charge+'']:"未充电" }}
|
||||
</view>
|
||||
<view class="smallTxt">设备状态</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
</view>
|
||||
<view class="eqinfo">
|
||||
@ -38,27 +30,53 @@
|
||||
<text class="lbl">蓝牙名称</text>
|
||||
<text class="value">{{device.bluetoothName}}</text>
|
||||
</view>
|
||||
<view class="item">
|
||||
<view class="item" @click.top="bleStatuToggle">
|
||||
<text class="lbl">蓝牙状态</text>
|
||||
<text class="value" :class="formData.bleStatu?'green':'red'">{{formData.bleStatu?'已连接':'未连接'}}</text>
|
||||
<text class="value" :class="formData.bleStatu?'green':'red'">{{getbleStatu}}</text>
|
||||
</view>
|
||||
<view class="item">
|
||||
<text class="lbl">设备状态</text>
|
||||
<text class="value">{{formData.sta_charge?dic.sta_charge[formData.sta_charge+'']:"未充电" }}</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 class="warnnig">
|
||||
<view>设备静止报警中!</view>
|
||||
</view>
|
||||
<view class="warnnig">
|
||||
<view>设备声光报警中!</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="warnnig" v-show="formData.sta_ShakeBit!='' && formData.sta_ShakeBit!='0'">
|
||||
<view>{{ShakeBit}}</view>
|
||||
</view>
|
||||
|
||||
|
||||
<view class="lampMode">
|
||||
<view class="sosContent">
|
||||
<view class="btnSos openSos center" :class="{active:formData.sta_LedType==='led_alarm'}"
|
||||
@click="sosSetting(dic.sta_LightType[4],4)">
|
||||
{{formData.sta_LedType==='led_alarm'?'报警中':'声光报警'}}
|
||||
<view class="btnSos openSos center"
|
||||
:class="{active:formData.sta_ShakeBit=='1'||formData.sta_ShakeBit==1}" @click="sosToggle(1)">
|
||||
{{formData.sta_ShakeBit==='1'?'报警中':'强制报警'}}
|
||||
</view>
|
||||
<view class="btnSos closeSos center" @click="sosSetting(dic.sta_LightType[3],3)">解除</view>
|
||||
<view class="btnSos closeSos center" @click="sosToggle(0)">解除</view>
|
||||
|
||||
</view>
|
||||
|
||||
@ -72,13 +90,11 @@
|
||||
</view>
|
||||
|
||||
<view class="lampMode">
|
||||
<view class="mode fleft " v-for="item,index in dic.sta_LightType.filter(v=>{return v.group=='sta_LedType'})"
|
||||
:class="{'active':formData[item.group]===item.key,
|
||||
'marginLeft':index%2===1,
|
||||
'displayNone':!item.show
|
||||
}" v-on:click.stop="LighSetting(item,index)">
|
||||
<view class="mode fleft " v-for="item,index in dic.sta_Side_Light" :class="{'active':formData.sta_Side_Light==item.key,'marginLeft':index%2===1
|
||||
}" @click.stop="LighSetting(item,index)">
|
||||
<view class="leftImg">
|
||||
<image class="img" :src="formData[item.group]===item.key?item.activeImg:item.img" mode="aspectFit">
|
||||
<image class="img" :src="formData.sta_Side_Light==item.key?item.activeImg:item.img"
|
||||
mode="aspectFit">
|
||||
</image>
|
||||
|
||||
</view>
|
||||
@ -88,6 +104,30 @@
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="mode fleft marginLeft" @click.stop="gotoPage('TxtMsgSetting')">
|
||||
<view class="leftImg">
|
||||
<image class="img" src="/static/images/common/shortMsg.png" mode="aspectFit">
|
||||
</image>
|
||||
|
||||
</view>
|
||||
<view class="rightTxt">
|
||||
<text class="bigTxt">短信设置</text>
|
||||
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="mode fleft " @click.stop="gotoPage('LinkManSetting')">
|
||||
<view class="leftImg">
|
||||
<image class="img" src="/static/images/common/linkMan.png" mode="aspectFit">
|
||||
</image>
|
||||
|
||||
</view>
|
||||
<view class="rightTxt">
|
||||
<text class="bigTxt">紧急联系人</text>
|
||||
|
||||
</view>
|
||||
</view>
|
||||
|
||||
|
||||
|
||||
<view class="clear"></view>
|
||||
@ -103,6 +143,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import api from '@/api/670/HBY670.js';
|
||||
import gbk from '@/utils/gbk.js'
|
||||
import BleTool from '@/utils/BleHelper.js'
|
||||
import BleReceive from '@/utils/BleReceive';
|
||||
@ -117,21 +158,25 @@
|
||||
MsgClose,
|
||||
MsgWarning,
|
||||
showPop,
|
||||
MsgInfo
|
||||
MsgInfo,
|
||||
MsgClear
|
||||
} from '@/utils/MsgPops.js'
|
||||
import request, {
|
||||
baseURL
|
||||
} from '@/utils/request.js'
|
||||
import lnglatConvert from '@/utils/wgs84_to_gcj02.js';
|
||||
|
||||
import Common from '@/utils/Common.js';
|
||||
import MqttClient from '@/utils/mqtt.js';
|
||||
|
||||
import Common from '@/utils/Common.js'
|
||||
const pagePath = "/pages/018A/HBY018A";
|
||||
|
||||
var ble = null;
|
||||
var these = null;
|
||||
var recei = null;
|
||||
|
||||
var mq = null;
|
||||
var instrusionTime = null;
|
||||
|
||||
var reGeoTime = null;
|
||||
|
||||
|
||||
export default {
|
||||
@ -146,70 +191,46 @@
|
||||
usrToggle: false,
|
||||
},
|
||||
formData: {
|
||||
img: '/static/images/common/HBY102.png',
|
||||
sta_PowerPercent: '',
|
||||
xuhang: '',
|
||||
blename: '',
|
||||
img: '/static/images/common/HBY018A.png',
|
||||
deviceId: '',
|
||||
deviceName: '',
|
||||
RSSI: '',
|
||||
statu: '',
|
||||
sta_address: '',
|
||||
bleStatu: false,
|
||||
sta_charge: '',
|
||||
sta_LedType: '',
|
||||
sta_RadarType: '',
|
||||
sta_Online: '',
|
||||
warnTime: '',
|
||||
sta_sosadd: "",
|
||||
sta_sosName: '',
|
||||
sta_IntrusTime: ''
|
||||
|
||||
address: '湖北省武汉市洪山区关山街道宏宇楼',
|
||||
sta_longitude: "114.409500",
|
||||
sta_latitude: "30.495455",
|
||||
sta_PowerPercent: '', //电量
|
||||
sta_Side_Light: 0, //灯光状态
|
||||
sta_ShakeBit: 0, //报警状态
|
||||
sta_system: '', //0关机 1关机充电 2开机未充电 3开机充电
|
||||
bleStatu: '',
|
||||
},
|
||||
dic: {
|
||||
sta_LightType: [
|
||||
sta_Side_Light: [
|
||||
|
||||
{
|
||||
key: 'led_flash',
|
||||
name: '红色爆闪',
|
||||
show: true,
|
||||
img: '/static/images/100/light.png',
|
||||
activeImg: '/static/images/100/lightActive.png',
|
||||
group: 'sta_LedType'
|
||||
},
|
||||
{
|
||||
key: 'led_low_flash',
|
||||
key: 1,
|
||||
name: '红色慢闪',
|
||||
show: true,
|
||||
img: '/static/images/102/lowFlash.png',
|
||||
activeImg: '/static/images/102/lowFlashActive.png',
|
||||
group: 'sta_LedType'
|
||||
group: 'sta_Side_Light'
|
||||
},
|
||||
{
|
||||
key: 'led_steady',
|
||||
key: 3,
|
||||
name: '红色快闪',
|
||||
show: true,
|
||||
img: '/static/images/100/light.png',
|
||||
activeImg: '/static/images/100/lightActive.png',
|
||||
group: 'sta_Side_Light'
|
||||
},
|
||||
{
|
||||
key: 2,
|
||||
name: '红色常亮',
|
||||
show: true,
|
||||
img: '/static/images/102/liting.png',
|
||||
activeImg: '/static/images/102/litingActive.png',
|
||||
group: 'sta_LedType'
|
||||
},
|
||||
{
|
||||
key: 'led_off',
|
||||
name: '关闭',
|
||||
show: false,
|
||||
img: '/static/images/100/light.png',
|
||||
activeImg: '/static/images/100/lightActive.png',
|
||||
group: 'sta_LedType'
|
||||
},
|
||||
{
|
||||
key: 'led_alarm',
|
||||
name: '爆闪+喇叭',
|
||||
show: false,
|
||||
img: '/static/images/100/light.png',
|
||||
activeImg: '/static/images/100/lightActive.png',
|
||||
group: 'sta_LedType'
|
||||
group: 'sta_Side_Light'
|
||||
}
|
||||
|
||||
|
||||
],
|
||||
sta_charge: {
|
||||
"0": '未充电',
|
||||
@ -230,11 +251,14 @@
|
||||
bindingTime: "",
|
||||
onlineStatus: 0,
|
||||
battery: "0",
|
||||
latitude: null,
|
||||
longitude: null,
|
||||
latitude: '30.495455',
|
||||
longitude: '114.409500',
|
||||
alarmStatus: null,
|
||||
detailPageUrl: "/pages/650/HBY650",
|
||||
showConfirm: false
|
||||
detailPageUrl: "/pages/018A/HBY018A",
|
||||
showConfirm: false,
|
||||
contact1Phone: "",
|
||||
contact2Phone: "",
|
||||
sosSmsMsg: ""
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -257,27 +281,21 @@
|
||||
ble.addDisposeCallback(this.deviceDispose, pagePath);
|
||||
ble.addRecoveryCallback(this.deviceRecovry, pagePath);
|
||||
|
||||
this.initWatch();
|
||||
|
||||
|
||||
let eventChannel = this.getOpenerEventChannel();
|
||||
|
||||
eventChannel.on('detailData', function(data) {
|
||||
eventChannel.on('detailData', (data) => {
|
||||
|
||||
// console.log("收到父页面的参数:" + JSON.stringify(data));
|
||||
var device = data.data;
|
||||
these.device = device;
|
||||
let f = ble.data.LinkedList.find((v) => {
|
||||
if (v.macAddress == device.deviceMac) {
|
||||
// console.log("找到设备了", v);
|
||||
these.formData.deviceId = v.deviceId;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
this.getDeviceDetail();
|
||||
let f = these.getDevice();
|
||||
if (!f) {
|
||||
|
||||
|
||||
these.showBleUnConnect();
|
||||
|
||||
return;
|
||||
}
|
||||
let form = f.formData;
|
||||
@ -318,146 +336,391 @@
|
||||
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);
|
||||
});;
|
||||
});
|
||||
}
|
||||
},
|
||||
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 '未连接';
|
||||
},
|
||||
ShakeBit() {
|
||||
let dic = {
|
||||
"1": "设备SOS求救中",
|
||||
"2": "设备静止报警中",
|
||||
"6": "设备遇水报警中"
|
||||
};
|
||||
let keys = Object.keys(dic);
|
||||
let f = keys.find(key => {
|
||||
if (key == this.formData.sta_ShakeBit) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
if (f) {
|
||||
return dic[f];
|
||||
}
|
||||
return "";
|
||||
|
||||
}
|
||||
|
||||
},
|
||||
methods: {
|
||||
getDeviceDetail() {
|
||||
api.getDetail(this.device.id).then(res => {
|
||||
|
||||
LighSetting(item, index) {
|
||||
let val = item.key;
|
||||
if (item.key === this.formData.sta_LedType) {
|
||||
val = 'led_off';
|
||||
if (res && res.code == 200) {
|
||||
let data = res.data;
|
||||
let keys = Object.keys(data);
|
||||
let dKeys=Object.keys(this.device);
|
||||
for (let i = 0; i < keys.length; i++) {
|
||||
let key = keys[i];
|
||||
|
||||
let dk=dKeys.find(k=>{
|
||||
return key.toLowerCase()==k.toLowerCase();
|
||||
});
|
||||
if(dk){
|
||||
this.$set(this.device,dk,data[key]);
|
||||
}else{
|
||||
this.$set(this.device,key,data[key]);
|
||||
}
|
||||
|
||||
let f = this.getDevice();
|
||||
|
||||
// #ifdef APP-PLUS
|
||||
if (!f) {
|
||||
this.showBleUnConnect();
|
||||
return;
|
||||
}
|
||||
// #endif
|
||||
// #ifdef H5
|
||||
f = {
|
||||
deviceId: '12345'
|
||||
}
|
||||
// #endif
|
||||
|
||||
let json = {
|
||||
ins_LedType: val
|
||||
}
|
||||
json = JSON.stringify(json);
|
||||
ble.sendString(f.deviceId, json, f.writeServiceId, f.wirteCharactId, 30).then(res => {
|
||||
this.formData.sta_LedType = val;
|
||||
these.setBleFormData();
|
||||
|
||||
}).catch(ex => {
|
||||
MsgError(ex.msg,'',these);
|
||||
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
sosSetting(item, isOk) {
|
||||
|
||||
if (item.key == 'led_alarm' && this.formData.sta_LedType == 'led_alarm') {
|
||||
return;
|
||||
}
|
||||
|
||||
if (item.key == 'led_off' && this.formData.sta_LedType !== 'led_alarm') {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
bleStatuToggle() {
|
||||
let f = this.getDevice();
|
||||
|
||||
// #ifdef APP-PLUS
|
||||
if (!f) {
|
||||
this.showBleUnConnect();
|
||||
return;
|
||||
}
|
||||
// #endif
|
||||
// #ifdef H5
|
||||
f = {
|
||||
deviceId: '12345'
|
||||
if (this.formData.bleStatu === true) {
|
||||
this.formData.bleStatu = 'dicconnect';
|
||||
ble.disconnectDevice(f.deviceId).finally(r => {
|
||||
this.formData.bleStatu = false;
|
||||
});
|
||||
return;
|
||||
}
|
||||
// #endif
|
||||
debugger;
|
||||
let task = (val) => {
|
||||
let promise = new Promise((resolve, reject) => {
|
||||
let json = {
|
||||
ins_LedType: val
|
||||
}
|
||||
json = JSON.stringify(json);
|
||||
ble.sendString(f.deviceId, json, f.writeServiceId, f.wirteCharactId, 30).then(res => {
|
||||
this.formData.sta_LedType = val;
|
||||
these.setBleFormData();
|
||||
resolve();
|
||||
|
||||
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 => {
|
||||
|
||||
}).catch(ex => {
|
||||
MsgError(ex.msg,'',these);
|
||||
these.formData.bleStatu = 'err';
|
||||
MsgError("连接错误:" + ex.msg, "确定", these);
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
},
|
||||
initWatch() {
|
||||
this.$watch("formData.sta_PowerPercent", (newVal, oldVal) => {
|
||||
console.log("电量发生变化");
|
||||
if (newVal <= 20 && (this.formData.sta_system === 2 || this.formData.sta_system === 0)) {
|
||||
MsgError("设备电量低于20%,请充电", '', these);
|
||||
}
|
||||
});
|
||||
this.$watch("device.deviceImei", (newVal, oldVal) => {
|
||||
|
||||
if (newVal) {
|
||||
these.initMQ();
|
||||
}
|
||||
});
|
||||
|
||||
this.$watch("formData.sta_longitude", (newVal, oldVal) => {
|
||||
if (newVal) {
|
||||
this.reGeo();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
this.$watch("formData.sta_latitude", (newVal, oldVal) => {
|
||||
if (newVal) {
|
||||
this.reGeo();
|
||||
}
|
||||
});
|
||||
|
||||
},
|
||||
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];
|
||||
|
||||
Common.regeo(lnglat[0], lnglat[1]).then(res => {
|
||||
this.formData.address = res.regeocode.formatted_address
|
||||
}).catch(ex => {
|
||||
console.error("逆地理失败了")
|
||||
})
|
||||
}).catch(err => {
|
||||
console.error("坐标转换失败了");
|
||||
});
|
||||
} else {
|
||||
console.error("经纬度缺失");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
clearTimeout(reGeoTime);
|
||||
reGeoTime = setTimeout(task, 500);
|
||||
},
|
||||
gotoPage(page) {
|
||||
uni.navigateTo({
|
||||
url: '/pages/common/sosSet/' + page,
|
||||
success(res) {
|
||||
res.eventChannel.emit('device', these.device);
|
||||
},
|
||||
events:{
|
||||
linkManOver:(data)=>{
|
||||
this.device.contact1Phone=data[0];
|
||||
this.device.contact2Phone=data[1];
|
||||
},
|
||||
MsgOver:(data)=>{
|
||||
this.device.sosSmsMsg=data;
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
showUnWarning() {
|
||||
MsgError("设备正在报警中", "", these);
|
||||
},
|
||||
sendCallback(json) {
|
||||
let keys = Object.keys(json);
|
||||
for (let i = 0; i < keys.length; i++) {
|
||||
let key = keys[i].replace('ins_', 'sta_');
|
||||
console.log("key=", key);
|
||||
this.formData[key] = json[keys[i]];
|
||||
console.log("this.formData[key] =", this.formData[key]);
|
||||
}
|
||||
},
|
||||
bleSend(json, validWarn = true) {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (this.formData.sta_ShakeBit != '' && this.formData.sta_ShakeBit != '0' && validWarn) {
|
||||
reject({
|
||||
code: -1
|
||||
});
|
||||
this.showUnWarning();
|
||||
return;
|
||||
}
|
||||
let f = this.getDevice();
|
||||
if (!f) {
|
||||
reject({
|
||||
code: -1
|
||||
});
|
||||
|
||||
this.showBleUnConnect();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
let str = "";
|
||||
if (json instanceof Object) {
|
||||
str = JSON.stringify(json);
|
||||
} else {
|
||||
str = json;
|
||||
}
|
||||
|
||||
ble.sendString(f.deviceId, str).then(() => {
|
||||
console.log("发送数据成功,", json);
|
||||
this.sendCallback(json);
|
||||
resolve();
|
||||
}).catch((ex) => {
|
||||
reject(ex);
|
||||
});
|
||||
});
|
||||
return promise;
|
||||
|
||||
}
|
||||
if (item.key == 'led_alarm') {
|
||||
showPop({
|
||||
message: '确定开启声光报警?',
|
||||
iconUrl: "/static/images/common/uploadErr.png",
|
||||
borderColor: "#e034344d",
|
||||
buttonBgColor: "#E03434",
|
||||
okCallback: () => {
|
||||
task("led_alarm");
|
||||
},
|
||||
buttonText: "开启",
|
||||
showCancel: true,
|
||||
buttonCancelText: '取消'
|
||||
},these);
|
||||
} else {
|
||||
if (this.formData.sta_LedType == 'led_alarm') {
|
||||
showPop({
|
||||
message: '确定解除声光报警模式?',
|
||||
iconUrl: "/static/images/common/uploadErr.png",
|
||||
borderColor: "#e034344d",
|
||||
buttonBgColor: "#E03434",
|
||||
okCallback: () => {
|
||||
task(item.key).then(r => {
|
||||
|
||||
|
||||
}).catch(ex => {
|
||||
|
||||
});
|
||||
},
|
||||
buttonText: "解除",
|
||||
showCancel: true,
|
||||
buttonCancelText: '取消'
|
||||
mqSend(json, validWarn = true) {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (this.formData.sta_ShakeBit != '' && this.formData.sta_ShakeBit != '0' && validWarn) {
|
||||
reject({
|
||||
code: -1
|
||||
});
|
||||
this.showUnWarning();
|
||||
return;
|
||||
}
|
||||
if (!mq) {
|
||||
reject({
|
||||
code: -2,
|
||||
msg: '消息队列未初始化'
|
||||
});
|
||||
|
||||
},these);
|
||||
return;
|
||||
}
|
||||
let str = "";
|
||||
if (json instanceof Object) {
|
||||
str = JSON.stringify(json);
|
||||
} else {
|
||||
task(item.key);
|
||||
str = json;
|
||||
}
|
||||
let flag = mq.publish("B/" + this.device.deviceImei, str);
|
||||
if (flag) {
|
||||
console.log("mq发送成功,", str)
|
||||
this.sendCallback(json);
|
||||
resolve(true);
|
||||
return;
|
||||
}
|
||||
|
||||
reject({
|
||||
code: 500,
|
||||
msg: '网络连接失败'
|
||||
});
|
||||
|
||||
});
|
||||
},
|
||||
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.device.deviceImei}`;
|
||||
mq.subscribe(statusTopic, (payload, receive) => {
|
||||
console.log("mq收到消息", payload)
|
||||
let json = JSON.parse(payload);
|
||||
this.receivData(json);
|
||||
});
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
|
||||
},
|
||||
gotoMap() {
|
||||
if (!this.formData.sta_longitude || !this.formData.sta_latitude) {
|
||||
MsgError("获取设备位置异常", '', these);
|
||||
return;
|
||||
}
|
||||
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
|
||||
});
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
},
|
||||
LighSetting(item, index) {
|
||||
let val = item.key;
|
||||
if (item.key === this.formData.sta_Side_Light) {
|
||||
val = 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
let json = {
|
||||
ins_Side_Light: val
|
||||
}
|
||||
this.bleSend(json, true).then(() => {}).catch(ex => {
|
||||
if (ex.code == -1) {
|
||||
return;
|
||||
}
|
||||
console.log("蓝牙发送失败,尝试用mq发送");
|
||||
this.mqSend(json, true).catch(err => {
|
||||
if (err.code == -1) {
|
||||
return;
|
||||
}
|
||||
console.error("mq发送失败", err);
|
||||
MsgError(err.msg, '', these);
|
||||
})
|
||||
})
|
||||
},
|
||||
|
||||
|
||||
sosToggle(type) {
|
||||
|
||||
|
||||
if (this.formData.sta_ShakeBit != 1 && this.formData.sta_ShakeBit != 0) {
|
||||
MsgError("设备正在报警中", '', these);
|
||||
return;
|
||||
}
|
||||
if (this.formData.sta_ShakeBit == type) {
|
||||
return;
|
||||
}
|
||||
let msg = type == 1 ? "确定开启强制报警" : '确定解除强制报警';
|
||||
|
||||
showPop({
|
||||
|
||||
message: msg,
|
||||
iconUrl: "/static/images/common/sgActive.png",
|
||||
borderColor: "#e034344d",
|
||||
buttonBgColor: "#E03434",
|
||||
buttonText: '确定',
|
||||
buttonTextColor: '#232323de',
|
||||
showCancel: true,
|
||||
buttonCancelText: "取消",
|
||||
cancelCallback: () => {
|
||||
|
||||
MsgClear(these);
|
||||
},
|
||||
okCallback: () => {
|
||||
let json = {
|
||||
ins_ShakeBit: type
|
||||
};
|
||||
|
||||
this.bleSend(json, false).catch(ex => {
|
||||
if (ex.code == -1) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.mqSend(json, false).catch(err => {
|
||||
if (err.code == -1) {
|
||||
return;
|
||||
}
|
||||
MsgError(err.msg, '', these);
|
||||
})
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}, these, false);
|
||||
|
||||
|
||||
},
|
||||
deviceRecovry(res) {
|
||||
if (this.Status.pageHide) {
|
||||
return;
|
||||
}
|
||||
console.log("蓝牙连接成功", these.formData);
|
||||
console.log("蓝牙连接成功", res);
|
||||
if (res.deviceId == these.formData.deviceId) {
|
||||
this.formData.bleStatu = true;
|
||||
setTimeout(() => {
|
||||
@ -471,9 +734,6 @@
|
||||
|
||||
},
|
||||
deviceDispose(res) {
|
||||
// if (this.Status.pageHide) {
|
||||
// return;
|
||||
// }
|
||||
if (res.deviceId == these.formData.deviceId) {
|
||||
if (res.device) {
|
||||
these.formData.bleStatu = 'connecting';
|
||||
@ -513,7 +773,7 @@
|
||||
text: "蓝牙恢复可用,正在连接设备"
|
||||
});
|
||||
ble.LinkBlue(these.formData.deviceId).then(() => {
|
||||
these.formData.bleStatu = true;
|
||||
|
||||
updateLoading(these, {
|
||||
text: '连接成功'
|
||||
});
|
||||
@ -551,46 +811,26 @@
|
||||
|
||||
console.log("json=", json)
|
||||
|
||||
|
||||
|
||||
let active = -1;
|
||||
let f = this.Status.BottomMenu.menuItems.find((item, index) => {
|
||||
|
||||
if (item.value === json.sta_RadarType) {
|
||||
active = index;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
let msg = [];
|
||||
if (json.sta_PowerPercent <= 20 && (json.sta_charge === 0 || json.sta_charge === '0')) {
|
||||
if (json.sta_PowerPercent <= 20 && (json.sta_system != 1 || json.sta_system != 3)) {
|
||||
msg.push("设备电量低");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
let keys = Object.keys(json);
|
||||
|
||||
keys.forEach(key => {
|
||||
if (key in this.formData) {
|
||||
// console.log("key=",key+",value=",json[key]);
|
||||
this.formData[key] = json[key];
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
if (msg.length > 0) {
|
||||
MsgError(msg.join(','), '', these);
|
||||
}
|
||||
|
||||
these.setBleFormData();
|
||||
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
getDevice: function() {
|
||||
|
||||
// console.log("LinkedList=", ble.data.LinkedList);
|
||||
@ -598,7 +838,9 @@
|
||||
let f = ble.data.LinkedList.find((v) => {
|
||||
return v.macAddress == these.device.deviceMac;
|
||||
});
|
||||
|
||||
if (f) {
|
||||
this.formData.deviceId = f.deviceId;
|
||||
}
|
||||
return f;
|
||||
},
|
||||
|
||||
@ -616,50 +858,57 @@
|
||||
uni.setStorageSync(ble.StorageKey, ble.data.LinkedList);
|
||||
},
|
||||
showBleUnConnect() {
|
||||
|
||||
showPop({
|
||||
message: "蓝牙未连接过该设备,请使用蓝牙重新添加该设备",
|
||||
iconUrl: "/static/images/common/uploadErr.png",
|
||||
borderColor: "#e034344d",
|
||||
buttonBgColor: "#E03434",
|
||||
buttonText: '去连接',
|
||||
buttonTextColor: '#FFFFFFde',
|
||||
okCallback: function() {
|
||||
|
||||
MsgError("蓝牙未连接过该设备,请使用蓝牙重新添加该设备", "", these, () => {
|
||||
uni.navigateTo({
|
||||
url: "/pages/common/addBLE/addEquip",
|
||||
events: {
|
||||
BindOver: function(data) {
|
||||
console.log(data)
|
||||
these.formData.bleStatu = true;
|
||||
}
|
||||
// BindOver: function(data) {
|
||||
// console.log(data)
|
||||
// these.formData.bleStatu = true;
|
||||
// }
|
||||
},
|
||||
success: function(res) {
|
||||
// 通过eventChannel向被打开页面传送数据
|
||||
res.eventChannel.emit('detailData', {
|
||||
data: these.device
|
||||
})
|
||||
},
|
||||
fail(ex) {
|
||||
console.log("跳转失败", ex);
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
}
|
||||
},these);
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.eqinfo .valueFont {
|
||||
font-family: 'PingFang SC';
|
||||
font-size: 28rpx !important;
|
||||
font-weight: 400;
|
||||
color: rgba(255, 255, 255, 0.6);
|
||||
}
|
||||
|
||||
.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;
|
||||
}
|
||||
|
||||
.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)
|
||||
}
|
||||
|
||||
.content {
|
||||
padding: 30rpx;
|
||||
box-sizing: border-box;
|
||||
@ -753,7 +1002,7 @@
|
||||
|
||||
.eqinfo .item {
|
||||
width: 100%;
|
||||
height: 60rpx;
|
||||
height: auto;
|
||||
line-height: 60rpx;
|
||||
padding: 0rpx 28rpx;
|
||||
box-sizing: border-box;
|
||||
|
||||
@ -339,36 +339,37 @@
|
||||
},
|
||||
dic: {
|
||||
sta_VoiceType: {
|
||||
"1": {
|
||||
key: "1",
|
||||
name: '消防',
|
||||
show: true
|
||||
},
|
||||
"2": {
|
||||
key: "2",
|
||||
name: '公安',
|
||||
show: true
|
||||
},
|
||||
"1": {
|
||||
key: "1",
|
||||
name: '消防',
|
||||
show: true
|
||||
},
|
||||
"3": {
|
||||
key: "3",
|
||||
name: '交警',
|
||||
show: true
|
||||
},
|
||||
"4": {
|
||||
key: "4",
|
||||
name: '市政',
|
||||
show: true
|
||||
},
|
||||
"5": {
|
||||
key: "5",
|
||||
name: '应急',
|
||||
show: true
|
||||
},
|
||||
|
||||
"6": {
|
||||
key: "6",
|
||||
name: '医疗',
|
||||
show: true
|
||||
},
|
||||
"4": {
|
||||
key: "4",
|
||||
name: '市政',
|
||||
show: true
|
||||
},
|
||||
"7": {
|
||||
key: "7",
|
||||
name: '铁道',
|
||||
|
||||
@ -334,26 +334,22 @@
|
||||
},
|
||||
dic: {
|
||||
sta_VoiceType: {
|
||||
"1": {
|
||||
key: "1",
|
||||
name: '消防',
|
||||
show: true
|
||||
},
|
||||
"0": {
|
||||
key: "0",
|
||||
name: '公安',
|
||||
show: true
|
||||
},
|
||||
"1": {
|
||||
key: "1",
|
||||
name: '消防',
|
||||
show: true
|
||||
},
|
||||
|
||||
"3": {
|
||||
key: "3",
|
||||
name: '交警',
|
||||
show: true
|
||||
},
|
||||
"4": {
|
||||
key: "4",
|
||||
name: '市政',
|
||||
show: true
|
||||
},
|
||||
"2": {
|
||||
key: "2",
|
||||
name: '应急',
|
||||
@ -364,6 +360,11 @@
|
||||
name: '医疗',
|
||||
show: true
|
||||
},
|
||||
"4": {
|
||||
key: "4",
|
||||
name: '市政',
|
||||
show: true
|
||||
},
|
||||
"5": {
|
||||
key: "5",
|
||||
name: '铁道',
|
||||
|
||||
@ -184,7 +184,8 @@
|
||||
isLock: false,
|
||||
empty: {
|
||||
tip: '暂无数据',
|
||||
hideScroll: false
|
||||
hideScroll: false,
|
||||
icon: '/static/images/common/empty.png'
|
||||
}
|
||||
},
|
||||
page: 1, // 当前页码
|
||||
|
||||
@ -193,6 +193,7 @@
|
||||
empty: {
|
||||
tip: "暂无数据",
|
||||
hideScroll: false,
|
||||
icon: '/static/images/common/empty.png'
|
||||
},
|
||||
textNoMore: "没有更多数据了",
|
||||
},
|
||||
|
||||
@ -25,17 +25,11 @@
|
||||
<view class="row">
|
||||
<image class="img" src="/static/images/common/battry.png" mode="aspectFit"></image>
|
||||
<view class="txt">
|
||||
<view class="bigTxt">{{formData.battary}}%</view>
|
||||
<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.xuhang}}</view>
|
||||
<view class="smallTxt">续航时间</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
</view>
|
||||
<view class="eqinfo">
|
||||
@ -91,12 +85,20 @@
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="warnnig" :class="ShakeBit?'':'displayNone'">
|
||||
<view>{{ShakeBit}}!</view>
|
||||
<view>{{AlarmTime}}</view>
|
||||
<uni-icons type="closeempty" size="16" color="#FFFFFF" @click="CloseWarn()"></uni-icons>
|
||||
</view>
|
||||
|
||||
|
||||
<view class="lampMode">
|
||||
<view class="mode " :class="{active:formData.sta_SOSGrade=='2'}" v-on:click.stop="sosSetting(2)">
|
||||
<view class="leftImg">
|
||||
<image v-show="formData.sta_SOSGrade!='2'" class="img" src="/static/images/670/rb.png" mode="aspectFit"></image>
|
||||
<image v-show="formData.sta_SOSGrade=='2'" class="img" src="/static/images/670/rbActive.png" mode="aspectFit"></image>
|
||||
<image v-show="formData.sta_SOSGrade!='2'" class="img" src="/static/images/670/rb.png"
|
||||
mode="aspectFit"></image>
|
||||
<image v-show="formData.sta_SOSGrade=='2'" class="img" src="/static/images/670/rbActive.png"
|
||||
mode="aspectFit"></image>
|
||||
</view>
|
||||
<view class="rightTxt">
|
||||
<text class="bigTxt">红蓝警示</text>
|
||||
@ -105,8 +107,10 @@
|
||||
</view>
|
||||
<view class="mode " :class="{active:formData.sta_SOSGrade=='1'}" v-on:click.stop="sosSetting(1)">
|
||||
<view class="leftImg">
|
||||
<image v-show="formData.sta_SOSGrade!='1'" class="img" src="/static/images/670/sg.png" mode="aspectFit"></image>
|
||||
<image v-show="formData.sta_SOSGrade=='1'" class="img" src="/static/images/670/sgActive.png" mode="aspectFit"></image>
|
||||
<image v-show="formData.sta_SOSGrade!='1'" class="img" src="/static/images/670/sg.png"
|
||||
mode="aspectFit"></image>
|
||||
<image v-show="formData.sta_SOSGrade=='1'" class="img" src="/static/images/670/sgActive.png"
|
||||
mode="aspectFit"></image>
|
||||
</view>
|
||||
<view class="rightTxt">
|
||||
<text class="bigTxt">声光报警</text>
|
||||
@ -114,18 +118,71 @@
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="mode " :class="{active:formData.sta_RadarType=='1'}" v-on:click.stop="redarSetting(1)">
|
||||
<view class="mode " :class="{active:formData.sta_RadarType=='1'}"
|
||||
v-on:click.stop="showAction">
|
||||
<view class="leftImg">
|
||||
<image v-show="formData.sta_RadarType=='1'" class="img" src="/static/images/102/redarActive.png" mode="aspectFit"></image>
|
||||
<image v-show="formData.sta_RadarType!='1'" class="img" src="/static/images/102/redar.png" mode="aspectFit"></image>
|
||||
<image v-show="formData.sta_RadarType=='1'" class="img" src="/static/images/102/redarActive.png"
|
||||
mode="aspectFit"></image>
|
||||
<image v-show="formData.sta_RadarType!='1'" class="img" src="/static/images/102/redar.png"
|
||||
mode="aspectFit"></image>
|
||||
</view>
|
||||
<view class="rightTxt">
|
||||
<text class="bigTxt">物体感应</text>
|
||||
<text class="smallTxt">{{formData.sta_RadarType=='1'?'开启':'关闭'}}</text>
|
||||
<text class="bigTxt">雷达感应</text>
|
||||
<text class="smallTxt">{{formData.sta_RadarType==0?'关闭':formData.sta_RadarType+'M'}}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
|
||||
<view class="mode " :class="{active:formData.sta_InfraRed=='1'}"
|
||||
v-on:click.stop="toggleSetting(1,'InfraRed')">
|
||||
<view class="leftImg">
|
||||
<image v-show="formData.sta_InfraRed=='1'" class="img" src="/static/images/common/hongwaiActive.png"
|
||||
mode="aspectFit"></image>
|
||||
<image v-show="formData.sta_InfraRed!='1'" class="img" src="/static/images/common/hongwai.png"
|
||||
mode="aspectFit"></image>
|
||||
</view>
|
||||
<view class="rightTxt">
|
||||
<text class="bigTxt">红外感应</text>
|
||||
<text class="smallTxt">{{formData.sta_InfraRed=='1'?'开启':'关闭'}}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
|
||||
<view class="usrinfo">
|
||||
<view>
|
||||
<text class="usrtitle fleft">人员信息登记</text>
|
||||
<view class="btnSend fright" v-on:click.stop="sendUsr">发送</view>
|
||||
<view class="clear"></view>
|
||||
<TextToHexV1 class="TextToHex" ref="textToHex" :txts="formData.textLines" :bgColor="'#FFFFFF'"
|
||||
:color="'#000000'" :fontSize="16" />
|
||||
</view>
|
||||
|
||||
<view class="item">
|
||||
<text class="lbl">单位:</text>
|
||||
<input class="value" v-model.trim="formData.textLines[0]" placeholder="请输入单位" maxlength="8"
|
||||
placeholder-class="usrplace" />
|
||||
</view>
|
||||
<view class="item">
|
||||
<text class="lbl">部门:</text>
|
||||
<input class="value" v-model.trim="formData.textLines[1]" placeholder="请输入姓名" maxlength="8"
|
||||
placeholder-class="usrplace" />
|
||||
</view>
|
||||
<view class="item">
|
||||
<text class="lbl">姓名:</text>
|
||||
<input class="value" v-model.trim="formData.textLines[2]" placeholder="请输入职位" maxlength="8"
|
||||
placeholder-class="usrplace" />
|
||||
</view>
|
||||
<view class="item">
|
||||
<text class="lbl">ID:</text>
|
||||
<input class="value" v-model.trim="formData.textLines[3]" placeholder="ID" maxlength="16"
|
||||
placeholder-class="usrplace" />
|
||||
</view>
|
||||
</view>
|
||||
|
||||
|
||||
|
||||
<BottomSlideMenuPlus :config="Status.BottomMenu" @btnClick="btnClick" @itemClick="itemClick" @close="closeActionSheet"></BottomSlideMenuPlus>
|
||||
<ProParams :id="device.id"></ProParams>
|
||||
<MsgBox ref="msgPop" />
|
||||
<global-loading ref="loading" />
|
||||
@ -133,6 +190,8 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import usrApi from '@/api/670/HBY670.js';
|
||||
import TextToHexV1 from '@/components/TextToHex/TextToHexV1.vue';
|
||||
import request from '@/utils/request.js';
|
||||
import {
|
||||
showLoading,
|
||||
@ -161,6 +220,9 @@
|
||||
var pagePath = "/pages/210/HBY210";
|
||||
|
||||
export default {
|
||||
components: {
|
||||
TextToHexV1
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
Status: {
|
||||
@ -181,10 +243,59 @@
|
||||
height: 90
|
||||
},
|
||||
usrToggle: true,
|
||||
bleLinkCnt: 0
|
||||
bleLinkCnt: 0,
|
||||
BottomMenu: {
|
||||
show: false,
|
||||
showHeader: true,
|
||||
menuItems: [{
|
||||
text: '2M',
|
||||
value: 2,
|
||||
icon: ''
|
||||
},
|
||||
{
|
||||
text: '4M',
|
||||
value: 4,
|
||||
icon: ''
|
||||
},
|
||||
{
|
||||
text: '7M',
|
||||
value: 7,
|
||||
icon: ''
|
||||
},
|
||||
{
|
||||
text: '10M',
|
||||
value: 10,
|
||||
icon: ''
|
||||
},
|
||||
{
|
||||
text: '关闭',
|
||||
value: 0,
|
||||
icon: ''
|
||||
}
|
||||
],
|
||||
activeIndex: -1,
|
||||
bgColor: '#2a2a2a',
|
||||
itemBgColor: '#3a3a3a',
|
||||
textColor: '#ffffffde',
|
||||
textAlign: 'flex-start',
|
||||
title: '雷达设置',
|
||||
showDivider: false,
|
||||
dividerColor: '#00000000',
|
||||
dividerThickness: '0rpx',
|
||||
dividerMargin: '10rpx',
|
||||
itemHeight: '80rpx',
|
||||
type: '',
|
||||
showBtn: true,
|
||||
btnBgColor: "#bbe600",
|
||||
btnText: "确定",
|
||||
btnTextColor: "#232323de",
|
||||
showMask: true,
|
||||
maskBgColor: '#00000066',
|
||||
showClose: false
|
||||
}
|
||||
},
|
||||
formData: {
|
||||
img: '/static/images/common/BJQ6075.png',
|
||||
img: '/static/images/common/HBY210.png',
|
||||
|
||||
|
||||
address: "", //地址
|
||||
@ -197,14 +308,17 @@
|
||||
deviceId: "",
|
||||
|
||||
bleStatu: false,
|
||||
|
||||
sta_AlarmTime:0,
|
||||
sta_PowerPercent: "",
|
||||
sta_PowerTime: "",
|
||||
sta_SOSGrade: '',
|
||||
sta_SOSGrade:0,
|
||||
sta_longitude: "",
|
||||
sta_latitude: "",
|
||||
sta_system: "", //设备状态,0关机,1仅充电,2开机未充电,3,开机且充电
|
||||
sta_RadarType:""
|
||||
sta_RadarType: "",
|
||||
sta_ShakeBit: 0, //报警状态
|
||||
sta_InfraRed:0,
|
||||
textLines: ['湖北星汉文化', '有限', '公司','12345678']
|
||||
},
|
||||
device: {
|
||||
id: "",
|
||||
@ -231,6 +345,35 @@
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
AlarmTime(){
|
||||
if(this.formData.sta_AlarmTime){
|
||||
return Common.formatTime(this.formData.sta_AlarmTime,"second");
|
||||
}
|
||||
return "";
|
||||
},
|
||||
ShakeBit() {
|
||||
//"sta_ShakeBit":0-未报警,1-强制报警,2静止报警,3撞击报警,4雷达报警,5漏电报警,6触水报警,7红外报警
|
||||
let dic = {
|
||||
"0": "",
|
||||
"1": "设备强制报警中",
|
||||
"2": "设备静止报警中",
|
||||
"3": "设备疑似受到撞击",
|
||||
"4": "设备雷达报警中",
|
||||
"5": "设监测到漏电",
|
||||
"6": "设备触水报警中",
|
||||
"7": "红外闯入报警中"
|
||||
};
|
||||
let keys = Object.keys(dic);
|
||||
let f = keys.find(v => {
|
||||
return v == this.formData.sta_ShakeBit;
|
||||
});
|
||||
if (f) {
|
||||
let str= dic[f]
|
||||
|
||||
return str;
|
||||
}
|
||||
return "";
|
||||
},
|
||||
getbleStatu() {
|
||||
if (this.formData.bleStatu === true) {
|
||||
return '已连接';
|
||||
@ -338,7 +481,7 @@
|
||||
});
|
||||
if (!f) {
|
||||
these.showBleUnConnect();
|
||||
these.getDetail();
|
||||
// these.getDetail();
|
||||
return;
|
||||
}
|
||||
let form = f.formData;
|
||||
@ -355,7 +498,7 @@
|
||||
} else if (these.device.deviceImei) {
|
||||
these.formData['imei'] = these.device.deviceImei;
|
||||
}
|
||||
these.getDetail();
|
||||
// these.getDetail();
|
||||
|
||||
these.formData.bleStatu = 'connecting';
|
||||
ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId).then(res => {
|
||||
@ -369,7 +512,23 @@
|
||||
|
||||
},
|
||||
methods: {
|
||||
redarSetting(val) {
|
||||
showAction(){
|
||||
this.Status.BottomMenu.show = true;
|
||||
|
||||
this.Status.BottomMenu.menuItems.find((v,i)=>{
|
||||
if(this.formData.sta_RadarType==v.value){
|
||||
this.Status.BottomMenu.activeIndex=i;
|
||||
return true;
|
||||
}
|
||||
})
|
||||
},
|
||||
btnClick(){
|
||||
this.Status.BottomMenu.show = false;
|
||||
|
||||
let d=this.Status.BottomMenu.menuItems[this.Status.BottomMenu.activeIndex];
|
||||
|
||||
|
||||
|
||||
let f = this.getDevice();
|
||||
|
||||
|
||||
@ -378,24 +537,18 @@
|
||||
return;
|
||||
}
|
||||
|
||||
let newVal = null;
|
||||
if (val == this.formData.sta_RadarType) {
|
||||
newVal = 0;
|
||||
}else{
|
||||
newVal=val;
|
||||
}
|
||||
|
||||
|
||||
|
||||
let bleSend = () => {
|
||||
let json={ins_RadarType:newVal};
|
||||
let json = {ins_RadarType:d.value};
|
||||
|
||||
json = JSON.stringify(json);
|
||||
if (ble) {
|
||||
ble.sendString(f.deviceId, json).then(res => {
|
||||
this.formData.sta_RadarType=newVal;
|
||||
console.log("send success")
|
||||
this.formData.sta_RadarType = d.value;
|
||||
}).catch(ex => {
|
||||
this.mqSend(json);
|
||||
this.formData.sta_RadarType=newVal;
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -404,6 +557,278 @@
|
||||
bleSend();
|
||||
|
||||
|
||||
},
|
||||
itemClick(item, index) {
|
||||
this.Status.BottomMenu.activeIndex=index;
|
||||
|
||||
|
||||
},
|
||||
closeActionSheet() {
|
||||
this.Status.BottomMenu.show = false;
|
||||
},
|
||||
sendUsr() {
|
||||
if (!this.permissions.includes('4') && this.Status.apiType !== 'listA') {
|
||||
|
||||
|
||||
MsgError('无操作权限', '', these);
|
||||
return;
|
||||
}
|
||||
let f = this.getDevice();
|
||||
if (!f) {
|
||||
these.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;
|
||||
}
|
||||
|
||||
let err = false;
|
||||
this.formData.textLines.find((txt) => {
|
||||
if (txt.length === 0) {
|
||||
console.log("txt=", txt);
|
||||
err = true;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
})
|
||||
if (err) {
|
||||
MsgError('单位、部门、姓名、ID必须填写', '', these);
|
||||
return;
|
||||
}
|
||||
showLoading(these, {
|
||||
text: "请稍候..."
|
||||
});
|
||||
//握手
|
||||
let holdHand = () => {
|
||||
return new Promise((resolve, reject) => {
|
||||
updateLoading(these, {
|
||||
text: '设备准备中...'
|
||||
})
|
||||
let hexs = 'word transmit start';
|
||||
ble.sendString(f.deviceId, hexs, f.writeServiceId, f.wirteCharactId, 10).then(res => {
|
||||
setTimeout(() => {
|
||||
resolve(res)
|
||||
}, 2200);
|
||||
|
||||
}).catch(ex => {
|
||||
reject(ex)
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
//画图
|
||||
let drawText = () => {
|
||||
return new Promise((resolve, reject) => {
|
||||
this.$refs.textToHex.drawAndGetPixels().then(allPixels => {
|
||||
if (!allPixels) {
|
||||
reject("文本初始化失败");
|
||||
return;
|
||||
}
|
||||
resolve(allPixels);
|
||||
}).catch(compEx => {
|
||||
reject(compEx);
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
//发送3个分包的数据
|
||||
let task = (allPixels) => {
|
||||
try {
|
||||
let combinedData = [];
|
||||
for (let i = 0; i < this.formData.textLines.length; 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);
|
||||
|
||||
}
|
||||
combinedData.push([0xFA, 0x06, i + 1, 1].concat(linePixels.slice(0, 128)));
|
||||
combinedData.push([0xFA, 0x06, i + 1, 2].concat(linePixels.slice(128, 256)));
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
combinedData.push([0x74, 0x72, 0x61, 0x6E, 0x73, 0x6D, 0x69, 0x74, 0x20, 0x63, 0x6F, 0x6D,
|
||||
0x70, 0x6C, 0x65, 0x74, 0x65
|
||||
]);
|
||||
|
||||
|
||||
|
||||
let curr = 1;
|
||||
let len = combinedData.length;
|
||||
console.log(combinedData);
|
||||
showLoading(these, {
|
||||
text: '正在发送' + (curr - 1) + '/' + len
|
||||
});
|
||||
|
||||
//分包发送
|
||||
let sendPacket = () => {
|
||||
|
||||
if (combinedData.length === curr - 1) {
|
||||
|
||||
these.setBleFormData();
|
||||
|
||||
MsgSuccess("发送成功", '', these);
|
||||
let json = {
|
||||
deviceId: these.device.id,
|
||||
name: these.formData.textLines[1],
|
||||
position: these.formData.textLines[0],
|
||||
unitName: these.formData.textLines[2],
|
||||
code: ""
|
||||
};
|
||||
usrApi.sendUsr(json);
|
||||
|
||||
hideLoading(these);
|
||||
return;
|
||||
}
|
||||
|
||||
let array = combinedData[curr - 1];
|
||||
|
||||
|
||||
ble.sendHexs(f.deviceId, array, f.writeServiceId, f.wirteCharactId, 10).then(
|
||||
res => {
|
||||
|
||||
|
||||
updateLoading(these, {
|
||||
text: '正在发送' + curr + '/' + len
|
||||
});
|
||||
curr++;
|
||||
setTimeout(sendPacket, 300);
|
||||
}).catch(err => {
|
||||
if (err.code == '10007') {
|
||||
|
||||
setTimeout(sendPacket, 300);
|
||||
} else {
|
||||
console.log("err:", err);
|
||||
hideLoading(these);
|
||||
MsgError("发送失败: " + (err.msg || err.message), '', these)
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
setTimeout(sendPacket, 0);
|
||||
// 5. 发送成功处理
|
||||
|
||||
|
||||
} catch (ex) {
|
||||
hideLoading(these);
|
||||
|
||||
MsgError("发送失败: " + (ex.msg || ex.message), '', these);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
setTimeout(() => {
|
||||
Promise.allSettled([holdHand(), drawText()]).then(results => {
|
||||
console.log("results=", results)
|
||||
if (results[0].status == 'rejected') {
|
||||
updateLoading(these, {
|
||||
text: results[0].reason
|
||||
});
|
||||
setTimeout(() => {
|
||||
hideLoading(these)
|
||||
}, 500);
|
||||
return;
|
||||
}
|
||||
if (results[1].status == 'rejected') {
|
||||
updateLoading(these, {
|
||||
text: results[1].reason
|
||||
})
|
||||
setTimeout(() => {
|
||||
hideLoading(these)
|
||||
}, 500);
|
||||
return;
|
||||
}
|
||||
|
||||
task(results[1].value);
|
||||
})
|
||||
|
||||
}, 0);
|
||||
},
|
||||
toggleSetting(val, type) {
|
||||
let f = this.getDevice();
|
||||
|
||||
|
||||
if (!f) {
|
||||
this.showBleUnConnect();
|
||||
return;
|
||||
}
|
||||
let sta_type = "sta_" + type;
|
||||
let newVal = null;
|
||||
if (val == this.formData[sta_type]) {
|
||||
newVal = 0;
|
||||
} else {
|
||||
newVal = val;
|
||||
}
|
||||
|
||||
|
||||
|
||||
let bleSend = () => {
|
||||
let json = {};
|
||||
json['ins_' + type] = newVal
|
||||
json = JSON.stringify(json);
|
||||
if (ble) {
|
||||
ble.sendString(f.deviceId, json).then(res => {
|
||||
console.log("send success")
|
||||
this.formData[sta_type] = newVal;
|
||||
}).catch(ex => {
|
||||
this.mqSend(json);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bleSend();
|
||||
|
||||
|
||||
},
|
||||
CloseWarn(){
|
||||
let f = this.getDevice();
|
||||
|
||||
// #ifdef APP
|
||||
if (!f) {
|
||||
this.showBleUnConnect();
|
||||
return;
|
||||
}
|
||||
// #endif
|
||||
|
||||
// #ifdef WEB
|
||||
f={deviceId:12345}
|
||||
// #endif
|
||||
|
||||
let bleSend = () => {
|
||||
let json = {
|
||||
ins_ShakeBit: 0
|
||||
};
|
||||
json = JSON.stringify(json);
|
||||
if (ble) {
|
||||
ble.sendString(f.deviceId, json).then(res => {
|
||||
this.formData.sta_ShakeBit = 0;
|
||||
this.formData.sta_InfraRed=0;
|
||||
}).catch(ex => {
|
||||
this.mqSend(json);
|
||||
this.formData.sta_ShakeBit = 0;
|
||||
this.formData.sta_InfraRed=0;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
MsgError('确定解除报警?', '', these, bleSend);
|
||||
},
|
||||
sosSetting(val) {
|
||||
let f = this.getDevice();
|
||||
@ -426,12 +851,13 @@
|
||||
if (newVal == 0 && this.formData.sta_SOSGrade == 1) {
|
||||
msg = "确定解除声光报警?";
|
||||
|
||||
}
|
||||
else if (newVal == 1) {
|
||||
} else if (newVal == 1) {
|
||||
msg = "确定开启声光报警?";
|
||||
}
|
||||
let bleSend = () => {
|
||||
let json={ins_SOSGrade:newVal};
|
||||
let json = {
|
||||
ins_SOSGrade: newVal
|
||||
};
|
||||
json = JSON.stringify(json);
|
||||
if (ble) {
|
||||
ble.sendString(f.deviceId, json).then(res => {
|
||||
@ -447,8 +873,7 @@
|
||||
MsgError(msg, '', these, () => {
|
||||
bleSend();
|
||||
});
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
bleSend();
|
||||
}
|
||||
|
||||
@ -495,7 +920,12 @@
|
||||
mqSend(json) {
|
||||
if (mq) {
|
||||
mq.publish("B/" + this.device.deviceImei, json).then(res => {
|
||||
|
||||
let keys = Object.keys(JSON.parse(json));
|
||||
for (let i = 0; i < keys.length; i++) {
|
||||
let key = keys[i];
|
||||
let state = key.replace('ins_', 'sta_');
|
||||
this.formData[state] = json[key];
|
||||
}
|
||||
}).catch(ex => {
|
||||
|
||||
});
|
||||
@ -891,11 +1321,12 @@ display: flex;
|
||||
justify-content: flex-start;
|
||||
padding: 30rpx;
|
||||
box-sizing: border-box;
|
||||
border: 1rpx solid #00000000;
|
||||
}
|
||||
|
||||
.lampMode .mode.active {
|
||||
|
||||
border: 1px solid rgba(174, 214, 0, 1);
|
||||
border: 1rpx solid rgba(174, 214, 0, 1) !important;
|
||||
}
|
||||
|
||||
.lampMode .mode.active .bigTxt {
|
||||
@ -939,7 +1370,7 @@ display: flex;
|
||||
font-weight: 400;
|
||||
|
||||
letter-spacing: 0.07px;
|
||||
|
||||
border: 1px solid #00000000;
|
||||
}
|
||||
|
||||
.usrinfo {
|
||||
@ -1424,4 +1855,11 @@ display: flex;
|
||||
/deep/ .uni-navbar__placeholder {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
.TextToHex {
|
||||
position: fixed;
|
||||
top: -99999rpx;
|
||||
left: -99999rpx;
|
||||
visibility: hidden;
|
||||
}
|
||||
</style>
|
||||
@ -291,7 +291,8 @@
|
||||
MsgClose,
|
||||
MsgWarning,
|
||||
showPop,
|
||||
MsgInfo
|
||||
MsgInfo,
|
||||
MsgClear
|
||||
} from '@/utils/MsgPops.js'
|
||||
const pagePath = "/pages/4877/BJQ4877";
|
||||
|
||||
@ -1180,6 +1181,7 @@
|
||||
if (receive.deviceId !== this.formData.deviceId) {
|
||||
return;
|
||||
}
|
||||
|
||||
console.log("收到设备的数据", receive)
|
||||
let data = recei.ReceiveData(receive, device, pagePath, recArr);
|
||||
console.log("处理后的数据:", data);
|
||||
@ -1206,6 +1208,7 @@
|
||||
}
|
||||
if (msg.length) {
|
||||
msg = msg.join(",");
|
||||
MsgClear(these);
|
||||
this.showMsg(msg);
|
||||
}
|
||||
|
||||
@ -1350,22 +1353,12 @@
|
||||
|
||||
|
||||
showMsg(msg, isSucc) {
|
||||
let icoUrl = '/static/images/common/uploadErr.png';
|
||||
let borderColor = "#e034344d";
|
||||
let buttonBgColor = "#E03434";
|
||||
if (isSucc) {
|
||||
icoUrl = '/static/images/common/success.png';
|
||||
borderColor = "#BBE600";
|
||||
buttonBgColor = "#BBE600";
|
||||
MsgSuccess(msg,'',this);
|
||||
}
|
||||
else{
|
||||
MsgError(msg,'',this);
|
||||
}
|
||||
showPop({
|
||||
message: msg,
|
||||
iconUrl: icoUrl,
|
||||
borderColor: borderColor,
|
||||
buttonBgColor: buttonBgColor,
|
||||
buttonText: '确定',
|
||||
okCallback: null
|
||||
},this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -39,15 +39,8 @@
|
||||
</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="eqinfo">
|
||||
@ -119,8 +112,15 @@
|
||||
</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>
|
||||
@ -223,10 +223,7 @@
|
||||
<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>
|
||||
|
||||
@ -625,7 +622,7 @@
|
||||
borderColor: "#e034344d",
|
||||
buttonBgColor: "#E03434",
|
||||
buttonText: '确定',
|
||||
buttonTextColor: '#232323de',
|
||||
buttonTextColor: '#FFFFFFde',
|
||||
showCancel: false,
|
||||
showHeader: false,
|
||||
visibleClose: true,
|
||||
@ -1128,7 +1125,7 @@
|
||||
uni.chooseImage({
|
||||
count: 1,
|
||||
sizeType: ['original', 'compressed'],
|
||||
sourceType: ['album'],
|
||||
sourceType: ['album','camera'],
|
||||
success: function(res) {
|
||||
uni.navigateTo({
|
||||
url: "/pages/common/ImgCrop/ImgCrop",
|
||||
@ -1426,7 +1423,7 @@
|
||||
borderColor: "#e034344d",
|
||||
buttonBgColor: "#E03434",
|
||||
buttonText: '确定',
|
||||
buttonTextColor: '#232323de',
|
||||
buttonTextColor: '#FFFFFFde',
|
||||
showCancel: true,
|
||||
buttonCancelText: '取消',
|
||||
okCallback: send
|
||||
@ -1463,7 +1460,7 @@
|
||||
borderColor: "#e034344d",
|
||||
buttonBgColor: "#E03434",
|
||||
buttonText: '确定',
|
||||
buttonTextColor: '#232323de',
|
||||
buttonTextColor: '#FFFFFFde',
|
||||
showCancel: true,
|
||||
showHeader: true,
|
||||
visibleClose: false,
|
||||
@ -1522,9 +1519,7 @@
|
||||
}
|
||||
|
||||
|
||||
this.formData.textLines = [this.formData.company, this.formData.usrname, this.formData.job, this.formData
|
||||
.usrid
|
||||
];
|
||||
this.formData.textLines = [this.formData.company, this.formData.usrname, this.formData.job];
|
||||
console.log("data=", this.formData.textLines);
|
||||
showLoading(these, {
|
||||
text: "发送中"
|
||||
@ -1590,11 +1585,14 @@
|
||||
let sendPacket = () => {
|
||||
|
||||
if (combinedData.length === curr - 1) {
|
||||
setTimeout(()=>{
|
||||
holdHand('transmit complete', 200).then(res => {
|
||||
MsgSuccess("人员信息发送成功", "确定", these);
|
||||
hideLoading(these);
|
||||
this.setBleFormData();
|
||||
});
|
||||
},300);
|
||||
|
||||
hideLoading();
|
||||
return;
|
||||
}
|
||||
@ -1608,7 +1606,7 @@
|
||||
curr++;
|
||||
console.log("发送成功", curr);
|
||||
updateLoading(these, {
|
||||
text: '发送中,' + (curr - 1) + '/' + 4
|
||||
text: '发送中,' + (curr - 1) + '/' + combinedData.length
|
||||
})
|
||||
setTimeout(sendPacket, 250);
|
||||
}).catch(err => {
|
||||
|
||||
@ -865,7 +865,7 @@
|
||||
uni.chooseImage({
|
||||
count: 1,
|
||||
sizeType: ['original', 'compressed'],
|
||||
sourceType: ['album'],
|
||||
sourceType: ['album','camera'],
|
||||
success: function(res) {
|
||||
uni.navigateTo({
|
||||
url: "/pages/common/ImgCrop/ImgCrop",
|
||||
|
||||
@ -903,7 +903,7 @@
|
||||
uni.chooseImage({
|
||||
count: 1,
|
||||
sizeType: ['original', 'compressed'],
|
||||
sourceType: ['album'],
|
||||
sourceType: ['album','camera'],
|
||||
success: function(res) {
|
||||
uni.navigateTo({
|
||||
url: "/pages/common/ImgCrop/ImgCrop",
|
||||
|
||||
@ -31,7 +31,7 @@
|
||||
<view class="battery-v1">
|
||||
<image src="/static/images/common/time.png" class="dlIMG" mode="aspectFit"></image>
|
||||
<view>
|
||||
<view class="battery-v2">{{ deviceInfo.batteryRemainingTime || '0' }}分钟</view>
|
||||
<view class="battery-v2">{{remainTime}}</view>
|
||||
<view class="battery-v3">续航时间</view>
|
||||
</view>
|
||||
</view>
|
||||
@ -112,7 +112,7 @@
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="mode-v1" v-if="hasPermission('2')">
|
||||
<view class="mode-v1" v-if="hasPermission('2')" :class="{'active':isLaserOn}">
|
||||
<view class="mode-v2" @click="lasermode">
|
||||
<image src="/static/images/6170/jg.png" class="setIMG" mode="aspectFit"></image>
|
||||
<view>
|
||||
@ -122,10 +122,13 @@
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="mode-v1" :class="{'active':itemInfo.alarmStatus===1 || itemInfo.alarmStatus==='1'}" >
|
||||
<view class="mode-v1"
|
||||
:class="{'active':itemInfo.alarmStatus===1 || itemInfo.alarmStatus==='1'}">
|
||||
<view class="mode-v2" @click="warnToggle">
|
||||
<image v-show="itemInfo.alarmStatus!=1" src="/static/images/common/sg.png" class="setIMG" mode="aspectFit"></image>
|
||||
<image v-show="itemInfo.alarmStatus==1" src="/static/images/common/sgActive.png" class="setIMG" mode="aspectFit"></image>
|
||||
<image v-show="itemInfo.alarmStatus!=1" src="/static/images/common/sg.png"
|
||||
class="setIMG" mode="aspectFit"></image>
|
||||
<image v-show="itemInfo.alarmStatus==1" src="/static/images/common/sgActive.png"
|
||||
class="setIMG" mode="aspectFit"></image>
|
||||
<view>
|
||||
<view class="battery-v2">{{itemInfo.alarmStatus==1?'解除报警':'强制报警'}}</view>
|
||||
</view>
|
||||
@ -147,7 +150,7 @@
|
||||
<!-- 人员信息登记 -->
|
||||
<view class="form-section" v-if="hasPermission('4')">
|
||||
<TextToHexV2 class="TextToHex" ref="textToHex" :txts="formData.textLines" :bgColor="'#FFFFFF'"
|
||||
:color="'#000000'" :fontSize="14" :returnType="10" />
|
||||
:color="'#000000'" :fontSize="12" :returnType="10" />
|
||||
|
||||
<view class="mode-buttons">
|
||||
<view class="section-title">人员信息登记</view>
|
||||
@ -161,17 +164,16 @@
|
||||
<view class="form-row">
|
||||
<text class="form-label">单位:</text>
|
||||
<input class="form-input" placeholder="请输入单位" v-model="personnelInfo.unitName"
|
||||
:maxlength="15" />
|
||||
:maxlength="8" />
|
||||
</view>
|
||||
<view class="form-row">
|
||||
<text class="form-label">姓名:</text>
|
||||
<input class="form-input" placeholder="请输入姓名" v-model="personnelInfo.name"
|
||||
:maxlength="15" />
|
||||
<input class="form-input" placeholder="请输入姓名" v-model="personnelInfo.name" :maxlength="8" />
|
||||
</view>
|
||||
<view class="form-row">
|
||||
<text class="form-label">职位:</text>
|
||||
<input class="form-input" placeholder="请输入职位" v-model="personnelInfo.position"
|
||||
:maxlength="15" />
|
||||
:maxlength="8" />
|
||||
</view>
|
||||
<view class="form-row">
|
||||
<text class="form-label">ID:</text>
|
||||
@ -180,7 +182,7 @@
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 人员信息登记 -->
|
||||
<!-- 发送信息-->
|
||||
<view class="form-section" v-if="hasPermission('5')">
|
||||
<view class="mode-buttons">
|
||||
<view class="section-title">发送信息</view>
|
||||
@ -276,13 +278,15 @@
|
||||
<CustomPopup v-if="popupType === 'cancel'" :show="showPopupFlag"
|
||||
popupBorder="1rpx solid rgba(224, 52, 52, 0.3)" :message="popupMessage"
|
||||
icon="/static/images/6170/svg.png" :confirm-text="popupConfirmText" :show-cancel="true"
|
||||
@confirm="onPopupConfirmPolice" confirmBtnBg="rgba(224, 52, 52, 1)" confirmBtnColor="#fff" />
|
||||
@cancel="onPopupConfirm" @confirm="onPopupConfirmPolice" confirmBtnBg="rgba(224, 52, 52, 1)"
|
||||
confirmBtnColor="#fff" />
|
||||
|
||||
<!-- 强制报警 -->
|
||||
<CustomPopup v-if="popupType === 'openWarn'" :show="showPopupFlag"
|
||||
popupBorder="1rpx solid rgba(224, 52, 52, 0.3)" :message="popupMessage"
|
||||
icon="/static/images/6170/svg.png" :confirm-text="popupConfirmText" :show-cancel="true"
|
||||
@confirm="OpenWarn(1)" confirmBtnBg="rgba(224, 52, 52, 1)" confirmBtnColor="#fff" />
|
||||
@cancel="onPopupConfirm" @confirm="OpenWarn(1)" confirmBtnBg="rgba(224, 52, 52, 1)"
|
||||
confirmBtnColor="#fff" />
|
||||
|
||||
|
||||
<MsgBox ref="msgPop" />
|
||||
@ -306,7 +310,8 @@
|
||||
MsgError,
|
||||
MsgClose,
|
||||
MsgWarning,
|
||||
showPop
|
||||
showPop,
|
||||
MsgInfo
|
||||
} from '@/utils/MsgPops.js';
|
||||
import Common from '@/utils/Common.js';
|
||||
|
||||
@ -355,7 +360,7 @@
|
||||
navTitle: "",
|
||||
sliderValue: 25,
|
||||
lightModeA: false,
|
||||
currentMainMode: '强光',
|
||||
currentMainMode: '关闭',
|
||||
currentlaserMode: "关闭",
|
||||
lightModeB: false,
|
||||
lightModeC: false, //激光提示框
|
||||
@ -402,7 +407,7 @@
|
||||
rgb565Data: null,
|
||||
selectedItemIndex: 0,
|
||||
popupType: 'person', //弹框类型
|
||||
isLaserOn: false,
|
||||
isLaserOn: false, //激光开启状态
|
||||
isSending: false,
|
||||
isProcessing: false,
|
||||
isPolling: false, // 轮询状态
|
||||
@ -418,6 +423,9 @@
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
remainTime() {
|
||||
return Common.formatTime(this.deviceInfo.batteryRemainingTime);
|
||||
},
|
||||
computedDeviceId() {
|
||||
return this.apiType === 'listA' ? this.deviceID : this.itemInfo.deviceId;
|
||||
},
|
||||
@ -442,7 +450,8 @@
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
onReceive(deviceState){//蓝牙/Mq通用消息处理
|
||||
|
||||
onReceive(deviceState, parsedMessage) { //蓝牙/Mq通用消息处理
|
||||
switch (deviceState[0]) {
|
||||
// 1设备切换灯光实时返回
|
||||
case 1:
|
||||
@ -452,13 +461,21 @@
|
||||
this.sliderValue = deviceState[2];
|
||||
this.deviceInfo.batteryRemainingTime = deviceState[3];
|
||||
break;
|
||||
case 6:
|
||||
if(deviceState[1]==50){
|
||||
this.popupType = 'person';
|
||||
this.showPopupFlag = true;
|
||||
this.popupMessage = '信息发送成功';
|
||||
uni.hideLoading();
|
||||
}
|
||||
break;
|
||||
// 12为设备实时上报
|
||||
case 12:
|
||||
this.currentMainMode = this.getMainLightModeLabel(
|
||||
deviceState[
|
||||
1]);
|
||||
this.currentMainMode = this.getMainLightModeLabel(deviceState[1]);
|
||||
this.isLaserOn = deviceState[2] === 1; //第3位表示当时激光灯档位
|
||||
this.currentlaserMode = this.isLaserOn ? "开启" : "关闭";
|
||||
this.deviceInfo.alarmStatus= deviceState[6];//报警状态
|
||||
this.itemInfo.alarmStatus= deviceState[6];
|
||||
if (this.deviceInfo) {
|
||||
this.deviceInfo.batteryPercentage = deviceState[3]; //第4位电量百分比
|
||||
this.deviceInfo.chargeState = deviceState[4]; //第5位为充电状态(0没有充电,1正在充电,2为已充满)
|
||||
@ -583,8 +600,13 @@
|
||||
return;
|
||||
}
|
||||
let data = rec.ReceiveData(receive, device, pagePath, recArr);
|
||||
console.log("蓝牙收到消息", data)
|
||||
this.onReceive(data.state);
|
||||
let keys = Object.keys(data);
|
||||
if (keys.length && "state" in data) {
|
||||
this.onReceive(data.state, receive.str);
|
||||
} else {
|
||||
console.log("不是状态数据,丢弃", data);
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
bleStateBreak() {
|
||||
@ -737,60 +759,62 @@
|
||||
});
|
||||
},
|
||||
onSliderChanging(e) {
|
||||
if (!this.cardRect) return;
|
||||
|
||||
let value = e.detail.value;
|
||||
if (value < 10) {
|
||||
value = 10;
|
||||
}
|
||||
|
||||
this.sliderValue = value; // 实时更新UI
|
||||
const now = Date.now();
|
||||
// 使用节流防止指令发送过于频繁
|
||||
if (now - this.lastBrightnessTime > 200) { // 200毫秒节流
|
||||
this.lastBrightnessTime = now;
|
||||
|
||||
let mqSend = () => {
|
||||
|
||||
// 增加轻微的震动反馈,提升手感
|
||||
uni.vibrateShort({
|
||||
type: 'light'
|
||||
});
|
||||
|
||||
let data = {
|
||||
deviceId: this.computedDeviceId,
|
||||
instructValue: this.sliderValue + '.00',
|
||||
deviceImei: this.itemInfo.deviceImei,
|
||||
}
|
||||
lightBrightnessSettings(data).then((res) => {
|
||||
if (res.code !== 200) {
|
||||
// 可以在这里处理错误,但滑动中不建议用toast
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
if (ble && this.itemInfo.deviceMac) {
|
||||
let f = this.getDevice();
|
||||
if (f) {
|
||||
let json = {
|
||||
instruct: [5, 0, 0, 0, 0]
|
||||
};
|
||||
json.instruct[1] = parseInt(this.sliderValue);
|
||||
|
||||
ble.sendString(f.deviceId, json).then(res => {
|
||||
|
||||
}).catch(ex => {
|
||||
mqSend();
|
||||
});
|
||||
} else {
|
||||
mqSend();
|
||||
}
|
||||
return;
|
||||
} else {
|
||||
mqSend();
|
||||
}
|
||||
}
|
||||
// const now = Date.now();
|
||||
// // 使用节流防止指令发送过于频繁
|
||||
// if (now - this.lastBrightnessTime > 200) { // 200毫秒节流
|
||||
// this.lastBrightnessTime = now;
|
||||
|
||||
// let mqSend = () => {
|
||||
|
||||
// // 增加轻微的震动反馈,提升手感
|
||||
// uni.vibrateShort({
|
||||
// type: 'light'
|
||||
// });
|
||||
|
||||
// let data = {
|
||||
// deviceId: this.computedDeviceId,
|
||||
// instructValue: this.sliderValue + '.00',
|
||||
// deviceImei: this.itemInfo.deviceImei,
|
||||
// }
|
||||
// lightBrightnessSettings(data).then((res) => {
|
||||
// if (res.code !== 200) {
|
||||
// // 可以在这里处理错误,但滑动中不建议用toast
|
||||
// }
|
||||
// })
|
||||
// }
|
||||
|
||||
// if (ble && this.itemInfo.deviceMac) {
|
||||
// let f = this.getDevice();
|
||||
// if (f) {
|
||||
// let json = {
|
||||
// instruct: [5, 0, 0, 0, 0]
|
||||
// };
|
||||
// json.instruct[1] = parseInt(this.sliderValue);
|
||||
|
||||
// ble.sendString(f.deviceId, json).then(res => {
|
||||
|
||||
// }).catch(ex => {
|
||||
// mqSend();
|
||||
// });
|
||||
// } else {
|
||||
// mqSend();
|
||||
// }
|
||||
// return;
|
||||
// } else {
|
||||
// mqSend();
|
||||
// }
|
||||
// }
|
||||
},
|
||||
onSliderChangeEnd(e) {
|
||||
|
||||
if (this.deviceInfo.alarmStatus == 1) {
|
||||
MsgError('请先解除强制报警', '', these);
|
||||
return;
|
||||
}
|
||||
let value = e.detail.value;
|
||||
if (value < 10) {
|
||||
value = 10;
|
||||
@ -847,6 +871,10 @@
|
||||
}
|
||||
},
|
||||
selectMode(type) {
|
||||
if (this.deviceInfo.alarmStatus == 1) {
|
||||
MsgError('请先解除强制报警', '', these);
|
||||
return;
|
||||
}
|
||||
this.modeType = type;
|
||||
this.lightModeA = true;
|
||||
if (type === 'main') {
|
||||
@ -906,7 +934,10 @@
|
||||
},
|
||||
// 灯光模式的确认
|
||||
handleSumbit() {
|
||||
|
||||
if (this.deviceInfo.alarmStatus == 1) {
|
||||
MsgError('请先解除强制报警', '', these);
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.selectedItemIndex === null) return;
|
||||
const selectedItem = this.items[this.selectedItemIndex];
|
||||
@ -928,8 +959,13 @@
|
||||
};
|
||||
lightModeSettings(data).then((res) => {
|
||||
if (res.code == 200) {
|
||||
this.currentMainMode = this.pendingMainMode;
|
||||
|
||||
this.selectedItemIndex = selectedItem;
|
||||
|
||||
this.currentMainMode = this.getMainLightModeLabel(selectedItem.instructValue);
|
||||
this.isLaserOn = false; //第3位表示当时激光灯档位
|
||||
this.currentlaserMode = "关闭";
|
||||
|
||||
uni.showToast({
|
||||
title: res.msg,
|
||||
icon: 'none'
|
||||
@ -961,6 +997,9 @@
|
||||
ble.sendString(f.deviceId, json).then(res => {
|
||||
console.log("ble send success", json);
|
||||
this.lightModeA = false;
|
||||
this.currentMainMode = this.getMainLightModeLabel(selectedItem.instructValue);
|
||||
this.isLaserOn = false;
|
||||
this.currentlaserMode = "关闭";
|
||||
}).catch(ex => {
|
||||
console.error("ble send fail,mqsending....")
|
||||
mqSend();
|
||||
@ -976,7 +1015,10 @@
|
||||
},
|
||||
// 激光模式
|
||||
lasermode() {
|
||||
|
||||
if (this.deviceInfo.alarmStatus == 1) {
|
||||
MsgError('请先解除强制报警', '', these);
|
||||
return;
|
||||
}
|
||||
this.lightModeC = true
|
||||
|
||||
|
||||
@ -985,6 +1027,11 @@
|
||||
// 激光确认框提交
|
||||
handleBtn() {
|
||||
|
||||
if (this.deviceInfo.alarmStatus == 1) {
|
||||
MsgError('请先解除强制报警', '', these);
|
||||
return;
|
||||
}
|
||||
|
||||
const instructValue = this.isLaserOn ? 0 : 1;
|
||||
|
||||
let mqSend = () => {
|
||||
@ -1011,6 +1058,10 @@
|
||||
// 更新状态
|
||||
this.isLaserOn = !this.isLaserOn;
|
||||
this.currentlaserMode = this.isLaserOn ? "开启" : "关闭";
|
||||
|
||||
this.currentMainMode = this.getMainLightModeLabel(0);
|
||||
|
||||
|
||||
this.lightModeC = false;
|
||||
} else {
|
||||
uni.showToast({
|
||||
@ -1035,6 +1086,8 @@
|
||||
this.lightModeC = false;
|
||||
this.isLaserOn = !this.isLaserOn;
|
||||
this.currentlaserMode = this.isLaserOn ? "开启" : "关闭";
|
||||
|
||||
this.currentMainMode = this.getMainLightModeLabel(0);
|
||||
}).catch(ex => {
|
||||
mqSend();
|
||||
});
|
||||
@ -1052,7 +1105,12 @@
|
||||
},
|
||||
// 上传开机画面
|
||||
uploadStartup() {
|
||||
this.lightModeB = true
|
||||
if (this.deviceInfo.alarmStatus == 1) {
|
||||
MsgError('请先解除强制报警', '', these);
|
||||
return;
|
||||
}
|
||||
this.lightModeB = true;
|
||||
this.selectedImage=null;
|
||||
},
|
||||
// 上传开机画面
|
||||
checkImgUpload() {
|
||||
@ -1102,6 +1160,10 @@
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (this.deviceInfo.alarmStatus == 1) {
|
||||
MsgError('请先解除强制报警', '', these);
|
||||
return;
|
||||
}
|
||||
|
||||
let mqSend = () => {
|
||||
if (this.deviceInfo.onlineStatus !== 1) {
|
||||
@ -1373,6 +1435,11 @@
|
||||
},
|
||||
// 发送人员信息
|
||||
sendPersonnelInfo() {
|
||||
if (this.deviceInfo.alarmStatus == 1) {
|
||||
MsgError('请先解除强制报警', '', these);
|
||||
return;
|
||||
}
|
||||
|
||||
let mqSend = async () => {
|
||||
if (this.isSending) return;
|
||||
const requiredFields = [{
|
||||
@ -1532,9 +1599,9 @@
|
||||
hideLoading();
|
||||
return;
|
||||
}
|
||||
|
||||
let packData = combinedData[curr - 1];
|
||||
let array = {
|
||||
instruct: [2, curr].concat(combinedData[curr - 1])
|
||||
instruct: [2, curr, packData.length].concat(packData)
|
||||
};
|
||||
|
||||
|
||||
@ -1574,15 +1641,17 @@
|
||||
setTimeout(() => {
|
||||
Promise.allSettled([holdHand('word transmit start', 2200), drawText()]).then(
|
||||
results => {
|
||||
console.log("results=", results);
|
||||
if (results[0].status == 'rejected') {
|
||||
|
||||
MsgError(results[0].reason.code + ':' + results[0].reason.msg, '',
|
||||
these);
|
||||
setTimeout(() => {
|
||||
hideLoading(these)
|
||||
}, 500);
|
||||
return;
|
||||
}
|
||||
if (results[1].status == 'rejected') {
|
||||
|
||||
MsgError("无法完成文字取模", '', these);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1618,7 +1687,9 @@
|
||||
OpenWarn(val) { //开启/解除强制报警
|
||||
debugger;
|
||||
const topic = `B/${this.itemInfo.deviceImei}`;
|
||||
let message={"instruct":[7,val,0,0,0,0]};
|
||||
let message = {
|
||||
"instruct": [7, val, 0, 0, 0, 0]
|
||||
};
|
||||
message = JSON.stringify(message);
|
||||
|
||||
let flag = this.mqttClient.publish(topic, message, {
|
||||
@ -1626,11 +1697,13 @@
|
||||
});
|
||||
if (flag) {
|
||||
this.itemInfo.alarmStatus = val;
|
||||
this.deviceInfo.alarmStatus = val;
|
||||
} else {
|
||||
MsgError("操作没有成功", '确定', this);
|
||||
}
|
||||
|
||||
this.showPopupFlag = false;
|
||||
this.onPopupConfirm();
|
||||
|
||||
},
|
||||
warnToggle() {
|
||||
if (this.itemInfo.alarmStatus == 1) {
|
||||
@ -1701,14 +1774,18 @@
|
||||
// title: registerRes.msg,
|
||||
// icon: 'none'
|
||||
// })
|
||||
this.OpenWarn(0);
|
||||
|
||||
|
||||
return
|
||||
}
|
||||
this.itemInfo.alarmStatus = 0;
|
||||
this.deviceInfo.alarmStatus = 0;
|
||||
uni.hideLoading();
|
||||
this.showPopupFlag = false
|
||||
// 4. 获取设备状态FunctionAccessBatchStatusRule 批量
|
||||
let deviceImei = this.itemInfo.deviceImei
|
||||
let typeName = this.itemInfo.typeName
|
||||
const statusRes = await getdeviceSTatus({
|
||||
getdeviceSTatus({
|
||||
functionMode: 2,
|
||||
batchId,
|
||||
typeName: 'FunctionAccessBatchStatusRule',
|
||||
@ -1716,14 +1793,14 @@
|
||||
interval: 500
|
||||
},
|
||||
deviceRealTimeStatus
|
||||
);
|
||||
).then(statusRes => {
|
||||
if (statusRes.data.functionAccess === 'OK') {
|
||||
uni.showToast({
|
||||
title: statusRes.msg,
|
||||
icon: 'none'
|
||||
});
|
||||
uni.$emit('deviceStatusUpdate', {});
|
||||
this.showPopupFlag = false
|
||||
|
||||
if (this.apiType === 'listA') {
|
||||
this.fetchDeviceDetail(this.computedDeviceId)
|
||||
} else {
|
||||
@ -1732,6 +1809,10 @@
|
||||
}
|
||||
|
||||
}
|
||||
}).catch(ex => {
|
||||
console.error("出现错误", ex);
|
||||
});
|
||||
|
||||
} catch (error) {
|
||||
uni.showToast({
|
||||
title: error.message,
|
||||
@ -1751,6 +1832,12 @@
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.deviceInfo.alarmStatus == 1) {
|
||||
MsgError('请先解除强制报警', '', these);
|
||||
return;
|
||||
}
|
||||
|
||||
// 防重复提交
|
||||
if (this.isSending) return;
|
||||
if (!this.messageToSend) {
|
||||
@ -1801,9 +1888,9 @@
|
||||
);
|
||||
// 只有当状态为'OK'时才显示成功弹窗
|
||||
if (statusRes.data.functionAccess === 'OK') {
|
||||
this.popupType = 'person';
|
||||
this.showPopupFlag = true;
|
||||
this.popupMessage = '信息发送成功';
|
||||
// this.popupType = 'person';
|
||||
// this.showPopupFlag = true;
|
||||
// this.popupMessage = '信息发送成功';
|
||||
}
|
||||
} catch (error) {
|
||||
uni.showToast({
|
||||
@ -1955,14 +2042,30 @@
|
||||
this.mqttClient.subscribe(statusTopic, (payload) => {
|
||||
try {
|
||||
console.log(`收到来自 ${statusTopic} 的消息:`, payload);
|
||||
console.log("typeof payload=", typeof payload);
|
||||
const parsedMessage = typeof payload === 'string' ? JSON.parse(
|
||||
payload) :
|
||||
payload;
|
||||
payload) : payload;
|
||||
|
||||
let keys = Object.keys(parsedMessage);
|
||||
if("sta_BreakNews" in parsedMessage){
|
||||
console.error("收到确认消息")
|
||||
if(parsedMessage.sta_BreakNews=='I get it'){
|
||||
MsgSuccess("用户已确认收到紧急通知","",this);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
else if (keys.length && "state" in parsedMessage) {
|
||||
const deviceState = parsedMessage.state; // 直接取 state 数组
|
||||
// 切换主灯光模式,亮度值设备同步
|
||||
if (!deviceState) return;
|
||||
if (!deviceState || !deviceState instanceof Array) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.onReceive(deviceState);
|
||||
this.onReceive(deviceState, parsedMessage);
|
||||
}else{
|
||||
console.error("丢弃的消息",payload)
|
||||
}
|
||||
} catch (error) {
|
||||
console.log('解析MQTT消息失败:', error, '原始消息:', payload);
|
||||
}
|
||||
@ -2261,6 +2364,7 @@
|
||||
box-sizing: border-box;
|
||||
border: 1rpx solid #00000000;
|
||||
}
|
||||
|
||||
.mode-v1.active {
|
||||
border: 1rpx solid #bbe600 !important;
|
||||
}
|
||||
|
||||
@ -758,7 +758,7 @@
|
||||
uni.chooseImage({
|
||||
count: 1,
|
||||
sizeType: ['original', 'compressed'],
|
||||
sourceType: ['album'],
|
||||
sourceType: ['album','camera'],
|
||||
success: function(res) {
|
||||
uni.navigateTo({
|
||||
url: "/pages/common/ImgCrop/ImgCrop",
|
||||
|
||||
@ -26,7 +26,8 @@
|
||||
|
||||
<view class="list" style="margin-bottom: 30rpx;">
|
||||
|
||||
<view class="item " @click.stop="disConnect(item,index)" v-for="item, index in PairEquip" v-show="PairEquip.length>0">
|
||||
<view class="item " @click.stop="disConnect(item,index)" v-for="item, index in PairEquip"
|
||||
v-show="PairEquip.length>0">
|
||||
<view class="leftImg ">
|
||||
<image src="/static/images/common/bluetooth.png" class="titleIco filterNone"
|
||||
mode="heightFix">
|
||||
@ -50,10 +51,8 @@
|
||||
<text>发现设备:{{deviceCnt}}</text>
|
||||
<view @click="refreshBleList()">刷新</view>
|
||||
</view>
|
||||
<view class="lblTitle">
|
||||
<view class="">
|
||||
<input class="uni-input" v-model="search" placeholder="名称筛选" />
|
||||
<!-- <uni-easyinput :styles="{color:'#ffffffde',borderColor:'#cbcbcba8'}" :clearable="true" class="uni-mt-5" :trim="'both'"
|
||||
prefixIcon="search" v-model="search" placeholder="名称筛选"></uni-easyinput> -->
|
||||
</view>
|
||||
<view class="list searchList">
|
||||
<view class="item" v-on:click="Link(item,index)" v-for="item, index in EquipMents"
|
||||
@ -500,7 +499,8 @@
|
||||
}
|
||||
const hasPermission = await this.checkAndRequestLocationPermission();
|
||||
if (!hasPermission) {
|
||||
console.log("缺少定位权限,已中止蓝牙扫描。");
|
||||
|
||||
MsgError('缺少定位权限,已中止蓝牙扫描', '', this);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -534,9 +534,9 @@
|
||||
if (err.code === 10001) {
|
||||
these.showOpenSetting();
|
||||
} else {
|
||||
|
||||
MsgError('出现错误:' + err.msg, '确定', these, () => {
|
||||
MsgClear(these);
|
||||
MsgError('出现错误:' + err.msg, '确定', these);
|
||||
});
|
||||
|
||||
}
|
||||
}).finally(() => {
|
||||
|
||||
@ -486,13 +486,11 @@
|
||||
|
||||
MsgError('蓝牙不可用','',these);
|
||||
|
||||
these.EquipMents.filter((v, i) => {
|
||||
these.$set(these.EquipMents[i], 'link', false);
|
||||
});
|
||||
these.EquipMents=[];
|
||||
}, pagePath);
|
||||
ble.addStateRecoveryCallback(() => {
|
||||
|
||||
|
||||
these.ReSearch();
|
||||
MsgSuccess('蓝牙恢复可用','',these,()=>{
|
||||
MsgClear(these);
|
||||
})
|
||||
@ -557,6 +555,7 @@
|
||||
|
||||
|
||||
setTimeout(()=>{
|
||||
debugger;
|
||||
MsgInfo("如需要在PC上查看此数据,请复制链接后通过微信发送到PC,在PC端打开,然后点右上角扫码授权","复制链接",these,true,()=>{
|
||||
console.log("执行复制");
|
||||
uni.setClipboardData({
|
||||
@ -566,10 +565,18 @@
|
||||
title:'已复制链接'
|
||||
});
|
||||
|
||||
|
||||
// #ifdef APP
|
||||
plus.runtime.openURL('weixin://', (err) => {
|
||||
MsgError("打开微信失败,请手动打开微信,发送至'文件传输助手'");
|
||||
});
|
||||
// #endif
|
||||
|
||||
// #ifndef APP
|
||||
MsgInfo("已复制链接,请打开浏览器查看","",these);
|
||||
setTimeout(()=>{
|
||||
MsgClear(these);
|
||||
},1200)
|
||||
// #endif
|
||||
},
|
||||
fail(ex){
|
||||
console.error("无法复制",ex)
|
||||
@ -878,9 +885,10 @@
|
||||
},
|
||||
ReSearch() {
|
||||
if (!ble) {
|
||||
MsgError('蓝牙模块未初始化','',this);
|
||||
return;
|
||||
}
|
||||
|
||||
showLoading(this,{text:'请稍候...'});
|
||||
ble.disconnectDevice().finally(dis => {
|
||||
|
||||
ble.StopSearch().finally(res => {
|
||||
@ -893,6 +901,8 @@
|
||||
}).catch(err => {
|
||||
console.error("err=", err);
|
||||
MsgError("出现错误:" + err.msg, '', these);
|
||||
}).finally(()=>{
|
||||
hideLoading(these);
|
||||
});
|
||||
},200);
|
||||
|
||||
|
||||
@ -9,8 +9,13 @@
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
<scroll-view class="device-list" scroll-y @scrolltolower="onScrollToLower" :lower-threshold="100"
|
||||
style="height:80vh">
|
||||
<view style="height: calc(100% - 200rpx);">
|
||||
|
||||
|
||||
<mescroll-uni class="device-list" @init="mescrollInit" @down="downCallback" @up="upCallback"
|
||||
:up="upOption" :down="downOption" :fixed="false">
|
||||
<!-- <scroll-view class="device-list" scroll-y @scrolltolower="onScrollToLower" :lower-threshold="100"
|
||||
style="height:80vh"> -->
|
||||
<view v-if="deviceList.length>0">
|
||||
<view v-for="(group, groupIndex) in groupedDevices" :key="groupIndex">
|
||||
<view class="share-header">
|
||||
@ -53,13 +58,15 @@
|
||||
</block>
|
||||
</view>
|
||||
</view>
|
||||
<view v-else class="noDATA">
|
||||
<!-- <view v-else class="noDATA">
|
||||
<view>
|
||||
<uni-icons type="image-filled" size="120" color="rgba(255, 255, 255, 0.9)"></uni-icons>
|
||||
</view>
|
||||
暂无数据
|
||||
</view> -->
|
||||
<!-- </scroll-view> -->
|
||||
</mescroll-uni>
|
||||
</view>
|
||||
</scroll-view>
|
||||
</view>
|
||||
<!-- 删除弹框 -->
|
||||
<view class="agreement-mask" v-if="deleteShow" @click="closePopup('delete')">
|
||||
@ -81,6 +88,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
var timeout=null;
|
||||
import {
|
||||
deviceShareList,
|
||||
otherDeviceShareList,
|
||||
@ -89,6 +97,23 @@
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
mescroll: null,
|
||||
downOption: {
|
||||
auto: true,
|
||||
autoShowLoading: false,
|
||||
},
|
||||
upOption: {
|
||||
auto: false,
|
||||
noMoreSize: 0,
|
||||
offset: 10,
|
||||
isLock: false,
|
||||
empty: {
|
||||
tip: '暂无数据',
|
||||
hideScroll: false,
|
||||
icon: '/static/images/common/empty.png'
|
||||
},
|
||||
textNoMore: '没有更多数据了'
|
||||
},
|
||||
deviceList: [],
|
||||
tabs: [{
|
||||
name: '我的分享',
|
||||
@ -131,6 +156,28 @@
|
||||
|
||||
},
|
||||
methods: {
|
||||
mescrollInit(mescroll) {
|
||||
this.mescroll = mescroll;
|
||||
},
|
||||
// 下拉刷新
|
||||
downCallback() {
|
||||
|
||||
|
||||
if (this.mescroll) {
|
||||
this.mescroll.resetUpScroll(false);
|
||||
this.mescroll.scrollTo(0, 0);
|
||||
}
|
||||
this.getData();
|
||||
|
||||
|
||||
},
|
||||
// 上拉加载
|
||||
upCallback() {
|
||||
|
||||
|
||||
|
||||
this.getData();
|
||||
},
|
||||
// 点击弹框外的区域关闭
|
||||
closePopup(type) {
|
||||
if (type === 'delete') {
|
||||
@ -147,7 +194,8 @@
|
||||
// 页面跳转成功后的回调函数
|
||||
res.eventChannel.emit('detailData', {
|
||||
data: item,
|
||||
apiType:this.activeTab===0?'listA':'listB' // 自定义标识 // 自定义标识,详情哪里根据这个参数不同信息
|
||||
apiType: this.activeTab === 0 ? 'listA' :
|
||||
'listB' // 自定义标识 // 自定义标识,详情哪里根据这个参数不同信息
|
||||
});
|
||||
}
|
||||
})
|
||||
@ -200,15 +248,22 @@
|
||||
},
|
||||
// 获取设备列表
|
||||
getData(tab) {
|
||||
//console.log(tab.name, 'tab');
|
||||
let task = () => {
|
||||
if (this.loading) return;
|
||||
this.loading = true;
|
||||
let data = {
|
||||
pageNum: this.page,
|
||||
pageNum: this.mescroll.num,
|
||||
pageSize: this.size,
|
||||
}
|
||||
|
||||
if (!data.pageNum) {
|
||||
this.mescroll.endSuccess(0, false);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// 根据当前tab决定调用哪个接口
|
||||
const apiCall = tab.name === '我的分享' ? deviceShareList : otherDeviceShareList;
|
||||
const apiCall = this.tabs[this.activeTab].name === '我的分享' ? deviceShareList : otherDeviceShareList;
|
||||
console.log('nihao');
|
||||
apiCall(data).then((res) => {
|
||||
if (res.code == 200) {
|
||||
@ -226,17 +281,26 @@
|
||||
}
|
||||
|
||||
this.total = res.total;
|
||||
let hasNext = true;
|
||||
// 判断是否已加载全部数据
|
||||
if (res.rows.length < this.size || this.deviceList.length >= this.total) {
|
||||
this.finished = true;
|
||||
hasNext = false;
|
||||
} else {
|
||||
this.page++;
|
||||
hasNext = true;
|
||||
}
|
||||
this.mescroll.endSuccess(res.rows.length, hasNext);
|
||||
}else{
|
||||
this.mescroll.endSuccess(0, false);
|
||||
}
|
||||
}).finally(() => {
|
||||
this.loading = false;
|
||||
});
|
||||
}
|
||||
|
||||
clearTimeout(timeout);
|
||||
timeout = setTimeout(task, 50);
|
||||
|
||||
},
|
||||
// 滚动触底事件处理
|
||||
@ -267,6 +331,9 @@
|
||||
min-height: 100vh;
|
||||
background-color: rgb(18, 18, 18);
|
||||
padding: 30rpx;
|
||||
width: 100%;
|
||||
height: 100vh;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.tab-bar {
|
||||
|
||||
@ -196,7 +196,8 @@
|
||||
isLock: false,
|
||||
empty: {
|
||||
tip: '暂无数据',
|
||||
hideScroll: false
|
||||
hideScroll: false,
|
||||
icon: '/static/images/common/empty.png'
|
||||
}
|
||||
},
|
||||
page: 1, // 当前页码
|
||||
|
||||
@ -117,6 +117,13 @@
|
||||
sendApi: deviceSendAlarmMessage,
|
||||
statusTypeName: '',
|
||||
sendType: 'XSSend'
|
||||
},
|
||||
,
|
||||
{
|
||||
type: ['HBY018A'],
|
||||
sendApi: deviceSendAlarmMessage,
|
||||
statusTypeName: '',
|
||||
sendType: 'CommonSend'
|
||||
}
|
||||
]
|
||||
},
|
||||
@ -134,7 +141,8 @@
|
||||
isLock: false,
|
||||
empty: {
|
||||
tip: '暂无数据',
|
||||
hideScroll: false
|
||||
hideScroll: false,
|
||||
icon: '/static/images/common/empty.png'
|
||||
},
|
||||
textNoMore: '没有更多数据了'
|
||||
},
|
||||
|
||||
@ -29,10 +29,10 @@
|
||||
<view v-if="deviceList.length>0">
|
||||
<uni-swipe-action ref="swipeAction" >
|
||||
<block v-for="(item, index) in deviceList" :key="index" :ref="'swipeItem_' + index">
|
||||
<uni-swipe-action-item :right-options="Options"
|
||||
<uni-swipe-action-item :right-options="Options" :show="item.showOption"
|
||||
@click="handleSwipeClick($event, item, index)" class="device-card"
|
||||
:style="{ border: item.communicationMode==0 && item.onlineStatus==1 && item.alarmStatus==1 ? '1px solid rgba(224, 52, 52, 1)' : 'none' }">
|
||||
<view @click.stop="handleFile(item)">
|
||||
<view @click.stop="handleFile(item,index)">
|
||||
<view class="device-header">
|
||||
<view class="deviceIMG">
|
||||
<image :src="item.devicePic" class="IMG" mode="aspectFit"></image>
|
||||
@ -62,7 +62,7 @@
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<image src="/static/images/common/cires.png" class="circle" mode="aspectFit"></image>
|
||||
<image @click.stop="swipeToggle(item,index)" src="/static/images/common/cires.png" class="circle" mode="aspectFit"></image>
|
||||
</uni-swipe-action-item>
|
||||
</block>
|
||||
</uni-swipe-action>
|
||||
@ -242,7 +242,8 @@
|
||||
isLock: false,
|
||||
empty: {
|
||||
tip: '暂无数据',
|
||||
hideScroll: false
|
||||
hideScroll: false,
|
||||
icon: '/static/images/common/empty.png'
|
||||
},
|
||||
textNoMore: '没有更多数据了'
|
||||
},
|
||||
@ -697,13 +698,20 @@
|
||||
}
|
||||
})
|
||||
},
|
||||
swipeToggle(item,index){
|
||||
if(!item.showOption || item.showOption=='none'){
|
||||
this.$set(this.deviceList[index],'showOption','right');
|
||||
return;
|
||||
}
|
||||
this.$set(this.deviceList[index],'showOption','none');
|
||||
},
|
||||
// 列表跳转
|
||||
handleFile(item) {
|
||||
handleFile(item,index) {
|
||||
if(item.showOption=='right'){
|
||||
this.$set(this.deviceList[index],'showOption','none');
|
||||
return;
|
||||
}
|
||||
let url = item.detailPageUrl;
|
||||
// url="/pages/6075/BJQ6075L";
|
||||
// if(!url){
|
||||
// url="/pages/6075/BJQ6075"
|
||||
// }
|
||||
uni.navigateTo({
|
||||
url: url,
|
||||
events: {
|
||||
@ -773,7 +781,7 @@
|
||||
});
|
||||
// 监听设备状态更新事件
|
||||
uni.$on('deviceStatusUpdate', (data) => {
|
||||
console.log('列表收到消息了么');
|
||||
// console.log('列表收到消息了么');
|
||||
this.downCallback();
|
||||
});
|
||||
ble = bleTool.getBleTool();
|
||||
@ -805,9 +813,9 @@
|
||||
|
||||
//接收到消息的回调
|
||||
ble.addReceiveCallback((receive, device, path, recArr) => {
|
||||
console.error("首页收到消息了");
|
||||
// console.error("首页收到消息了");
|
||||
let json=recei.ReceiveData(receive, device, path, recArr);
|
||||
console.error("消息内容",json);
|
||||
// console.error("消息内容",json);
|
||||
this.updateBleStatu();
|
||||
}, pagePath);
|
||||
|
||||
@ -1148,7 +1156,7 @@
|
||||
border-radius: 40rpx;
|
||||
padding: 30rpx;
|
||||
text-align: center;
|
||||
border: 1px solid #E034344d;
|
||||
border: 1px solid #E0343480;
|
||||
}
|
||||
|
||||
|
||||
@ -1161,7 +1169,7 @@
|
||||
}
|
||||
|
||||
.agreement-popupC .cancelBtn{
|
||||
border:1rpx solid #E034344d;
|
||||
border:1rpx solid #E03434;
|
||||
color:#E03434;
|
||||
}
|
||||
|
||||
|
||||
@ -113,7 +113,8 @@
|
||||
isLock: false,
|
||||
empty: {
|
||||
tip: '暂无数据',
|
||||
hideScroll: false
|
||||
hideScroll: false,
|
||||
icon: '/static/images/common/empty.png'
|
||||
},
|
||||
textNoMore: '没有更多数据了'
|
||||
},
|
||||
|
||||
398
pages/common/sosSet/LinkManSetting.vue
Normal file
398
pages/common/sosSet/LinkManSetting.vue
Normal file
@ -0,0 +1,398 @@
|
||||
<template>
|
||||
<view class="maincontent contentBg">
|
||||
<view class='btnAdd' @click="showEdit(null,null)">添加</view>
|
||||
<view class="clear"></view>
|
||||
<view v-for="item,index in list" v-if="item" class="item">
|
||||
<view class="itemTitle">紧急联系人{{index+1}}</view>
|
||||
<view class="center main">
|
||||
<view class="phone">{{item}}</view>
|
||||
<view class="btns">
|
||||
<view class="btnEdit" @click.stop="showEdit(item,index)">修改</view>
|
||||
<view class="btnDrop" @click.stop="dropPerson(item,index)">删除</view>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
<view class="line" v-if="index%2==0"></view>
|
||||
</view>
|
||||
|
||||
<mescroll-empty v-show="calcList.length==0" :option="Status.optEmpty"></mescroll-empty>
|
||||
|
||||
<!-- 编辑弹窗 -->
|
||||
<MsgBox ref="editPop">
|
||||
<view>
|
||||
修改紧急联系人
|
||||
</view>
|
||||
<view class="w60">
|
||||
|
||||
<input type="text" placeholder="输入手机号" class="uni-input" v-model="cEdit.txt" />
|
||||
</view>
|
||||
|
||||
</MsgBox>
|
||||
|
||||
|
||||
<MsgBox ref="msgPop" />
|
||||
<global-loading ref="loading" />
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import request from '@/utils/request.js';
|
||||
import {
|
||||
showLoading,
|
||||
hideLoading,
|
||||
updateLoading
|
||||
} from '@/utils/loading.js';
|
||||
|
||||
import {
|
||||
MsgSuccess,
|
||||
MsgError,
|
||||
MsgClose,
|
||||
MsgWarning,
|
||||
showPop,
|
||||
MsgInfo,
|
||||
MsgPrompt
|
||||
} from '@/utils/MsgPops.js'
|
||||
import Common from '@/utils/Common.js';
|
||||
var these = null;
|
||||
var eventChannel = null;
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
list: ['', ''],
|
||||
cEdit: {
|
||||
txt: '',
|
||||
index: -1
|
||||
},
|
||||
Status: {
|
||||
optEmpty: {
|
||||
tip: '暂无数据',
|
||||
icon: '/static/images/common/empty.png'
|
||||
}
|
||||
},
|
||||
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/650/HBY650",
|
||||
showConfirm: false
|
||||
}
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
calcList() {
|
||||
let f = this.list.filter((v, i) => {
|
||||
return v;
|
||||
});
|
||||
|
||||
return f;
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
onUnload() {
|
||||
|
||||
|
||||
|
||||
},
|
||||
onShow() {
|
||||
|
||||
},
|
||||
onHide: function() {
|
||||
|
||||
},
|
||||
|
||||
onLoad() {
|
||||
|
||||
these = this;
|
||||
|
||||
|
||||
eventChannel = this.getOpenerEventChannel();
|
||||
|
||||
eventChannel.on('device', (data) => {
|
||||
|
||||
console.log("收到父页面的参数:" + JSON.stringify(data));
|
||||
these.device = data;
|
||||
|
||||
this.list[0] = data.contact1Phone;
|
||||
this.list[1] = data.contact2Phone;
|
||||
|
||||
});
|
||||
|
||||
|
||||
},
|
||||
methods: {
|
||||
notifyPrevPage(){//通知上一个页面
|
||||
if (eventChannel) {
|
||||
eventChannel.emit('linkManOver', this.list);
|
||||
}
|
||||
},
|
||||
saveData(json) {
|
||||
return request({
|
||||
url: "/app/hby018a/device/SetContactPhone",
|
||||
method: 'POST',
|
||||
data:json
|
||||
});
|
||||
},
|
||||
dropPerson(item, index) {
|
||||
showPop({
|
||||
iconUrl: '/static/images/common/dell.png',
|
||||
borderColor: "#e034344d",
|
||||
buttonBgColor: "#E03434",
|
||||
bgColor: '#383934cc',
|
||||
buttonTextColor: '#FFFFFFde',
|
||||
message: "确定删除紧急联系人" + (index + 1),
|
||||
buttonText: '确定',
|
||||
showSlot: false,
|
||||
showCancel: true,
|
||||
buttonCancelText: '取消',
|
||||
okCallback: () => {
|
||||
|
||||
let url = '/app/hby018a/device/SetContactPhone';
|
||||
|
||||
if (!url) {
|
||||
this.$set(this.list,index,"");
|
||||
return;
|
||||
}
|
||||
let json = {
|
||||
deviceId: this.device.id,
|
||||
contact1Phone:index == 0 ? "" : this.list[0],
|
||||
contact2Phone: index == 0 ? this.list[1] : ""
|
||||
};
|
||||
showLoading(these,{text:'请稍候...'});
|
||||
this.saveData(json).then(res => {
|
||||
if (res && res.code == 200) {
|
||||
|
||||
this.$set(this.list,index,"");
|
||||
this.notifyPrevPage();
|
||||
return;
|
||||
}
|
||||
MsgError(res.msg, '', these);
|
||||
}).catch(ex => {
|
||||
MsgError(ex.msg, '', these);
|
||||
}).finally(() => {
|
||||
hideLoading(these)
|
||||
});
|
||||
|
||||
|
||||
|
||||
}
|
||||
}, these, false);
|
||||
|
||||
},
|
||||
showEdit(item, index) {
|
||||
if (!item && this.calcList.length >= 2) {
|
||||
MsgError('紧急联系人数量达到上限', '', these);
|
||||
return;
|
||||
}
|
||||
if (item) {
|
||||
this.cEdit.txt = item;
|
||||
this.cEdit.index = index;
|
||||
} else {
|
||||
this.cEdit.index = this.calcList.length;
|
||||
}
|
||||
MsgPrompt(these, 'editPop', () => {
|
||||
if (this.cEdit.txt.replace(/ /g, '') == '') {
|
||||
MsgError('请输入联系人号码', '', these);
|
||||
return true;
|
||||
}
|
||||
let reg = /^1\d{10}$/;
|
||||
if (!reg.test(this.cEdit.txt)) {
|
||||
MsgError('手机号格式不正确', '', these);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (item) {
|
||||
let f = this.list.find((v, i) => {
|
||||
if (i == index) {
|
||||
return false;
|
||||
}
|
||||
if (v == this.cEdit.txt) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
if (f) {
|
||||
MsgError('已设置了相同的手机号', '', these);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
let requestCall = () => {
|
||||
|
||||
this.$set(this.list, this.cEdit.index, this.cEdit.txt)
|
||||
|
||||
|
||||
this.cEdit.txt = "";
|
||||
this.cEdit.index = -1;
|
||||
}
|
||||
|
||||
let url = '/app/hby018a/device/SetContactPhone';
|
||||
|
||||
if (!url) {
|
||||
requestCall();
|
||||
return;
|
||||
}
|
||||
let json = {
|
||||
deviceId: this.device.id,
|
||||
contact1Phone: this.cEdit.index == 0 ? this.cEdit.txt : this.list[0],
|
||||
contact2Phone: this.cEdit.index == 0 ? this.list[1] : this.cEdit.txt
|
||||
};
|
||||
showLoading(these,{text:'请稍候...'});
|
||||
this.saveData(json).then(res => {
|
||||
if (res && res.code == 200) {
|
||||
requestCall();
|
||||
this.notifyPrevPage();
|
||||
return;
|
||||
}
|
||||
MsgError(res.msg, '', these);
|
||||
}).catch(ex => {
|
||||
MsgError(ex.msg, '', these);
|
||||
}).finally(() => {
|
||||
hideLoading(these)
|
||||
});
|
||||
|
||||
}, false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.item .main {
|
||||
margin-top: 10rpx;
|
||||
}
|
||||
|
||||
.line {
|
||||
width: 100%;
|
||||
height: 0rpx;
|
||||
border-bottom: 1px solid rgba(255, 255, 255, 0.06);
|
||||
margin: 30rpx 0rpx 20rpx 0rpx;
|
||||
}
|
||||
|
||||
|
||||
.phone {
|
||||
border-radius: 8px;
|
||||
background: rgba(26, 26, 26, 1);
|
||||
width: calc(100% - 160rpx);
|
||||
height: 80rpx;
|
||||
line-height: 80rpx;
|
||||
text-indent: 20rpx;
|
||||
}
|
||||
|
||||
.btns .btnEdit {
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
margin-right: 20rpx;
|
||||
}
|
||||
|
||||
.btns .btnDrop {
|
||||
color: rgba(224, 52, 52, 1);
|
||||
}
|
||||
|
||||
.btns {
|
||||
width: 160rpx;
|
||||
height: 80rpx;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
flex-wrap: nowrap;
|
||||
align-content: center;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
font-family: "PingFang SC";
|
||||
font-style: Regular;
|
||||
font-size: 28rpx;
|
||||
font-weight: 400;
|
||||
|
||||
letter-spacing: 0.07px;
|
||||
text-align: left;
|
||||
|
||||
}
|
||||
|
||||
.itemTitle {
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
|
||||
font-family: "PingFang SC";
|
||||
font-style: Regular;
|
||||
font-size: 28rpx;
|
||||
font-weight: 400;
|
||||
line-height: 40rpx;
|
||||
height: 40rpx;
|
||||
letter-spacing: 0.07px;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.w60 {
|
||||
width: 70%;
|
||||
margin-left: 15%;
|
||||
}
|
||||
|
||||
.uni-input {
|
||||
margin: 30rpx 0rpx 0rpx 0rpx;
|
||||
background-color: #121212;
|
||||
width: 100%;
|
||||
height: 60rpx;
|
||||
color: #ffffffde;
|
||||
border: 1rpx solid #BBE600de;
|
||||
border-radius: 8rpx;
|
||||
font-size: 26rpx;
|
||||
text-indent: 8rpx;
|
||||
font-family: "PingFang SC";
|
||||
line-height: 60rpx;
|
||||
caret-color: #BBE600;
|
||||
font-weight: 200;
|
||||
text-align: left;
|
||||
text-indent: 10rpx;
|
||||
}
|
||||
|
||||
.btnAdd {
|
||||
float: right;
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
font-family: "PingFang SC";
|
||||
font-style: Regular;
|
||||
font-size: 28rpx;
|
||||
font-weight: 400;
|
||||
line-height: 40rpx;
|
||||
height: 40rpx;
|
||||
letter-spacing: 0.07px;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.content {
|
||||
padding: 30rpx;
|
||||
width: 100%;
|
||||
min-height: 100vh;
|
||||
height: auto;
|
||||
}
|
||||
|
||||
|
||||
.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;
|
||||
}
|
||||
</style>
|
||||
251
pages/common/sosSet/TxtMsgSetting.vue
Normal file
251
pages/common/sosSet/TxtMsgSetting.vue
Normal file
@ -0,0 +1,251 @@
|
||||
<template>
|
||||
<view class="maincontent contentBg">
|
||||
|
||||
<view class="text-content">
|
||||
<view class="uni-textarea">
|
||||
<textarea class="textarea" v-model="txt" placeholder-class="placehoderClass"
|
||||
placeholder="SOS求救短信内容二十字以内" :auto-height="true" maxlength="20" cursor-color="#BBE600" />
|
||||
</view>
|
||||
|
||||
|
||||
</view>
|
||||
<view class="footBtn">
|
||||
<view class="fright convert" @click.stop="saveTxt()">保存</view>
|
||||
<view class="clear"></view>
|
||||
</view>
|
||||
|
||||
<view class="title">常用短信</view>
|
||||
<view class="staItem" v-for="item,index in list" @click="copyTo(item,index)">{{item}}</view>
|
||||
|
||||
|
||||
<MsgBox ref="msgPop" />
|
||||
<global-loading ref="loading" />
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import request from '@/utils/request.js';
|
||||
import {
|
||||
showLoading,
|
||||
hideLoading,
|
||||
updateLoading
|
||||
} from '@/utils/loading.js';
|
||||
|
||||
import {
|
||||
MsgSuccess,
|
||||
MsgError,
|
||||
MsgClose,
|
||||
MsgWarning,
|
||||
showPop,
|
||||
MsgInfo
|
||||
} from '@/utils/MsgPops.js'
|
||||
import Common from '@/utils/Common.js';
|
||||
|
||||
|
||||
var these = null;
|
||||
var eventChannel = null;
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
txt: '',
|
||||
oldTxt:'',
|
||||
list: ['出现危险,速来救我!', '被困险境,万分危急,求援!', '生死关头,请立刻报警'],
|
||||
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: "",
|
||||
showConfirm: false
|
||||
}
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
|
||||
|
||||
},
|
||||
|
||||
onUnload() {
|
||||
|
||||
|
||||
},
|
||||
onShow() {
|
||||
|
||||
},
|
||||
onHide: function() {
|
||||
|
||||
},
|
||||
|
||||
onLoad() {
|
||||
|
||||
these = this;
|
||||
|
||||
|
||||
eventChannel = this.getOpenerEventChannel();
|
||||
|
||||
eventChannel.on('device', (data)=> {
|
||||
|
||||
console.log("收到父页面的参数:" + JSON.stringify(data));
|
||||
these.device = data;
|
||||
if(data.sosSmsMsg){
|
||||
this.txt=data.sosSmsMsg;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
},
|
||||
methods: {
|
||||
copyTo(item, index) {
|
||||
this.txt = item;
|
||||
},
|
||||
|
||||
saveTxt() {
|
||||
if (this.txt.replace(/ /g, '') == '') {
|
||||
MsgError('请输入通知内容', '', these);
|
||||
return;
|
||||
}
|
||||
|
||||
showLoading(this, {
|
||||
text: '请稍候...'
|
||||
});
|
||||
console.log("this.device=",this.device);
|
||||
request({
|
||||
url: '/app/hby018a/device/SetSmsMsg',
|
||||
method: 'POST',
|
||||
data: {
|
||||
sendMsg: this.txt,
|
||||
deviceIds: [this.device.id]
|
||||
}
|
||||
}).then(res => {
|
||||
if (res && res.code == 200) {
|
||||
MsgSuccess('操作成功', '', these);
|
||||
|
||||
if(eventChannel){
|
||||
eventChannel.emit('MsgOver', this.txt);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
MsgError(res.msg, '', these);
|
||||
}).catch(ex => {
|
||||
MsgError('出现错误,操作失败', '', these);
|
||||
}).finally(() => {
|
||||
hideLoading(these)
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.staItem {
|
||||
width: 100%;
|
||||
height: 80rpx;
|
||||
line-height: 80rpx;
|
||||
border-radius: 8px;
|
||||
background: rgba(26, 26, 26, 1);
|
||||
text-indent: 30rpx;
|
||||
color: rgba(255, 255, 255, 0.6);
|
||||
font-family: "PingFang SC";
|
||||
font-style: Regular;
|
||||
font-size: 28rpx;
|
||||
font-weight: 400;
|
||||
letter-spacing: 0.07px;
|
||||
margin-bottom: 25rpx;
|
||||
}
|
||||
|
||||
.title {
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
margin: 15rpx 0rpx;
|
||||
font-family: "PingFang SC";
|
||||
font-style: Regular;
|
||||
font-size: 28rpx;
|
||||
font-weight: 400;
|
||||
line-height: 40rpx;
|
||||
width: 100%;
|
||||
height: 40rpx;
|
||||
letter-spacing: 0.07px;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.footBtn .convert {
|
||||
/* 组合 99 */
|
||||
width: 130rpx;
|
||||
height: 55rpx;
|
||||
line-height: 55rpx;
|
||||
border-radius: 180px;
|
||||
color: #232323;
|
||||
background-color: #AED600;
|
||||
text-align: center;
|
||||
font-family: 'PingFang SC';
|
||||
font-size: 24rpx;
|
||||
font-weight: 400;
|
||||
letter-spacing: 12rpx;
|
||||
}
|
||||
|
||||
.placehoderClass {
|
||||
color: rgba(255, 255, 255, 0.6);
|
||||
|
||||
font-family: PingFang SC;
|
||||
font-size: 32rpx;
|
||||
font-weight: 400;
|
||||
line-height: 44rpx;
|
||||
letter-spacing: 0.14px;
|
||||
}
|
||||
|
||||
.textarea {
|
||||
min-height: 200rpx;
|
||||
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.text-content {
|
||||
border-radius: 16rpx;
|
||||
background: rgba(26, 26, 26, 1);
|
||||
width: 100%;
|
||||
height: auto;
|
||||
box-sizing: border-box;
|
||||
padding: 20rpx;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.content {
|
||||
padding: 30rpx;
|
||||
width: 100%;
|
||||
min-height: 100vh;
|
||||
height: auto;
|
||||
}
|
||||
|
||||
|
||||
.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;
|
||||
}
|
||||
</style>
|
||||
@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<view class="pageContent">
|
||||
<image src="/static/images/common/login.png" mode="" class="login-bg"></image>
|
||||
<view class="content_con">
|
||||
<view class="content_con" @click="account">
|
||||
<view class="user_logo">
|
||||
<image src="/static/images/common/logo.png" class="logo"></image>
|
||||
</view>
|
||||
@ -37,14 +37,14 @@
|
||||
<text class="title">关于我们</text>
|
||||
<uni-icons type="right" size="25" color="rgba(255, 255, 255, 0.4)" class="uniIcon"></uni-icons>
|
||||
</view>
|
||||
<view class="menu-item" @click="logOff">
|
||||
<!-- <view class="menu-item" @click="logOff">
|
||||
<image src="/static/images/common/zhuxiao.png" class="icon"></image>
|
||||
<text class="title">注销账号</text>
|
||||
<uni-icons type="right" size="25" color="rgba(255, 255, 255, 0.4)" class="uniIcon"></uni-icons>
|
||||
</view>
|
||||
</view> -->
|
||||
<view class="menu-item" @click="account">
|
||||
<image src="/static/images/common/wm.png" class="icon"></image>
|
||||
<text class="title">账号安全</text>
|
||||
<text class="title">账号</text>
|
||||
<uni-icons type="right" size="25" color="rgba(255, 255, 255, 0.4)" class="uniIcon"></uni-icons>
|
||||
</view>
|
||||
<view class="btn_footer">
|
||||
|
||||
BIN
static/images/common/HBY018A.png
Normal file
BIN
static/images/common/HBY018A.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 20 KiB |
BIN
static/images/common/empty.png
Normal file
BIN
static/images/common/empty.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 7.9 KiB |
BIN
static/images/common/hongwai.png
Normal file
BIN
static/images/common/hongwai.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.8 KiB |
BIN
static/images/common/hongwaiActive.png
Normal file
BIN
static/images/common/hongwaiActive.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.9 KiB |
BIN
static/images/common/linkMan.png
Normal file
BIN
static/images/common/linkMan.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.4 KiB |
BIN
static/images/common/shortMsg.png
Normal file
BIN
static/images/common/shortMsg.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.4 KiB |
@ -768,6 +768,7 @@ class BleHelper {
|
||||
} catch (convertException) {
|
||||
if (str && (str.trim().startsWith('{') || str.trim().startsWith('['))) {
|
||||
console.error("JSON解析失败(可能是格式错误的数据)", convertException);
|
||||
console.error("错误的数据", str);
|
||||
}
|
||||
}
|
||||
|
||||
@ -810,6 +811,7 @@ class BleHelper {
|
||||
console.error(
|
||||
"订阅消息出现异常",
|
||||
err);
|
||||
console.error("异常数据:", str);
|
||||
}
|
||||
|
||||
}
|
||||
@ -976,7 +978,10 @@ class BleHelper {
|
||||
if (this.cfg.recoveryCallback.length > 0) {
|
||||
this.cfg.recoveryCallback.forEach(c => {
|
||||
try {
|
||||
c.callback({ deviceId: res.deviceId, connected: true });
|
||||
c.callback({
|
||||
deviceId: res.deviceId,
|
||||
connected: true
|
||||
});
|
||||
} catch (err) {
|
||||
console.error("执行蓝牙恢复连接的回调异常", err);
|
||||
}
|
||||
@ -1575,9 +1580,11 @@ class BleHelper {
|
||||
return Promise.resolve(true);
|
||||
}
|
||||
if (this.data.connectingDevices[deviceId]) {
|
||||
console.error("连接任务进行中,本次连接被阻断")
|
||||
return Promise.resolve(false);
|
||||
}
|
||||
this.data.connectingDevices = true;
|
||||
|
||||
this.data.connectingDevices[deviceId] = true;
|
||||
|
||||
if (maxRetries === undefined) {
|
||||
maxRetries = 0; // 最大重试次数
|
||||
@ -1607,11 +1614,13 @@ class BleHelper {
|
||||
//连接设备
|
||||
var linkDevice = () => {
|
||||
// 添加重试次数限制
|
||||
|
||||
let retryCount = 0;
|
||||
|
||||
|
||||
const connect = () => {
|
||||
return new Promise((resolve, reject) => {
|
||||
|
||||
if (fIndex > -1 && f?.Linked) {
|
||||
// console.log("当前已连接,跳过其他步骤");
|
||||
resolve(false);
|
||||
@ -1625,10 +1634,10 @@ class BleHelper {
|
||||
return;
|
||||
}
|
||||
|
||||
// console.log("正在连接" + deviceId);
|
||||
console.log("正在连接" + deviceId);
|
||||
uni.createBLEConnection({
|
||||
deviceId: deviceId,
|
||||
timeout: 20000,
|
||||
timeout: 10000,
|
||||
success: (info) => {
|
||||
//释放连接锁
|
||||
|
||||
@ -1728,7 +1737,7 @@ class BleHelper {
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
this.OpenBlue().then((res) => {
|
||||
////console.log("2222222");
|
||||
console.log("2222222");
|
||||
return linkDevice(deviceId);
|
||||
}).then((res) => {
|
||||
|
||||
@ -1772,6 +1781,7 @@ class BleHelper {
|
||||
}, 500);
|
||||
}).catch((ex) => {
|
||||
console.error("出现异常", ex);
|
||||
delete this.data.connectingDevices[deviceId];
|
||||
reject(ex);
|
||||
});
|
||||
});
|
||||
@ -1869,6 +1879,7 @@ class BleHelper {
|
||||
}
|
||||
//向蓝牙设备发送一个字符串的ASCII码
|
||||
sendString(deviceid, str, writeServiceId, wirteCharactId, ms, iosIsChuck, chunkSize) {
|
||||
debugger;
|
||||
if (str && typeof(str) == 'object') {
|
||||
str = JSON.stringify(str);
|
||||
}
|
||||
@ -1913,6 +1924,7 @@ class BleHelper {
|
||||
}
|
||||
//向蓝牙设备发送数据,如果没连接将自动连接后再发
|
||||
sendData(deviceid, buffer, writeServiceId, wirteCharactId, ms, iosIsChuck, chunkSize) {
|
||||
debugger;
|
||||
if (this.data.platform == 'web') {
|
||||
return Promise.resolve("h5平台默认成功");
|
||||
}
|
||||
@ -1995,7 +2007,9 @@ class BleHelper {
|
||||
},
|
||||
fail: (ex) => {
|
||||
ex = this.getError(ex);
|
||||
console.error("✗ 蓝牙指令发送失败 - deviceId:",device.deviceId, "错误:", ex);
|
||||
console.error(
|
||||
"✗ 蓝牙指令发送失败 - deviceId:",
|
||||
device.deviceId, "错误:", ex);
|
||||
|
||||
_err(ex);
|
||||
}
|
||||
|
||||
@ -31,6 +31,7 @@ class BleReceive {
|
||||
'/pages/100J/HBY100-J': this.Receive_100J.bind(this),
|
||||
'/pages/6075J/BJQ6075J': this.Receive_6075.bind(this),
|
||||
'/pages/210/HBY210':this.Receive_210.bind(this),
|
||||
'/pages/018A/HBY018A':this.Receive_018A.bind(this)
|
||||
};
|
||||
|
||||
}
|
||||
@ -743,9 +744,9 @@ class BleReceive {
|
||||
let receiveData = {};
|
||||
|
||||
try {
|
||||
console.log("订阅消息者:", path);
|
||||
console.log("设备收到消息:", f);
|
||||
console.log("消息内容:", receive);
|
||||
// console.log("订阅消息者:", path);
|
||||
// console.log("设备收到消息:", f);
|
||||
// console.log("消息内容:", receive);
|
||||
receiveData = JSON.parse(receive.str);
|
||||
|
||||
let recCnt = recArr.find(v => {
|
||||
@ -770,6 +771,7 @@ class BleReceive {
|
||||
} catch (error) {
|
||||
receiveData = {};
|
||||
console.error("文本解析失败", error)
|
||||
console.error("错误数据:",receive);
|
||||
}
|
||||
return receiveData;
|
||||
|
||||
@ -973,6 +975,35 @@ class BleReceive {
|
||||
return receiveData;
|
||||
|
||||
}
|
||||
Receive_018A(receive, f, path, recArr) {
|
||||
let receiveData = {};
|
||||
|
||||
try {
|
||||
|
||||
receiveData = JSON.parse(receive.str);
|
||||
|
||||
let recCnt = recArr.find(v => {
|
||||
return v.key.replace(/\//g, "").toLowerCase() == f.device.detailPageUrl
|
||||
.replace(/\//g, "").toLowerCase();
|
||||
});
|
||||
if (!recCnt && this.ref) {
|
||||
if (receiveData.sta_PowerPercent <= 20 && (receiveData.sta_system != 3 || receiveData.sta_system !=1)) {
|
||||
|
||||
MsgError("设备'" + f.device.deviceName + "'电量低", '', this.ref, () => {
|
||||
MsgClear(this.ref);
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
receiveData = {};
|
||||
console.log("文本解析失败", error)
|
||||
}
|
||||
return receiveData;
|
||||
|
||||
}
|
||||
|
||||
Receive_210(receive, f, path, recArr) {
|
||||
let receiveData = {};
|
||||
|
||||
@ -1008,11 +1039,9 @@ class BleReceive {
|
||||
let receiveInstance = null;
|
||||
export default {
|
||||
getBleReceive: function(_ref) {
|
||||
console.log("_ref=",_ref);
|
||||
// console.log("_ref=",_ref);
|
||||
if (!receiveInstance) {
|
||||
receiveInstance = new BleReceive(_ref);
|
||||
}else{
|
||||
console.log("使用现有实例receiveInstance")
|
||||
}
|
||||
return receiveInstance;
|
||||
}
|
||||
|
||||
100
utils/Common.js
100
utils/Common.js
@ -457,12 +457,13 @@ export default {
|
||||
let url = ''
|
||||
if (os === 'ios') {
|
||||
url = 'https://apps.apple.com/cn/app/星汉物联/id6752555460'
|
||||
}
|
||||
|
||||
else if(os==='android'){
|
||||
} else if (os === 'android') {
|
||||
url = 'https://www.pgyer.com/xhwl';
|
||||
}
|
||||
return {os:os,url:url};
|
||||
return {
|
||||
os: os,
|
||||
url: url
|
||||
};
|
||||
},
|
||||
|
||||
|
||||
@ -488,5 +489,96 @@ export default {
|
||||
}
|
||||
|
||||
return result;
|
||||
},
|
||||
formatTime(value, unit = 'minute') {
|
||||
// 边界处理:空值、0或负数
|
||||
if (!value || value <= 0) return '0秒';
|
||||
|
||||
// 将所有单位统一转换为分钟和总秒数
|
||||
let minutes;
|
||||
let totalSeconds;
|
||||
|
||||
switch (unit) {
|
||||
case 'second': // 秒
|
||||
minutes = value / 60;
|
||||
totalSeconds = value;
|
||||
break;
|
||||
case 'minute': // 分钟(默认)
|
||||
minutes = value;
|
||||
totalSeconds = value * 60;
|
||||
break;
|
||||
case 'hour': // 小时
|
||||
minutes = value * 60;
|
||||
totalSeconds = value * 3600;
|
||||
break;
|
||||
case 'day': // 天
|
||||
minutes = value * 24 * 60;
|
||||
totalSeconds = value * 86400;
|
||||
break;
|
||||
default:
|
||||
minutes = value;
|
||||
totalSeconds = value * 60;
|
||||
}
|
||||
|
||||
// 定义时间单位(分钟)
|
||||
const units = [
|
||||
{ label: '年', minutes: 365 * 24 * 60 },
|
||||
{ label: '月', minutes: 30 * 24 * 60 }, // 按30天简化计算
|
||||
{ label: '天', minutes: 24 * 60 },
|
||||
{ label: '小时', minutes: 60 },
|
||||
{ label: '分', minutes: 1 }
|
||||
];
|
||||
|
||||
let remaining = minutes;
|
||||
const parts = [];
|
||||
|
||||
for (const unitObj of units) {
|
||||
const val = Math.floor(remaining / unitObj.minutes);
|
||||
if (val > 0) {
|
||||
parts.push(`${val}${unitObj.label}`);
|
||||
remaining %= unitObj.minutes;
|
||||
}
|
||||
}
|
||||
|
||||
// 处理剩余的秒数(remaining 现在是小于1分钟的分钟数)
|
||||
if (remaining > 0) {
|
||||
const seconds = Math.round(remaining * 60);
|
||||
if (seconds > 0) {
|
||||
parts.push(`${seconds}秒`);
|
||||
}
|
||||
}
|
||||
|
||||
// 如果没有任何部分,返回总秒数
|
||||
if (parts.length === 0) {
|
||||
return `${Math.floor(totalSeconds)}秒`;
|
||||
}
|
||||
|
||||
return parts.join('');
|
||||
},
|
||||
regeo(lon, lat) {
|
||||
return new Promise((resolve, reject) => {
|
||||
let url =
|
||||
'https://restapi.amap.com/v3/geocode/regeo?key=ca3af8a20d628897020893892bda5ae4&location=' +
|
||||
lon + ',' + lat;
|
||||
|
||||
request({
|
||||
url: url,
|
||||
method: 'GET',
|
||||
isAuthen: false
|
||||
}).then(res => {
|
||||
if (res) {
|
||||
if (res.infocode == '10000' && res.info == 'OK') {
|
||||
resolve(res);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
reject(res);
|
||||
}).catch(ex => {
|
||||
reject(ex);
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,5 +1,5 @@
|
||||
import config from '../config/index.js';
|
||||
export const env = 'production'; //production development //开发of线上 改这里就行
|
||||
export const env = 'development'; //production development //开发of线上 改这里就行
|
||||
const BASE = config[env];
|
||||
const request = (options) => {
|
||||
// console.log("options" + JSON.stringify(options), BASE.BASE_URL)
|
||||
|
||||
Reference in New Issue
Block a user