Compare commits
4 Commits
main
...
new-202508
| Author | SHA1 | Date | |
|---|---|---|---|
| 677586e51c | |||
| 5128c29d86 | |||
| 1f88de4710 | |||
| 01ff9c7a05 |
119
App.vue
119
App.vue
@ -9,32 +9,38 @@
|
||||
export default {
|
||||
|
||||
onLaunch: function() {
|
||||
//以下代码仅在开发时使用,否则会出现不可预知的问题。
|
||||
//清除登陆之外的所有信息;
|
||||
// let store=uni.getStorageInfoSync();
|
||||
// store.keys.forEach((val,index,array)=>{
|
||||
// if(val=="tokenTime"){
|
||||
// let time=uni.getStorageSync(val);
|
||||
// if(!time){
|
||||
// time=0;
|
||||
// }
|
||||
// let currTime=new Date().getTime();
|
||||
// if(currTime>=time){
|
||||
// uni.removeStorageSync(val);
|
||||
// uni.removeStorageSync("token");
|
||||
// uni.removeStorageSync("clientID");
|
||||
// }
|
||||
// }
|
||||
// else if(val=="token" || val=="clientID" || val=='phone'){
|
||||
// console.log("忽略登陆信息");
|
||||
// }else{
|
||||
// uni.removeStorageSync(val);
|
||||
// }
|
||||
// });
|
||||
// uni.clearStorageSync();
|
||||
//以上代码仅在开发时使用,否则会出现不可预知的问题。
|
||||
|
||||
// #ifdef APP|APP-PLUS
|
||||
let appid = plus.runtime.appid;
|
||||
console.log("appid=", appid);
|
||||
|
||||
if (appid === 'HBuilder') {
|
||||
let store = uni.getStorageInfoSync();
|
||||
store.keys.forEach((val, index, array) => {
|
||||
if (val == "tokenTime") {
|
||||
let time = uni.getStorageSync(val);
|
||||
if (!time) {
|
||||
time = 0;
|
||||
}
|
||||
let currTime = new Date().getTime();
|
||||
if (currTime >= time) {
|
||||
uni.removeStorageSync(val);
|
||||
uni.removeStorageSync("token");
|
||||
uni.removeStorageSync("clientID");
|
||||
}
|
||||
} else if (val == "token" || val == "clientID" || val == 'phone') {
|
||||
console.log("忽略登陆信息");
|
||||
} else {
|
||||
uni.removeStorageSync(val);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
let system = uni.getSystemInfoSync();
|
||||
|
||||
|
||||
let initOS = () => {
|
||||
let ble = bleTool.getBleTool();
|
||||
|
||||
@ -48,14 +54,17 @@
|
||||
}
|
||||
});
|
||||
if (!uni.setAppBadgeNumber) { //兼容鸿蒙的写法
|
||||
uni.setAppBadgeNumber = plus.runtime.setBadgeNumber;
|
||||
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 +75,7 @@
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
if (plus.os.name == 'Android') {
|
||||
if (plus.runtime.isAgreePrivacy()) {
|
||||
initOS();
|
||||
@ -75,8 +85,8 @@
|
||||
}
|
||||
|
||||
|
||||
let system=uni.getSystemInfoSync();
|
||||
console.log("system=",system);
|
||||
|
||||
console.log("system=", system);
|
||||
// #endif
|
||||
},
|
||||
onShow: function() {
|
||||
@ -95,6 +105,14 @@
|
||||
if (appid !== 'HBuilder') {
|
||||
upgrade.checkAndUpdateWgt();
|
||||
}
|
||||
|
||||
uni.setKeepScreenOn({
|
||||
keepScreenOn: true
|
||||
}).then(res => {
|
||||
console.log("已设置屏幕常亮");
|
||||
}).catch(ex => {
|
||||
console.error("设置屏幕常亮失败,ex=", ex)
|
||||
})
|
||||
// #endif
|
||||
|
||||
|
||||
@ -102,6 +120,15 @@
|
||||
onHide: function() {
|
||||
console.log('App Hide');
|
||||
// #ifdef APP|APP-PLUS
|
||||
|
||||
uni.setKeepScreenOn({
|
||||
keepScreenOn: false
|
||||
}).then(res => {
|
||||
console.log("已关闭屏幕常亮");
|
||||
}).catch(ex => {
|
||||
console.error("设置屏幕常亮失败,ex=", ex)
|
||||
})
|
||||
|
||||
// 上传中不主动断开:语音上传进行中则不断开蓝牙
|
||||
let ble = bleTool.getBleTool();
|
||||
if (ble && ble.isVoiceUploading && ble.isVoiceUploading()) {
|
||||
@ -206,6 +233,10 @@
|
||||
color: #ffffffde;
|
||||
}
|
||||
|
||||
.uni-app--maxwidth,
|
||||
.uni-body {
|
||||
background-color: #121212;
|
||||
}
|
||||
|
||||
.fleft {
|
||||
float: left;
|
||||
@ -236,14 +267,32 @@
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
|
||||
@font-face {
|
||||
font-family: "PingFang SC";
|
||||
src: url("~@/static/fonts/PingFangSC.ttf") format("opentype");
|
||||
.navbarRight .img {
|
||||
width: 35rpx;
|
||||
height: 35rpx;
|
||||
margin-right: 30rpx;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: "PingFangBold";
|
||||
src: url("~@/static/fonts/PingFangBold.ttf") format("opentype");
|
||||
.uni-navbar--fixed {
|
||||
top: 0rpx;
|
||||
}
|
||||
|
||||
::v-deep .uni-navbar--fixed {
|
||||
top: 0px;
|
||||
}
|
||||
|
||||
::v-deep .uni-navbar__placeholder {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
|
||||
// @font-face {
|
||||
// font-family: "PingFang SC";
|
||||
// src: url("~@/static/fonts/PingFangSC.ttf") format("opentype");
|
||||
// }
|
||||
|
||||
// @font-face {
|
||||
// font-family: "PingFangBold";
|
||||
// src: url("~@/static/fonts/PingFangBold.ttf") format("opentype");
|
||||
// }
|
||||
</style>
|
||||
@ -33,7 +33,7 @@
|
||||
<image v-if="item.icon" :src="item.icon" mode="aspectFit"></image>
|
||||
</view>
|
||||
|
||||
<text>{{ item.text }}</text>
|
||||
<text class="itemTxt" :class="(config.textAlign=='flex-start'&&!item.icon)?'txtIndent':''">{{ item.text }}</text>
|
||||
</view>
|
||||
|
||||
|
||||
@ -139,6 +139,9 @@
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.txtIndent{
|
||||
text-indent: 30rpx;
|
||||
}
|
||||
.message-popup {
|
||||
position: relative;
|
||||
display: none;
|
||||
|
||||
@ -14,7 +14,13 @@
|
||||
<view v-if="!visiblePrompt">
|
||||
<image v-if="iconUrl" :src="iconUrl" mode="aspectFit" class="popup-icon"
|
||||
:style="{ tintColor: textColor || getTypeStyle('textColor') }"></image>
|
||||
<view class="popup-message" :class="showSlot?'displayNone':''">{{ message }}</view>
|
||||
<view :class="showSlot?'displayNone':''">
|
||||
<view class="popup-message" v-if="typeof(message)=='string'">{{ message }}</view>
|
||||
<view class="popup-message" v-else>
|
||||
<view v-for="item,i in message">{{item}}</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="popup-message" :class="showSlot?'':'displayNone'">
|
||||
<slot></slot>
|
||||
</view>
|
||||
@ -83,7 +89,7 @@
|
||||
buttonTextColor: String,
|
||||
iconUrl: String,
|
||||
message: {
|
||||
type: String,
|
||||
type: String|Array,
|
||||
default: ''
|
||||
},
|
||||
buttonText: {
|
||||
@ -135,30 +141,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,36 @@
|
||||
icoUrl: '/static/images/common/uploadErr.png',
|
||||
borderColor: "#e034344d",
|
||||
buttonBgColor: "#E03434",
|
||||
bgColor:'#38393466',
|
||||
buttonTextColor:'#FFFFFFde'
|
||||
bgColor:'#383934cc',
|
||||
buttonTextColor:'#FFFFFFde',
|
||||
showCancel:true,
|
||||
buttonCancelText:'取消'
|
||||
},
|
||||
succ: {
|
||||
icoUrl: '/static/images/common/success.png',
|
||||
borderColor: "#BBE6004d",
|
||||
buttonBgColor: "#BBE600",
|
||||
bgColor:'#38393466'
|
||||
buttonTextColor:'#232323de',
|
||||
bgColor:'#383934cc',
|
||||
showCancel:true,
|
||||
buttonCancelText:'取消'
|
||||
},
|
||||
warn: {
|
||||
icoUrl: '/static/images/common/warning.png',
|
||||
borderColor: "#FFC84E4d",
|
||||
buttonBgColor: "#FFC84E",
|
||||
bgColor:'#38393466'
|
||||
buttonTextColor:'#FFFFFFde',
|
||||
bgColor:'#383934cc',
|
||||
showCancel:true,
|
||||
buttonCancelText:'取消'
|
||||
},
|
||||
info:{
|
||||
borderColor: "#BBE6004d",
|
||||
buttonBgColor: "#BBE600",
|
||||
bgColor:'#38393466'
|
||||
bgColor:'#383934cc',
|
||||
buttonTextColor:'#232323de',
|
||||
showCancel:true,
|
||||
buttonCancelText:'取消'
|
||||
},
|
||||
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.27",
|
||||
"versionCode" : 101,
|
||||
"transformPx" : false,
|
||||
/* 5+App特有相关 */
|
||||
@ -79,7 +79,8 @@
|
||||
"NSMicrophoneUsageDescription" : "App需要您的同意访问麦克风,用于上传语音包"
|
||||
},
|
||||
"idfa" : false,
|
||||
"urltypes" : ""
|
||||
"urltypes" : "",
|
||||
"urlschemewhitelist" : ""
|
||||
},
|
||||
/* SDK配置 */
|
||||
"sdkConfigs" : {
|
||||
@ -100,23 +101,19 @@
|
||||
},
|
||||
"push" : {
|
||||
"unipush" : {
|
||||
"version" : "2",
|
||||
"offline" : true,
|
||||
"hms" : {},
|
||||
"oppo" : {},
|
||||
"vivo" : {},
|
||||
"mi" : {},
|
||||
"meizu" : {},
|
||||
"honor" : {},
|
||||
"version" : "2",
|
||||
"icons" : {
|
||||
"small" : {
|
||||
"ldpi" : "unpackage/res/icons/18x18.png",
|
||||
"mdpi" : "unpackage/res/icons/24x24.png",
|
||||
"hdpi" : "unpackage/res/icons/36x36.png",
|
||||
"xhdpi" : "unpackage/res/icons/48x48.png",
|
||||
"xxhdpi" : "unpackage/res/icons/72x72.png"
|
||||
"hdpi" : "unpackage/res/icons/36x36.png"
|
||||
}
|
||||
},
|
||||
"meizu" : {}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
39
pages.json
39
pages.json
@ -169,6 +169,7 @@
|
||||
"path": "pages/common/map/index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "地图"
|
||||
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -180,7 +181,14 @@
|
||||
{
|
||||
"path": "pages/common/allShare/index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "所有分享"
|
||||
"navigationBarTitleText": "所有分享",
|
||||
"app-plus": {
|
||||
"pullToRefresh": {
|
||||
"support": false, // 开启下拉刷新
|
||||
"color": "#FF5500", // 刷新图标颜色,仅 circle 样式支持
|
||||
"style": "default" // 可选 "default" 或 "circle"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@ -357,7 +365,8 @@
|
||||
"path" : "pages/018A/HBY018A",
|
||||
"style" :
|
||||
{
|
||||
"navigationBarTitleText" : "HBY018A"
|
||||
"navigationBarTitleText" : "HBY018A",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -466,6 +475,32 @@
|
||||
"navigationStyle": "custom",
|
||||
"navigationBarTitleText": "HBY210"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/common/sosSet/TxtMsgSetting",
|
||||
"style": {
|
||||
"navigationBarTitleText": "短信设置",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/common/sosSet/LinkManSetting",
|
||||
"style": {
|
||||
"navigationBarTitleText": "紧急联系人",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/common/sosSet/remark",
|
||||
"style": {
|
||||
"navigationBarTitleText": ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/018A/018AMsg",
|
||||
"style": {
|
||||
"navigationBarTitleText": "报警记录"
|
||||
}
|
||||
}
|
||||
|
||||
],
|
||||
|
||||
@ -100,7 +100,7 @@
|
||||
var ble = null;
|
||||
var recei = null;
|
||||
var mq = null;
|
||||
var pagePath="pages/008A/HBY008A";
|
||||
var pagePath = "pages/008A/HBY008A";
|
||||
|
||||
export default {
|
||||
data() {
|
||||
@ -112,9 +112,11 @@
|
||||
apiType: "listA",
|
||||
navbar: {
|
||||
icons: [{
|
||||
type:'msg',
|
||||
src: '/static/images/common/msg.png'
|
||||
},
|
||||
{
|
||||
type:'share',
|
||||
src: '/static/images/common/shape.png'
|
||||
}
|
||||
],
|
||||
@ -196,9 +198,9 @@
|
||||
onUnload() {
|
||||
console.log("页面卸载,释放资源");
|
||||
let statusTopic = `A/${this.formData.imei?this.formData.imei:this.device.deviceImei}`;
|
||||
if(ble){
|
||||
ble.removeAllCallback(pagePath);
|
||||
ble.removeReceiveCallback(pagePath);
|
||||
if (ble) {
|
||||
ble.removeAllCallback(pagePath);
|
||||
ble.removeReceiveCallback(pagePath);
|
||||
}
|
||||
|
||||
if (mq) {
|
||||
@ -230,7 +232,7 @@
|
||||
|
||||
eventChannel = this.getOpenerEventChannel();
|
||||
|
||||
eventChannel.on('detailData', (data)=> {
|
||||
eventChannel.on('detailData', (data) => {
|
||||
|
||||
console.log("收到父页面的参数:" + JSON.stringify(data));
|
||||
var device = data.data;
|
||||
@ -285,7 +287,7 @@
|
||||
these.formData.bleStatu = true;
|
||||
}).catch(ex => {
|
||||
these.formData.bleStatu = 'err';
|
||||
MsgError("连接错误:" + ex.msg, "确定", these);
|
||||
MsgError("连接错误:" + ex.msg, "确定", these);
|
||||
});
|
||||
});
|
||||
|
||||
@ -312,12 +314,43 @@
|
||||
these.formData.bleStatu = true;
|
||||
}).catch(ex => {
|
||||
these.formData.bleStatu = 'err';
|
||||
MsgError("连接错误:" + ex.msg, "确定", these);
|
||||
MsgError("连接错误:" + ex.msg, "确定", these);
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
},
|
||||
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() {
|
||||
|
||||
@ -442,8 +475,8 @@
|
||||
updateLoading(these, {
|
||||
text: ex.msg
|
||||
})
|
||||
these.formData.bleStatu = 'err';
|
||||
MsgError("连接错误:" + ex.msg, "确定", these);
|
||||
these.formData.bleStatu = 'err';
|
||||
MsgError("连接错误:" + ex.msg, "确定", these);
|
||||
}).finally(() => {
|
||||
setTimeout(() => {
|
||||
hideLoading(these);
|
||||
|
||||
330
pages/018A/018AMsg.vue
Normal file
330
pages/018A/018AMsg.vue
Normal file
@ -0,0 +1,330 @@
|
||||
<template>
|
||||
<view class="maincontent1 contentBg">
|
||||
<!-- <view class="tab">
|
||||
<view class="tabItem" :class="{active:Status.tabIndex===0}" @click.stop="tabChange(0)">报警</view>
|
||||
<view class="tabItem" :class="{active:Status.tabIndex===1}" @click.stop="tabChange(1)">通话</view>
|
||||
<view class="tabItem" :class="{active:Status.tabIndex===2}" @click.stop="tabChange(2)">开机</view>
|
||||
<view class="tabItem" :class="{active:Status.tabIndex===3}" @click.stop="tabChange(3)">故障</view>
|
||||
</view> -->
|
||||
|
||||
|
||||
<view class="list">
|
||||
<mescroll-uni class="device-list" @init="mescrollInit" @down="downCallback" @up="upCallback" :up="upOption"
|
||||
:down="downOption" :fixed="false">
|
||||
<view v-for="item,index in list" class="listItem">
|
||||
|
||||
<view v-if="Status.tabIndex==0">
|
||||
<view class="row">
|
||||
<view class="label">报警事项:</view>
|
||||
<view class="red value">{{item.content}}</view>
|
||||
</view>
|
||||
<view class="row">
|
||||
<view class="label">报警地点:</view>
|
||||
<view class="value">{{item.location}}</view>
|
||||
</view>
|
||||
<view class="row">
|
||||
<view class="label">报警时间:</view>
|
||||
<view class="value">{{item.startTime}}</view>
|
||||
</view>
|
||||
<view class="row">
|
||||
<view class="label">解除时间:</view>
|
||||
<view class="value">{{item.finishTime}}</view>
|
||||
</view>
|
||||
<view class="row">
|
||||
<view class="label">报警时长:</view>
|
||||
<view class="value">{{item.durationTime}}</view>
|
||||
</view>
|
||||
</view>
|
||||
<view v-if="Status.tabIndex==1">
|
||||
|
||||
</view>
|
||||
<view v-if="Status.tabIndex==2">
|
||||
|
||||
</view>
|
||||
<view v-if="Status.tabIndex==3">
|
||||
|
||||
</view>
|
||||
</view>
|
||||
</mescroll-uni>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
var timeout = null;
|
||||
import request from '@/utils/request.js';
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
Status: {
|
||||
tabIndex: 0
|
||||
},
|
||||
list: [],
|
||||
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: '没有更多数据了'
|
||||
},
|
||||
device: {
|
||||
|
||||
}
|
||||
}
|
||||
},
|
||||
onLoad() {
|
||||
let eventChannel = this.getOpenerEventChannel();
|
||||
eventChannel.on('detailData', (data) => {
|
||||
debugger;
|
||||
if (data) {
|
||||
this.device = data;
|
||||
}
|
||||
|
||||
});
|
||||
},
|
||||
methods: {
|
||||
mescrollInit(mescroll) {
|
||||
this.mescroll = mescroll;
|
||||
},
|
||||
// 下拉刷新
|
||||
downCallback() {
|
||||
|
||||
|
||||
if (this.mescroll) {
|
||||
this.mescroll.resetUpScroll(false);
|
||||
this.mescroll.scrollTo(0, 0);
|
||||
}
|
||||
this.getData();
|
||||
|
||||
|
||||
},
|
||||
// 上拉加载
|
||||
upCallback() {
|
||||
|
||||
|
||||
|
||||
this.getData();
|
||||
},
|
||||
getWarList(data) {
|
||||
return request({
|
||||
url: '/app/device/AlarmList',
|
||||
method: 'get',
|
||||
data: data
|
||||
});
|
||||
},
|
||||
getNotifyList() {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve({
|
||||
code: 200,
|
||||
total: 0,
|
||||
rows: []
|
||||
})
|
||||
});
|
||||
},
|
||||
getTrun() {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve({
|
||||
total: 0,
|
||||
rows: []
|
||||
})
|
||||
});
|
||||
},
|
||||
getGuzhang() {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve({
|
||||
total: 0,
|
||||
rows: []
|
||||
})
|
||||
});
|
||||
},
|
||||
getData() {
|
||||
let task = () => {
|
||||
debugger;
|
||||
let data = {
|
||||
deviceId:(this.device&& this.device.id)?this.device.id:"00000000",
|
||||
pageNum: this.mescroll.num,
|
||||
pageSize: 10,
|
||||
}
|
||||
console.log("device=", JSON.stringify(this.device));
|
||||
console.log("data", JSON.stringify(data));
|
||||
if (!data.pageNum) {
|
||||
this.mescroll.endSuccess(0, false);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
let arr = {
|
||||
"0": this.getWarList.bind(this),
|
||||
"1": this.getNotifyList.bind(this),
|
||||
"2": this.getTrun.bind(this),
|
||||
"3": this.getGuzhang.bind(this),
|
||||
}
|
||||
|
||||
let apiCall = arr[this.Status.tabIndex + ''];
|
||||
apiCall(data).then((res) => {
|
||||
if (res.code == 200) {
|
||||
|
||||
|
||||
if (data.pageNum === 1) {
|
||||
this.list = res.rows;
|
||||
} else {
|
||||
this.list = this.list.concat(res.rows);
|
||||
}
|
||||
this.total = res.total;
|
||||
let hasNext = true;
|
||||
// 判断是否已加载全部数据
|
||||
if (res.rows.length < this.size || this.list.length >= this.total) {
|
||||
|
||||
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);
|
||||
},
|
||||
tabChange(index) {
|
||||
if (this.Status.tabIndex === index) {
|
||||
return;
|
||||
}
|
||||
this.Status.tabIndex = index
|
||||
this.downCallback();
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
/* #ifdef WEB|H5 */
|
||||
.maincontent1 {
|
||||
height: calc(100vh - 45px);
|
||||
}
|
||||
|
||||
/* #endif */
|
||||
.maincontent1 {
|
||||
height: 100vh;
|
||||
|
||||
width: 100%;
|
||||
padding: 30rpx;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.listItem {
|
||||
border-radius: 8px;
|
||||
background: rgba(26, 26, 26, 1);
|
||||
width: 100%;
|
||||
height: auto;
|
||||
margin-bottom: 20rpx;
|
||||
padding: 15rpx 20rpx;
|
||||
}
|
||||
|
||||
.listItem .label {
|
||||
color: rgba(255, 255, 255, 0.6);
|
||||
font-family: "PingFang SC";
|
||||
font-style: Regular;
|
||||
font-size: 26rpx;
|
||||
font-weight: 400;
|
||||
line-height: 30rpx;
|
||||
letter-spacing: 0.14rpx;
|
||||
width: 120rpx;
|
||||
text-align: left;
|
||||
white-space: nowrap;
|
||||
|
||||
}
|
||||
|
||||
.listItem .value {
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
|
||||
font-family: "PingFang SC";
|
||||
font-style: Regular;
|
||||
font-size: 26rpx;
|
||||
font-weight: 400;
|
||||
line-height: 30rpx;
|
||||
letter-spacing: 0.14rpx;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.listItem .row {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
flex-wrap: nowrap;
|
||||
align-content: flex-start;
|
||||
justify-content: flex-start;
|
||||
align-items: flex-start;
|
||||
height: auto;
|
||||
padding: 5rpx 0rpx;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
.list {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
|
||||
}
|
||||
|
||||
.tab {
|
||||
width: 100%;
|
||||
height: 40rpx;
|
||||
line-height: 40rpx;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
flex-wrap: nowrap;
|
||||
align-content: center;
|
||||
justify-content: flex-start;
|
||||
align-items: center;
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
font-family: "PingFang SC";
|
||||
font-style: Regular;
|
||||
font-size: 28rpx;
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
.tab .tabItem {
|
||||
position: relative;
|
||||
padding: 0rpx 30rpx;
|
||||
}
|
||||
|
||||
.tab .tabItem::after {
|
||||
position: absolute;
|
||||
content: "";
|
||||
width: 50%;
|
||||
height: 8rpx;
|
||||
border-radius: 30px;
|
||||
top: 100%;
|
||||
left: 25%;
|
||||
margin-top: 5rpx;
|
||||
background: #00000000;
|
||||
}
|
||||
|
||||
.tab .tabItem.active::after {
|
||||
background: rgba(187, 230, 0, 1);
|
||||
}
|
||||
|
||||
.tab .tabItem.active {
|
||||
color: rgba(174, 214, 0, 1);
|
||||
font-style: Bold;
|
||||
font-size: 32rpx;
|
||||
|
||||
}
|
||||
</style>
|
||||
File diff suppressed because it is too large
Load Diff
@ -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, // 当前页码
|
||||
|
||||
@ -241,22 +241,22 @@
|
||||
show: false,
|
||||
showHeader: true,
|
||||
menuItems: [{
|
||||
text: '2M',
|
||||
text: '低档',
|
||||
value: 'status_2M',
|
||||
icon: ''
|
||||
},
|
||||
{
|
||||
text: '4M',
|
||||
text: '中档',
|
||||
value: 'status_4M',
|
||||
icon: ''
|
||||
},
|
||||
{
|
||||
text: '7M',
|
||||
text: '高档',
|
||||
value: 'status_7M',
|
||||
icon: ''
|
||||
},
|
||||
{
|
||||
text: '10M',
|
||||
text: '超强',
|
||||
value: 'status_10M',
|
||||
icon: ''
|
||||
},
|
||||
|
||||
@ -192,7 +192,8 @@
|
||||
isLock: false,
|
||||
empty: {
|
||||
tip: "暂无数据",
|
||||
hideScroll: false,
|
||||
hideScroll: false,
|
||||
icon: '/static/images/common/empty.png'
|
||||
},
|
||||
textNoMore: "没有更多数据了",
|
||||
},
|
||||
|
||||
1237
pages/210/HBY210.vue
1237
pages/210/HBY210.vue
File diff suppressed because it is too large
Load Diff
@ -10,7 +10,7 @@
|
||||
<view slot="right">
|
||||
<view class="navbarRight center">
|
||||
<view class="imgContent" :class="{'visibilityHidden':Status.apiType!=item.apiType}"
|
||||
@click.stop="handleRightClick(item,index)" v-for="item,index in Status.navbar.icons">
|
||||
@click.stop="handleRightClick(item,index)" v-for="item,index in Status.navbar.icons">
|
||||
<image class="img" :src="item.src" mode="aspectFit"></image>
|
||||
<view class="baber" v-if="item.math">{{item.math>9?'9+':item.math}}</view>
|
||||
</view>
|
||||
@ -95,13 +95,13 @@
|
||||
|
||||
<view class="lampMode">
|
||||
<view class="mode fleft " v-for="item,index in dic.SOS"
|
||||
:class="{active:formData.sta_SOSType===item.val,marginLeft:index%2==1}"
|
||||
v-on:click.stop="sosSetting(item,index)">
|
||||
:class="{active:formData.sta_SOSType===item.val,marginLeft:index%2==1}"
|
||||
v-on:click.stop="sosSetting(item,index)">
|
||||
<view class="leftImg">
|
||||
<image class="img" :class="(formData.sta_SOSType!==item.val || !item.activeImg)?'':'displayNone'"
|
||||
:src="item.img" mode="aspectFit"></image>
|
||||
:src="item.img" mode="aspectFit"></image>
|
||||
<image class="img" :class="(formData.sta_SOSType===item.val && item.activeImg)?'':'displayNone'"
|
||||
:src="item.activeImg" mode="aspectFit"></image>
|
||||
:src="item.activeImg" mode="aspectFit"></image>
|
||||
</view>
|
||||
<view class="rightTxt">
|
||||
<text class="bigTxt">{{item['text']}}</text>
|
||||
@ -109,7 +109,16 @@
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="mode fleft " :class="{active:Status.sendDisc}" v-on:click.stop="discern()">
|
||||
<view class="leftImg">
|
||||
<image class="img" src="/static/images/common/svg.png" mode="aspectFit"></image>
|
||||
|
||||
</view>
|
||||
<view class="rightTxt">
|
||||
<text class="bigTxt">识别设备</text>
|
||||
<text class="smallTxt" v-show="Status.sendDisc">蓝光闪烁中</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="clear"></view>
|
||||
</view>
|
||||
|
||||
@ -128,8 +137,8 @@
|
||||
<view class="lampMode">
|
||||
<view class="colorContent">
|
||||
<view v-for="item,index in formData.groups" class="item"
|
||||
:class="{active:item.id==formData.sta_GroupType,marginNoLeft:index%3===0}"
|
||||
@click.stop="groupSetting(item,index)">
|
||||
:class="{active:item.id==formData.sta_GroupType,marginNoLeft:index%3===0}"
|
||||
@click.stop="groupSetting(item,index)">
|
||||
|
||||
<view class="polygon" :style="{backgroundColor:item.hex}">
|
||||
|
||||
@ -153,7 +162,7 @@
|
||||
<view class="modeSetting">
|
||||
|
||||
<view class="arrow" @click.stop="ArrowModeSet('right_off')"
|
||||
:class="formData.sta_ArrowMode=='right_off'?'active':''">
|
||||
:class="formData.sta_ArrowMode=='right_off'?'active':''">
|
||||
<view class="outCircle">
|
||||
<view class="item">
|
||||
<image class="img nomal" src="/static/images/4877/arrow.png" mode="aspectFit"></image>
|
||||
@ -164,13 +173,13 @@
|
||||
<view class="text">朝左</view>
|
||||
</view>
|
||||
<view class="arrow" @click.stop="ArrowModeSet('right_on')"
|
||||
:class="formData.sta_ArrowMode=='right_on'?'active':''">
|
||||
:class="formData.sta_ArrowMode=='right_on'?'active':''">
|
||||
<view class="outCircle">
|
||||
<view class="item">
|
||||
<image class="img nomal translate" src="/static/images/4877/arrow.png" mode="aspectFit">
|
||||
</image>
|
||||
<image class="img activity translate" src="/static/images/4877/arrowActive.png"
|
||||
mode="aspectFit"></image>
|
||||
mode="aspectFit"></image>
|
||||
</view>
|
||||
</view>
|
||||
<view class="text">朝右</view>
|
||||
@ -185,7 +194,7 @@
|
||||
<view class="modeSetting">
|
||||
|
||||
<view class="arrow" @click.stop="ArrowSet('red_front')"
|
||||
:class="formData.sta_ArrowType=='red_front'?'redactive':''">
|
||||
:class="formData.sta_ArrowType=='red_front'?'redactive':''">
|
||||
<view class="outCircle">
|
||||
<view class="item">
|
||||
<view class="text">红色</view>
|
||||
@ -194,7 +203,7 @@
|
||||
|
||||
</view>
|
||||
<view class="arrow" @click.stop="ArrowSet('green_back')"
|
||||
:class="formData.sta_ArrowType=='green_back'?'greenactive':''">
|
||||
:class="formData.sta_ArrowType=='green_back'?'greenactive':''">
|
||||
<view class="outCircle">
|
||||
<view class="item">
|
||||
<view class="text">绿色</view>
|
||||
@ -217,7 +226,7 @@
|
||||
<view class="modeSetting">
|
||||
|
||||
<view class="arrow" @click.stop="ArrowSet('red_all')"
|
||||
:class="formData.sta_ArrowType=='red_all'?'active':''">
|
||||
:class="formData.sta_ArrowType=='red_all'?'active':''">
|
||||
<view class="outCircle">
|
||||
<view class="item">
|
||||
<image class="img nomal" src="/static/images/4877/arrowLR.png" mode="aspectFit"></image>
|
||||
@ -228,13 +237,13 @@
|
||||
<view class="text">红色双向</view>
|
||||
</view>
|
||||
<view class="arrow" @click.stop="ArrowSet('green_all')"
|
||||
:class="formData.sta_ArrowType=='green_all'?'active':''">
|
||||
:class="formData.sta_ArrowType=='green_all'?'active':''">
|
||||
<view class="outCircle">
|
||||
<view class="item">
|
||||
<image class="img nomal translate" src="/static/images/4877/arrowLR.png" mode="aspectFit">
|
||||
</image>
|
||||
<image class="img activity translate" src="/static/images/4877/arrowLRActive.png"
|
||||
mode="aspectFit"></image>
|
||||
mode="aspectFit"></image>
|
||||
</view>
|
||||
</view>
|
||||
<view class="text">绿色双向</view>
|
||||
@ -247,16 +256,16 @@
|
||||
|
||||
<!-- 弹窗通知 -->
|
||||
<MessagePopup :visible="Status.Pop.showPop" :type="Status.Pop.popType" :bgColor="Status.Pop.bgColor"
|
||||
:borderColor="Status.Pop.borderColor" :textColor="Status.Pop.textColor"
|
||||
:buttonBgColor="Status.Pop.buttonBgColor" :buttonTextColor="Status.Pop.buttonTextColor"
|
||||
:iconUrl="Status.Pop.iconUrl" :message="Status.Pop.message" :buttonText="Status.Pop.buttonText"
|
||||
@buttonClick="HidePop" :visiblePrompt="Status.Pop.visiblePrompt" :promptTitle="Status.Pop.promptTitle"
|
||||
v-model="Status.Pop.modelValue" @closePop="closePop" :buttonCancelText="Status.Pop.buttonCancelText"
|
||||
:showCancel="Status.Pop.showCancel" @cancelPop="closePop" :showSlot="Status.Pop.showSlot">
|
||||
:borderColor="Status.Pop.borderColor" :textColor="Status.Pop.textColor"
|
||||
:buttonBgColor="Status.Pop.buttonBgColor" :buttonTextColor="Status.Pop.buttonTextColor"
|
||||
:iconUrl="Status.Pop.iconUrl" :message="Status.Pop.message" :buttonText="Status.Pop.buttonText"
|
||||
@buttonClick="HidePop" :visiblePrompt="Status.Pop.visiblePrompt" :promptTitle="Status.Pop.promptTitle"
|
||||
v-model="Status.Pop.modelValue" @closePop="closePop" :buttonCancelText="Status.Pop.buttonCancelText"
|
||||
:showCancel="Status.Pop.showCancel" @cancelPop="closePop" :showSlot="Status.Pop.showSlot">
|
||||
<view v-if="Status.ShowEditChannel" class="popup-prompt">
|
||||
<text class="popup-prompt-title">修改信道</text>
|
||||
<input class="popup-prompt-input" type="number" placeholder="1-125的整数"
|
||||
placeholder-class="popup-prompt-input-placeHolder" v-model="formData.sta_Channel" />
|
||||
placeholder-class="popup-prompt-input-placeHolder" v-model="formData.sta_Channel" />
|
||||
|
||||
</view>
|
||||
</MessagePopup>
|
||||
@ -285,14 +294,15 @@
|
||||
} from '@/api/4877/BJQ4877.js';
|
||||
|
||||
import MqTool from '@/utils/MqHelper.js'
|
||||
import {
|
||||
MsgSuccess,
|
||||
MsgError,
|
||||
MsgClose,
|
||||
MsgWarning,
|
||||
showPop,
|
||||
MsgInfo
|
||||
} from '@/utils/MsgPops.js'
|
||||
import {
|
||||
MsgSuccess,
|
||||
MsgError,
|
||||
MsgClose,
|
||||
MsgWarning,
|
||||
showPop,
|
||||
MsgInfo,
|
||||
MsgClear
|
||||
} from '@/utils/MsgPops.js'
|
||||
const pagePath = "/pages/4877/BJQ4877";
|
||||
|
||||
var ble = null;
|
||||
@ -305,6 +315,7 @@
|
||||
data() {
|
||||
return {
|
||||
Status: {
|
||||
sendDisc: '',
|
||||
apiType: '',
|
||||
navbar: {
|
||||
icons: [{
|
||||
@ -397,6 +408,7 @@
|
||||
groups: [
|
||||
|
||||
]
|
||||
|
||||
},
|
||||
dic: {
|
||||
SOS: [{
|
||||
@ -563,14 +575,14 @@
|
||||
onShow() {
|
||||
this.Status.pageHide = false;
|
||||
|
||||
let f=this.getDevice();
|
||||
if(f){
|
||||
these.formData.bleStatu = 'connecting';
|
||||
ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId).then(res => {
|
||||
console.log("连接成功")
|
||||
these.formData.bleStatu = true;
|
||||
});
|
||||
}
|
||||
let f = this.getDevice();
|
||||
if (f) {
|
||||
these.formData.bleStatu = 'connecting';
|
||||
ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId).then(res => {
|
||||
console.log("连接成功")
|
||||
these.formData.bleStatu = true;
|
||||
});
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
getbleStatu() {
|
||||
@ -706,7 +718,7 @@
|
||||
buttonBgColor: "#E03434",
|
||||
okCallback: null,
|
||||
buttonText: "确定"
|
||||
},these)
|
||||
}, these)
|
||||
return;
|
||||
}
|
||||
|
||||
@ -737,7 +749,7 @@
|
||||
cancelCallback: () => {
|
||||
this.Status.ShowEditChannel = false;
|
||||
}
|
||||
},these);
|
||||
}, these);
|
||||
},
|
||||
onChannelChanging() {
|
||||
let regex = /^(0|([1-9]\d?)|1[01]\d|12[0-5])$/;
|
||||
@ -787,7 +799,7 @@
|
||||
buttonBgColor: "#E03434",
|
||||
okCallback: null,
|
||||
buttonText: "确定"
|
||||
},these)
|
||||
}, these)
|
||||
return;
|
||||
}
|
||||
|
||||
@ -850,7 +862,7 @@
|
||||
buttonBgColor: "#E03434",
|
||||
okCallback: null,
|
||||
buttonText: "确定"
|
||||
},these)
|
||||
}, these)
|
||||
return;
|
||||
}
|
||||
uni.navigateTo({
|
||||
@ -933,7 +945,7 @@
|
||||
buttonBgColor: "#E03434",
|
||||
okCallback: null,
|
||||
buttonText: "确定"
|
||||
},these)
|
||||
}, these)
|
||||
return;
|
||||
}
|
||||
|
||||
@ -981,7 +993,45 @@
|
||||
this.formData.warnTime = 0;
|
||||
}
|
||||
},
|
||||
discern() {
|
||||
//识别设备,连续发送20次识别指令
|
||||
let f = this.getDevice();
|
||||
if (!f) {
|
||||
this.showBleUnConnect();
|
||||
|
||||
return;
|
||||
}
|
||||
var json = {
|
||||
ins_disc: 1
|
||||
}
|
||||
let index = 0;
|
||||
let total = 20;
|
||||
|
||||
console.error("发送识别指令:", json);
|
||||
this.Status.sendDisc = true;
|
||||
|
||||
let sendNextPacket = () => {
|
||||
if(index>total){
|
||||
this.Status.sendDisc = false;
|
||||
|
||||
return;
|
||||
}
|
||||
ble.sendString(f.deviceId, json, f.writeServiceId, f.wirteCharactId, 30).then(res => {
|
||||
index++;
|
||||
setTimeout(sendNextPacket,300);
|
||||
}).catch(err => {
|
||||
if (err.code == '10007') {
|
||||
setTimeout(sendNextPacket, 800);
|
||||
return;
|
||||
}
|
||||
if(index==0){
|
||||
MsgError(err.msg,'',these);
|
||||
}
|
||||
this.Status.sendDisc = false;
|
||||
});
|
||||
}
|
||||
sendNextPacket();
|
||||
},
|
||||
sosSetting(item, index) {
|
||||
if (!this.permissions.includes('42') && this.Status.apiType !== 'listA') {
|
||||
|
||||
@ -992,7 +1042,7 @@
|
||||
buttonBgColor: "#E03434",
|
||||
okCallback: null,
|
||||
buttonText: "确定"
|
||||
},these)
|
||||
}, these)
|
||||
return;
|
||||
}
|
||||
let f = this.getDevice();
|
||||
@ -1034,7 +1084,7 @@
|
||||
buttonText: (this.formData.sta_SOSType === 'sos' ? '关闭' : '开启'),
|
||||
showCancel: true,
|
||||
buttonCancelText: '取消'
|
||||
},these);
|
||||
}, these);
|
||||
}
|
||||
if (item.val === 'sos') {
|
||||
confirmTask();
|
||||
@ -1084,9 +1134,9 @@
|
||||
// return;
|
||||
// }
|
||||
if (res.deviceId == these.formData.deviceId) {
|
||||
if(res.device){
|
||||
if (res.device) {
|
||||
these.formData.bleStatu = 'connecting';
|
||||
}else{
|
||||
} else {
|
||||
this.formData.bleStatu = false;
|
||||
}
|
||||
setTimeout(() => {
|
||||
@ -1180,6 +1230,7 @@
|
||||
if (receive.deviceId !== this.formData.deviceId) {
|
||||
return;
|
||||
}
|
||||
|
||||
console.log("收到设备的数据", receive)
|
||||
let data = recei.ReceiveData(receive, device, pagePath, recArr);
|
||||
console.log("处理后的数据:", data);
|
||||
@ -1206,6 +1257,7 @@
|
||||
}
|
||||
if (msg.length) {
|
||||
msg = msg.join(",");
|
||||
MsgClear(these);
|
||||
this.showMsg(msg);
|
||||
}
|
||||
|
||||
@ -1222,8 +1274,8 @@
|
||||
},
|
||||
getDevice: function() {
|
||||
|
||||
// console.log("LinkedList=", ble.data.LinkedList);
|
||||
// console.log("formData=", these.formData);
|
||||
console.log("LinkedList=", ble.data.LinkedList);
|
||||
console.log("formData=", these.device);
|
||||
let f = ble.data.LinkedList.find((v) => {
|
||||
return v.macAddress == these.device.deviceMac;
|
||||
});
|
||||
@ -1252,7 +1304,7 @@
|
||||
borderColor: "#e034344d",
|
||||
buttonBgColor: "#E03434",
|
||||
buttonText: '去连接',
|
||||
buttonTextColor: '#FFFFFFde',
|
||||
buttonTextColor: '#FFFFFFde',
|
||||
okCallback: function() {
|
||||
|
||||
uni.navigateTo({
|
||||
@ -1274,7 +1326,7 @@
|
||||
}
|
||||
})
|
||||
}
|
||||
},these);
|
||||
}, these);
|
||||
},
|
||||
|
||||
|
||||
@ -1299,73 +1351,62 @@
|
||||
this.Status.Pop.okCallback();
|
||||
}
|
||||
},
|
||||
showPop: function (option) {
|
||||
hideLoading(this);
|
||||
let def = {
|
||||
showPop: true, //是否显示弹窗
|
||||
popType: 'custom',
|
||||
bgColor: '#383934bd',
|
||||
borderColor: '#BBE600',
|
||||
textColor: '#ffffffde',
|
||||
buttonBgColor: '#BBE600',
|
||||
buttonTextColor: '#232323DE',
|
||||
iconUrl: '',
|
||||
message: '',
|
||||
buttonText: '确定',
|
||||
clickEvt: '',
|
||||
visiblePrompt: false,
|
||||
promptTitle: '',
|
||||
modelValue: '',
|
||||
visibleClose: false,
|
||||
okCallback: null,
|
||||
showSlot: false,
|
||||
buttonCancelText: '',
|
||||
showCancel: false,
|
||||
}
|
||||
showPop: function(option) {
|
||||
hideLoading(this);
|
||||
let def = {
|
||||
showPop: true, //是否显示弹窗
|
||||
popType: 'custom',
|
||||
bgColor: '#383934bd',
|
||||
borderColor: '#BBE600',
|
||||
textColor: '#ffffffde',
|
||||
buttonBgColor: '#BBE600',
|
||||
buttonTextColor: '#232323DE',
|
||||
iconUrl: '',
|
||||
message: '',
|
||||
buttonText: '确定',
|
||||
clickEvt: '',
|
||||
visiblePrompt: false,
|
||||
promptTitle: '',
|
||||
modelValue: '',
|
||||
visibleClose: false,
|
||||
okCallback: null,
|
||||
showSlot: false,
|
||||
buttonCancelText: '',
|
||||
showCancel: false,
|
||||
}
|
||||
|
||||
let keys = Object.keys(def);
|
||||
let keys = Object.keys(def);
|
||||
|
||||
for (let i = 0; i < keys.length; i++) {
|
||||
let key = keys[i];
|
||||
if (key in option) {
|
||||
continue;
|
||||
}
|
||||
this.Status.Pop[key] = def[key];
|
||||
}
|
||||
if (option) {
|
||||
keys = Object.keys(option);
|
||||
for (let i = 0; i < keys.length; i++) {
|
||||
let key = keys[i];
|
||||
for (let i = 0; i < keys.length; i++) {
|
||||
let key = keys[i];
|
||||
if (key in option) {
|
||||
continue;
|
||||
}
|
||||
this.Status.Pop[key] = def[key];
|
||||
}
|
||||
if (option) {
|
||||
keys = Object.keys(option);
|
||||
for (let i = 0; i < keys.length; i++) {
|
||||
let key = keys[i];
|
||||
|
||||
this.Status.Pop[key] = option[key];
|
||||
}
|
||||
}
|
||||
this.Status.Pop[key] = option[key];
|
||||
}
|
||||
}
|
||||
|
||||
if (!option.borderColor) {
|
||||
option.borderColor = '#BBE600';
|
||||
option.buttonBgColor = '#BBE600';
|
||||
}
|
||||
these.Status.Pop.showPop = true;
|
||||
},
|
||||
if (!option.borderColor) {
|
||||
option.borderColor = '#BBE600';
|
||||
option.buttonBgColor = '#BBE600';
|
||||
}
|
||||
these.Status.Pop.showPop = true;
|
||||
},
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1576,7 +1617,7 @@
|
||||
border-color: #aed600 !important;
|
||||
}
|
||||
|
||||
.lampMode .mode.active .bigTxt {
|
||||
.lampMode .mode.active .bigTxt,.lampMode .mode.active .smallTxt {
|
||||
|
||||
color: #aed600 !important;
|
||||
}
|
||||
|
||||
@ -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>
|
||||
|
||||
@ -279,14 +276,19 @@
|
||||
import BleTool from '@/utils/BleHelper.js'
|
||||
import BleReceive from '@/utils/BleReceive';
|
||||
import MqttClient from '@/utils/mqtt.js';
|
||||
import lnglatConvert from '@/utils/wgs84_to_gcj02.js'
|
||||
import lnglatConvert from '@/utils/wgs84_to_gcj02.js';
|
||||
import SendBatchData from '@/utils/SendBatchData.js';
|
||||
var batchTool=null;
|
||||
var eventChannel = null;
|
||||
var these = null;
|
||||
var ble = null;
|
||||
|
||||
var recei = null;
|
||||
var mq = null;
|
||||
var pagePath = "pages/6075J/BJQ6075J";
|
||||
var brightnessTimer = null;
|
||||
var reGeoTime=null;
|
||||
|
||||
export default {
|
||||
components: {
|
||||
TextToHexV1
|
||||
@ -625,7 +627,7 @@
|
||||
borderColor: "#e034344d",
|
||||
buttonBgColor: "#E03434",
|
||||
buttonText: '确定',
|
||||
buttonTextColor: '#232323de',
|
||||
buttonTextColor: '#FFFFFFde',
|
||||
showCancel: false,
|
||||
showHeader: false,
|
||||
visibleClose: true,
|
||||
@ -646,341 +648,15 @@
|
||||
|
||||
let f = this.getDevice();
|
||||
|
||||
let timeDelayCloseLoading = () => {
|
||||
setTimeout(() => {
|
||||
hideLoading(these);
|
||||
}, 1500);
|
||||
if(!f){
|
||||
this.showBleUnConnect();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
let sendVideoPackets = (ReSendNo) => {
|
||||
console.log("开始发送分片数据");
|
||||
return new Promise((resolve, reject) => {
|
||||
if (f) {
|
||||
// 总数据包数
|
||||
var totalPackets = 1536; //36;
|
||||
|
||||
let currentPacket = 1;
|
||||
console.log("发送数据准备中,总共" + totalPackets);
|
||||
if (ReSendNo) {
|
||||
totalPackets = ReSendNo;
|
||||
currentPacket = ReSendNo;
|
||||
}
|
||||
this.totalPackets = totalPackets;
|
||||
// 发送单个数据包
|
||||
const sendNextVideoPacket = () => {
|
||||
// console.log("准备发送一段数据");
|
||||
if (currentPacket > totalPackets) {
|
||||
if (!ReSendNo) {
|
||||
setTimeout(() => {
|
||||
|
||||
ble.sendString(f.deviceId, "transmit complete", f
|
||||
.writeServiceId, f.wirteCharactId, 20)
|
||||
.then(
|
||||
() => {
|
||||
console.log("全部发送完毕")
|
||||
}).catch((ex) => {
|
||||
console.log("出现异常", ex);
|
||||
});
|
||||
}, 500);
|
||||
|
||||
}
|
||||
|
||||
hideLoading(these);
|
||||
showPop({
|
||||
showPop: true,
|
||||
message: "上传成功",
|
||||
iconUrl: "/static/images/common/success.png"
|
||||
}, these);
|
||||
these.videoHexArray = null;
|
||||
resolve();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// 计算当前包的数据
|
||||
let packetSize = 500;
|
||||
|
||||
|
||||
// 创建数据包
|
||||
const startIndex = (currentPacket - 1) * packetSize;
|
||||
const endIndex = Math.min(startIndex + packetSize, these.videoHexArray
|
||||
.length);
|
||||
if (startIndex > endIndex) {
|
||||
resolve();
|
||||
return;
|
||||
}
|
||||
////console.log("111111");
|
||||
const packetData = these.videoHexArray.slice(startIndex, endIndex);
|
||||
|
||||
// 构建数据包
|
||||
////console.log("packetData.length"+packetData.length);
|
||||
const bufferSize = 504; // 头部5字节 + 数据部分
|
||||
const buffer = new ArrayBuffer(bufferSize);
|
||||
const dataView = new DataView(buffer);
|
||||
|
||||
let sortNo = currentPacket.toString(16).padStart(4, '0');
|
||||
|
||||
// 填充头部
|
||||
dataView.setUint8(0, 0x55); // 帧头
|
||||
dataView.setUint8(1, 0x04); // 帧类型:开机画面
|
||||
dataView.setUint8(2, '0x' + sortNo.substring(0, 2)); // 包序号
|
||||
dataView.setUint8(3, '0x' + sortNo.substring(2, 4)); // 包序号
|
||||
|
||||
// dataView.setUint8(4, 0x01);
|
||||
// dataView.setUint8(5, 0xF4);
|
||||
|
||||
for (let i = 0; i < packetData.length; i++) {
|
||||
dataView.setUint8(4 + i, '0x' + packetData[i]);
|
||||
}
|
||||
|
||||
let inteval = 40;
|
||||
|
||||
ble.sendData(f.deviceId, buffer, f.writeServiceId, f
|
||||
.wirteCharactId, 10).then(() => {
|
||||
|
||||
updateLoading(these, {
|
||||
text: "正在发送:" + currentPacket + "/" +
|
||||
totalPackets
|
||||
})
|
||||
|
||||
currentPacket++;
|
||||
|
||||
// console.log("发送一段成功,发送下一段");
|
||||
setTimeout(sendNextVideoPacket, inteval);
|
||||
}).catch(err => {
|
||||
console.log("发送失败了", err);
|
||||
if (err.code == '10007') { //遇到这个错误自动重新发送
|
||||
console.log(err.errMsg + ",发送失败了,正在补偿:" +
|
||||
currentPacket);
|
||||
setTimeout(sendNextVideoPacket, inteval);
|
||||
} else {
|
||||
|
||||
hideLoading(these);
|
||||
|
||||
showPop({
|
||||
showPop: true,
|
||||
message: err.msg + ",发送失败了",
|
||||
borderColor: "#e034344d",
|
||||
buttonBgColor: "#E03434",
|
||||
buttonText: "确定",
|
||||
iconUrl: "/static/images/common/uploadErr.png"
|
||||
}, these);
|
||||
reject(err);
|
||||
these.videoHexArray = null;
|
||||
return;
|
||||
}
|
||||
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
sendNextVideoPacket();
|
||||
|
||||
|
||||
} else {
|
||||
console.log("Fail.......")
|
||||
}
|
||||
});
|
||||
if(!batchTool){
|
||||
batchTool=new SendBatchData(these,f,ble);
|
||||
}
|
||||
|
||||
var sendVideo = (videoPath) => {
|
||||
let uploadVideo = () => {
|
||||
|
||||
these.videoHexArray = [];
|
||||
console.log("开始处理,正在上传");
|
||||
|
||||
showLoading(these, {
|
||||
text: "上传中"
|
||||
});
|
||||
let p1 = new Promise((resolve, reject) => {
|
||||
|
||||
ble.sendString(f.deviceId, "video transmit start", f
|
||||
.writeServiceId, f.wirteCharactId).then(res => {
|
||||
|
||||
setTimeout(() => {
|
||||
console.log("握手成功了");
|
||||
resolve(true);
|
||||
}, 2200)
|
||||
}).catch(ex => {
|
||||
reject(ex);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
let p2 = new Promise((succ, err) => {
|
||||
|
||||
const token = uni.getStorageSync('token');
|
||||
const clientid = uni.getStorageSync('clientID');
|
||||
if (!token) {
|
||||
err({
|
||||
code: 401,
|
||||
msg: "请先登陆后再试"
|
||||
});
|
||||
hideLoading(these);
|
||||
return;
|
||||
}
|
||||
console.log("baseURL=", baseURL);
|
||||
console.log("token", token);
|
||||
console.log("clientID", clientid);
|
||||
uni.uploadFile({
|
||||
// url: 'http://114.55.111.217/video/upload',
|
||||
url: baseURL + "/app/video/upload",
|
||||
filePath: videoPath,
|
||||
name: 'file',
|
||||
header: {
|
||||
"Method": "POST",
|
||||
"Content-Type": "multipart/form-data",
|
||||
"Authorization": 'Bearer ' + token,
|
||||
"clientid": clientid
|
||||
},
|
||||
timeout: 600000,
|
||||
fail: (ex) => {
|
||||
console.log("上传视频失败" + JSON.stringify(ex));
|
||||
|
||||
err(ex);
|
||||
},
|
||||
success: (res) => {
|
||||
|
||||
console.log("上传完成,向蓝牙设备发送");
|
||||
succ(res);
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
Promise.all([p1, p2]).then((arr) => {
|
||||
|
||||
if (arr[0].status == 'rejected') {
|
||||
showPop({
|
||||
message: "设备准备未就绪",
|
||||
iconUrl: "/static/images/common/uploadErr.png",
|
||||
borderColor: "#e034344d",
|
||||
buttonBgColor: "#E03434",
|
||||
}, these);
|
||||
return;
|
||||
}
|
||||
let res = arr[1];
|
||||
// console.log("11111111111111111111111",res);
|
||||
res = JSON.parse(res.data);
|
||||
// console.log("22222222222222222222");
|
||||
if (res.data) {
|
||||
these.videoHexArray = res.data;
|
||||
updateLoading(these, {
|
||||
text: "正在发送:0/1536"
|
||||
});
|
||||
|
||||
|
||||
|
||||
shotVideoClick(res.data);
|
||||
|
||||
|
||||
} else {
|
||||
console.log("服务器未返回正确的数据");
|
||||
|
||||
|
||||
showPop({
|
||||
message: "与服务器连接出现异常,请检查网络设置",
|
||||
iconUrl: "/static/images/common/uploadErr.png",
|
||||
borderColor: "#e034344d",
|
||||
buttonBgColor: "#E03434",
|
||||
}, these);
|
||||
}
|
||||
|
||||
}).catch((ex) => {
|
||||
console.log("出现异常,", ex)
|
||||
hideLoading(these);
|
||||
showPop({
|
||||
message: "出现异常," + ex.msg,
|
||||
iconUrl: "/static/images/common/uploadErr.png",
|
||||
borderColor: "#e034344d",
|
||||
buttonBgColor: "#E03434",
|
||||
}, these);
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
let shotVideoClick = () => {
|
||||
console.log("正在开始发送");
|
||||
sendVideoPackets().then(() => {
|
||||
console.log("发送完成");
|
||||
|
||||
}).catch((ex1) => {
|
||||
//console.log("出现了异常", ex1)
|
||||
}).finally(() => {
|
||||
hideLoading(these);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
uploadVideo();
|
||||
|
||||
}
|
||||
|
||||
uni.chooseVideo({
|
||||
sourceType: ['album'],
|
||||
compressed: false, // 关闭视频压缩,确保上传原始文件
|
||||
success: function(res) {
|
||||
console.log("res=", res);
|
||||
let path = res.tempFilePath;
|
||||
// iOS可能返回浮点数,需要转换为整数进行比较
|
||||
let width = Math.round(res.width);
|
||||
let height = Math.round(res.height);
|
||||
let duration = res.duration;
|
||||
|
||||
// 获取平台信息
|
||||
const systemInfo = uni.getSystemInfoSync();
|
||||
const platform = systemInfo.platform;
|
||||
const isIOS = platform === 'ios';
|
||||
|
||||
console.log("平台:", platform, "uni.chooseVideo返回 - 宽度:", width, "高度:", height,
|
||||
"时长:", duration);
|
||||
|
||||
// iOS特殊处理:如果返回的是80*40,很可能是160*80的一半(iOS的bug)
|
||||
if (isIOS && width === 80 && height === 40) {
|
||||
console.log("检测到iOS特殊情况:返回80*40,实际应该是160*80,进行修正");
|
||||
width = 160;
|
||||
height = 80;
|
||||
}
|
||||
|
||||
// 检查分辨率是否符合要求
|
||||
let checkResolution = (w, h) => {
|
||||
// 使用容差比较,允许1像素的误差
|
||||
return Math.abs(w - 160) <= 1 && Math.abs(h - 80) <= 1;
|
||||
};
|
||||
|
||||
let err = [];
|
||||
if (duration < 2) {
|
||||
err.push("视频时长至少2秒");
|
||||
}
|
||||
|
||||
if (!checkResolution(width, height)) {
|
||||
err.push("视频宽高必须是160*80,当前分辨率:" + width + "*" + height);
|
||||
}
|
||||
|
||||
if (err.length > 0) {
|
||||
err = err.join(";");
|
||||
showPop({
|
||||
message: err,
|
||||
iconUrl: "/static/images/common/uploadErr.png",
|
||||
borderColor: "#e034344d",
|
||||
buttonBgColor: "#E03434",
|
||||
}, these);
|
||||
return;
|
||||
}
|
||||
|
||||
showLoading(these, {
|
||||
text: '正在上传'
|
||||
});
|
||||
setTimeout(() => {
|
||||
sendVideo(path);
|
||||
}, 0);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
batchTool.SendVideo(504);
|
||||
},
|
||||
sendImg() {
|
||||
if (!this.permissions.includes('3') && this.Status.apiType !== 'listA') {
|
||||
@ -990,178 +666,19 @@
|
||||
}
|
||||
|
||||
let f = this.getDevice();
|
||||
if(!f){
|
||||
this.showBleUnConnect();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
var sendImagePackets = function(ReSendNo) {
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
|
||||
// 总数据包数
|
||||
let totalPackets = 52;
|
||||
let currentPacket = 1;
|
||||
|
||||
if (ReSendNo) {
|
||||
totalPackets = ReSendNo;
|
||||
currentPacket = ReSendNo;
|
||||
}
|
||||
|
||||
if (f) {
|
||||
// 发送单个数据包
|
||||
const sendNextPacket = () => {
|
||||
if (currentPacket > totalPackets) {
|
||||
hideLoading(these);
|
||||
these.closeAction();
|
||||
showPop({
|
||||
showPop: true,
|
||||
message: "上传成功",
|
||||
iconUrl: "/static/images/common/success.png",
|
||||
});
|
||||
|
||||
setTimeout(() => {
|
||||
ble.sendString(f.deviceId, "transmit complete", f
|
||||
.writeServiceId, f
|
||||
.wirteCharactId);
|
||||
}, 1000);
|
||||
|
||||
these.rgb565Data = null;
|
||||
resolve();
|
||||
return;
|
||||
}
|
||||
|
||||
// 计算当前包的数据
|
||||
let packetSize = 250;
|
||||
// if (currentPacket <= 51) {
|
||||
// packetSize = 250; // 前51个包每个500字节
|
||||
// } else {
|
||||
// packetSize = 50; // 最后一个包100字节
|
||||
// }
|
||||
|
||||
// 创建数据包
|
||||
const startIndex = (currentPacket - 1) * packetSize;
|
||||
const endIndex = Math.min(startIndex + packetSize, these.rgb565Data
|
||||
.length);
|
||||
if (startIndex > endIndex) {
|
||||
return;
|
||||
}
|
||||
const packetData = these.rgb565Data.slice(startIndex,
|
||||
endIndex);
|
||||
// 构建数据包
|
||||
const bufferSize = 505; // 5 + packetData.length * 2; // 头部5字节 + 数据部分
|
||||
const buffer = new ArrayBuffer(bufferSize);
|
||||
const dataView = new DataView(buffer);
|
||||
|
||||
// 填充头部
|
||||
dataView.setUint8(0, 0x55); // 帧头
|
||||
dataView.setUint8(1, 0x02); // 帧类型:开机画面
|
||||
dataView.setUint8(2, '0x' + currentPacket.toString(16).padStart(2,
|
||||
'0')); // 包序号
|
||||
|
||||
|
||||
dataView.setUint16(3, packetData.length*2,false); // 包t长度
|
||||
|
||||
// 填充数据(每个RGB565值占2字节)
|
||||
for (let i = 0; i < packetData.length; i++) {
|
||||
dataView.setUint16(5 + i * 2, packetData[i], false); // 大端字节序
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//发送数据包
|
||||
ble.sendData(f.deviceId, buffer, f.writeServiceId, f.wirteCharactId,
|
||||
10)
|
||||
.then(() => {
|
||||
|
||||
|
||||
updateLoading(these, {
|
||||
text: "正在发送:" + currentPacket + "/" +
|
||||
totalPackets
|
||||
})
|
||||
currentPacket++;
|
||||
|
||||
setTimeout(sendNextPacket, these.inteval);
|
||||
}).catch(err => {
|
||||
console.log("发送数据包失败了" + JSON.stringify(err));
|
||||
if (err.code == '10007') {
|
||||
setTimeout(sendNextPacket, these.inteval);
|
||||
return;
|
||||
}
|
||||
these.closeAction();
|
||||
showPop({
|
||||
message: err.msg,
|
||||
iconUrl: "/static/images/common/uploadErr.png",
|
||||
borderColor: "#e034344d",
|
||||
buttonBgColor: "#E03434",
|
||||
});
|
||||
hideLoading(these);
|
||||
these.rgb565Data = null;
|
||||
reject(err);
|
||||
});
|
||||
}
|
||||
|
||||
if (ReSendNo) {
|
||||
sendNextPacket(ReSendNo);
|
||||
return;
|
||||
}
|
||||
// 开始牵手
|
||||
ble.sendString(f.deviceId, "picture transmit start", f.writeServiceId,
|
||||
f.wirteCharactId).then(() => {
|
||||
setTimeout(sendNextPacket, 120);
|
||||
|
||||
}).catch((err) => {
|
||||
console.log("握手没有成功");
|
||||
showPop({
|
||||
message: err.msg,
|
||||
iconUrl: "/static/images/common/uploadErr.png",
|
||||
borderColor: "#e034344d",
|
||||
buttonBgColor: "#E03434",
|
||||
});
|
||||
hideLoading(these);
|
||||
reject(err);
|
||||
});
|
||||
}
|
||||
});
|
||||
if(!batchTool){
|
||||
batchTool=new SendBatchData(these,f,ble);
|
||||
}
|
||||
|
||||
|
||||
uni.chooseImage({
|
||||
count: 1,
|
||||
sizeType: ['original', 'compressed'],
|
||||
sourceType: ['album'],
|
||||
success: function(res) {
|
||||
uni.navigateTo({
|
||||
url: "/pages/common/ImgCrop/ImgCrop",
|
||||
events: {
|
||||
ImgCutOver: function(data) {
|
||||
batchTool.SendImg();
|
||||
|
||||
showLoading(these, {
|
||||
text: "正在发送0/52"
|
||||
});
|
||||
|
||||
|
||||
these.rgb565Data = Common.convertToRGB565(data.piexls);
|
||||
|
||||
setTimeout(function() {
|
||||
sendImagePackets().catch(() => {
|
||||
|
||||
});
|
||||
}, 0)
|
||||
|
||||
}
|
||||
},
|
||||
success(ev) {
|
||||
ev.eventChannel.emit('checkImg', {
|
||||
data: res.tempFiles[0].path
|
||||
})
|
||||
},
|
||||
fail(ex) {
|
||||
console.log("跳转页面失败" + JSON.stringify(ex));
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
return ;
|
||||
|
||||
},
|
||||
sliderChanging(e) {
|
||||
@ -1336,17 +853,16 @@
|
||||
];
|
||||
|
||||
let item3 = Object.assign({}, json);
|
||||
item3.textAlign='center';
|
||||
item3.name = 'media';
|
||||
item3.title = '选择媒体';
|
||||
item3.menuItems = [{
|
||||
text: '照片',
|
||||
icon: '/static/images/lightImg/qiang.png',
|
||||
value: 'img',
|
||||
key: 'media'
|
||||
},
|
||||
{
|
||||
text: '动画',
|
||||
icon: '/static/images/lightImg/qiang.png',
|
||||
value: 'flash',
|
||||
key: 'media'
|
||||
}
|
||||
@ -1426,7 +942,7 @@
|
||||
borderColor: "#e034344d",
|
||||
buttonBgColor: "#E03434",
|
||||
buttonText: '确定',
|
||||
buttonTextColor: '#232323de',
|
||||
buttonTextColor: '#FFFFFFde',
|
||||
showCancel: true,
|
||||
buttonCancelText: '取消',
|
||||
okCallback: send
|
||||
@ -1451,6 +967,7 @@
|
||||
let sendLaser = () => {
|
||||
this.sendData(json, null, 'string').then(res => {
|
||||
this.formData.sta_laser = val;
|
||||
this.formData.sta_LightGrade=6;
|
||||
this.setBleFormData();
|
||||
}).catch(ex => {
|
||||
console.error("出现错误", ex)
|
||||
@ -1463,7 +980,7 @@
|
||||
borderColor: "#e034344d",
|
||||
buttonBgColor: "#E03434",
|
||||
buttonText: '确定',
|
||||
buttonTextColor: '#232323de',
|
||||
buttonTextColor: '#FFFFFFde',
|
||||
showCancel: true,
|
||||
showHeader: true,
|
||||
visibleClose: false,
|
||||
@ -1487,6 +1004,9 @@
|
||||
this.sendData(json, null, 'string').then((res) => {
|
||||
let key = li.key.replace(/ins_/g, 'sta_');
|
||||
this.formData[key] = li.value;
|
||||
if(li.value!=6){
|
||||
this.formData.sta_laser=0;
|
||||
}
|
||||
this.setBleFormData();
|
||||
this.formData.sta_brightness = 100;
|
||||
}).catch((ex) => {
|
||||
@ -1508,151 +1028,10 @@
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
if(!batchTool){
|
||||
batchTool=new SendBatchData(these,f,ble);
|
||||
}
|
||||
|
||||
|
||||
this.formData.textLines = [this.formData.company, this.formData.usrname, this.formData.job, this.formData
|
||||
.usrid
|
||||
];
|
||||
console.log("data=", this.formData.textLines);
|
||||
showLoading(these, {
|
||||
text: "发送中"
|
||||
});
|
||||
//握手
|
||||
let holdHand = (hexs, time) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
|
||||
|
||||
this.sendData(hexs, 'ble', "string").then(res => {
|
||||
setTimeout(() => {
|
||||
resolve(res)
|
||||
}, time);
|
||||
|
||||
}).catch(ex => {
|
||||
reject(ex)
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
//画图
|
||||
let drawText = () => {
|
||||
return new Promise((resolve, reject) => {
|
||||
this.$refs.textToHex.drawAndGetPixels().then(allPixels => {
|
||||
if (!allPixels) {
|
||||
reject("文本初始化失败");
|
||||
return;
|
||||
}
|
||||
console.log("画图成功");
|
||||
resolve(allPixels);
|
||||
}).catch(compEx => {
|
||||
reject(compEx);
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
//发送3个分包的数据
|
||||
let task = (allPixels) => {
|
||||
try {
|
||||
let combinedData = [];
|
||||
for (let i = 0; i < 4; i++) {
|
||||
let linePixels = (allPixels[i] || []).flat(Infinity).map(item =>
|
||||
typeof item === 'string' ? toByteValue(item) : item
|
||||
);
|
||||
|
||||
for (var j = linePixels.length; j < 256; j++) {
|
||||
linePixels.push(0x00);
|
||||
}
|
||||
linePixels = [0xFA, 0x06, 0x03, i + 1].concat(linePixels);
|
||||
|
||||
linePixels.push(0xFF)
|
||||
|
||||
combinedData.push(linePixels);
|
||||
}
|
||||
|
||||
|
||||
let curr = 1;
|
||||
let len = combinedData.length;
|
||||
|
||||
|
||||
|
||||
//分包发送
|
||||
let sendPacket = () => {
|
||||
|
||||
if (combinedData.length === curr - 1) {
|
||||
holdHand('transmit complete', 200).then(res => {
|
||||
MsgSuccess("人员信息发送成功", "确定", these);
|
||||
hideLoading(these);
|
||||
this.setBleFormData();
|
||||
});
|
||||
hideLoading();
|
||||
return;
|
||||
}
|
||||
|
||||
let array = combinedData[curr - 1];
|
||||
|
||||
|
||||
console.log("array=", array);
|
||||
ble.sendHexs(f.deviceId, array, null, null, 15).then(
|
||||
res => {
|
||||
curr++;
|
||||
console.log("发送成功", curr);
|
||||
updateLoading(these, {
|
||||
text: '发送中,' + (curr - 1) + '/' + 4
|
||||
})
|
||||
setTimeout(sendPacket, 250);
|
||||
}).catch(err => {
|
||||
console.err("发送失败", err);
|
||||
if (err.code == '10007') {
|
||||
setTimeout(sendPacket, 250);
|
||||
} else {
|
||||
console.log("err:", err);
|
||||
MsgError('发送失败' + (err.msg || err.code), '确定', these);
|
||||
hideLoading();
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
setTimeout(sendPacket, 0);
|
||||
// 5. 发送成功处理
|
||||
|
||||
|
||||
} catch (ex) {
|
||||
MsgError('发送失败' + (ex.msg || ex.code), '确定', these);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
setTimeout(() => {
|
||||
Promise.allSettled([holdHand('word transmit start', 2200), drawText()]).then(results => {
|
||||
if (results[0].status == 'rejected') {
|
||||
|
||||
setTimeout(() => {
|
||||
hideLoading(these)
|
||||
}, 500);
|
||||
return;
|
||||
}
|
||||
if (results[1].status == 'rejected') {
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
task(results[1].value);
|
||||
})
|
||||
|
||||
}, 0);
|
||||
batchTool.SendUsr(3);
|
||||
},
|
||||
sendMsg() {
|
||||
debugger;
|
||||
@ -1977,9 +1356,43 @@
|
||||
this.$set(this.dic.actionSheets[0], 'value', this.formData.sta_LightGrade);
|
||||
this.$set(this.dic.actionSheets[1], 'value', this.formData.sta_Side_Light);
|
||||
|
||||
if ('sta_longitude' in data) {
|
||||
this.reGeo();
|
||||
}
|
||||
this.setBleFormData();
|
||||
},
|
||||
reGeo() {
|
||||
console.log("经纬度发生变化,执行逆地理")
|
||||
let task = () => {
|
||||
if (this.formData.sta_longitude && this.formData.sta_latitude) {
|
||||
let promise = lnglatConvert.wgs84_to_gcj02(this.formData.sta_longitude, this.formData
|
||||
.sta_latitude);
|
||||
promise.then(lnglat => {
|
||||
|
||||
this.device.longitude = lnglat[0];
|
||||
this.device.latitude = lnglat[1];
|
||||
this.formData.sta_longitude=lnglat[0];
|
||||
this.formData.sta_latitude=lnglat[1];
|
||||
|
||||
|
||||
Common.regeo(lnglat[0], lnglat[1]).then(res => {
|
||||
this.formData.address = res.regeocode.formatted_address
|
||||
this.setBleFormData();
|
||||
}).catch(ex => {
|
||||
console.error("逆地理失败了")
|
||||
});
|
||||
}).catch(err => {
|
||||
console.error("坐标转换失败了");
|
||||
});
|
||||
} else {
|
||||
console.error("经纬度缺失");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
clearTimeout(reGeoTime);
|
||||
reGeoTime = setTimeout(task, 500);
|
||||
},
|
||||
setBleFormData() {
|
||||
if (!ble) {
|
||||
return;
|
||||
@ -2003,6 +1416,8 @@
|
||||
}
|
||||
if (res.deviceId == these.formData.deviceId) {
|
||||
this.formData.bleStatu = true;
|
||||
|
||||
batchTool=new SendBatchData(this,res,ble);
|
||||
setTimeout(() => {
|
||||
hideLoading(these, 1000);
|
||||
});
|
||||
@ -2018,6 +1433,7 @@
|
||||
// return;
|
||||
// }
|
||||
if (res.deviceId == these.formData.deviceId) {
|
||||
batchTool=null;
|
||||
if (res.device) {
|
||||
these.formData.bleStatu = 'connecting';
|
||||
} else {
|
||||
@ -2101,7 +1517,7 @@
|
||||
|
||||
},
|
||||
gotoMap() {
|
||||
let promise = lnglatConvert.wgs84_to_gcj02(this.formData.sta_longitude, this.formData.sta_latitude);
|
||||
let promise =Promise.resolve([this.formData.sta_longitude, this.formData.sta_latitude]); //lnglatConvert.wgs84_to_gcj02(this.formData.sta_longitude, this.formData.sta_latitude);
|
||||
promise.then(lnglat => {
|
||||
|
||||
this.detailData.longitude = lnglat[0];
|
||||
|
||||
@ -10,7 +10,7 @@
|
||||
<view slot="right">
|
||||
<view class="navbarRight center">
|
||||
<view class="imgContent" :class="{'visibilityHidden':Status.apiType!=item.apiType}"
|
||||
@click.stop="handleRightClick(item,index)" v-for="item,index in Status.navbar.icons">
|
||||
@click.stop="handleRightClick(item,index)" v-for="item,index in Status.navbar.icons">
|
||||
<image class="img" :src="item.src" mode="aspectFit"></image>
|
||||
<view class="baber" v-if="item.math">{{item.math>9?'9+':item.math}}</view>
|
||||
</view>
|
||||
@ -74,8 +74,8 @@
|
||||
|
||||
<view class="slider-container">
|
||||
<slider min="1" max="100" step="1" :disabled="false" :value="formData.liangDu" activeColor="#bbe600"
|
||||
backgroundColor="#00000000" block-size="20" block-color="#ffffffde" @change="sliderChange" @changing="sliderChanging"
|
||||
class="custom-slider" />
|
||||
backgroundColor="#00000000" block-size="20" block-color="#ffffffde" @change="sliderChange"
|
||||
@changing="sliderChanging" class="custom-slider" />
|
||||
|
||||
</view>
|
||||
</view>
|
||||
@ -124,23 +124,23 @@
|
||||
<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" />
|
||||
:color="'#000000'" :fontSize="15" />
|
||||
</view>
|
||||
|
||||
<view class="item">
|
||||
<text class="lbl">单位:</text>
|
||||
<input class="value" v-model.trim="formData.textLines[0]" placeholder="请输入单位" maxlength="8"
|
||||
placeholder-class="usrplace" />
|
||||
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" />
|
||||
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" />
|
||||
placeholder-class="usrplace" />
|
||||
</view>
|
||||
|
||||
</view>
|
||||
@ -150,7 +150,7 @@
|
||||
|
||||
<!-- 下方菜单 -->
|
||||
<BottomSlideMenuPlus :config="Status.BottomMenu" @close="closeMenu" @itemClick="handleItemClick"
|
||||
@btnClick="btnClick">
|
||||
@btnClick="btnClick">
|
||||
<view class="addIco">
|
||||
<view class="icoContent center" v-on:click.stop="checkImgUpload()">
|
||||
<image mode="aspectFit" class="img" src="/static/images/6155/DeviceDetail/add.png"></image>
|
||||
@ -180,14 +180,14 @@
|
||||
} from '@/utils/request.js';
|
||||
|
||||
var pagePath = "/pages/6155/BJQ6155";
|
||||
import {
|
||||
MsgSuccess,
|
||||
MsgError,
|
||||
MsgClose,
|
||||
MsgWarning,
|
||||
showPop,
|
||||
MsgInfo
|
||||
} from '@/utils/MsgPops.js'
|
||||
import {
|
||||
MsgSuccess,
|
||||
MsgError,
|
||||
MsgClose,
|
||||
MsgWarning,
|
||||
showPop,
|
||||
MsgInfo
|
||||
} from '@/utils/MsgPops.js'
|
||||
|
||||
var ble = null;
|
||||
var these = null;
|
||||
@ -343,6 +343,7 @@
|
||||
},
|
||||
onLoad: function() {
|
||||
these = this;
|
||||
this.initWatch();
|
||||
recei = BleReceive.getBleReceive();
|
||||
ble = bleTool.getBleTool();
|
||||
|
||||
@ -400,10 +401,10 @@
|
||||
these.formData.bleStatu = 'connecting';
|
||||
ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId).then(res => {
|
||||
these.formData.bleStatu = true;
|
||||
}).catch(ex => {
|
||||
these.formData.bleStatu = 'err';
|
||||
MsgError("连接错误:" + ex.msg, "确定", these);
|
||||
});;
|
||||
}).catch(ex => {
|
||||
these.formData.bleStatu = 'err';
|
||||
MsgError("连接错误:" + ex.msg, "确定", these);
|
||||
});;
|
||||
these.setBleFormData();
|
||||
these.getDetail();
|
||||
|
||||
@ -423,10 +424,10 @@
|
||||
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);
|
||||
});;
|
||||
}).catch(ex => {
|
||||
these.formData.bleStatu = 'err';
|
||||
MsgError("连接错误:" + ex.msg, "确定", these);
|
||||
});;
|
||||
}
|
||||
},
|
||||
onBackPress(e) {
|
||||
@ -453,6 +454,19 @@
|
||||
|
||||
},
|
||||
methods: {
|
||||
initWatch() {
|
||||
this.$watch('formData.battary', (newVal, oldVal) => {
|
||||
if (newVal <= 20 && this.formData.statu == 0x00) {
|
||||
this.showPop({
|
||||
message: "设备电量低",
|
||||
iconUrl: "/static/images/common/uploadErr.png",
|
||||
borderColor: "#e034344d",
|
||||
buttonBgColor: "#E03434",
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
},
|
||||
bleStatuToggle() {
|
||||
let f = this.getDevice();
|
||||
if (!f) {
|
||||
@ -473,7 +487,7 @@
|
||||
these.formData.bleStatu = true;
|
||||
}).catch(ex => {
|
||||
these.formData.bleStatu = 'err';
|
||||
MsgError("连接错误:" + ex.msg, "确定", these);
|
||||
MsgError("连接错误:" + ex.msg, "确定", these);
|
||||
});
|
||||
return;
|
||||
}
|
||||
@ -635,7 +649,7 @@
|
||||
updateLoading(these, {
|
||||
text: ex.msg
|
||||
});
|
||||
MsgError("连接错误:" + ex.msg, "确定", these);
|
||||
MsgError("连接错误:" + ex.msg, "确定", these);
|
||||
}).finally(() => {
|
||||
setTimeout(() => {
|
||||
hideLoading(these);
|
||||
@ -690,14 +704,7 @@
|
||||
these.$forceUpdate();
|
||||
// console.log("更新后的电量:", these.formData.battary);
|
||||
|
||||
if (this.formData.battary <= 20) {
|
||||
this.showPop({
|
||||
message: "设备电量低",
|
||||
iconUrl: "/static/images/common/uploadErr.png",
|
||||
borderColor: "#e034344d",
|
||||
buttonBgColor: "#E03434",
|
||||
});
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
|
||||
@ -708,7 +715,7 @@
|
||||
borderColor: "#e034344d",
|
||||
buttonBgColor: "#E03434",
|
||||
buttonText: '去连接',
|
||||
buttonTextColor: '#FFFFFFde',
|
||||
buttonTextColor: '#FFFFFFde',
|
||||
okCallback: function() {
|
||||
// console.log("1111");
|
||||
uni.navigateTo({
|
||||
@ -746,7 +753,7 @@
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
// 总数据包数
|
||||
let totalPackets = os=='Android'?52:200;
|
||||
let totalPackets = os == 'Android' ? 52 : 200;
|
||||
let currentPacket = 1;
|
||||
|
||||
if (ReSendNo) {
|
||||
@ -791,7 +798,7 @@
|
||||
let packetData = these.rgb565Data.slice(startIndex,
|
||||
endIndex);
|
||||
// 构建数据包
|
||||
let bufferSize = packetData.length * 2+5; // 头部5字节 + 数据部分
|
||||
let bufferSize = packetData.length * 2 + 5; // 头部5字节 + 数据部分
|
||||
let buffer = new ArrayBuffer(bufferSize);
|
||||
let dataView = new DataView(buffer);
|
||||
|
||||
@ -799,7 +806,7 @@
|
||||
dataView.setUint8(0, os == 'Android' ? 0x55 : 0x56); // 帧头
|
||||
dataView.setUint8(1, 0x02); // 帧类型:开机画面
|
||||
dataView.setUint8(2, currentPacket); // 包序号
|
||||
dataView.setUint16(3, packetData.length*2,false);
|
||||
dataView.setUint16(3, packetData.length * 2, false);
|
||||
|
||||
// 填充数据(每个RGB565值占2字节)
|
||||
for (let i = 0; i < packetData.length; i++) {
|
||||
@ -817,7 +824,8 @@
|
||||
})
|
||||
currentPacket++;
|
||||
|
||||
setTimeout(sendNextPacket,os=='Android'? these.inteval:these.inteval/2);
|
||||
setTimeout(sendNextPacket, os == 'Android' ? these
|
||||
.inteval : these.inteval / 2);
|
||||
}).catch(err => {
|
||||
console.log("发送数据包失败了" + JSON.stringify(err));
|
||||
if (err.code == '10007') {
|
||||
@ -865,7 +873,7 @@
|
||||
uni.chooseImage({
|
||||
count: 1,
|
||||
sizeType: ['original', 'compressed'],
|
||||
sourceType: ['album'],
|
||||
sourceType: ['album', 'camera'],
|
||||
success: function(res) {
|
||||
uni.navigateTo({
|
||||
url: "/pages/common/ImgCrop/ImgCrop",
|
||||
@ -878,7 +886,7 @@
|
||||
console.log("data=", data);
|
||||
these.Status.BottomMenu.show = false;
|
||||
these.rgb565Data = Common.convertToRGB565(data.piexls);
|
||||
console.log("1111111111")
|
||||
console.log("1111111111")
|
||||
setTimeout(function() {
|
||||
console.log("1111111111")
|
||||
sendImagePackets().catch(() => {
|
||||
@ -915,8 +923,8 @@ console.log("1111111111")
|
||||
})
|
||||
return;
|
||||
}
|
||||
let os=plus.os.name;
|
||||
// os='Android';
|
||||
let os = plus.os.name;
|
||||
// os='Android';
|
||||
let f = these.getDevice();
|
||||
|
||||
if (!f) {
|
||||
@ -936,7 +944,7 @@ console.log("1111111111")
|
||||
return new Promise((resolve, reject) => {
|
||||
if (f) {
|
||||
// 总数据包数
|
||||
var totalPackets =os=='Android' ? 1536 : 6000; //36;
|
||||
var totalPackets = os == 'Android' ? 1536 : 6000; //36;
|
||||
|
||||
let currentPacket = 1;
|
||||
console.log("发送数据准备中,总共" + totalPackets);
|
||||
@ -949,11 +957,14 @@ console.log("1111111111")
|
||||
const sendNextVideoPacket = () => {
|
||||
// console.log("准备发送一段数据");
|
||||
if (currentPacket > totalPackets) {
|
||||
updateLoading(these,{text:'发送完毕,正在处理'})
|
||||
updateLoading(these, {
|
||||
text: '发送完毕,正在处理'
|
||||
})
|
||||
if (!ReSendNo) {
|
||||
setTimeout(() => {
|
||||
|
||||
ble.sendString(f.deviceId, "transmit complete", f.writeServiceId, f.wirteCharactId, 20)
|
||||
ble.sendString(f.deviceId, "transmit complete", f
|
||||
.writeServiceId, f.wirteCharactId, 20)
|
||||
.then(
|
||||
() => {
|
||||
console.log("全部发送完毕")
|
||||
@ -968,7 +979,7 @@ console.log("1111111111")
|
||||
}).catch((ex) => {
|
||||
console.log("出现异常", ex);
|
||||
});
|
||||
}, os=='Android'?500:15000);
|
||||
}, os == 'Android' ? 500 : 15000);
|
||||
|
||||
}
|
||||
these.Status.BottomMenu.show = false;
|
||||
@ -980,7 +991,7 @@ console.log("1111111111")
|
||||
}
|
||||
|
||||
// 计算当前包的数据
|
||||
let packetSize =os=='Android'? 500:128;
|
||||
let packetSize = os == 'Android' ? 500 : 128;
|
||||
|
||||
|
||||
// 创建数据包
|
||||
@ -996,28 +1007,29 @@ console.log("1111111111")
|
||||
|
||||
// 构建数据包
|
||||
////console.log("packetData.length"+packetData.length);
|
||||
const bufferSize =packetSize+4; // 头部5字节 + 数据部分
|
||||
const bufferSize = packetSize + 4; // 头部5字节 + 数据部分
|
||||
const buffer = new ArrayBuffer(bufferSize);
|
||||
const dataView = new DataView(buffer);
|
||||
|
||||
|
||||
|
||||
// 填充头部
|
||||
dataView.setUint8(0, os=='Android'?0x55:0x56); // 帧头
|
||||
dataView.setUint8(0, os == 'Android' ? 0x55 : 0x56); // 帧头
|
||||
dataView.setUint8(1, 0x04); // 帧类型:开机画面
|
||||
dataView.setUint16(2, currentPacket,false); // 包序号
|
||||
dataView.setUint16(2, currentPacket, false); // 包序号
|
||||
|
||||
for (let i = 0; i < packetData.length; i++) {
|
||||
dataView.setUint8(4 + i, parseInt(packetData[i],16));
|
||||
dataView.setUint8(4 + i, parseInt(packetData[i], 16));
|
||||
}
|
||||
|
||||
let inteval = os=='Android'? 100:40;
|
||||
let inteval = os == 'Android' ? 100 : 40;
|
||||
|
||||
ble.sendData(f.deviceId, buffer, f.writeServiceId, f
|
||||
.wirteCharactId, 10).then(() => {
|
||||
|
||||
updateLoading(these, {
|
||||
text: "正在发送:" +currentPacket+'/'+totalPackets
|
||||
text: "正在发送:" + currentPacket + '/' +
|
||||
totalPackets
|
||||
})
|
||||
|
||||
currentPacket++;
|
||||
@ -1753,7 +1765,7 @@ console.log("1111111111")
|
||||
});
|
||||
|
||||
},
|
||||
sliderChanging(evt){
|
||||
sliderChanging(evt) {
|
||||
this.formData.liangDu = evt.detail.value;
|
||||
},
|
||||
sliderChange: function(evt) {
|
||||
|
||||
@ -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>
|
||||
@ -43,24 +43,34 @@
|
||||
<!-- 设备基本信息 -->
|
||||
<view class="info-card">
|
||||
<view class="info-row">
|
||||
<text class="info-label">IMEI号</text>
|
||||
<text class="info-label">IMEI</text>
|
||||
<text class="info-value status-running">{{ deviceInfo.deviceImei }}</text>
|
||||
</view>
|
||||
<view class="info-row">
|
||||
<text class="info-label">MAC</text>
|
||||
<text class="info-value status-running">{{ itemInfo.deviceMac }}</text>
|
||||
</view>
|
||||
<view class="info-row">
|
||||
<text class="info-label">设备状态</text>
|
||||
<text class="info-value status-running">
|
||||
{{ deviceInfo.onlineStatus === 0 ? '离线' : deviceInfo.onlineStatus === 2 ? '故障' : '在线' }}
|
||||
</text>
|
||||
</view>
|
||||
<view class="info-row" v-if="itemInfo.deviceMac" @click="bleStatuToggle">
|
||||
<text class="info-label">蓝牙状态</text>
|
||||
<text class="info-value status-running" :class="formData.bleStatu?'green':'red'" >
|
||||
{{getbleStatu}}
|
||||
<view class="info-row" >
|
||||
<text class="info-label">蓝牙名称</text>
|
||||
<text class="info-value status-running" >
|
||||
{{deviceInfo.bluetoothName}}
|
||||
</text>
|
||||
</view>
|
||||
<view class="info-row" v-if="itemInfo.deviceMac" @click="bleStatuToggle">
|
||||
<view class="info-row" @click="bleStatuToggle">
|
||||
<text class="info-label">蓝牙状态</text>
|
||||
<text class="info-value status-running" :class="getbleStatu.cls">
|
||||
{{getbleStatu.txt}}
|
||||
</text>
|
||||
</view>
|
||||
<view class="info-row" @click="bleStatuToggle">
|
||||
<text class="info-label">充电状态</text>
|
||||
<text class="info-value status-running" >
|
||||
<text class="info-value status-running">
|
||||
{{deviceInfo.chargeState != 0?'充电中':'未充电'}}
|
||||
</text>
|
||||
</view>
|
||||
@ -112,7 +122,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 +132,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 +160,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 +174,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 +192,7 @@
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 人员信息登记 -->
|
||||
<!-- 发送信息-->
|
||||
<view class="form-section" v-if="hasPermission('5')">
|
||||
<view class="mode-buttons">
|
||||
<view class="section-title">发送信息</view>
|
||||
@ -276,13 +288,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 +320,8 @@
|
||||
MsgError,
|
||||
MsgClose,
|
||||
MsgWarning,
|
||||
showPop
|
||||
showPop,
|
||||
MsgInfo
|
||||
} from '@/utils/MsgPops.js';
|
||||
import Common from '@/utils/Common.js';
|
||||
|
||||
@ -355,7 +370,7 @@
|
||||
navTitle: "",
|
||||
sliderValue: 25,
|
||||
lightModeA: false,
|
||||
currentMainMode: '强光',
|
||||
currentMainMode: '关闭',
|
||||
currentlaserMode: "关闭",
|
||||
lightModeB: false,
|
||||
lightModeC: false, //激光提示框
|
||||
@ -402,7 +417,7 @@
|
||||
rgb565Data: null,
|
||||
selectedItemIndex: 0,
|
||||
popupType: 'person', //弹框类型
|
||||
isLaserOn: false,
|
||||
isLaserOn: false, //激光开启状态
|
||||
isSending: false,
|
||||
isProcessing: false,
|
||||
isPolling: false, // 轮询状态
|
||||
@ -418,6 +433,9 @@
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
remainTime() {
|
||||
return Common.formatTime(this.deviceInfo.batteryRemainingTime);
|
||||
},
|
||||
computedDeviceId() {
|
||||
return this.apiType === 'listA' ? this.deviceID : this.itemInfo.deviceId;
|
||||
},
|
||||
@ -425,24 +443,37 @@
|
||||
return this.modeType === 'main' ? '灯光模式' : '激光模式';
|
||||
},
|
||||
getbleStatu() {
|
||||
|
||||
let txt="未连接"
|
||||
let cls="";
|
||||
if (this.formData.bleStatu === true) {
|
||||
return '已连接';
|
||||
txt= '已连接';
|
||||
cls="green";
|
||||
}
|
||||
if (this.formData.bleStatu === 'connecting') {
|
||||
return '连接中';
|
||||
txt= '连接中';
|
||||
}
|
||||
if (this.formData.bleStatu === 'dicconnect') {
|
||||
return '正在断开';
|
||||
txt= '正在断开';
|
||||
}
|
||||
if (this.formData.bleStatu === 'err') {
|
||||
return '连接异常';
|
||||
txt= '连接异常';
|
||||
cls="red"
|
||||
}
|
||||
return '未连接';
|
||||
return {txt:txt,cls:cls}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
onReceive(deviceState){//蓝牙/Mq通用消息处理
|
||||
initWatch(){
|
||||
this.$watch("deviceInfo.batteryPercentage",(newVal,oldVal)=>{
|
||||
if (this.deviceInfo.batteryPercentage < 20 &&
|
||||
this.deviceInfo.chargeState == 0) {
|
||||
this.popupType = 'bettery';
|
||||
this.popupMessage = '请及时充电';
|
||||
this.showPopupFlag = true;
|
||||
}
|
||||
});
|
||||
},
|
||||
onReceive(deviceState, parsedMessage) { //蓝牙/Mq通用消息处理
|
||||
switch (deviceState[0]) {
|
||||
// 1设备切换灯光实时返回
|
||||
case 1:
|
||||
@ -452,25 +483,28 @@
|
||||
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为已充满)
|
||||
this.deviceInfo.batteryRemainingTime = deviceState[5]; //第6位200代表电池剩余续航时间200分钟
|
||||
}
|
||||
setTimeout(() => {
|
||||
if (this.deviceInfo.batteryPercentage < 20 &&
|
||||
this.deviceInfo.chargeState == 0) {
|
||||
this.popupType = 'bettery';
|
||||
this.popupMessage = '请及时充电';
|
||||
this.showPopupFlag = true;
|
||||
}
|
||||
|
||||
if (this.apiType === 'listA') {
|
||||
this.fetchDeviceDetail(data.data.id)
|
||||
} else {
|
||||
@ -508,7 +542,7 @@
|
||||
these.formData.bleStatu = true;
|
||||
}).catch(ex => {
|
||||
these.formData.bleStatu = 'err';
|
||||
MsgError("连接错误:"+ex.msg,"确定",these);
|
||||
MsgError("连接错误:" + ex.msg, "确定", these);
|
||||
});
|
||||
return;
|
||||
}
|
||||
@ -556,7 +590,7 @@
|
||||
borderColor: "#e034344d",
|
||||
buttonBgColor: "#E03434",
|
||||
buttonText: '去连接',
|
||||
buttonTextColor: '#FFFFFFde',
|
||||
buttonTextColor: '#FFFFFFde',
|
||||
showCancel: true,
|
||||
okCallback: function() {
|
||||
console.log("1111");
|
||||
@ -583,8 +617,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() {
|
||||
@ -620,7 +659,7 @@
|
||||
text: ex.msg
|
||||
})
|
||||
these.formData.bleStatu = 'err';
|
||||
MsgError("连接错误:"+ex.msg,"确定",these);
|
||||
MsgError("连接错误:" + ex.msg, "确定", these);
|
||||
}).finally(() => {
|
||||
setTimeout(() => {
|
||||
hideLoading(these);
|
||||
@ -737,60 +776,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;
|
||||
return;
|
||||
// const now = Date.now();
|
||||
// // 使用节流防止指令发送过于频繁
|
||||
// if (now - this.lastBrightnessTime > 200) { // 200毫秒节流
|
||||
// this.lastBrightnessTime = now;
|
||||
|
||||
let mqSend = () => {
|
||||
// let mqSend = () => {
|
||||
|
||||
// 增加轻微的震动反馈,提升手感
|
||||
uni.vibrateShort({
|
||||
type: 'light'
|
||||
});
|
||||
// // 增加轻微的震动反馈,提升手感
|
||||
// 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
|
||||
}
|
||||
})
|
||||
}
|
||||
// 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);
|
||||
// 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 => {
|
||||
// ble.sendString(f.deviceId, json).then(res => {
|
||||
|
||||
}).catch(ex => {
|
||||
mqSend();
|
||||
});
|
||||
} else {
|
||||
mqSend();
|
||||
}
|
||||
return;
|
||||
} else {
|
||||
mqSend();
|
||||
}
|
||||
}
|
||||
// }).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 +888,10 @@
|
||||
}
|
||||
},
|
||||
selectMode(type) {
|
||||
if (this.deviceInfo.alarmStatus == 1) {
|
||||
MsgError('请先解除强制报警', '', these);
|
||||
return;
|
||||
}
|
||||
this.modeType = type;
|
||||
this.lightModeA = true;
|
||||
if (type === 'main') {
|
||||
@ -906,7 +951,10 @@
|
||||
},
|
||||
// 灯光模式的确认
|
||||
handleSumbit() {
|
||||
|
||||
if (this.deviceInfo.alarmStatus == 1) {
|
||||
MsgError('请先解除强制报警', '', these);
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.selectedItemIndex === null) return;
|
||||
const selectedItem = this.items[this.selectedItemIndex];
|
||||
@ -928,8 +976,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'
|
||||
@ -959,8 +1012,11 @@
|
||||
json.instruct[1] = parseInt(selectedItem.instructValue);
|
||||
|
||||
ble.sendString(f.deviceId, json).then(res => {
|
||||
console.log("ble send success",json);
|
||||
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 +1032,10 @@
|
||||
},
|
||||
// 激光模式
|
||||
lasermode() {
|
||||
|
||||
if (this.deviceInfo.alarmStatus == 1) {
|
||||
MsgError('请先解除强制报警', '', these);
|
||||
return;
|
||||
}
|
||||
this.lightModeC = true
|
||||
|
||||
|
||||
@ -985,6 +1044,11 @@
|
||||
// 激光确认框提交
|
||||
handleBtn() {
|
||||
|
||||
if (this.deviceInfo.alarmStatus == 1) {
|
||||
MsgError('请先解除强制报警', '', these);
|
||||
return;
|
||||
}
|
||||
|
||||
const instructValue = this.isLaserOn ? 0 : 1;
|
||||
|
||||
let mqSend = () => {
|
||||
@ -1011,6 +1075,10 @@
|
||||
// 更新状态
|
||||
this.isLaserOn = !this.isLaserOn;
|
||||
this.currentlaserMode = this.isLaserOn ? "开启" : "关闭";
|
||||
|
||||
this.currentMainMode = this.getMainLightModeLabel(0);
|
||||
|
||||
|
||||
this.lightModeC = false;
|
||||
} else {
|
||||
uni.showToast({
|
||||
@ -1035,6 +1103,8 @@
|
||||
this.lightModeC = false;
|
||||
this.isLaserOn = !this.isLaserOn;
|
||||
this.currentlaserMode = this.isLaserOn ? "开启" : "关闭";
|
||||
|
||||
this.currentMainMode = this.getMainLightModeLabel(0);
|
||||
}).catch(ex => {
|
||||
mqSend();
|
||||
});
|
||||
@ -1052,7 +1122,12 @@
|
||||
},
|
||||
// 上传开机画面
|
||||
uploadStartup() {
|
||||
this.lightModeB = true
|
||||
if (this.deviceInfo.alarmStatus == 1) {
|
||||
MsgError('请先解除强制报警', '', these);
|
||||
return;
|
||||
}
|
||||
this.lightModeB = true;
|
||||
this.selectedImage=null;
|
||||
},
|
||||
// 上传开机画面
|
||||
checkImgUpload() {
|
||||
@ -1102,6 +1177,10 @@
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (this.deviceInfo.alarmStatus == 1) {
|
||||
MsgError('请先解除强制报警', '', these);
|
||||
return;
|
||||
}
|
||||
|
||||
let mqSend = () => {
|
||||
if (this.deviceInfo.onlineStatus !== 1) {
|
||||
@ -1264,7 +1343,7 @@
|
||||
dataView.setUint8(0, 0x55); // 帧头
|
||||
dataView.setUint8(1, 0x02); // 帧类型:开机画面
|
||||
dataView.setUint8(2, currentPacket); // 包序号
|
||||
dataView.setUint16(3, packetData.length*2,false); // 包t长度
|
||||
dataView.setUint16(3, packetData.length * 2, false); // 包t长度
|
||||
|
||||
|
||||
|
||||
@ -1338,11 +1417,11 @@
|
||||
});
|
||||
}
|
||||
|
||||
setTimeout(()=> {
|
||||
setTimeout(() => {
|
||||
sendImagePackets().catch(() => {
|
||||
|
||||
}).finally(()=>{
|
||||
this.lightModeB=false;
|
||||
}).finally(() => {
|
||||
this.lightModeB = false;
|
||||
});
|
||||
}, 0)
|
||||
}
|
||||
@ -1373,6 +1452,11 @@
|
||||
},
|
||||
// 发送人员信息
|
||||
sendPersonnelInfo() {
|
||||
if (this.deviceInfo.alarmStatus == 1) {
|
||||
MsgError('请先解除强制报警', '', these);
|
||||
return;
|
||||
}
|
||||
|
||||
let mqSend = async () => {
|
||||
if (this.isSending) return;
|
||||
const requiredFields = [{
|
||||
@ -1532,9 +1616,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 +1658,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;
|
||||
}
|
||||
|
||||
@ -1615,29 +1701,33 @@
|
||||
this.showPopupFlag = true;
|
||||
// this.popupConfirmText="";
|
||||
},
|
||||
OpenWarn(val){//开启/解除强制报警
|
||||
debugger;
|
||||
OpenWarn(val) { //开启/解除强制报警
|
||||
debugger;
|
||||
const topic = `B/${this.itemInfo.deviceImei}`;
|
||||
let message={"instruct":[7,val,0,0,0,0]};
|
||||
message=JSON.stringify(message);
|
||||
let message = {
|
||||
"instruct": [7, val, 0, 0, 0, 0]
|
||||
};
|
||||
message = JSON.stringify(message);
|
||||
|
||||
let flag=this.mqttClient.publish(topic, message, {
|
||||
let flag = this.mqttClient.publish(topic, message, {
|
||||
qos: 1
|
||||
});
|
||||
if(flag){
|
||||
this.itemInfo.alarmStatus=val;
|
||||
}else{
|
||||
MsgError("操作没有成功",'确定',this);
|
||||
if (flag) {
|
||||
this.itemInfo.alarmStatus = val;
|
||||
this.deviceInfo.alarmStatus = val;
|
||||
} else {
|
||||
MsgError("操作没有成功", '确定', this);
|
||||
}
|
||||
|
||||
this.showPopupFlag = false;
|
||||
this.onPopupConfirm();
|
||||
|
||||
},
|
||||
warnToggle(){
|
||||
if(this.itemInfo.alarmStatus==1){
|
||||
warnToggle() {
|
||||
if (this.itemInfo.alarmStatus == 1) {
|
||||
this.popupType = 'cancel';
|
||||
this.popupMessage = '确认解除报警状态';
|
||||
|
||||
}else{
|
||||
} else {
|
||||
this.popupType = 'openWarn';
|
||||
this.popupMessage = '确认开启报警状态';
|
||||
|
||||
@ -1676,7 +1766,7 @@
|
||||
// title: '设备已离线',
|
||||
// icon: 'none'
|
||||
// });
|
||||
this.OpenWarn(0);//走mq直发
|
||||
this.OpenWarn(0); //走mq直发
|
||||
return;
|
||||
}
|
||||
this.isPolling = true; // 标记开始轮询
|
||||
@ -1701,14 +1791,18 @@
|
||||
// title: registerRes.msg,
|
||||
// icon: 'none'
|
||||
// })
|
||||
this.OpenWarn(0);
|
||||
|
||||
|
||||
return
|
||||
}
|
||||
this.itemInfo.alarmStatus=0;
|
||||
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,22 +1810,26 @@
|
||||
interval: 500
|
||||
},
|
||||
deviceRealTimeStatus
|
||||
);
|
||||
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 {
|
||||
// 分享权限详情
|
||||
this.fetchSharedDeviceDetail(this.itemInfo.id)
|
||||
}
|
||||
).then(statusRes => {
|
||||
if (statusRes.data.functionAccess === 'OK') {
|
||||
uni.showToast({
|
||||
title: statusRes.msg,
|
||||
icon: 'none'
|
||||
});
|
||||
uni.$emit('deviceStatusUpdate', {});
|
||||
|
||||
if (this.apiType === 'listA') {
|
||||
this.fetchDeviceDetail(this.computedDeviceId)
|
||||
} else {
|
||||
// 分享权限详情
|
||||
this.fetchSharedDeviceDetail(this.itemInfo.id)
|
||||
}
|
||||
|
||||
}
|
||||
}).catch(ex => {
|
||||
console.error("出现错误", ex);
|
||||
});
|
||||
|
||||
}
|
||||
} catch (error) {
|
||||
uni.showToast({
|
||||
title: error.message,
|
||||
@ -1751,6 +1849,12 @@
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.deviceInfo.alarmStatus == 1) {
|
||||
MsgError('请先解除强制报警', '', these);
|
||||
return;
|
||||
}
|
||||
|
||||
// 防重复提交
|
||||
if (this.isSending) return;
|
||||
if (!this.messageToSend) {
|
||||
@ -1801,9 +1905,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({
|
||||
@ -1927,7 +2031,7 @@
|
||||
},
|
||||
onLoad(options) {
|
||||
these = this;
|
||||
|
||||
this.initWatch();
|
||||
rec = BleReceive.getBleReceive();
|
||||
const eventChannel = this.getOpenerEventChannel();
|
||||
// 监听 'detailData' 事件,获取传过来的数据
|
||||
@ -1955,14 +2059,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;
|
||||
const deviceState = parsedMessage.state; // 直接取 state 数组
|
||||
// 切换主灯光模式,亮度值设备同步
|
||||
if (!deviceState) return;
|
||||
payload) : payload;
|
||||
|
||||
this.onReceive(deviceState);
|
||||
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 || !deviceState instanceof Array) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.onReceive(deviceState, parsedMessage);
|
||||
}else{
|
||||
console.error("丢弃的消息",payload)
|
||||
}
|
||||
} catch (error) {
|
||||
console.log('解析MQTT消息失败:', error, '原始消息:', payload);
|
||||
}
|
||||
@ -1999,10 +2119,10 @@
|
||||
ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId).then(
|
||||
res => {
|
||||
these.formData.bleStatu = true;
|
||||
}).catch(ex=>{
|
||||
these.formData.bleStatu = 'err';
|
||||
MsgError("连接错误:"+ex.msg,"确定",these);
|
||||
});
|
||||
}).catch(ex => {
|
||||
these.formData.bleStatu = 'err';
|
||||
MsgError("连接错误:" + ex.msg, "确定", these);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -2022,8 +2142,8 @@
|
||||
ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId).then(res => {
|
||||
console.log("连接成功")
|
||||
this.formData.bleStatu = true;
|
||||
}).catch(ex=>{
|
||||
MsgError("连接错误:"+ex.msg,"确定",these);
|
||||
}).catch(ex => {
|
||||
MsgError("连接错误:" + ex.msg, "确定", these);
|
||||
});
|
||||
}
|
||||
},
|
||||
@ -2261,8 +2381,9 @@
|
||||
box-sizing: border-box;
|
||||
border: 1rpx solid #00000000;
|
||||
}
|
||||
.mode-v1.active{
|
||||
border:1rpx solid #bbe600 !important;
|
||||
|
||||
.mode-v1.active {
|
||||
border: 1rpx solid #bbe600 !important;
|
||||
}
|
||||
|
||||
.mode-v2 {
|
||||
|
||||
@ -113,7 +113,7 @@
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="mode marginLeft fleft" :class="formData.cMode=='mode'?'':'active'"
|
||||
<view class="mode marginLeft fleft"
|
||||
v-on:click.stop="ShowUpload()">
|
||||
<view class="leftImg">
|
||||
<image class="img" src="/static/images/6155/DeviceDetail/open.png" mode="aspectFit"></image>
|
||||
@ -166,13 +166,6 @@
|
||||
<!-- 下方菜单 -->
|
||||
<BottomSlideMenuPlus :config="Status.BottomMenu" @close="closeMenu" @itemClick="handleItemClick"
|
||||
@btnClick="btnClick">
|
||||
<view>
|
||||
<view class="addIco">
|
||||
<view class="icoContent center" v-on:click.stop="checkImgUpload()">
|
||||
<image mode="aspectFit" class="img" src="/static/images/6155/DeviceDetail/add.png"></image>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</BottomSlideMenuPlus>
|
||||
|
||||
<global-loading ref="loading" />
|
||||
@ -202,7 +195,8 @@ import request, { baseURL } from '@/utils/request.js';
|
||||
MsgInfo
|
||||
} from '@/utils/MsgPops.js'
|
||||
const pagePath = "/pages/650/HBY650";
|
||||
|
||||
import SendBatchData from '@/utils/SendBatchData.js';
|
||||
var batchTool=null;
|
||||
var ble = null;
|
||||
var these = null;
|
||||
var recei = null;
|
||||
@ -226,16 +220,12 @@ import request, { baseURL } from '@/utils/request.js';
|
||||
show: false,
|
||||
showHeader: true,
|
||||
menuItems: [{
|
||||
text: '强光',
|
||||
icon: '/static/images/lightImg/qiang.png'
|
||||
text: '照片',
|
||||
value:'img'
|
||||
},
|
||||
{
|
||||
text: '弱光',
|
||||
icon: '/static/images/lightImg/ruo.png'
|
||||
},
|
||||
{
|
||||
text: '爆闪',
|
||||
icon: '/static/images/lightImg/shan.png'
|
||||
text: '动画',
|
||||
value:'flash'
|
||||
}
|
||||
],
|
||||
activeIndex: -1,
|
||||
@ -864,8 +854,31 @@ import request, { baseURL } from '@/utils/request.js';
|
||||
},
|
||||
|
||||
checkImgUpload: function(type, index) {
|
||||
console.log("123213213213");
|
||||
let f = these.getDevice();
|
||||
if(!f){
|
||||
this.showBleUnConnect();
|
||||
return;
|
||||
}
|
||||
|
||||
if(!batchTool){
|
||||
batchTool=new SendBatchData(these,f,ble);
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (type) {
|
||||
if (type == 'img') {
|
||||
// sendImagePackets(index);
|
||||
batchTool.SendImg();
|
||||
} else{
|
||||
// sendVideoPackets(index);
|
||||
batchTool.SendVideo(506);
|
||||
}
|
||||
|
||||
}
|
||||
return;
|
||||
console.log("123213213213");
|
||||
|
||||
// 分包发送图片数据
|
||||
var sendImagePackets = function(ReSendNo) {
|
||||
|
||||
@ -1338,11 +1351,10 @@ import request, { baseURL } from '@/utils/request.js';
|
||||
return;
|
||||
}
|
||||
//上传开机画面
|
||||
this.Status.BottomMenu.menuItems = [];
|
||||
this.Status.BottomMenu.title = "上传开机画面";
|
||||
this.Status.BottomMenu.type = "checkImg";
|
||||
this.Status.BottomMenu.show = true;
|
||||
this.formData.cMode = "img";
|
||||
this.Status.BottomMenu.activeIndex=0;
|
||||
},
|
||||
|
||||
showMenu(flag) {
|
||||
@ -1352,8 +1364,8 @@ import request, { baseURL } from '@/utils/request.js';
|
||||
this.Status.BottomMenu.show = false;
|
||||
},
|
||||
btnClick(item, index) {
|
||||
|
||||
|
||||
this.Status.BottomMenu.show = false;
|
||||
this.checkImgUpload(item.value,index);
|
||||
|
||||
|
||||
},
|
||||
@ -1365,14 +1377,7 @@ import request, { baseURL } from '@/utils/request.js';
|
||||
},
|
||||
handleItemClick(item, index) {
|
||||
|
||||
switch (this.Status.BottomMenu.type) {
|
||||
case "main":
|
||||
|
||||
break;
|
||||
case "fu":
|
||||
|
||||
break;
|
||||
}
|
||||
this.Status.BottomMenu.activeIndex = index;
|
||||
|
||||
},
|
||||
|
||||
@ -258,13 +258,7 @@
|
||||
<!-- 下方菜单 -->
|
||||
<BottomSlideMenuPlus :config="Status.BottomMenu" @close="closeMenu" @itemClick="handleItemClick"
|
||||
@btnClick="btnClick">
|
||||
<view>
|
||||
<view class="addIco">
|
||||
<view class="icoContent center" v-on:click.stop="checkImgUpload()">
|
||||
<image mode="aspectFit" class="img" src="/static/images/6155/DeviceDetail/add.png"></image>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
</BottomSlideMenuPlus>
|
||||
|
||||
<!-- 弹窗通知 -->
|
||||
@ -304,6 +298,8 @@
|
||||
MsgInfo
|
||||
} from '@/utils/MsgPops.js'
|
||||
const pagePath = "/pages/670/HBY670";
|
||||
import SendBatchData from '@/utils/SendBatchData.js';
|
||||
var batchTool=null;
|
||||
var ble = null;
|
||||
var these = null;
|
||||
var recei = null;
|
||||
@ -358,16 +354,12 @@
|
||||
show: false,
|
||||
showHeader: true,
|
||||
menuItems: [{
|
||||
text: '强光',
|
||||
icon: '/static/images/lightImg/qiang.png'
|
||||
text: '照片',
|
||||
value:'img'
|
||||
},
|
||||
{
|
||||
text: '弱光',
|
||||
icon: '/static/images/lightImg/ruo.png'
|
||||
},
|
||||
{
|
||||
text: '爆闪',
|
||||
icon: '/static/images/lightImg/shan.png'
|
||||
text: '动画',
|
||||
value:'flash'
|
||||
}
|
||||
],
|
||||
activeIndex: -1,
|
||||
@ -1694,7 +1686,26 @@
|
||||
checkImgUpload: function(type, index) {
|
||||
console.log("123213213213");
|
||||
let f = these.getDevice();
|
||||
if(!f){
|
||||
this.showBleUnConnect();
|
||||
return;
|
||||
}
|
||||
|
||||
if(!batchTool){
|
||||
batchTool=new SendBatchData(these,f,ble);
|
||||
}
|
||||
|
||||
if (type) {
|
||||
if (type == 'img') {
|
||||
// sendImagePackets(index);
|
||||
batchTool.SendImg();
|
||||
} else {
|
||||
// sendVideoPackets(index);
|
||||
batchTool.SendVideo(506);
|
||||
}
|
||||
|
||||
}
|
||||
return;
|
||||
var sendImgByRequest = () => {
|
||||
return new Promise((resolve, reject) => {
|
||||
api.sendPic({
|
||||
@ -2208,11 +2219,12 @@
|
||||
return;
|
||||
}
|
||||
//上传开机画面
|
||||
this.Status.BottomMenu.menuItems = [];
|
||||
|
||||
this.Status.BottomMenu.title = "上传开机画面";
|
||||
this.Status.BottomMenu.type = "checkImg";
|
||||
this.Status.BottomMenu.show = true;
|
||||
this.Status.BottomMenu.showBtn = false;
|
||||
this.Status.BottomMenu.showBtn = true;
|
||||
this.Status.BottomMenu.activeIndex=0;
|
||||
},
|
||||
|
||||
showMenu(flag) {
|
||||
@ -2222,10 +2234,8 @@
|
||||
this.Status.BottomMenu.show = false;
|
||||
},
|
||||
btnClick(item, index) {
|
||||
|
||||
|
||||
|
||||
|
||||
this.Status.BottomMenu.show = false;
|
||||
this.checkImgUpload(item.value,index);
|
||||
},
|
||||
setMode(mode) {
|
||||
|
||||
|
||||
@ -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",
|
||||
|
||||
@ -24,7 +24,7 @@
|
||||
{{Statu.boundRemark}}
|
||||
</view>
|
||||
</view>
|
||||
<view class="btnLink" @click="Link()">
|
||||
<view class="btnLink" @click="Bind()">
|
||||
绑定
|
||||
</view>
|
||||
|
||||
@ -71,7 +71,10 @@
|
||||
"communicationMode": "",
|
||||
"imei": ""
|
||||
},
|
||||
serverDevice: null
|
||||
serverDevice: null,
|
||||
groupid:null,
|
||||
typeList:[],
|
||||
uploadStatu:null
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
@ -86,7 +89,6 @@
|
||||
}
|
||||
},
|
||||
deviceStatu: function() {
|
||||
debugger;
|
||||
if (!this.device.name && !this.device.macAddress) {
|
||||
return "";
|
||||
}
|
||||
@ -127,7 +129,8 @@
|
||||
console.log("返回取消订阅");
|
||||
clearInterval(inteval);
|
||||
ble.removeAllCallback(pagePath);
|
||||
|
||||
clearTimeout(this.Statu.timeInteval);
|
||||
this.uploadStatu=null;
|
||||
if(!this.Statu.isBind && these.device.deviceId){
|
||||
ble.disconnectDevice(these.device.deviceId).catch(ex=>{
|
||||
console.error("无法断开蓝牙连接");
|
||||
@ -137,6 +140,8 @@
|
||||
|
||||
onLoad(option) {
|
||||
these = this;
|
||||
this.groupid=new Date().getTime()+"";
|
||||
|
||||
ble = bleTool.getBleTool();
|
||||
|
||||
ble.addStateBreakCallback(res => {
|
||||
@ -258,6 +263,108 @@
|
||||
|
||||
},
|
||||
methods: {
|
||||
getDevList() {
|
||||
return new Promise((resolve,reject)=>{
|
||||
let arr = [
|
||||
|
||||
];
|
||||
request({
|
||||
url: '/app/xinghan/device/typeAll',
|
||||
method: 'get'
|
||||
}).then(res => {
|
||||
if (res && res.code == 200) {
|
||||
console.log("获取到类型", res.data);
|
||||
arr = res.data;
|
||||
this.typeList = arr;
|
||||
resolve(arr);
|
||||
return;
|
||||
}
|
||||
reject();
|
||||
|
||||
}).catch(ex => {
|
||||
console.error("获取设备类型列表失败",ex);
|
||||
reject();
|
||||
})
|
||||
});
|
||||
|
||||
},
|
||||
uploadItem() {
|
||||
if(this.uploadStatu!==null){
|
||||
console.error("执行过上传,不再执行");
|
||||
return;
|
||||
}
|
||||
|
||||
this.uploadStatu="start";
|
||||
console.log("开始上传设备");
|
||||
|
||||
let type=this.device.name.toLowerCase();
|
||||
if(type.indexOf("bjq6155-")>-1){//6155特别处理
|
||||
type="xh6155"
|
||||
}
|
||||
if(type.indexOf("bjq6155-")>-1){//6155特别处理
|
||||
type="xh6155"
|
||||
}
|
||||
if(type.indexOf("bjq6075-")>-1){//6075j特别处理
|
||||
bype='bjq6075j';
|
||||
}
|
||||
type=type.replace(/-/g,'');
|
||||
let upload=()=>{
|
||||
let f=this.typeList.find((v,i)=>{
|
||||
if(type.indexOf(v.typeName.replace(/-/g,'').toLowerCase())>-1){
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
if(!f){
|
||||
this.uploadStatu="type is valid";
|
||||
console.error("找不到此类型名称",type);
|
||||
console.error("tpelist=",this.typeList);
|
||||
return;
|
||||
}
|
||||
let json = {
|
||||
"deviceType": f.id,
|
||||
"deviceName": this.device.name,
|
||||
"deviceMac": this.device.macAddress,
|
||||
"bluetoothName": this.device.name,
|
||||
"deviceImei":this.device.imei?this.device.imei:'',
|
||||
"remark": "com.chxhyc.cn auto upload"
|
||||
}
|
||||
request({
|
||||
url: '/app/xinghan/device/add',
|
||||
method: 'post',
|
||||
data: json
|
||||
}).then(res => {
|
||||
if (res && res.code == 200) {
|
||||
this.uploadStatu="success";
|
||||
console.log("上传成功",res);
|
||||
} else {
|
||||
this.uploadStatu="upload error";
|
||||
console.error("上传失败,",res);
|
||||
}
|
||||
}).catch(ex => {
|
||||
this.uploadStatu="upload error";
|
||||
console.error("上传失败,",ex);
|
||||
});
|
||||
}
|
||||
|
||||
let exec = () => {
|
||||
|
||||
if(this.typeList.length==0){
|
||||
this.getDevList().then(results=>{
|
||||
upload();
|
||||
}).catch(ex=>{
|
||||
this.uploadStatu="get types error";
|
||||
console.error("获取类型失败,",ex);
|
||||
});
|
||||
}else{
|
||||
upload();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
setTimeout(exec, 10)
|
||||
},
|
||||
reLinkdevice() {
|
||||
ble.LinkBlue(these.device.deviceId).then(res => {
|
||||
updateLoading(these, {
|
||||
@ -320,6 +427,7 @@
|
||||
clearInterval(inteval);
|
||||
} else {
|
||||
deviceInvalid();
|
||||
this.uploadItem();
|
||||
}
|
||||
} else {
|
||||
this.serverDevice =null;
|
||||
@ -337,7 +445,7 @@
|
||||
}, 500);
|
||||
|
||||
},
|
||||
Link() {
|
||||
Bind() {
|
||||
// 调用绑定设备接口
|
||||
|
||||
// let f = ble.data.LinkedList.find((v) => {
|
||||
|
||||
@ -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"
|
||||
@ -165,7 +164,7 @@
|
||||
},
|
||||
search: '', //筛选
|
||||
PairEquip: [], //已配对设备
|
||||
tmpLink:[],//本次已配对
|
||||
tmpLink: [], //本次已配对
|
||||
EquipMents: [], //搜索出来的设备
|
||||
device: null,
|
||||
item: {
|
||||
@ -224,7 +223,7 @@
|
||||
|
||||
const systemInfo = uni.getSystemInfoSync();
|
||||
|
||||
// Ensure ble is initialized
|
||||
// Ensure ble is initialized
|
||||
|
||||
if (systemInfo.uniPlatform == 'web') {
|
||||
|
||||
@ -253,7 +252,7 @@
|
||||
];
|
||||
|
||||
console.error("1111111111")
|
||||
this.PairEquip=[this.EquipMents[0]];
|
||||
this.PairEquip = [this.EquipMents[0]];
|
||||
|
||||
return;
|
||||
}
|
||||
@ -273,7 +272,7 @@
|
||||
}
|
||||
console.log("处理蓝牙不可用");
|
||||
hideLoading(these);
|
||||
console.error("1111111111")
|
||||
|
||||
these.PairEquip = [];
|
||||
these.EquipMents = [];
|
||||
uni.showToast({
|
||||
@ -286,13 +285,15 @@
|
||||
|
||||
//蓝牙恢复可用的回调
|
||||
ble.addStateRecoveryCallback(res => {
|
||||
console.log("蓝牙恢复可用");
|
||||
these.Status.BottomMenu.show = false;
|
||||
these.PairEquip = [];
|
||||
these.EquipMents = [];
|
||||
|
||||
if (these.Status.isPageHidden) {
|
||||
return;
|
||||
}
|
||||
these.Status.BottomMenu.show = false;
|
||||
console.error("1111111111")
|
||||
these.PairEquip = [];
|
||||
these.EquipMents = [];
|
||||
|
||||
uni.showToast({
|
||||
icon: 'fail',
|
||||
title: '蓝牙恢复可用'
|
||||
@ -378,7 +379,7 @@
|
||||
|
||||
if (!these.device) {
|
||||
hideLoading(these);
|
||||
}else{
|
||||
} else {
|
||||
clearInterval(this.Status.intval);
|
||||
these.DeviceVerdict(res.deviceId);
|
||||
}
|
||||
@ -437,16 +438,16 @@
|
||||
this.refreshLinked();
|
||||
},
|
||||
methods: {
|
||||
refreshLinked(){
|
||||
refreshLinked() {
|
||||
|
||||
|
||||
|
||||
if(ble){
|
||||
let arr=[];
|
||||
arr=ble.data.LinkedList.filter(v=>{
|
||||
if (ble) {
|
||||
let arr = [];
|
||||
arr = ble.data.LinkedList.filter(v => {
|
||||
return v.Linked;
|
||||
});
|
||||
this.PairEquip=arr;
|
||||
this.PairEquip = arr;
|
||||
}
|
||||
|
||||
|
||||
@ -500,7 +501,8 @@
|
||||
}
|
||||
const hasPermission = await this.checkAndRequestLocationPermission();
|
||||
if (!hasPermission) {
|
||||
console.log("缺少定位权限,已中止蓝牙扫描。");
|
||||
|
||||
MsgError('缺少定位权限,已中止蓝牙扫描', '', this);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -528,15 +530,15 @@
|
||||
|
||||
ble.StartSearch().then(result => {
|
||||
// console.log("开始搜索成功", result);
|
||||
these.Status.BottomMenu.show=false;
|
||||
these.Status.BottomMenu.show = false;
|
||||
}).catch(err => {
|
||||
console.error("开始搜索失败:", err);
|
||||
if (err.code === 10001) {
|
||||
these.showOpenSetting();
|
||||
} else {
|
||||
|
||||
MsgClear(these);
|
||||
MsgError('出现错误:' + err.msg, '确定', these);
|
||||
MsgError('出现错误:' + err.msg, '确定', these, () => {
|
||||
MsgClear(these);
|
||||
});
|
||||
|
||||
}
|
||||
}).finally(() => {
|
||||
@ -580,9 +582,9 @@
|
||||
ble.showBlueSetting(false);
|
||||
},
|
||||
DeviceVerdict(deviceId) { //判断是否是目标设备
|
||||
if (these.Status.isPageHidden) {
|
||||
return;
|
||||
}
|
||||
if (these.Status.isPageHidden) {
|
||||
return;
|
||||
}
|
||||
console.log("deviceid=", deviceId);
|
||||
console.log("these.device=", these.device)
|
||||
if (these.device) { //从设备详情过来的,回设备详情去
|
||||
@ -727,7 +729,7 @@
|
||||
});
|
||||
|
||||
let index = 1;
|
||||
let total = 5;
|
||||
let total = 1;
|
||||
|
||||
let linkCallback = (res) => {
|
||||
console.log("连接成功", these.device);
|
||||
@ -759,7 +761,7 @@
|
||||
return;
|
||||
}
|
||||
ble.LinkBlue(item.deviceId).then((res) => {
|
||||
this.tmpLink=[item];
|
||||
this.tmpLink = [item];
|
||||
console.log("连接成功");
|
||||
ble.StopSearch();
|
||||
resolve(res);
|
||||
@ -767,9 +769,9 @@
|
||||
if (index == total) {
|
||||
console.log("连接了N次都没连上");
|
||||
reject(ex);
|
||||
updateLoading(this, {
|
||||
text: ex.msg
|
||||
})
|
||||
updateLoading(this, {
|
||||
text: ex.msg
|
||||
})
|
||||
return;
|
||||
}
|
||||
index++;
|
||||
@ -786,7 +788,7 @@
|
||||
|
||||
execLink().then((res) => {
|
||||
console.log("res=", res);
|
||||
if(this.Status.isPageHidden){
|
||||
if (this.Status.isPageHidden) {
|
||||
return;
|
||||
}
|
||||
linkCallback(res);
|
||||
@ -802,16 +804,16 @@
|
||||
|
||||
|
||||
},
|
||||
disConnect:function(item,index){
|
||||
disConnect: function(item, index) {
|
||||
// #ifdef H5|WEB
|
||||
|
||||
this.PairEquip.splice(index,1);
|
||||
this.PairEquip.splice(index, 1);
|
||||
|
||||
// #endif
|
||||
// #ifdef APP|APP-PLUS
|
||||
if(ble){
|
||||
ble.disconnectDevice(item.deviceId).catch(ex=>{
|
||||
console.error("无法断开连接",ex);
|
||||
if (ble) {
|
||||
ble.disconnectDevice(item.deviceId).catch(ex => {
|
||||
console.error("无法断开连接", ex);
|
||||
});
|
||||
}
|
||||
// #endif
|
||||
|
||||
@ -45,12 +45,17 @@
|
||||
|
||||
|
||||
</view>
|
||||
<view class="tab">
|
||||
<view class="center tabItem" @click="Status.tabIndex=0" :class="{'active':Status.tabIndex==0}">未入库(<text class="mathIcon">{{UnJoin.length}}</text>)</view>
|
||||
<view class="center tabItem" @click="Status.tabIndex=1" :class="{'active':Status.tabIndex==1}">已入库(<text class="mathIcon">{{joined.length}}</text>)</view>
|
||||
<view class="center tabItem" @click="Status.tabIndex=2" :class="{'active':Status.tabIndex==2}">全部(<text class="mathIcon">{{SearchEquips.length}}</text>)</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="mainContent">
|
||||
<view class="p100">
|
||||
|
||||
<view class="list searchList">
|
||||
<view class="item" v-on:click="Link(item,index)" v-for="item, index in SearchEquips"
|
||||
<view class="item" v-on:click="Link(item,index)" v-for="item, index in list"
|
||||
v-show="!item['linkStatu']"
|
||||
:class="{'displayNone':item.name.toLowerCase().indexOf(search.toLowerCase())===-1}">
|
||||
<view class="leftImg ">
|
||||
@ -152,7 +157,8 @@
|
||||
title: '添加设备',
|
||||
showBack: true,
|
||||
height: 90
|
||||
}
|
||||
},
|
||||
tabIndex:0
|
||||
},
|
||||
search: '',
|
||||
groupid: '',
|
||||
@ -168,12 +174,35 @@
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
list(){
|
||||
if(this.Status.tabIndex==0){
|
||||
return this.UnJoin;
|
||||
}
|
||||
if(this.Status.tabIndex==1){
|
||||
return this.joined;
|
||||
}
|
||||
|
||||
return this.SearchEquips;
|
||||
},
|
||||
SearchEquips: function() {
|
||||
let f = this.EquipMents.filter(v => {
|
||||
return v.name.toLowerCase().indexOf(this.search.toLowerCase()) > -1
|
||||
});
|
||||
return f;
|
||||
}
|
||||
},
|
||||
joined(){
|
||||
let f=this.EquipMents.filter(v => {
|
||||
return v.name.toLowerCase().indexOf(this.search.toLowerCase()) > -1 && v.isUpload;
|
||||
});
|
||||
return f;
|
||||
},
|
||||
UnJoin(){
|
||||
let f=this.EquipMents.filter(v => {
|
||||
return v.name.toLowerCase().indexOf(this.search.toLowerCase()) > -1 && !v.isUpload;
|
||||
});
|
||||
return f;
|
||||
},
|
||||
|
||||
},
|
||||
onHide: function() {
|
||||
ble.StopSearch();
|
||||
@ -427,7 +456,7 @@
|
||||
|
||||
if (!f) {
|
||||
arr[i].remark = '正在校验...';
|
||||
these.EquipMents.push(arr[i]);
|
||||
these.EquipMents.unshift(arr[i]);
|
||||
|
||||
these.getDevice(arr[i]);
|
||||
|
||||
@ -482,20 +511,19 @@
|
||||
|
||||
|
||||
ble.addStateBreakCallback(() => {
|
||||
MsgError('蓝牙不可用','确定',these);
|
||||
|
||||
|
||||
MsgError('蓝牙不可用','',these);
|
||||
|
||||
these.EquipMents.filter((v, i) => {
|
||||
these.$set(these.EquipMents[i], 'link', false);
|
||||
});
|
||||
}, pagePath);
|
||||
ble.addStateRecoveryCallback(() => {
|
||||
|
||||
|
||||
MsgSuccess('蓝牙恢复可用','',these,()=>{
|
||||
these.ReSearch();
|
||||
MsgSuccess('蓝牙恢复可用','确定',these,()=>{
|
||||
MsgClear(these);
|
||||
})
|
||||
});
|
||||
},
|
||||
pagePath);
|
||||
|
||||
@ -555,10 +583,10 @@
|
||||
|
||||
|
||||
|
||||
|
||||
// #ifdef APP|APP-PLUS
|
||||
setTimeout(()=>{
|
||||
MsgInfo("如需要在PC上查看此数据,请复制链接后通过微信发送到PC,在PC端打开,然后点右上角扫码授权","复制链接",these,true,()=>{
|
||||
console.log("执行复制");
|
||||
console.log("开始访问剪切板");
|
||||
uni.setClipboardData({
|
||||
data:'https://static-mp-5b7c35fc-f6fe-4100-a2e1-3669e4d4bfc9.next.bspapp.com/AppTools/views/index.html',
|
||||
success(){
|
||||
@ -571,12 +599,14 @@
|
||||
MsgError("打开微信失败,请手动打开微信,发送至'文件传输助手'");
|
||||
});
|
||||
},
|
||||
fail(ex){
|
||||
console.error("无法复制",ex)
|
||||
fail(ex) {
|
||||
console.error("ex=",ex);
|
||||
}
|
||||
});
|
||||
});
|
||||
},500);
|
||||
// #endif
|
||||
|
||||
},
|
||||
|
||||
onShow: function() {
|
||||
@ -806,6 +836,7 @@
|
||||
let json = getUrlParams(res.result);
|
||||
if (!json.key) {
|
||||
|
||||
|
||||
MsgError('无效的二维码','',these);
|
||||
return;
|
||||
}
|
||||
@ -878,23 +909,26 @@
|
||||
},
|
||||
ReSearch() {
|
||||
if (!ble) {
|
||||
MsgError('蓝牙模块未初始化','',this);
|
||||
return;
|
||||
}
|
||||
|
||||
showLoading(this,{text:'请稍候...'});
|
||||
ble.disconnectDevice().finally(dis => {
|
||||
|
||||
ble.StopSearch().finally(res => {
|
||||
|
||||
setTimeout(()=>{
|
||||
this.EquipMents = [];
|
||||
this.EquipMents = [];
|
||||
this.PairEquip = [];
|
||||
ble.StartSearch().then(result => {
|
||||
setTimeout(()=>{
|
||||
ble.StartSearch().then(result => {
|
||||
|
||||
}).catch(err => {
|
||||
console.error("err=", err);
|
||||
MsgError("出现错误:" + err.msg, '', these);
|
||||
}).finally(()=>{
|
||||
hideLoading(these);
|
||||
});
|
||||
},200);
|
||||
},600)
|
||||
|
||||
}).catch(ex => {
|
||||
console.error("ex=", ex);
|
||||
@ -983,7 +1017,7 @@
|
||||
});
|
||||
|
||||
let index = 1;
|
||||
let total = 5;
|
||||
let total = 1;
|
||||
|
||||
let linkCallback = (res) => {
|
||||
let c = these.PairEquip.find(function(v) {
|
||||
@ -1019,14 +1053,11 @@
|
||||
return false;
|
||||
});
|
||||
|
||||
ble.StopSearch();
|
||||
|
||||
resolve(res);
|
||||
}).catch((ex) => {
|
||||
if (index == total) {
|
||||
console.log("连接了N次都没连上");
|
||||
updateLoading(this, {
|
||||
text: ex.msg
|
||||
});
|
||||
reject(ex);
|
||||
return;
|
||||
}
|
||||
@ -1049,7 +1080,7 @@
|
||||
}).catch(ex => {
|
||||
console.log("ex=", ex)
|
||||
|
||||
MsgError("连接失败:" + ex.msg,'',these);
|
||||
MsgError("连接失败"+ex.code + ex.msg,'',these);
|
||||
hideLoading(these);
|
||||
});
|
||||
}
|
||||
@ -1066,6 +1097,22 @@
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.tabItem.active{
|
||||
border-bottom:2rpx solid #BBE600;
|
||||
color:#BBE600;
|
||||
}
|
||||
.mathIcon{
|
||||
color: #BBE600;
|
||||
}
|
||||
.tab{
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
flex-wrap: nowrap;
|
||||
align-content: center;
|
||||
justify-content: space-evenly;
|
||||
height: 60rpx;
|
||||
font-size: 28rpx;
|
||||
}
|
||||
.noLink {
|
||||
text-align: center;
|
||||
width: 100%;
|
||||
@ -1218,12 +1265,7 @@
|
||||
min-height: 120rpx;
|
||||
}
|
||||
|
||||
.searchList {
|
||||
width: 100%;
|
||||
height: calc(100% - 186rpx);
|
||||
overflow-y: scroll;
|
||||
margin-top: 120rpx;
|
||||
}
|
||||
|
||||
|
||||
.list .item {
|
||||
width: 100%;
|
||||
@ -1437,7 +1479,7 @@
|
||||
.topStatric {
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
padding: 30rpx;
|
||||
padding:0rpx 30rpx;
|
||||
position: fixed;
|
||||
top: 0rpx;
|
||||
z-index: 99;
|
||||
@ -1453,9 +1495,15 @@
|
||||
|
||||
.mainContent {
|
||||
|
||||
margin-top: 160rpx;
|
||||
margin-top: 280rpx;
|
||||
}
|
||||
|
||||
.searchList {
|
||||
width: 100%;
|
||||
height: calc(100% - 186rpx);
|
||||
overflow-y: scroll;
|
||||
margin-top: 90rpx;
|
||||
}
|
||||
|
||||
/* #endif */
|
||||
|
||||
@ -1466,9 +1514,15 @@
|
||||
}
|
||||
|
||||
.topStatric {
|
||||
top: 90rpx
|
||||
top: 130rpx
|
||||
}
|
||||
|
||||
.searchList {
|
||||
width: 100%;
|
||||
height: calc(100% - 186rpx);
|
||||
overflow-y: scroll;
|
||||
margin-top: 150rpx;
|
||||
}
|
||||
/* #endif */
|
||||
|
||||
|
||||
|
||||
@ -9,57 +9,64 @@
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
<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">
|
||||
<text>{{
|
||||
<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">
|
||||
<text>{{
|
||||
tabs[activeTab].name === '我的分享'
|
||||
? `分享给“${group.sharedTo}”的设备`
|
||||
: `来自“${group.othersharedTo}”分享的设备`
|
||||
}}</text>
|
||||
<text class="edit-btn"
|
||||
@click="toggleEdit(groupIndex)">{{editingGroup === groupIndex ? '完成' : '编辑'}}</text>
|
||||
</view>
|
||||
<block>
|
||||
<text class="edit-btn"
|
||||
@click="toggleEdit(groupIndex)">{{editingGroup === groupIndex ? '完成' : '编辑'}}</text>
|
||||
</view>
|
||||
<block>
|
||||
|
||||
<view class="device-card" v-for="(item, index) in group.devices" :key="index"
|
||||
:ref="'swipeItem_' + index">
|
||||
<view class="checkbox" v-if="editingGroup === groupIndex">
|
||||
<uni-icons @click="handleDelete(item)" type="minus" size="20"
|
||||
color="#FF4D4F"></uni-icons>
|
||||
</view>
|
||||
<view class="device-content" @click.stop="handleFile(item)">
|
||||
<view class="device-header">
|
||||
<view class="deviceIMG">
|
||||
<image :src="item.devicePic" class="IMG" mode="aspectFit"></image>
|
||||
</view>
|
||||
<view class="device-name">
|
||||
<view>设备:{{item.deviceName}}</view>
|
||||
<view class="ID">
|
||||
<view class="device-card" v-for="(item, index) in group.devices" :key="index"
|
||||
:ref="'swipeItem_' + index">
|
||||
<view class="checkbox" v-if="editingGroup === groupIndex">
|
||||
<uni-icons @click="handleDelete(item)" type="minus" size="20"
|
||||
color="#FF4D4F"></uni-icons>
|
||||
</view>
|
||||
<view class="device-content" @click.stop="handleFile(item)">
|
||||
<view class="device-header">
|
||||
<view class="deviceIMG">
|
||||
<image :src="item.devicePic" class="IMG" mode="aspectFit"></image>
|
||||
</view>
|
||||
<view class="device-name">
|
||||
<view>设备:{{item.deviceName}}</view>
|
||||
<view class="ID">
|
||||
ID:{{item.deviceImei}}</view>
|
||||
<!-- 在线状态 -->
|
||||
<view class="onlines" v-if="item.onlineStatus==1">在线</view>
|
||||
<!-- 离线状态 -->
|
||||
<view class="offlines" v-if="item.onlineStatus==0">离线</view>
|
||||
<view>电量:{{item.battery || '0'}}%</view>
|
||||
<view class="ID">
|
||||
ID:{{item.deviceImei}}</view>
|
||||
<!-- 在线状态 -->
|
||||
<view class="onlines" v-if="item.onlineStatus==1">在线</view>
|
||||
<!-- 离线状态 -->
|
||||
<view class="offlines" v-if="item.onlineStatus==0">离线</view>
|
||||
<view>电量:{{item.battery || '0'}}%</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</block>
|
||||
</block>
|
||||
</view>
|
||||
</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>
|
||||
</view> -->
|
||||
<!-- </scroll-view> -->
|
||||
</mescroll-uni>
|
||||
</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') {
|
||||
@ -142,12 +189,13 @@
|
||||
let url = item.detailPageUrl;
|
||||
uni.navigateTo({
|
||||
// url: "/pages/6170/deviceControl/index",
|
||||
url:url,
|
||||
url: url,
|
||||
success: (res) => {
|
||||
// 页面跳转成功后的回调函数
|
||||
res.eventChannel.emit('detailData', {
|
||||
data: item,
|
||||
apiType:this.activeTab===0?'listA':'listB' // 自定义标识 // 自定义标识,详情哪里根据这个参数不同信息
|
||||
apiType: this.activeTab === 0 ? 'listA' :
|
||||
'listB' // 自定义标识 // 自定义标识,详情哪里根据这个参数不同信息
|
||||
});
|
||||
}
|
||||
})
|
||||
@ -200,43 +248,59 @@
|
||||
},
|
||||
// 获取设备列表
|
||||
getData(tab) {
|
||||
//console.log(tab.name, 'tab');
|
||||
if (this.loading) return;
|
||||
this.loading = true;
|
||||
let data = {
|
||||
pageNum: this.page,
|
||||
pageSize: this.size,
|
||||
}
|
||||
// 根据当前tab决定调用哪个接口
|
||||
const apiCall = tab.name === '我的分享' ? deviceShareList : otherDeviceShareList;
|
||||
console.log('nihao');
|
||||
apiCall(data).then((res) => {
|
||||
if (res.code == 200) {
|
||||
const newDevices = res.rows.map(device => ({
|
||||
...device,
|
||||
showConfirm: false,
|
||||
sharedTo: device.phonenumber,
|
||||
othersharedTo: device.otherPhonenumber
|
||||
}));
|
||||
// 分页处理
|
||||
if (this.page === 1) {
|
||||
this.deviceList = newDevices;
|
||||
} else {
|
||||
this.deviceList = [...this.deviceList, ...newDevices];
|
||||
}
|
||||
|
||||
this.total = res.total;
|
||||
// 判断是否已加载全部数据
|
||||
if (res.rows.length < this.size || this.deviceList.length >= this.total) {
|
||||
this.finished = true;
|
||||
} else {
|
||||
this.page++;
|
||||
}
|
||||
let task = () => {
|
||||
if (this.loading) return;
|
||||
this.loading = true;
|
||||
let data = {
|
||||
pageNum: this.mescroll.num,
|
||||
pageSize: this.size,
|
||||
}
|
||||
}).finally(() => {
|
||||
this.loading = false;
|
||||
});
|
||||
|
||||
if (!data.pageNum) {
|
||||
this.mescroll.endSuccess(0, false);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// 根据当前tab决定调用哪个接口
|
||||
const apiCall = this.tabs[this.activeTab].name === '我的分享' ? deviceShareList : otherDeviceShareList;
|
||||
console.log('nihao');
|
||||
apiCall(data).then((res) => {
|
||||
if (res.code == 200) {
|
||||
const newDevices = res.rows.map(device => ({
|
||||
...device,
|
||||
showConfirm: false,
|
||||
sharedTo: device.phonenumber,
|
||||
othersharedTo: device.otherPhonenumber
|
||||
}));
|
||||
// 分页处理
|
||||
if (this.page === 1) {
|
||||
this.deviceList = newDevices;
|
||||
} else {
|
||||
this.deviceList = [...this.deviceList, ...newDevices];
|
||||
}
|
||||
|
||||
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: '没有更多数据了'
|
||||
},
|
||||
|
||||
@ -27,12 +27,13 @@
|
||||
<mescroll-uni class="device-list" @init="mescrollInit" @down="downCallback" @up="upCallback" :up="upOption"
|
||||
:down="downOption" :fixed="false" :style="{ height: mescrollHeight + 'px' }">
|
||||
<view v-if="deviceList.length>0">
|
||||
<uni-swipe-action ref="swipeAction" >
|
||||
<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"
|
||||
:class="item.active?'active':''"
|
||||
: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 +63,8 @@
|
||||
</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 +244,8 @@
|
||||
isLock: false,
|
||||
empty: {
|
||||
tip: '暂无数据',
|
||||
hideScroll: false
|
||||
hideScroll: false,
|
||||
icon: '/static/images/common/empty.png'
|
||||
},
|
||||
textNoMore: '没有更多数据了'
|
||||
},
|
||||
@ -314,7 +317,7 @@
|
||||
|
||||
},
|
||||
bleBreak(res) {
|
||||
// console.error("蓝牙断开连接", res);
|
||||
console.error("蓝牙断开连接", res);
|
||||
if (res.deviceId) {
|
||||
this.updateBleStatu(res.deviceId);
|
||||
}
|
||||
@ -697,30 +700,44 @@
|
||||
}
|
||||
})
|
||||
},
|
||||
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) {
|
||||
let url = item.detailPageUrl;
|
||||
// url="/pages/6075/BJQ6075L";
|
||||
// if(!url){
|
||||
// url="/pages/6075/BJQ6075"
|
||||
// }
|
||||
uni.navigateTo({
|
||||
url: url,
|
||||
events: {
|
||||
ack: function(data) {}
|
||||
},
|
||||
success: (res) => {
|
||||
// 页面跳转成功后的回调函数
|
||||
res.eventChannel.emit('detailData', {
|
||||
data: item,
|
||||
deviceType: this.tabs[this.activeTab].id || '',
|
||||
apiType: 'listA' //标识,根据这个参数,区分普通详情,分享跳转详情,查不一样的权限信息
|
||||
});
|
||||
},
|
||||
fail(ex) {
|
||||
console.log("ex=", ex);
|
||||
}
|
||||
})
|
||||
handleFile(item, index) {
|
||||
if (item.showOption == 'right') {
|
||||
this.$set(this.deviceList[index], 'showOption', 'none');
|
||||
return;
|
||||
}
|
||||
|
||||
this.$set(this.deviceList[index], 'active', true);
|
||||
setTimeout(() => {
|
||||
this.$set(this.deviceList[index], 'active', false);
|
||||
let url = item.detailPageUrl;
|
||||
uni.navigateTo({
|
||||
url: url,
|
||||
events: {
|
||||
ack: function(data) {}
|
||||
},
|
||||
success: (res) => {
|
||||
// 页面跳转成功后的回调函数
|
||||
res.eventChannel.emit('detailData', {
|
||||
data: item,
|
||||
deviceType: this.tabs[this.activeTab].id || '',
|
||||
apiType: 'listA' //标识,根据这个参数,区分普通详情,分享跳转详情,查不一样的权限信息
|
||||
});
|
||||
},
|
||||
fail(ex) {
|
||||
console.log("ex=", ex);
|
||||
}
|
||||
});
|
||||
}, 100);
|
||||
|
||||
|
||||
},
|
||||
|
||||
updateDeviceStatus(data) {
|
||||
@ -760,7 +777,6 @@
|
||||
}
|
||||
},
|
||||
onLoad() {
|
||||
|
||||
// console.error("首页加载");
|
||||
this.getTab()
|
||||
this.downCallback();
|
||||
@ -773,11 +789,11 @@
|
||||
});
|
||||
// 监听设备状态更新事件
|
||||
uni.$on('deviceStatusUpdate', (data) => {
|
||||
console.log('列表收到消息了么');
|
||||
// console.log('列表收到消息了么');
|
||||
this.downCallback();
|
||||
});
|
||||
ble = bleTool.getBleTool();
|
||||
console.log("this=",this);
|
||||
console.log("this=", this);
|
||||
recei = BleReceive.getBleReceive(this);
|
||||
//蓝牙连接成功的回调
|
||||
ble.addRecoveryCallback((res) => {
|
||||
@ -787,7 +803,7 @@
|
||||
|
||||
//蓝牙断开连接的回调
|
||||
ble.addDisposeCallback((res) => {
|
||||
// console.log("蓝牙断开连接的回调");
|
||||
console.log("蓝牙断开连接的回调");
|
||||
this.bleBreak(res);
|
||||
}, pagePath);
|
||||
|
||||
@ -805,9 +821,9 @@
|
||||
|
||||
//接收到消息的回调
|
||||
ble.addReceiveCallback((receive, device, path, recArr) => {
|
||||
console.error("首页收到消息了");
|
||||
let json=recei.ReceiveData(receive, device, path, recArr);
|
||||
console.error("消息内容",json);
|
||||
// console.error("首页收到消息了");
|
||||
let json = recei.ReceiveData(receive, device, path, recArr);
|
||||
// console.error("消息内容",json);
|
||||
this.updateBleStatu();
|
||||
}, pagePath);
|
||||
|
||||
@ -890,12 +906,13 @@
|
||||
height: 60rpx;
|
||||
font-weight: bold;
|
||||
}
|
||||
.tab-item.active::before{
|
||||
|
||||
.tab-item.active::before {
|
||||
content: "";
|
||||
background-color: #bbe600;
|
||||
background-color: #bbe600;
|
||||
position: absolute;
|
||||
top: 90%;
|
||||
left:35%;
|
||||
left: 35%;
|
||||
width: 30%;
|
||||
height: 6rpx;
|
||||
border-radius: 6rpx;
|
||||
@ -949,6 +966,9 @@
|
||||
box-sizing: border-box;
|
||||
position: relative;
|
||||
}
|
||||
.device-card.active{
|
||||
background-color: #2a2a2a !important;
|
||||
}
|
||||
|
||||
|
||||
.device-header {
|
||||
@ -1148,11 +1168,11 @@
|
||||
border-radius: 40rpx;
|
||||
padding: 30rpx;
|
||||
text-align: center;
|
||||
border: 1px solid #E034344d;
|
||||
border: 1px solid #E0343480;
|
||||
}
|
||||
|
||||
|
||||
.cancelBtn{
|
||||
.cancelBtn {
|
||||
|
||||
|
||||
text-align: center;
|
||||
@ -1160,15 +1180,16 @@
|
||||
background-color: #00000000;
|
||||
}
|
||||
|
||||
.agreement-popupC .cancelBtn{
|
||||
border:1rpx solid #E034344d;
|
||||
color:#E03434;
|
||||
.agreement-popupC .cancelBtn {
|
||||
border: 1rpx solid #E03434;
|
||||
color: #E03434;
|
||||
}
|
||||
|
||||
.agreement-popupD .cancelBtn{
|
||||
.agreement-popupD .cancelBtn {
|
||||
border: 1rpx solid rgba(255, 255, 255, 0.6);
|
||||
color:rgba(255, 255, 255, 0.6);
|
||||
color: rgba(255, 255, 255, 0.6);
|
||||
}
|
||||
|
||||
.agreement-popupD {
|
||||
width: 75%;
|
||||
background-color: rgb(42, 42, 42);
|
||||
|
||||
280
pages/common/map/index.nvue
Normal file
280
pages/common/map/index.nvue
Normal file
@ -0,0 +1,280 @@
|
||||
<template>
|
||||
<view class="container">
|
||||
<map class="map" :latitude="latitude" :longitude="longitude" :markers="covers" @markertap="onMarkerTap"
|
||||
:scale="16"></map>
|
||||
|
||||
<!-- 加载提示 -->
|
||||
<view v-if="loading" class="loading-mask">
|
||||
<view class="loading-content">加载中...</view>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import Common from "@/utils/Common.js";
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
latitude: 39.909,
|
||||
longitude: 116.39742,
|
||||
covers: [],
|
||||
loading: true,
|
||||
markerData: [],
|
||||
clickMarker: {
|
||||
"deviceId": "",
|
||||
"deviceName": "",
|
||||
"deviceImei": "",
|
||||
"deviceMac": "",
|
||||
"communicationMode": null,
|
||||
"devicePic": "",
|
||||
"typeName": "",
|
||||
"bluetoothName": "",
|
||||
"deviceStatus": 1,
|
||||
"personnelInfo": null,
|
||||
"sendMsg": null,
|
||||
"mainLightMode": null,
|
||||
"laserLightMode": "",
|
||||
"batteryPercentage": "",
|
||||
"chargeState": "0",
|
||||
"batteryRemainingTime": "0",
|
||||
"onlineStatus": 0,
|
||||
"longitude": "",
|
||||
"latitude": "",
|
||||
"address": "",
|
||||
"alarmStatus": null,
|
||||
"lightBrightness": null
|
||||
},
|
||||
Status: {
|
||||
BottomMenu: {
|
||||
show: false,
|
||||
showHeader: true,
|
||||
menuItems: [{
|
||||
text: '高德地图',
|
||||
value: 'amap',
|
||||
icon: ''
|
||||
},
|
||||
{
|
||||
text: '百度地图',
|
||||
value: 'baidumap',
|
||||
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: false,
|
||||
btnBgColor: "#bbe600",
|
||||
btnText: "确定",
|
||||
btnTextColor: "#232323de",
|
||||
showMask: true,
|
||||
maskBgColor: '#00000066',
|
||||
showClose: false
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
},
|
||||
onLoad() {
|
||||
const eventChannel = this.getOpenerEventChannel();
|
||||
eventChannel.on('Map', (receivedData) => {
|
||||
console.log("地图页收到数据",receivedData);
|
||||
this.loading = true;
|
||||
this.covers = [];
|
||||
const dataContent = receivedData.data;
|
||||
|
||||
if (Array.isArray(dataContent)) {
|
||||
const validDevices = dataContent.filter(device =>
|
||||
device.latitude && device.longitude &&
|
||||
device.latitude !== '' && device.longitude !== ''
|
||||
);
|
||||
this.markerData = validDevices;
|
||||
if (validDevices.length > 0) {
|
||||
this.processMultipleMarkers(validDevices);
|
||||
} else {
|
||||
console.log('无有效经纬度');
|
||||
this.loading = false;
|
||||
}
|
||||
} else if (typeof dataContent === 'object' && dataContent !== null) {
|
||||
if (this.validateMarker(dataContent)) {
|
||||
this.markerData = [dataContent];
|
||||
this.processSingleMarker(dataContent);
|
||||
} else {
|
||||
console.log('经纬度无效');
|
||||
this.loading = false;
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
methods: {
|
||||
showAction() {
|
||||
|
||||
let gd=plus.runtime.isApplicationExist({
|
||||
pname: 'com.autonavi.minimap', // 安卓高德包名
|
||||
action: 'iosamap://' // iOS高德 Scheme
|
||||
});
|
||||
|
||||
let bd= plus.runtime.isApplicationExist({
|
||||
pname: 'com.baidu.BaiduMap', // 安卓百度包名
|
||||
action: 'baidumap://' // iOS百度 Scheme
|
||||
});
|
||||
let list=[];
|
||||
let gdStr='高德地图';
|
||||
let bdStr='百度地图';
|
||||
console.log("gd=",gd);
|
||||
console.log("bd=",bd);
|
||||
list=[gdStr,bdStr];
|
||||
uni.showActionSheet({
|
||||
title: '选择地图',
|
||||
|
||||
itemList:list ,
|
||||
success: (res)=> {
|
||||
let mapType = 'amap';
|
||||
if (res.tapIndex == 1) {
|
||||
mapType = 'baiduMap';
|
||||
if(!bd){
|
||||
uni.showToast({
|
||||
icon:"error",
|
||||
title:'未安装'+bdStr
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if(res.tapIndex==0 && !gd) {
|
||||
uni.showToast({
|
||||
icon:"error",
|
||||
title:'未安装'+gdStr
|
||||
})
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
let marker = this.clickMarker;
|
||||
Common.MapNavi(marker.longitude, marker.latitude, marker.address, mapType).catch(
|
||||
ex => {
|
||||
uni.showToast({
|
||||
icon: "error",
|
||||
title: '无法打开地图'
|
||||
});
|
||||
});
|
||||
|
||||
},
|
||||
})
|
||||
|
||||
},
|
||||
|
||||
navigatMap(e) {
|
||||
console.log("点位被点击,", e);
|
||||
},
|
||||
processSingleMarker(marker) {
|
||||
const lat = parseFloat(marker.latitude);
|
||||
const lng = parseFloat(marker.longitude);
|
||||
this.latitude = lat;
|
||||
this.longitude = lng;
|
||||
|
||||
this.covers = [{
|
||||
id: marker.id+"",
|
||||
latitude: lat,
|
||||
longitude: lng,
|
||||
iconPath: '/static/images/common/mapLocation.png',
|
||||
width: 30,
|
||||
height: 50,
|
||||
anchor: {
|
||||
x: 0.5,
|
||||
y: 0.5
|
||||
},
|
||||
callout: {
|
||||
content: marker.deviceName
|
||||
}
|
||||
}];
|
||||
|
||||
console.log("covers=",this.covers);
|
||||
this.loading = false;
|
||||
},
|
||||
|
||||
processMultipleMarkers(markers) {
|
||||
const first = markers[0];
|
||||
this.latitude = parseFloat(first.latitude);
|
||||
this.longitude = parseFloat(first.longitude);
|
||||
|
||||
this.covers = markers.map((marker, index) => ({
|
||||
id: marker.id+"",
|
||||
latitude: parseFloat(marker.latitude),
|
||||
longitude: parseFloat(marker.longitude),
|
||||
iconPath: '/static/images/common/mapLocation.png',
|
||||
width: 30,
|
||||
height: 50,
|
||||
anchor: {
|
||||
x: 0.5,
|
||||
y: 0.5
|
||||
},
|
||||
callout: {
|
||||
content: marker.deviceName
|
||||
}
|
||||
}));
|
||||
this.loading = false;
|
||||
},
|
||||
|
||||
validateMarker(marker) {
|
||||
const lat = parseFloat(marker.latitude);
|
||||
const lng = parseFloat(marker.longitude);
|
||||
return !isNaN(lat) && !isNaN(lng);
|
||||
},
|
||||
|
||||
onMarkerTap(e) {
|
||||
console.log('点击了标记', e);
|
||||
let marker = this.markerData.find(item => {
|
||||
return item.id == e.detail.markerId
|
||||
});
|
||||
console.log('点击了标记', marker);
|
||||
if (marker) {
|
||||
this.clickMarker = marker;
|
||||
this.showAction();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
/* nvue 全屏必须这样写 */
|
||||
.container {
|
||||
flex: 1;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.map {
|
||||
width: 750rpx;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.loading-mask {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background-color: rgba(0, 0, 0, 0.5);
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
z-index: 999;
|
||||
}
|
||||
|
||||
.loading-content {
|
||||
color: #fff;
|
||||
font-size: 28rpx;
|
||||
padding: 20rpx 30rpx;
|
||||
background-color: rgba(0, 0, 0, 0.7);
|
||||
border-radius: 8rpx;
|
||||
}
|
||||
</style>
|
||||
@ -79,16 +79,17 @@ export default {
|
||||
this.latitude = lat;
|
||||
this.longitude = lng;
|
||||
// 创建标记点
|
||||
console.log("devicePic=",marker)
|
||||
this.covers = [{
|
||||
id: marker.deviceImei, // 适配deviceId字段
|
||||
latitude: lat,
|
||||
longitude: lng,
|
||||
iconPath: marker.devicePic || '/static/images/common/mapLocation.png',
|
||||
width: 40,
|
||||
height: 40,
|
||||
iconPath: '/static/images/common/mapLocation.png',
|
||||
width: 60,
|
||||
height: 60,
|
||||
anchor: {x: 0.5, y: 0.5}, // 锚点在中心
|
||||
callout: {
|
||||
content: `ID: ${marker.deviceImei}`
|
||||
content: `${marker.deviceName}`
|
||||
}
|
||||
}];
|
||||
|
||||
@ -102,17 +103,18 @@ export default {
|
||||
this.latitude = parseFloat(firstMarker.latitude);
|
||||
this.longitude = parseFloat(firstMarker.longitude);
|
||||
|
||||
console.log("devicePic=",marker.devicePic)
|
||||
// 转换所有有效标记点
|
||||
this.covers = markers.map((marker, index) => ({
|
||||
id: marker.deviceId || marker.id || marker.deviceImei || index + 1,
|
||||
latitude: parseFloat(marker.latitude),
|
||||
longitude: parseFloat(marker.longitude),
|
||||
iconPath: marker.devicePic || '/static/images/common/device.png',
|
||||
width: 40,
|
||||
height: 40,
|
||||
iconPath: '/static/images/common/mapLocation.png',
|
||||
width: 60,
|
||||
height: 60,
|
||||
anchor: {x: 0.5, y: 0.5},
|
||||
callout: {
|
||||
content: `ID: ${marker.deviceImei}`,
|
||||
content: `${marker.deviceName}`,
|
||||
}
|
||||
}));
|
||||
|
||||
|
||||
@ -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>
|
||||
22
pages/common/sosSet/remark.vue
Normal file
22
pages/common/sosSet/remark.vue
Normal file
@ -0,0 +1,22 @@
|
||||
<template>
|
||||
<view class="content contentBg">
|
||||
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
||||
</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">
|
||||
@ -151,7 +151,9 @@
|
||||
uni.reLaunch({
|
||||
url: '/pages/common/login/index'
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
|
||||
|
||||
},
|
||||
// 退出登录
|
||||
|
||||
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 |
@ -651,7 +651,7 @@ class BleHelper {
|
||||
BleReceive() {
|
||||
uni.onBLECharacteristicValueChange((receive) => {
|
||||
//订阅消息
|
||||
// console.log("收到订阅消息", receive);
|
||||
// console.log("收到订阅消息", receive);
|
||||
let f = this.data.LinkedList.find((v) => {
|
||||
return v.deviceId == receive.deviceId;
|
||||
})
|
||||
@ -768,7 +768,9 @@ class BleHelper {
|
||||
} catch (convertException) {
|
||||
if (str && (str.trim().startsWith('{') || str.trim().startsWith('['))) {
|
||||
console.error("JSON解析失败(可能是格式错误的数据)", convertException);
|
||||
|
||||
}
|
||||
console.error("错误的数据", str);
|
||||
}
|
||||
|
||||
if (isUpdate) {
|
||||
@ -789,7 +791,7 @@ class BleHelper {
|
||||
str: str,
|
||||
hexs: hexs
|
||||
};
|
||||
// console.log("监听到特征值:", recData);
|
||||
console.log("监听到特征值:", recData);
|
||||
if (this.cfg.receivDataCallback) {
|
||||
|
||||
if (this.cfg.receivDataCallback.length > 0) {
|
||||
@ -810,6 +812,7 @@ class BleHelper {
|
||||
console.error(
|
||||
"订阅消息出现异常",
|
||||
err);
|
||||
console.error("异常数据:", str);
|
||||
}
|
||||
|
||||
}
|
||||
@ -868,7 +871,7 @@ class BleHelper {
|
||||
if (!state.available) { //蓝牙状态不可用了,将所有设备标记为断开连接
|
||||
// 系统关蓝牙后原生 BLE 适配器已销毁;若仍认为 isOpenBlue=true,OpenBlue 会跳过重开,
|
||||
// 再开蓝牙后无法 createBLEConnection / 一直报 10001 适配器不可用
|
||||
this.data.isOpenBlue = false;
|
||||
// this.data.isOpenBlue = false;
|
||||
console.log("蓝牙模块不可用了,将所有设备标记为断开连接");
|
||||
this.data.connectingDevices = {}; //清空连接锁
|
||||
this.data.LinkedList.filter((v) => {
|
||||
@ -976,7 +979,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);
|
||||
}
|
||||
@ -998,15 +1004,15 @@ class BleHelper {
|
||||
// console.log("发现新设备",item.name+" "+item.RSSI);
|
||||
// }
|
||||
|
||||
let f = serviceDic.find(v => {
|
||||
return item.advertisServiceUUIDs
|
||||
.includes(v.serviceId);
|
||||
});
|
||||
if (f) {
|
||||
let f = serviceDic.find(v => {
|
||||
return item.advertisServiceUUIDs
|
||||
.includes(v.serviceId);
|
||||
});
|
||||
if (f) {
|
||||
|
||||
// console.log("发现目标设备:", item);
|
||||
arr.push(item);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if (arr.length === 0) {
|
||||
@ -1140,7 +1146,7 @@ class BleHelper {
|
||||
//停止搜索
|
||||
StopSearch() {
|
||||
if (this.data.platform == 'web' || !this.data.discovering) {
|
||||
console.error("web平台或当前没有搜索,直接返回",this.data.discovering);
|
||||
console.error("web平台或当前没有搜索,直接返回", this.data.discovering);
|
||||
return Promise.resolve();
|
||||
}
|
||||
let p1 = new Promise((resolve, reject) => {
|
||||
@ -1575,9 +1581,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 +1615,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 +1635,10 @@ class BleHelper {
|
||||
return;
|
||||
}
|
||||
|
||||
// console.log("正在连接" + deviceId);
|
||||
console.log("正在连接" + deviceId);
|
||||
uni.createBLEConnection({
|
||||
deviceId: deviceId,
|
||||
timeout: 20000,
|
||||
timeout: 10000,
|
||||
success: (info) => {
|
||||
//释放连接锁
|
||||
|
||||
@ -1728,7 +1738,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 +1782,7 @@ class BleHelper {
|
||||
}, 500);
|
||||
}).catch((ex) => {
|
||||
console.error("出现异常", ex);
|
||||
delete this.data.connectingDevices[deviceId];
|
||||
reject(ex);
|
||||
});
|
||||
});
|
||||
@ -1869,6 +1880,7 @@ class BleHelper {
|
||||
}
|
||||
//向蓝牙设备发送一个字符串的ASCII码
|
||||
sendString(deviceid, str, writeServiceId, wirteCharactId, ms, iosIsChuck, chunkSize) {
|
||||
debugger;
|
||||
if (str && typeof(str) == 'object') {
|
||||
str = JSON.stringify(str);
|
||||
}
|
||||
@ -1913,6 +1925,7 @@ class BleHelper {
|
||||
}
|
||||
//向蓝牙设备发送数据,如果没连接将自动连接后再发
|
||||
sendData(deviceid, buffer, writeServiceId, wirteCharactId, ms, iosIsChuck, chunkSize) {
|
||||
debugger;
|
||||
if (this.data.platform == 'web') {
|
||||
return Promise.resolve("h5平台默认成功");
|
||||
}
|
||||
@ -1995,7 +2008,9 @@ class BleHelper {
|
||||
},
|
||||
fail: (ex) => {
|
||||
ex = this.getError(ex);
|
||||
console.error("✗ 蓝牙指令发送失败 - deviceId:",device.deviceId, "错误:", ex);
|
||||
console.error(
|
||||
"✗ 蓝牙指令发送失败 - deviceId:",
|
||||
device.deviceId, "错误:", ex);
|
||||
|
||||
_err(ex);
|
||||
}
|
||||
@ -2057,7 +2072,7 @@ class BleHelper {
|
||||
);
|
||||
},
|
||||
20
|
||||
); // 20ms延迟,可根据需要调整
|
||||
); // 20ms延迟,可根据需要调整
|
||||
});
|
||||
}
|
||||
_resolve(result);
|
||||
@ -2078,7 +2093,7 @@ class BleHelper {
|
||||
);
|
||||
},
|
||||
20
|
||||
); // 20ms延迟,可根据需要调整
|
||||
); // 20ms延迟,可根据需要调整
|
||||
});
|
||||
}
|
||||
_resolve(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;
|
||||
}
|
||||
|
||||
189
utils/Common.js
189
utils/Common.js
@ -218,31 +218,31 @@ export default {
|
||||
value: "1",
|
||||
label: "灯光模式",
|
||||
checked: false,
|
||||
type: ['6170', '670','102','6155','650','7305','6075']
|
||||
type: ['6170', '670', '102', '6155', '650', '7305', '6075']
|
||||
},
|
||||
{
|
||||
value: "2",
|
||||
label: "激光模式",
|
||||
checked: false,
|
||||
type: ['6170','6075']
|
||||
type: ['6170', '6075']
|
||||
},
|
||||
{
|
||||
value: "3",
|
||||
label: "开机画面",
|
||||
checked: false,
|
||||
type: ['210', '6170', '670','6155','650','7305','6075']
|
||||
type: ['210', '6170', '670', '6155', '650', '7305', '6075']
|
||||
},
|
||||
{
|
||||
value: "4",
|
||||
label: "人员信息登记",
|
||||
checked: false,
|
||||
type: ['210', '6170', '670','6155','650','7305','6075']
|
||||
type: ['210', '6170', '670', '6155', '650', '7305', '6075']
|
||||
},
|
||||
{
|
||||
value: "5",
|
||||
label: "发送信息",
|
||||
checked: false,
|
||||
type: ['210', '6170', '670','6075']
|
||||
type: ['210', '6170', '670', '6075']
|
||||
},
|
||||
{
|
||||
value: "6",
|
||||
@ -253,12 +253,12 @@ export default {
|
||||
value: "41",
|
||||
label: "静电探测",
|
||||
checked: false,
|
||||
type: ['670','650']
|
||||
type: ['670', '650']
|
||||
}, {
|
||||
value: "42",
|
||||
label: "SOS",
|
||||
checked: false,
|
||||
type: ['670','4877','6075']
|
||||
type: ['670', '4877', '6075']
|
||||
},
|
||||
{
|
||||
value: "43",
|
||||
@ -266,25 +266,25 @@ export default {
|
||||
checked: false,
|
||||
type: ['210']
|
||||
},
|
||||
{
|
||||
{
|
||||
value: "44",
|
||||
label: "报警声音",
|
||||
checked: false,
|
||||
type: ['210']
|
||||
},
|
||||
{
|
||||
{
|
||||
value: "45",
|
||||
label: "自动报警",
|
||||
checked: false,
|
||||
type: ['210']
|
||||
},
|
||||
{
|
||||
{
|
||||
value: "46",
|
||||
label: "手动报警",
|
||||
checked: false,
|
||||
type: ['210','102','6170']
|
||||
type: ['210', '102', '6170','018A']
|
||||
},
|
||||
{
|
||||
{
|
||||
value: "47",
|
||||
label: "报警时长",
|
||||
checked: false,
|
||||
@ -307,21 +307,21 @@ export default {
|
||||
value: "50",
|
||||
label: "报警模式",
|
||||
checked: false,
|
||||
type: ['100','100J']
|
||||
type: ['100', '100J']
|
||||
},
|
||||
|
||||
{
|
||||
value: "51",
|
||||
label: "警示灯",
|
||||
checked: false,
|
||||
type: ['100','100J']
|
||||
type: ['100', '100J','018A']
|
||||
},
|
||||
|
||||
{
|
||||
value: "52",
|
||||
label: "语音管理",
|
||||
checked: false,
|
||||
type: ['100','100J']
|
||||
type: ['100', '100J']
|
||||
},
|
||||
|
||||
{
|
||||
@ -340,7 +340,7 @@ export default {
|
||||
value: "55",
|
||||
label: "修改信道",
|
||||
checked: false,
|
||||
type: ['4877','102']
|
||||
type: ['4877', '102']
|
||||
},
|
||||
{
|
||||
value: "56",
|
||||
@ -348,6 +348,12 @@ export default {
|
||||
checked: false,
|
||||
type: ['100J']
|
||||
},
|
||||
{
|
||||
value: "57",
|
||||
label: "紧急联系设置",
|
||||
checked: false,
|
||||
type: ['018A']
|
||||
}
|
||||
]
|
||||
|
||||
let arr = [];
|
||||
@ -403,7 +409,7 @@ export default {
|
||||
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
if(!tempFilePath){
|
||||
if (!tempFilePath) {
|
||||
console.log("无文件需要移动");
|
||||
resolve(tempFilePath);
|
||||
return;
|
||||
@ -452,17 +458,18 @@ export default {
|
||||
});
|
||||
},
|
||||
|
||||
getOSAndUpload(){
|
||||
let os=uni.getSystemInfoSync().platform;
|
||||
let url=''
|
||||
if(os==='ios'){
|
||||
url='https://apps.apple.com/cn/app/星汉物联/id6752555460'
|
||||
getOSAndUpload() {
|
||||
let os = uni.getSystemInfoSync().platform;
|
||||
let url = ''
|
||||
if (os === 'ios') {
|
||||
url = 'https://apps.apple.com/cn/app/星汉物联/id6752555460'
|
||||
} else if (os === 'android') {
|
||||
url = 'https://www.pgyer.com/xhwl';
|
||||
}
|
||||
|
||||
else if(os==='android'){
|
||||
url='https://www.pgyer.com/xhwl';
|
||||
}
|
||||
return {os:os,url:url};
|
||||
return {
|
||||
os: os,
|
||||
url: url
|
||||
};
|
||||
},
|
||||
|
||||
|
||||
@ -488,5 +495,133 @@ 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);
|
||||
});
|
||||
});
|
||||
|
||||
},
|
||||
MapNavi(lon, lat, name, mapType) {//打开地图路线规划页面
|
||||
return new Promise((resolve, reject) => {
|
||||
if (!lon || !lat) {
|
||||
reject("经纬度不能为空");
|
||||
return;
|
||||
}
|
||||
|
||||
let url = "";
|
||||
if (!mapType || mapType == 'amap') {
|
||||
let amapScheme = uni.getSystemInfoSync().platform === 'ios' ? 'iosamap://' : 'androidamap://';
|
||||
url = `${amapScheme}route/plan?sourceApplication=myapp&dlat=${lat}&dlon=${lon}&dname=${name}&dev=0&t=0`;
|
||||
} else {
|
||||
url =`baidumap://map/direction?destination=latlng:${lat},${lon}|name:${name}&coord_type=gcj02&src=myapp`
|
||||
}
|
||||
|
||||
plus.runtime.openURL(url, (ex) => {
|
||||
console.error("ex=",ex);
|
||||
reject("无法打开地图软件"+url);
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
743
utils/SendBatchData.js
Normal file
743
utils/SendBatchData.js
Normal file
@ -0,0 +1,743 @@
|
||||
import request, {
|
||||
baseURL
|
||||
} from '@/utils/request.js';
|
||||
import {
|
||||
showLoading,
|
||||
hideLoading,
|
||||
updateLoading
|
||||
} from '@/utils/loading.js';
|
||||
|
||||
import {
|
||||
MsgSuccess,
|
||||
MsgError,
|
||||
MsgClose,
|
||||
MsgWarning,
|
||||
showPop
|
||||
} from '@/utils/MsgPops.js';
|
||||
import Common from '@/utils/Common.js';
|
||||
|
||||
|
||||
class SendBatchData {
|
||||
|
||||
constructor(_these, _f, _ble) {
|
||||
this.videoHexArray = [];
|
||||
this.rgb565Data = [];
|
||||
this.these = _these;
|
||||
this.f = _f;
|
||||
this.ble = _ble;
|
||||
}
|
||||
|
||||
//发送开机视频
|
||||
SendVideo(bufferSize) {
|
||||
|
||||
let these = this.these;
|
||||
let f = this.f;
|
||||
let ble = this.ble;
|
||||
if (!bufferSize) {
|
||||
bufferSize = 504;
|
||||
}
|
||||
let timeDelayCloseLoading = () => {
|
||||
setTimeout(() => {
|
||||
hideLoading(these);
|
||||
}, 1500);
|
||||
}
|
||||
|
||||
|
||||
|
||||
let sendVideoPackets = (ReSendNo) => {
|
||||
console.log("开始发送分片数据");
|
||||
return new Promise((resolve, reject) => {
|
||||
if (f) {
|
||||
// 总数据包数
|
||||
var totalPackets = 1536; //36;
|
||||
|
||||
let currentPacket = 1;
|
||||
console.log("发送数据准备中,总共" + totalPackets);
|
||||
if (ReSendNo) {
|
||||
totalPackets = ReSendNo;
|
||||
currentPacket = ReSendNo;
|
||||
}
|
||||
|
||||
// 发送单个数据包
|
||||
const sendNextVideoPacket = () => {
|
||||
// console.log("准备发送一段数据");
|
||||
if (currentPacket > totalPackets) {
|
||||
if (!ReSendNo) {
|
||||
setTimeout(() => {
|
||||
|
||||
ble.sendString(f.deviceId, "transmit complete", f
|
||||
.writeServiceId, f.wirteCharactId, 20)
|
||||
.then(
|
||||
() => {
|
||||
console.log("全部发送完毕")
|
||||
}).catch((ex) => {
|
||||
console.log("出现异常", ex);
|
||||
});
|
||||
}, 500);
|
||||
|
||||
}
|
||||
|
||||
hideLoading(these);
|
||||
showPop({
|
||||
showPop: true,
|
||||
message: "上传成功",
|
||||
iconUrl: "/static/images/common/success.png"
|
||||
}, these);
|
||||
these.videoHexArray = null;
|
||||
resolve();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// 计算当前包的数据
|
||||
let packetSize = 500;
|
||||
|
||||
|
||||
// 创建数据包
|
||||
const startIndex = (currentPacket - 1) * packetSize;
|
||||
const endIndex = Math.min(startIndex + packetSize, these.videoHexArray
|
||||
.length);
|
||||
if (startIndex > endIndex) {
|
||||
resolve();
|
||||
return;
|
||||
}
|
||||
////console.log("111111");
|
||||
const packetData = these.videoHexArray.slice(startIndex, endIndex);
|
||||
|
||||
// 构建数据包
|
||||
////console.log("packetData.length"+packetData.length);
|
||||
|
||||
const buffer = new ArrayBuffer(bufferSize);
|
||||
const dataView = new DataView(buffer);
|
||||
|
||||
|
||||
|
||||
// 填充头部
|
||||
dataView.setUint8(0, 0x55); // 帧头
|
||||
dataView.setUint8(1, 0x04); // 帧类型:开机画面
|
||||
dataView.setUint16(2, currentPacket, false); // 包序号
|
||||
let beginIndex = 4;
|
||||
if (bufferSize == 506) {
|
||||
beginIndex = 6;
|
||||
dataView.setUint16(4, packetSize, false); //数据长度
|
||||
}
|
||||
|
||||
|
||||
|
||||
for (let i = 0; i < packetData.length; i++) {
|
||||
dataView.setUint8(beginIndex + i, packetData[i]);
|
||||
}
|
||||
|
||||
let inteval = 80;
|
||||
|
||||
ble.sendData(f.deviceId, buffer, f.writeServiceId, f
|
||||
.wirteCharactId, 10).then(() => {
|
||||
|
||||
updateLoading(these, {
|
||||
text: "正在发送:" + currentPacket + "/" +
|
||||
totalPackets
|
||||
});
|
||||
|
||||
currentPacket++;
|
||||
|
||||
// console.log("发送一段成功,发送下一段");
|
||||
setTimeout(sendNextVideoPacket, inteval);
|
||||
}).catch(err => {
|
||||
console.log("发送失败了", err);
|
||||
if (err.code == '10007') { //遇到这个错误自动重新发送
|
||||
console.log(err.errMsg + ",发送失败了,正在补偿:" +
|
||||
currentPacket);
|
||||
setTimeout(sendNextVideoPacket, 800);
|
||||
} else {
|
||||
|
||||
hideLoading(these);
|
||||
|
||||
showPop({
|
||||
showPop: true,
|
||||
message: err.msg + ",发送失败了",
|
||||
borderColor: "#e034344d",
|
||||
buttonBgColor: "#E03434",
|
||||
buttonText: "确定",
|
||||
iconUrl: "/static/images/common/uploadErr.png"
|
||||
}, these);
|
||||
reject(err);
|
||||
these.videoHexArray = null;
|
||||
return;
|
||||
}
|
||||
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
sendNextVideoPacket();
|
||||
|
||||
|
||||
} else {
|
||||
console.log("Fail.......")
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var sendVideo = (videoPath) => {
|
||||
let uploadVideo = () => {
|
||||
|
||||
these.videoHexArray = [];
|
||||
console.log("开始处理,正在上传");
|
||||
|
||||
showLoading(these, {
|
||||
text: "上传中"
|
||||
});
|
||||
let p1 = new Promise((resolve, reject) => {
|
||||
|
||||
ble.sendString(f.deviceId, "video transmit start", f
|
||||
.writeServiceId, f.wirteCharactId).then(res => {
|
||||
|
||||
setTimeout(() => {
|
||||
console.log("握手成功了");
|
||||
resolve(true);
|
||||
}, 2200)
|
||||
}).catch(ex => {
|
||||
reject(ex);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
let p2 = new Promise((succ, err) => {
|
||||
|
||||
const token = uni.getStorageSync('token');
|
||||
const clientid = uni.getStorageSync('clientID');
|
||||
if (!token) {
|
||||
err({
|
||||
code: 401,
|
||||
msg: "请先登陆后再试"
|
||||
});
|
||||
hideLoading(these);
|
||||
return;
|
||||
}
|
||||
console.log("baseURL=", baseURL);
|
||||
console.log("token", token);
|
||||
console.log("clientID", clientid);
|
||||
uni.uploadFile({
|
||||
// url: 'http://114.55.111.217/video/upload',
|
||||
url: baseURL + "/app/video/upload",
|
||||
filePath: videoPath,
|
||||
name: 'file',
|
||||
header: {
|
||||
"Method": "POST",
|
||||
"Content-Type": "multipart/form-data",
|
||||
"Authorization": 'Bearer ' + token,
|
||||
"clientid": clientid
|
||||
},
|
||||
timeout: 600000,
|
||||
fail: (ex) => {
|
||||
console.log("上传视频失败" + JSON.stringify(ex));
|
||||
|
||||
err(ex);
|
||||
},
|
||||
success: (res) => {
|
||||
|
||||
console.log("上传完成,向蓝牙设备发送");
|
||||
succ(res);
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
Promise.all([p1, p2]).then((arr) => {
|
||||
|
||||
if (arr[0].status == 'rejected') {
|
||||
MsgError("设备准备未就绪,请重试", '', these);
|
||||
return;
|
||||
}
|
||||
if (arr[1].status == 'rejected') {
|
||||
MsgError("读取视频失败", '', these);
|
||||
return;
|
||||
}
|
||||
let res = arr[1];
|
||||
// console.log("11111111111111111111111",res);
|
||||
res = JSON.parse(res.data);
|
||||
// console.log("22222222222222222222");
|
||||
if (res.data) {
|
||||
these.videoHexArray = res.data;
|
||||
updateLoading(these, {
|
||||
text: "正在发送:0/1536"
|
||||
});
|
||||
|
||||
|
||||
|
||||
shotVideoClick(res.data);
|
||||
|
||||
|
||||
} else {
|
||||
console.log("服务器未返回正确的数据");
|
||||
|
||||
|
||||
showPop({
|
||||
message: "与服务器连接出现异常,请检查网络设置",
|
||||
iconUrl: "/static/images/common/uploadErr.png",
|
||||
borderColor: "#e034344d",
|
||||
buttonBgColor: "#E03434",
|
||||
}, these);
|
||||
}
|
||||
|
||||
}).catch((ex) => {
|
||||
console.log("出现异常,", ex)
|
||||
hideLoading(these);
|
||||
showPop({
|
||||
message: "出现异常," + ex.msg,
|
||||
iconUrl: "/static/images/common/uploadErr.png",
|
||||
borderColor: "#e034344d",
|
||||
buttonBgColor: "#E03434",
|
||||
}, these);
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
let shotVideoClick = () => {
|
||||
console.log("正在开始发送");
|
||||
sendVideoPackets().then(() => {
|
||||
console.log("发送完成");
|
||||
|
||||
}).catch((ex1) => {
|
||||
//console.log("出现了异常", ex1)
|
||||
}).finally(() => {
|
||||
hideLoading(these);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
uploadVideo();
|
||||
|
||||
}
|
||||
|
||||
uni.chooseVideo({
|
||||
sourceType: ['album'],
|
||||
compressed: false, // 关闭视频压缩,确保上传原始文件
|
||||
success: function(res) {
|
||||
console.log("res=", res);
|
||||
let path = res.tempFilePath;
|
||||
// iOS可能返回浮点数,需要转换为整数进行比较
|
||||
let width = Math.round(res.width);
|
||||
let height = Math.round(res.height);
|
||||
let duration = res.duration;
|
||||
|
||||
// 获取平台信息
|
||||
const systemInfo = uni.getSystemInfoSync();
|
||||
const platform = systemInfo.platform;
|
||||
const isIOS = platform === 'ios';
|
||||
|
||||
console.log("平台:", platform, "uni.chooseVideo返回 - 宽度:", width, "高度:", height,
|
||||
"时长:", duration);
|
||||
|
||||
// iOS特殊处理:如果返回的是80*40,很可能是160*80的一半(iOS的bug)
|
||||
if (isIOS && width === 80 && height === 40) {
|
||||
console.log("检测到iOS特殊情况:返回80*40,实际应该是160*80,进行修正");
|
||||
width = 160;
|
||||
height = 80;
|
||||
}
|
||||
|
||||
// 检查分辨率是否符合要求
|
||||
let checkResolution = (w, h) => {
|
||||
// 使用容差比较,允许1像素的误差
|
||||
return Math.abs(w - 160) <= 1 && Math.abs(h - 80) <= 1;
|
||||
};
|
||||
|
||||
let err = [];
|
||||
if (duration < 2) {
|
||||
err.push("视频时长至少2秒");
|
||||
}
|
||||
|
||||
if (!checkResolution(width, height)) {
|
||||
err.push("视频宽高必须是160*80,当前分辨率:" + width + "*" + height);
|
||||
}
|
||||
|
||||
if (err.length > 0) {
|
||||
err = err.join(";");
|
||||
showPop({
|
||||
message: err,
|
||||
iconUrl: "/static/images/common/uploadErr.png",
|
||||
borderColor: "#e034344d",
|
||||
buttonBgColor: "#E03434",
|
||||
}, these);
|
||||
return;
|
||||
}
|
||||
|
||||
showLoading(these, {
|
||||
text: '正在上传'
|
||||
});
|
||||
setTimeout(() => {
|
||||
sendVideo(path);
|
||||
}, 0);
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
//发送图片,
|
||||
SendImg() {
|
||||
let these = this.these;
|
||||
let f = this.f;
|
||||
let ble = this.ble;
|
||||
|
||||
var sendImagePackets = function(ReSendNo) {
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
|
||||
// 总数据包数
|
||||
let totalPackets = 52;
|
||||
let currentPacket = 1;
|
||||
|
||||
if (ReSendNo) {
|
||||
totalPackets = ReSendNo;
|
||||
currentPacket = ReSendNo;
|
||||
}
|
||||
|
||||
if (f) {
|
||||
// 发送单个数据包
|
||||
const sendNextPacket = () => {
|
||||
if (currentPacket > totalPackets) {
|
||||
hideLoading(these);
|
||||
if (these.closeAction) {
|
||||
these.closeAction();
|
||||
}
|
||||
|
||||
|
||||
showPop({
|
||||
showPop: true,
|
||||
message: "上传成功",
|
||||
iconUrl: "/static/images/common/success.png",
|
||||
}, these);
|
||||
|
||||
setTimeout(() => {
|
||||
ble.sendString(f.deviceId, "transmit complete", f
|
||||
.writeServiceId, f
|
||||
.wirteCharactId);
|
||||
}, 1000);
|
||||
|
||||
these.rgb565Data = null;
|
||||
resolve();
|
||||
return;
|
||||
}
|
||||
|
||||
// 计算当前包的数据
|
||||
let packetSize = 250;
|
||||
// if (currentPacket <= 51) {
|
||||
// packetSize = 250; // 前51个包每个500字节
|
||||
// } else {
|
||||
// packetSize = 50; // 最后一个包100字节
|
||||
// }
|
||||
|
||||
// 创建数据包
|
||||
const startIndex = (currentPacket - 1) * packetSize;
|
||||
const endIndex = Math.min(startIndex + packetSize, these.rgb565Data
|
||||
.length);
|
||||
if (startIndex > endIndex) {
|
||||
return;
|
||||
}
|
||||
const packetData = these.rgb565Data.slice(startIndex,
|
||||
endIndex);
|
||||
// 构建数据包
|
||||
const bufferSize = 505; // 5 + packetData.length * 2; // 头部5字节 + 数据部分
|
||||
const buffer = new ArrayBuffer(bufferSize);
|
||||
const dataView = new DataView(buffer);
|
||||
|
||||
// 填充头部
|
||||
dataView.setUint8(0, 0x55); // 帧头
|
||||
dataView.setUint8(1, 0x02); // 帧类型:开机画面
|
||||
dataView.setUint8(2, currentPacket); // 包序号
|
||||
|
||||
|
||||
dataView.setUint16(3, packetData.length * 2, false); // 包t长度
|
||||
|
||||
// 填充数据(每个RGB565值占2字节)
|
||||
for (let i = 0; i < packetData.length; i++) {
|
||||
dataView.setUint16(5 + i * 2, packetData[i], false); // 大端字节序
|
||||
}
|
||||
|
||||
//发送数据包
|
||||
ble.sendData(f.deviceId, buffer, f.writeServiceId, f.wirteCharactId,
|
||||
10)
|
||||
.then(() => {
|
||||
|
||||
|
||||
updateLoading(these, {
|
||||
text: "正在发送:" + currentPacket + "/" +
|
||||
totalPackets
|
||||
})
|
||||
currentPacket++;
|
||||
|
||||
setTimeout(sendNextPacket, these.inteval ? these.inteval : 80);
|
||||
}).catch(err => {
|
||||
console.log("发送数据包失败了" + JSON.stringify(err));
|
||||
if (err.code == '10007') {
|
||||
setTimeout(sendNextPacket, 800);
|
||||
return;
|
||||
}
|
||||
if (these.closeAction) {
|
||||
these.closeAction();
|
||||
}
|
||||
showPop({
|
||||
message: err.msg,
|
||||
iconUrl: "/static/images/common/uploadErr.png",
|
||||
borderColor: "#e034344d",
|
||||
buttonBgColor: "#E03434",
|
||||
}, these);
|
||||
hideLoading(these);
|
||||
these.rgb565Data = null;
|
||||
reject(err);
|
||||
});
|
||||
}
|
||||
|
||||
if (ReSendNo) {
|
||||
sendNextPacket(ReSendNo);
|
||||
return;
|
||||
}
|
||||
// 开始牵手
|
||||
ble.sendString(f.deviceId, "picture transmit start", f.writeServiceId,
|
||||
f.wirteCharactId).then(() => {
|
||||
setTimeout(sendNextPacket, 120);
|
||||
|
||||
}).catch((err) => {
|
||||
console.log("握手没有成功");
|
||||
showPop({
|
||||
message: err.msg,
|
||||
iconUrl: "/static/images/common/uploadErr.png",
|
||||
borderColor: "#e034344d",
|
||||
buttonBgColor: "#E03434",
|
||||
}, these);
|
||||
hideLoading(these);
|
||||
reject(err);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
uni.chooseImage({
|
||||
count: 1,
|
||||
sizeType: ['original', 'compressed'],
|
||||
sourceType: ['album', 'camera'],
|
||||
success: function(res) {
|
||||
uni.navigateTo({
|
||||
url: "/pages/common/ImgCrop/ImgCrop",
|
||||
events: {
|
||||
ImgCutOver: function(data) {
|
||||
|
||||
showLoading(these, {
|
||||
text: "正在发送0/52"
|
||||
});
|
||||
|
||||
|
||||
these.rgb565Data = Common.convertToRGB565(data.piexls);
|
||||
|
||||
setTimeout(function() {
|
||||
sendImagePackets().catch(() => {
|
||||
|
||||
});
|
||||
}, 0)
|
||||
|
||||
}
|
||||
},
|
||||
success(ev) {
|
||||
ev.eventChannel.emit('checkImg', {
|
||||
data: res.tempFiles[0].path
|
||||
})
|
||||
},
|
||||
fail(ex) {
|
||||
console.log("跳转页面失败" + JSON.stringify(ex));
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//发送人员信息
|
||||
SendUsr(totalRows) {
|
||||
|
||||
let these = this.these;
|
||||
let f = this.f;
|
||||
let ble = this.ble;
|
||||
if (!totalRows) {
|
||||
totalRows = 3;
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
these.formData.textLines = [these.formData.company, these.formData.usrname, these.formData.job];
|
||||
if (totalRows == 4) {
|
||||
these.formData.textLines.push(these.formData.usrid);
|
||||
}
|
||||
|
||||
|
||||
console.log("data=", these.formData.textLines);
|
||||
showLoading(these, {
|
||||
text: "发送中"
|
||||
});
|
||||
//握手
|
||||
let holdHand = (hexs, time) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
|
||||
|
||||
these.sendData(hexs, 'ble', "string").then(res => {
|
||||
setTimeout(() => {
|
||||
resolve(res)
|
||||
}, time);
|
||||
|
||||
}).catch(ex => {
|
||||
console.error("握手失败")
|
||||
reject(ex)
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
//画图
|
||||
let drawText = () => {
|
||||
return new Promise((resolve, reject) => {
|
||||
these.$refs.textToHex.drawAndGetPixels().then(allPixels => {
|
||||
if (!allPixels) {
|
||||
reject("文本初始化失败");
|
||||
return;
|
||||
}
|
||||
console.log("画图成功");
|
||||
resolve(allPixels);
|
||||
}).catch(compEx => {
|
||||
reject(compEx);
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
//发送3个分包的数据
|
||||
let task = (allPixels) => {
|
||||
try {
|
||||
let combinedData = [];
|
||||
for (let i = 0; i < totalRows; i++) {
|
||||
let linePixels = (allPixels[i] || []).flat(Infinity).map(item =>
|
||||
typeof item === 'string' ? toByteValue(item) : item
|
||||
);
|
||||
|
||||
for (var j = linePixels.length; j < 256; j++) {
|
||||
linePixels.push(0x00);
|
||||
}
|
||||
linePixels = [0xFA, 0x06, 0x03, i + 1].concat(linePixels);
|
||||
|
||||
linePixels.push(0xFF)
|
||||
|
||||
combinedData.push(linePixels);
|
||||
}
|
||||
|
||||
|
||||
let curr = 1;
|
||||
let len = combinedData.length;
|
||||
|
||||
|
||||
|
||||
//分包发送
|
||||
let sendPacket = () => {
|
||||
|
||||
if (combinedData.length === curr - 1) {
|
||||
setTimeout(() => {
|
||||
holdHand('transmit complete', 200).then(res => {
|
||||
MsgSuccess("人员信息发送成功", "确定", these);
|
||||
hideLoading(these);
|
||||
these.setBleFormData();
|
||||
});
|
||||
}, 300);
|
||||
|
||||
hideLoading(these);
|
||||
return;
|
||||
}
|
||||
|
||||
let array = combinedData[curr - 1];
|
||||
|
||||
|
||||
console.log("array=", array);
|
||||
ble.sendHexs(f.deviceId, array, null, null, 15).then(
|
||||
res => {
|
||||
curr++;
|
||||
console.log("发送成功", curr);
|
||||
updateLoading(these, {
|
||||
text: '发送中,' + (curr - 1) + '/' + combinedData.length
|
||||
})
|
||||
setTimeout(sendPacket, 250);
|
||||
}).catch(err => {
|
||||
|
||||
console.error("err:", err);
|
||||
|
||||
if (err.code == '10007') {
|
||||
setTimeout(sendPacket, 250);
|
||||
} else {
|
||||
console.error("err:", err);
|
||||
MsgError('发送失败:' + (err.msg || err.code), 'OK', these);
|
||||
hideLoading(these);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
setTimeout(sendPacket, 0);
|
||||
// 5. 发送成功处理
|
||||
|
||||
|
||||
} catch (ex) {
|
||||
console.error("ex=", ex)
|
||||
MsgError('发送失败' + (ex.msg || ex.code), '确定', these);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
setTimeout(() => {
|
||||
Promise.allSettled([holdHand('word transmit start', 2200), drawText()]).then(results => {
|
||||
if (results[0].status == 'rejected') {
|
||||
MsgError("与蓝牙设备握手失败,请重试", '', these);
|
||||
setTimeout(() => {
|
||||
hideLoading(these)
|
||||
}, 500);
|
||||
return;
|
||||
}
|
||||
if (results[1].status == 'rejected') {
|
||||
MsgError("读取文字点阵失败,请重试", '', these);
|
||||
return;
|
||||
}
|
||||
|
||||
task(results[1].value);
|
||||
})
|
||||
|
||||
}, 0);
|
||||
}
|
||||
//发送识别指令
|
||||
SendDisc() {
|
||||
let these = this.these;
|
||||
let f = this.f;
|
||||
let ble = this.ble;
|
||||
|
||||
var json = {
|
||||
ins_disc: 1
|
||||
}
|
||||
|
||||
ble.sendString(f.deviceId, json, f.writeServiceId, f.wirteCharactId, 30).then(res => {
|
||||
|
||||
}).catch(ex => {
|
||||
console.error("蓝牙发送失败", ex);
|
||||
}).finally(() => {
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export default SendBatchData;
|
||||
Reference in New Issue
Block a user