批量报警、批量发送消息,分供应商处理

This commit is contained in:
liub
2026-03-10 14:07:13 +08:00
parent 4cacdbe7f7
commit 2be522977c
15 changed files with 1273 additions and 1011 deletions

28
App.vue
View File

@ -30,13 +30,11 @@
//以上代码仅在开发时使用,否则会出现不可预知的问题。 //以上代码仅在开发时使用,否则会出现不可预知的问题。
// #ifdef APP|APP-PLUS // #ifdef APP|APP-PLUS
if (plus.runtime.isAgreePrivacy()) {
bleTool.getBleTool(); bleTool.getBleTool();
var appid = plus.runtime.appid;
console.log('应用的 appid 为:' + appid);
uni.getPushClientId({ uni.getPushClientId({
success(res) { success(res) {
console.log("推送信息:", res); console.log("推送信息:", res);
@ -46,12 +44,12 @@
console.error(err) console.error(err)
} }
}); });
if(!uni.setAppBadgeNumber){//兼容鸿蒙的写法 if (!uni.setAppBadgeNumber) { //兼容鸿蒙的写法
uni.setAppBadgeNumber=plus.runtime.setBadgeNumber; uni.setAppBadgeNumber = plus.runtime.setBadgeNumber;
} }
uni.onPushMessage((res) => { uni.onPushMessage((res) => {
console.log("收到推送消息:", res); //监听推送消息 console.log("收到推送消息:", res); //监听推送消息
if(res.type=='click'){ if (res.type == 'click') {
//将App角标设置为0清空app在消息中心的所有消息 //将App角标设置为0清空app在消息中心的所有消息
uni.setAppBadgeNumber(0); uni.setAppBadgeNumber(0);
plus.push.clear(); plus.push.clear();
@ -60,13 +58,13 @@
uni.createPushMessage({ uni.createPushMessage({
title: res.data.title, title: res.data.title,
content: res.data.content, content: res.data.content,
payload:res.data.payload payload: res.data.payload
}); });
}); });
}
// #endif // #endif
}, },
@ -74,18 +72,15 @@
console.log('App Show'); console.log('App Show');
//将检查更新换到onshow,因为苹果用户喜欢一直挂着 //将检查更新换到onshow,因为苹果用户喜欢一直挂着
uni.getSystemInfo({ // #ifdef APP|APP-PLUS
success: function(res) {
if (res.uniPlatform == 'app') {
let appid = plus.runtime.appid; let appid = plus.runtime.appid;
if (appid !== 'HBuilder') {
console.log("appid=", appid); console.log("appid=", appid);
if (appid !== 'HBuilder') {
upgrade.checkAndUpdateWgt(); upgrade.checkAndUpdateWgt();
} }
} // #endif
}
});
}, },
onHide: function() { onHide: function() {
console.log('App Hide'); console.log('App Hide');
@ -212,5 +207,4 @@
font-family: "PingFangBold"; font-family: "PingFangBold";
src: url("~@/static/fonts/PingFangBold.ttf") format("opentype"); src: url("~@/static/fonts/PingFangBold.ttf") format("opentype");
} }
</style> </style>

View File

@ -52,8 +52,7 @@
{ {
"path": "pages/common/send/index", "path": "pages/common/send/index",
"style": { "style": {
"navigationBarTitleText": "发送信息", "navigationBarTitleText": "发送信息"
"enablePullDownRefresh": true
} }
}, },
{ {
@ -102,10 +101,9 @@
} }
}, },
{ {
"path": "pages/6170/callPolice/index", "path": "pages/common/callPolice/index",
"style": { "style": {
"navigationBarTitleText": "报警", "navigationBarTitleText": "报警"
"enablePullDownRefresh": true
} }
}, },
@ -160,14 +158,7 @@
"navigationStyle": "custom" "navigationStyle": "custom"
} }
}, },
{
"path": "pages/6155/ImgCrop",
"style": {
"navigationBarTitleText": "图像裁剪",
"navigationStyle": "custom",
"fullscreen": true
}
},
{ {
"path": "pages/6075/BJQ6075", "path": "pages/6075/BJQ6075",
"style": { "style": {
@ -447,6 +438,14 @@
{ {
"navigationStyle": "custom" "navigationStyle": "custom"
} }
},
{
"path": "pages/common/ImgCrop/ImgCrop",
"style": {
"navigationBarTitleText": "图像裁剪",
"navigationStyle": "custom",
"fullscreen": true
}
} }
], ],

View File

@ -679,7 +679,7 @@
} }
let that = this; let that = this;
uni.navigateTo({ uni.navigateTo({
url: "/pages/6155/ImgCrop", url: "/pages/ImgCrop/ImgCrop",
events: { events: {
ImgCutOverPath: function(data) { ImgCutOverPath: function(data) {
that.selectedImage = data.picPath; that.selectedImage = data.picPath;

View File

@ -1145,7 +1145,7 @@
sourceType: ['album'], sourceType: ['album'],
success: function(res) { success: function(res) {
uni.navigateTo({ uni.navigateTo({
url: "/pages/6155/ImgCrop", url: "/pages/ImgCrop/ImgCrop",
events: { events: {
ImgCutOver: function(data) { ImgCutOver: function(data) {

View File

@ -909,7 +909,7 @@
sourceType: ['album'], sourceType: ['album'],
success: function(res) { success: function(res) {
uni.navigateTo({ uni.navigateTo({
url: "/pages/6155/ImgCrop", url: "/pages/ImgCrop/ImgCrop",
events: { events: {
ImgCutOver: function(data) { ImgCutOver: function(data) {

View File

@ -1,100 +0,0 @@
<template>
<view>
<canvas id="splashCanvas" canvas-id="splashCanvas" :style="{'width':width+'px','height':height+'px'}" style=" z-index: 9999;position: fixed; visibility: hidden;"></canvas>
<qf-image-cropper :src="src" :showAngle="false" :width="cropWidth" :height="cropHeight" fileType="jpg"
@crop="handleCrop" :areaScale="0.1" :minScale="0.1" :gpu="true">
</qf-image-cropper>
</view>
</template>
<script>
import QfImageCropper from '@/uni_modules/qf-image-cropper/components/qf-image-cropper/qf-image-cropper.vue';
export default {
components: {
QfImageCropper
},
data() {
return {
src: "",
Statu: false,
width:160,
height:80,
times:10
}
},
computed:{
cropWidth(){
return this.width*this.times;
}
,
cropHeight(){
return this.height*this.times;
}
},
onLoad: function(option) {
const eventChannel = this.getOpenerEventChannel();
var these = this;
eventChannel.on('checkImg', (rec)=> {
console.log("我收到你的消息了,消息内容是:" + JSON.stringify(rec));
this.src = rec.data;
this.width=rec.width?rec.width:160;
this.height=rec.height?rec.height:80;
this.times=rec.times?rec.times:10;
})
},
methods: {
handleCrop(e) {
var these = this;
const eventChannel = these.getOpenerEventChannel();
this.Statu = true;
console.log("裁剪完成");
console.log(e.tempFilePath);
eventChannel.emit('ImgCutOver_Path',e.tempFilePath);
const ctx = uni.createCanvasContext('splashCanvas', this);
ctx.drawImage(
e.tempFilePath,
0,0,these.width,these.height
);
setTimeout(() => {
ctx.draw(false, ()=>{
console.log("abcdefg")
uni.canvasGetImageData({
canvasId: 'splashCanvas',
x: 0,
y: 0,
width: these.width,
height: these.height,
success: (res) => {
// 处理像素数据并发送
console.log("res.data.length="+res.data.length);
eventChannel.emit('ImgCutOverPath', {
picPath: e.tempFilePath
});
eventChannel.emit('ImgCutOver',{piexls:res.data,picPath:e.tempFilePath});
uni.navigateBack();
},
fail: (err) => {
reject(`获取canvas数据失败: ${err.errMsg}`);
}
});
});
}, 500);
}
}
}
</script>
<style>
.canvas {
border: 1px solid #ccc;
}
</style>

View File

@ -926,7 +926,7 @@
sourceType: ['album'], sourceType: ['album'],
success: function(res) { success: function(res) {
uni.navigateTo({ uni.navigateTo({
url: "/pages/6155/ImgCrop", url: "/pages/ImgCrop/ImgCrop",
events: { events: {
ImgCutOver: function(data) { ImgCutOver: function(data) {

View File

@ -979,7 +979,7 @@
} }
let that = this; let that = this;
uni.navigateTo({ uni.navigateTo({
url: "/pages/6155/ImgCrop", url: "/pages/ImgCrop/ImgCrop",
events: { events: {
ImgCutOver: function(data) { ImgCutOver: function(data) {
that.selectedImage = data.picPath; that.selectedImage = data.picPath;

View File

@ -1051,7 +1051,7 @@ import request, { baseURL } from '@/utils/request.js';
var gotoCutImg = (imgPath) => { var gotoCutImg = (imgPath) => {
uni.navigateTo({ uni.navigateTo({
url: "/pages/6155/ImgCrop", url: "/pages/ImgCrop/ImgCrop",
events: { events: {
ImgCutOver: function(data) { ImgCutOver: function(data) {
// console.log("我收到裁剪后的图片了,感谢老铁," + data) // console.log("我收到裁剪后的图片了,感谢老铁," + data)

View File

@ -1871,7 +1871,7 @@
var gotoCutImg = (imgPath) => { var gotoCutImg = (imgPath) => {
uni.navigateTo({ uni.navigateTo({
url: "/pages/6155/ImgCrop", url: "/pages/ImgCrop/ImgCrop",
events: { events: {
ImgCutOver: function(data) { ImgCutOver: function(data) {
// console.log("我收到裁剪后的图片了,感谢老铁," + data) // console.log("我收到裁剪后的图片了,感谢老铁," + data)

View File

@ -783,7 +783,7 @@
sourceType: ['album'], sourceType: ['album'],
success: function(res) { success: function(res) {
uni.navigateTo({ uni.navigateTo({
url: "/pages/6155/ImgCrop", url: "/pages/ImgCrop/ImgCrop",
events: { events: {
ImgCutOver: function(data) { ImgCutOver: function(data) {
//将8位的二进制数组转换成16进制数据 //将8位的二进制数组转换成16进制数据

View File

@ -0,0 +1,100 @@
<template>
<view>
<canvas id="splashCanvas" canvas-id="splashCanvas" :style="{'width':width+'px','height':height+'px'}" style=" z-index: 9999;position: fixed; visibility: hidden;"></canvas>
<qf-image-cropper :src="src" :showAngle="false" :width="cropWidth" :height="cropHeight" fileType="jpg"
@crop="handleCrop" :areaScale="0.1" :minScale="0.1" :gpu="true">
</qf-image-cropper>
</view>
</template>
<script>
import QfImageCropper from '@/uni_modules/qf-image-cropper/components/qf-image-cropper/qf-image-cropper.vue';
export default {
components: {
QfImageCropper
},
data() {
return {
src: "",
Statu: false,
width:160,
height:80,
times:10
}
},
computed:{
cropWidth(){
return this.width*this.times;
}
,
cropHeight(){
return this.height*this.times;
}
},
onLoad: function(option) {
const eventChannel = this.getOpenerEventChannel();
var these = this;
eventChannel.on('checkImg', (rec)=> {
console.log("我收到你的消息了,消息内容是:" + JSON.stringify(rec));
this.src = rec.data;
this.width=rec.width?rec.width:160;
this.height=rec.height?rec.height:80;
this.times=rec.times?rec.times:10;
})
},
methods: {
handleCrop(e) {
var these = this;
const eventChannel = these.getOpenerEventChannel();
this.Statu = true;
console.log("裁剪完成");
console.log(e.tempFilePath);
eventChannel.emit('ImgCutOver_Path',e.tempFilePath);
const ctx = uni.createCanvasContext('splashCanvas', this);
ctx.drawImage(
e.tempFilePath,
0,0,these.width,these.height
);
setTimeout(() => {
ctx.draw(false, ()=>{
console.log("abcdefg")
uni.canvasGetImageData({
canvasId: 'splashCanvas',
x: 0,
y: 0,
width: these.width,
height: these.height,
success: (res) => {
// 处理像素数据并发送
console.log("res.data.length="+res.data.length);
eventChannel.emit('ImgCutOverPath', {
picPath: e.tempFilePath
});
eventChannel.emit('ImgCutOver',{piexls:res.data,picPath:e.tempFilePath});
uni.navigateBack();
},
fail: (err) => {
reject(`获取canvas数据失败: ${err.errMsg}`);
}
});
});
}, 500);
}
}
}
</script>
<style>
.canvas {
border: 1px solid #ccc;
}
</style>

View File

@ -2,11 +2,12 @@
<view class="container"> <view class="container">
<!-- 设备列表 --> <!-- 设备列表 -->
<view class="allSelect" @click="selectAll"> 全选</view> <view class="allSelect" @click="selectAll"> 全选</view>
<scroll-view class="device-list" scroll-y> <mescroll-uni class="device-list" @init="mescrollInit" @down="downCallback" @up="upCallback" :up="upOption"
<view class="device-card" v-for="(item, index) in deviceList" :key="index" :down="downOption" :fixed="false" :style="{ height: mescrollHeight + 'px' }">
@click="item.onlineStatus === 1 ? toggleSelect(index) : null">
<view class="device-card" v-for="(item, index) in deviceList" :key="index" @click="toggleSelect(index)">
<!-- 复选框 --> <!-- 复选框 -->
<view class="checkbox" :class="{ checked: item.checked, disabled: item.onlineStatus !== 1 }"> <view class="checkbox" :class="{ checked: item.checked }">
<uni-icons v-if="item.checked" type="checkmarkempty" size="18" color="rgb(0, 0, 0)"></uni-icons> <uni-icons v-if="item.checked" type="checkmarkempty" size="18" color="rgb(0, 0, 0)"></uni-icons>
</view> </view>
<!-- 设备信息 --> <!-- 设备信息 -->
@ -28,11 +29,12 @@
</view> </view>
</view> </view>
</view> </view>
</mescroll-uni>
<view class="editInfmation"> <view class="editInfmation">
<button class="login-btn qz" @click="forceAlarm">强制报警</button> <button class="login-btn qz" @click="forceAlarm">强制报警</button>
<button class="login-btn jc" @click="cancelAlarm">解除报警</button> <button class="login-btn jc" @click="cancelAlarm">解除报警</button>
</view> </view>
</scroll-view>
<!-- 强制报警提示弹框 --> <!-- 强制报警提示弹框 -->
<CustomPopup v-if="popupType === 'force'" :show="showPopupFlag" popupBorder="1rpx solid rgba(224, 52, 52, 0.3)" <CustomPopup v-if="popupType === 'force'" :show="showPopupFlag" popupBorder="1rpx solid rgba(224, 52, 52, 0.3)"
:message="popupMessage" icon="/static/images/6170/bj.png" :confirm-text="popupConfirmText" :message="popupMessage" icon="/static/images/6170/bj.png" :confirm-text="popupConfirmText"
@ -68,9 +70,14 @@
deviceRealTimeStatus // deviceRealTimeStatus //
} from '@/api/6170/deviceControl.js' } from '@/api/6170/deviceControl.js'
import MescrollUni from '@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-uni.vue';
var timeout = null;
var these = null;
export default { export default {
components: { components: {
CustomPopup CustomPopup,
MescrollUni
}, },
data() { data() {
return { return {
@ -83,18 +90,38 @@
pendingAlarmAction: '', pendingAlarmAction: '',
sendInfo: '', sendInfo: '',
// 2. typeName // 2. typeName
alarmApiMapping: { dic: {
'HBY100-J': { //100J alarmApiMapping: [{
type: ['HBY100-J'],
sendApi: deviceForceAlarmActivation, sendApi: deviceForceAlarmActivation,
statusTypeName: 'FunctionAccessBatchStatusRule_BJQ100J' statusTypeName: 'FunctionAccessBatchStatusRule_BJQ100J'
}, },
'BJQ6170': { //6170 {
type: ['BJQ6170'],
sendApi: deviceSendAlarmMessage, sendApi: deviceSendAlarmMessage,
statusTypeName: 'FunctionAccessBatchStatusRule_BJQ200J' statusTypeName: 'FunctionAccessBatchStatusRule_BJQ200J'
} },
]
}, },
loading: false, loading: false,
total: 0 total: 0,
mescroll: null,
downOption: {
auto: true,
autoShowLoading: false,
},
upOption: {
auto: false,
noMoreSize: 0,
offset: 50,
isLock: false,
empty: {
tip: '暂无数据',
hideScroll: false
},
textNoMore: '没有更多数据了'
},
mescrollHeight: 0
} }
}, },
computed: { computed: {
@ -105,13 +132,52 @@
currentApiConfig() { currentApiConfig() {
const currentTypeName = this.sendInfo.typeName || ''; const currentTypeName = this.sendInfo.typeName || '';
// //
return this.alarmApiMapping[currentTypeName] || { let f= this.dic.alarmApiMapping.find(v=>{
return v.type.indexOf(currentTypeName)>-1;
});
if(f){
return f;
}else{
return {
sendApi: deviceDefaultAlarm, sendApi: deviceDefaultAlarm,
statusTypeName: 'FunctionAccessBatchStatusRule_Default' statusTypeName: 'FunctionAccessBatchStatusRule_Default'
}; };
} }
}
}, },
methods: { methods: {
getSystemInfoSyncH() {
let sysInfo = uni.getSystemInfoSync();
// footer 220rpx + 120rpx = 340rpx px1rpx = sysInfo.pixelRatio / 750 * rpx px
let footerHeight = 340 * (sysInfo.screenWidth / 750); // rpx px
// console.log("footerHeight=", footerHeight);
this.mescrollHeight = sysInfo.screenHeight - footerHeight;
// console.log("mescrollHeight=", this.mescrollHeight);
},
mescrollInit(mescroll) {
this.mescroll = mescroll;
},
//
downCallback() {
if (this.mescroll) {
this.mescroll.resetUpScroll(false);
this.mescroll.scrollTo(0, 0);
}
this.getData(this.sendInfo.id);
},
//
upCallback() {
this.getData(this.sendInfo.id);
},
onclosePopup() { onclosePopup() {
this.showPopupFlag = false this.showPopupFlag = false
}, },
@ -123,17 +189,19 @@
selectAll() { selectAll() {
console.log('123'); console.log('123');
// 线/ // 线/
const allSelected = this.deviceList.every(item => item.onlineStatus === 1 && item.checked); const allSelected = this.deviceList.every(item => item.checked);
this.deviceList.forEach(item => { this.deviceList.forEach(item => {
// 线checked // 线checked
if (item.onlineStatus === 1) {
item.checked = !allSelected; item.checked = !allSelected;
}
}); });
this.$forceUpdate(); this.$forceUpdate();
}, },
// //
getData(deviceType) { getData(deviceType) {
clearTimeout(timeout);
timeout = setTimeout(() => {
console.log(deviceType, 'deviceTypedeviceType'); console.log(deviceType, 'deviceTypedeviceType');
this.loading = true; this.loading = true;
let data = { let data = {
@ -149,11 +217,28 @@
checked: false checked: false
})); }));
this.total = res.total; this.total = res.total;
this.deviceList = newDevices this.deviceList = newDevices;
let hasNext = true;
if (res.rows.length < this.size || this.deviceList.length >= this
.total) {
hasNext = false;
} else {
hasNext = true;
}
this.mescroll.endSuccess(res.rows.length, hasNext);
} else {
this.mescroll.endSuccess(0, false);
} }
}).finally(() => { }).finally(() => {
this.loading = false; this.loading = false;
}).catch(ex => {
this.mescroll.endSuccess(0, false);
}); });
}, 200);
}, },
// //
forceAlarm() { forceAlarm() {
@ -252,13 +337,15 @@
}, },
}, },
onLoad(options) { onLoad(options) {
these = this;
const eventChannel = this.getOpenerEventChannel(); const eventChannel = this.getOpenerEventChannel();
// 'deviceSend' // 'deviceSend'
eventChannel.on('devicePolice', (data) => { eventChannel.on('devicePolice', (data) => {
this.getData(data.data.id) this.getData(data.data.id)
this.sendInfo = data.data this.sendInfo = data.data
}); });
eventChannel.emit('ack', {}) eventChannel.emit('ack', {});
this.getSystemInfoSyncH();
}, },
} }
</script> </script>

View File

@ -18,12 +18,15 @@
<image src="/static/images/common/more.png" mode="aspectFit" class="more"></image> <image src="/static/images/common/more.png" mode="aspectFit" class="more"></image>
</view> </view>
</view> </view>
<!-- <view class="sendFlex" v-if="activeTab && activeTab.id !== ''&& activeTabInfo.communicationMode==0 || activeTabInfo.communicationMode==2"> <view class="sendFlex"
<view class="callpolice" @click="callpolice">报警</view> v-show="showSendFlex"
<view class="Sendmessage" @click="location">位置</view> >
<view class="Sendmessage" @click="handleSend" v-if="activeTabInfo.typeName!=='HBY100-J'">发送信息</view> <view class="callpolice" @click="callpolice" v-show="showWarn">报警</view>
</view> --> <view class="Sendmessage" @click="location" v-show="showMap">位置</view>
<!-- <scroll-view class="device-list" scroll-y @scrolltolower="onScrollToLower" :lower-threshold="100" style="height:80vh;"> --> <view class="Sendmessage" @click="handleSend"
v-show="ShowSendmessage">发送信息</view>
</view>
<mescroll-uni class="device-list" @init="mescrollInit" @down="downCallback" @up="upCallback" :up="upOption" <mescroll-uni class="device-list" @init="mescrollInit" @down="downCallback" @up="upCallback" :up="upOption"
:down="downOption" :fixed="false" :style="{ height: mescrollHeight + 'px' }"> :down="downOption" :fixed="false" :style="{ height: mescrollHeight + 'px' }">
<view v-if="deviceList.length>0"> <view v-if="deviceList.length>0">
@ -40,15 +43,15 @@
<view class="device-name"> <view class="device-name">
<view>设备:{{item.deviceName}}</view> <view>设备:{{item.deviceName}}</view>
<view class="ID"> <view class="ID">
<view class="ID" v-if="item.communicationMode==0 || item.communicationMode==2">ID:{{item.deviceImei}} <view class="ID"
v-if="item.communicationMode==0 || item.communicationMode==2">
ID:{{item.deviceImei}}
</view> </view>
<view class="ID" v-else>ID:{{item.deviceMac}}</view> <view class="ID" v-else>ID:{{item.deviceMac}}</view>
<!-- 在线状态 --> <!-- 在线状态 -->
<view class="onlines" <view class="onlines" v-if="item.onlineStatus==1">在线</view>
v-if="item.onlineStatus==1">在线</view>
<!-- 离线状态 --> <!-- 离线状态 -->
<view class="offlines" <view class="offlines" v-if="item.onlineStatus==0">离线</view>
v-if="item.onlineStatus==0">离线</view>
<view>电量{{item.battery || '0'}}%</view> <view>电量{{item.battery || '0'}}%</view>
</view> </view>
</view> </view>
@ -74,7 +77,7 @@
暂无数据 暂无数据
</view> --> </view> -->
</mescroll-uni> </mescroll-uni>
<!-- </scroll-view> -->
</view> </view>
<!-- 删除弹框 --> <!-- 删除弹框 -->
<view class="agreement-mask" v-if="deleteShow" @click.stop="closePopup('delete')" catchtouchmove="true"> <view class="agreement-mask" v-if="deleteShow" @click.stop="closePopup('delete')" catchtouchmove="true">
@ -116,7 +119,7 @@
<view class="tooltip-content" @click.stop> <view class="tooltip-content" @click.stop>
<view class="tooltip-item" v-for="(item, index) in menuItems" :key="index" <view class="tooltip-item" v-for="(item, index) in menuItems" :key="index"
@click="handleMenuClick(item)"> @click="handleMenuClick(item)">
<image :src="item.icon" class="item-icon" mode="aspectFit"/> <image :src="item.icon" class="item-icon" mode="aspectFit" />
<text>{{ item.text }}</text> <text>{{ item.text }}</text>
</view> </view>
</view> </view>
@ -146,17 +149,34 @@
} from '@/api/common/index.js' } from '@/api/common/index.js'
import bleTool from '@/utils/BleHelper.js'; import bleTool from '@/utils/BleHelper.js';
import MescrollUni from '@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-uni.vue' import MescrollUni from '@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-uni.vue'
import BleReceive from '@/utils/BleReceive'; import BleReceive from '@/utils/BleReceive';
var pagePath = 'pages/common/index'; var pagePath = 'pages/common/index';
var ble = null; var ble = null;
var timeout = null; var timeout = null;
var recei=null; var recei = null;
export default { export default {
components: { components: {
MescrollUni MescrollUni
}, },
computed:{
showSendFlex(){
// return this.activeTab && this.activeTab.id !== ''&& (this.activeTabInfo.communicationMode==0 || this.activeTabInfo.communicationMode==2);
if(this.showMap || this.ShowSendmessage || this.showWarn){
return true;
}
return false;
},
ShowSendmessage(){
return this.dic.showMsgTypes.indexOf(this.activeTabInfo.typeName)>-1
},
showMap(){
return this.dic.showMapTypes.indexOf(this.activeTabInfo.typeName)>-1
},
showWarn(){
return this.dic.showCallPolice.indexOf(this.activeTabInfo.typeName)>-1
}
},
data() { data() {
return { return {
mescroll: null, mescroll: null,
@ -187,8 +207,7 @@ import BleReceive from '@/utils/BleReceive';
navTitle: "我的设备", navTitle: "我的设备",
deleteShow: false, deleteShow: false,
RenameModel: false, RenameModel: false,
menuItems: [ menuItems: [{
{
text: '扫一扫添加', text: '扫一扫添加',
icon: '/static/images/common/scane.png', icon: '/static/images/common/scane.png',
action: 'scan' action: 'scan'
@ -233,7 +252,12 @@ import BleReceive from '@/utils/BleReceive';
deviceId: '', deviceId: '',
deviceName: "", //重命名 deviceName: "", //重命名
activeTabInfo: '' activeTabInfo: '',
dic: {
showMsgTypes: ['BJQ6170', 'HBY210', 'HBY670', 'BJQ6075', 'BJQ6075J'],//需要发送消息的类型
showMapTypes:['BJQ6170','HBY210','HBY670','BJQ6075','HBY018A','HBY100-J','BJQ6075J','HBY008A','HBY100-Y'],//需要显示地图的类型
showCallPolice:['BJQ6170','HBY210','HBY670','BJQ6075','HBY018A','HBY100-J','BJQ6075J','HBY008A','HBY100-Y']//需要发送报警的类型
}
} }
}, },
methods: { methods: {
@ -496,7 +520,7 @@ import BleReceive from '@/utils/BleReceive';
case 'scan': case 'scan':
// 扫一扫 // 扫一扫
uni.navigateTo({ uni.navigateTo({
url:'/pages/common/addScan/ScanEquip' url: '/pages/common/addScan/ScanEquip'
}); });
break; break;
@ -619,7 +643,7 @@ import BleReceive from '@/utils/BleReceive';
const deviceType = currentTab.id || ''; const deviceType = currentTab.id || '';
console.log(`跳转到发送信息页面\n当前设备类型: ${deviceType}\n设备类型名称: ${currentTab.typeName}`); console.log(`跳转到发送信息页面\n当前设备类型: ${deviceType}\n设备类型名称: ${currentTab.typeName}`);
uni.navigateTo({ uni.navigateTo({
url: '/pages/6170/callPolice/index', url: '/pages/common/callPolice/index',
events: { events: {
ack: function(data) {} ack: function(data) {}
}, },
@ -772,8 +796,8 @@ import BleReceive from '@/utils/BleReceive';
this.updateBleStatu(); this.updateBleStatu();
}, pagePath); }, pagePath);
let phone=uni.getStorageSync("phone"); let phone = uni.getStorageSync("phone");
if(phone==='17671332251'){//先写死方便自己使用,后面按人员权限区分 if (phone === '17671332251') { //先写死方便自己使用,后面按人员权限区分
this.menuItems.push({ this.menuItems.push({
text: '上报设备', text: '上报设备',
icon: '/static/images/common/add.png', icon: '/static/images/common/add.png',

View File

@ -1,11 +1,12 @@
<template> <template>
<view class="container"> <view class="container">
<!-- 设备列表 --> <!-- 设备列表 -->
<scroll-view class="device-list" scroll-y> <!-- <scroll-view class="device-list" scroll-y> -->
<view class="device-card" v-for="(item, index) in deviceList" :key="index" <mescroll-uni class="device-list" @init="mescrollInit" @down="downCallback" @up="upCallback" :up="upOption"
@click="item.onlineStatus === 1 ? toggleSelect(index) : null"> :down="downOption" :fixed="false" :style="{ height: mescrollHeight + 'px' }">
<view class="device-card" v-for="(item, index) in deviceList" :key="index" @click="toggleSelect(index)">
<!-- 复选框 --> <!-- 复选框 -->
<view class="checkbox" :class="{ checked: item.checked, disabled: item.onlineStatus !== 1 }"> <view class="checkbox" :class="{ checked: item.checked }">
<uni-icons v-if="item.checked" type="checkmarkempty" size="18" color="rgb(0, 0, 0)"></uni-icons> <uni-icons v-if="item.checked" type="checkmarkempty" size="18" color="rgb(0, 0, 0)"></uni-icons>
</view> </view>
<!-- 设备信息 --> <!-- 设备信息 -->
@ -27,6 +28,9 @@
</view> </view>
</view> </view>
</view> </view>
</mescroll-uni>
<!-- </scroll-view> -->
<view class="editInfmation"> <view class="editInfmation">
<view class="ql-editor">编辑信息</view> <view class="ql-editor">编辑信息</view>
<view class="ql-input"> <view class="ql-input">
@ -35,7 +39,6 @@
</view> </view>
<button class="login-btn" @click.stop="sendTextMessage">发送</button> <button class="login-btn" @click.stop="sendTextMessage">发送</button>
</view> </view>
</scroll-view>
<!-- 成功提示弹框 --> <!-- 成功提示弹框 -->
<CustomPopup :show="showPopupFlag" :title="popupTitle" :message="popupMessage" <CustomPopup :show="showPopupFlag" :title="popupTitle" :message="popupMessage"
icon="/static/images/common/sendSucc.png" :confirm-text="popupConfirmText" :show-cancel="false" icon="/static/images/common/sendSucc.png" :confirm-text="popupConfirmText" :show-cancel="false"
@ -44,21 +47,26 @@
</template> </template>
<script> <script>
import CustomPopup from '@/components/CustomPopup/CustomPopup.vue' import CustomPopup from '@/components/CustomPopup/CustomPopup.vue'
import { import {
deviceInfo, deviceInfo,
} from '@/api/common/index.js' } from '@/api/common/index.js'
import { import {
deviceSendMessage, deviceSendMessage,
deviceRealTimeStatus //设备状态 deviceRealTimeStatus //设备状态
} from '@/api/6170/deviceControl.js' } from '@/api/6170/deviceControl.js'
import { import {
generateShortId, generateShortId,
getdeviceSTatus getdeviceSTatus
} from '@/utils/function.js'; } from '@/utils/function.js';
export default { import MescrollUni from '@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-uni.vue';
var timer=null;
var these=null;
export default {
components: { components: {
CustomPopup CustomPopup,
MescrollUni
}, },
data() { data() {
return { return {
@ -69,23 +77,76 @@ export default {
popupMessage: '信息发送成功!', popupMessage: '信息发送成功!',
popupConfirmText: '确认', popupConfirmText: '确认',
isSending: false, isSending: false,
sendInfo: {} sendInfo: {},
mescroll: null,
downOption: {
auto: true,
autoShowLoading: false,
},
upOption: {
auto: false,
noMoreSize: 0,
offset: 50,
isLock: false,
empty: {
tip: '暂无数据',
hideScroll: false
},
textNoMore: '没有更多数据了'
},
mescrollHeight: 0,
} }
}, },
methods: { methods: {
onPullDownRefresh() { getSystemInfoSyncH() {
// 执行下拉刷新时的操作,比如重新获取数据
this.getData(); let sysInfo = uni.getSystemInfoSync();
// 底部 footer 高度约 220rpx + 120rpx = 340rpx转换为 px1rpx = sysInfo.pixelRatio / 750 * 屏幕宽度?不,直接用 rpx 转 px 公式)
let footerHeight = 500 * (sysInfo.screenWidth / 750); // rpx 转 px
// console.log("footerHeight=", footerHeight);
this.mescrollHeight = sysInfo.screenHeight - footerHeight;
// console.log("mescrollHeight=", this.mescrollHeight);
}, },
mescrollInit(mescroll) {
this.mescroll = mescroll;
},
// 下拉刷新
downCallback() {
console.log("触发下拉刷新");
if (this.mescroll) {
this.mescroll.resetUpScroll(false);
this.mescroll.scrollTo(0, 0);
}
this.getData(this.sendInfo.id);
},
// 上拉加载
upCallback() {
console.log("触发上拉加载");
this.getData(this.sendInfo.id);
},
// onPullDownRefresh() {
// // 执行下拉刷新时的操作,比如重新获取数据
// this.getData();
// },
toggleSelect(index) { toggleSelect(index) {
this.deviceList[index].checked = !this.deviceList[index].checked this.deviceList[index].checked = !this.deviceList[index].checked
this.$forceUpdate() this.$forceUpdate()
}, },
// 获取设备列表 // 获取设备列表
getData(deviceType) { getData(deviceType) {
clearTimeout(timer);
timer=setTimeout(()=>{
console.log("开始加载第"+(this.mescroll? this.mescroll.num:1)+'页数据')
this.loading = true; this.loading = true;
let data = { let data = {
pageNum: 1, pageNum:this.mescroll? this.mescroll.num:1,
pageSize: 50, pageSize: 50,
deviceType: deviceType deviceType: deviceType
} }
@ -98,13 +159,33 @@ export default {
})); }));
this.total = res.total; this.total = res.total;
this.deviceList = newDevices this.deviceList = newDevices
this.total = res.total;
// 判断是否加载完成
let hasNext = true;
if (res.rows.length < this.size || this.deviceList.length >= this
.total) {
hasNext = false;
} else {
hasNext = true;
}
this.mescroll.endSuccess(res.rows.length, hasNext);
}else {
this.mescroll.endSuccess(0, false);
} }
}).finally(() => { }).finally(() => {
this.loading = false; this.loading = false;
}).catch(ex=>{
this.mescroll.endSuccess(0, false);
}); });
},200);
}, },
// 发送文本消息 // 发送文本消息
async sendTextMessage() { sendTextMessage() {
// 防重复提交 // 防重复提交
if (this.isSending) return; if (this.isSending) return;
const selectedDevices = this.deviceList.filter(item => item.checked) const selectedDevices = this.deviceList.filter(item => item.checked)
@ -125,13 +206,16 @@ export default {
return; return;
} }
this.isSending = true; this.isSending = true;
let loadingShown = false; //FYS的方法
let FYSSend =async () => {
try { try {
uni.showLoading({ uni.showLoading({
title: '发送中...', title: '发送中...',
mask: true mask: true
}); });
loadingShown = true;
// 2. 准备请求数据 // 2. 准备请求数据
const batchId = generateShortId(); const batchId = generateShortId();
const data = { const data = {
@ -157,7 +241,7 @@ export default {
const statusRes = await getdeviceSTatus({ const statusRes = await getdeviceSTatus({
functionMode: 2, functionMode: 2,
batchId, batchId,
typeName:'FunctionAccessBatchStatusRule', typeName: 'FunctionAccessBatchStatusRule',
deviceImei, deviceImei,
interval: 500 interval: 500
}, },
@ -176,6 +260,71 @@ export default {
uni.hideLoading(); uni.hideLoading();
this.isSending = false; this.isSending = false;
} }
}
//XS的方法
let XSSend=() => {
try {
this.showPopupFlag=true;
} catch (error) {
} finally {
this.isSending = false;
}
}
//FS的方法
let FSSend = () => {
try {
this.showPopupFlag = true
} catch (error) {
} finally {
this.isSending = false;
}
}
let device = selectedDevices[0];
let sendDic = [{
urls: ['/pages/6170/deviceControl/index', '/pages/210/HBY210', '/pages/6075/BJQ6075',
'/pages/100J/HBY100-J'
],
send: FYSSend,
},
{
urls: ['/pages/670/HBY670'],
send: XSSend
},
{
urls: ['/pages/6075J/BJQ6075J'],
send: FSSend
}
];
let f = sendDic.find(v => {
return v.urls.indexOf(device.detailPageUrl)>-1;
});
if (f) {
f.send();
} else {
FYSSend();
}
}, },
onPopupConfirm() { onPopupConfirm() {
this.showPopupFlag = false this.showPopupFlag = false
@ -185,43 +334,50 @@ export default {
}, },
}, },
onLoad(options) { onLoad(options) {
these=this;
const eventChannel = this.getOpenerEventChannel(); const eventChannel = this.getOpenerEventChannel();
// 监听 'deviceSend' 事件,获取传过来的数据 // 监听 'deviceSend' 事件,获取传过来的数据
eventChannel.on('deviceSend', (data) => { eventChannel.on('deviceSend', (data) => {
console.log('Received detail data:', data); console.log('Received detail data:', data);
this.getData(data.data.id)
this.sendInfo = data.data this.sendInfo = data.data
this.downCallback();
}); });
// 如果需要向调用页面返回数据,可以触发 'ack' 事件 // 如果需要向调用页面返回数据,可以触发 'ack' 事件
eventChannel.emit('ack', {}) eventChannel.emit('ack', {});
this.getSystemInfoSyncH();
}, },
} onUnload() {
clearTimeout(timer);
}
}
</script> </script>
<style scoped> <style scoped>
.container { .container {
min-height: 100vh; min-height: 100vh;
background-color: rgb(18, 18, 18); background-color: rgb(18, 18, 18);
box-sizing: border-box; box-sizing: border-box;
overflow-x: hidden; overflow-x: hidden;
} }
.device-list { .device-list {
flex: 1; flex: 1;
padding: 0 20rpx; padding: 0 20rpx;
} }
.device-card { .device-card {
position: relative; position: relative;
display: flex; display: flex;
align-items: center; align-items: center;
width: 95%; width: 95%;
margin-bottom: 20rpx; margin-bottom: 20rpx;
} }
.checkbox { .checkbox {
width: 40rpx; width: 40rpx;
height: 40rpx; height: 40rpx;
border: 2rpx solid rgba(255, 255, 255, 0.5); border: 2rpx solid rgba(255, 255, 255, 0.5);
@ -230,14 +386,14 @@ export default {
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
} }
.checkbox.checked { .checkbox.checked {
background-color: rgb(187, 230, 0); background-color: rgb(187, 230, 0);
border-color: rgb(187, 230, 0); border-color: rgb(187, 230, 0);
} }
.device-content { .device-content {
background-color: rgb(26, 26, 26); background-color: rgb(26, 26, 26);
border-radius: 16rpx; border-radius: 16rpx;
position: relative; position: relative;
@ -245,32 +401,32 @@ export default {
align-items: center; align-items: center;
padding: 20rpx; padding: 20rpx;
width: 95%; width: 95%;
} }
.device-header { .device-header {
display: flex; display: flex;
align-items: center; align-items: center;
margin-bottom: 15rpx; margin-bottom: 15rpx;
} }
.device-name { .device-name {
font-size: 32rpx; font-size: 32rpx;
color: rgba(255, 255, 255, 0.87); color: rgba(255, 255, 255, 0.87);
margin-left: 12rpx; margin-left: 12rpx;
line-height: 50rpx; line-height: 50rpx;
width: 83%; width: 83%;
white-space: nowrap; white-space: nowrap;
} }
.ID { .ID {
color: rgba(255, 255, 255, 0.6); color: rgba(255, 255, 255, 0.6);
font-size: 26rpx; font-size: 26rpx;
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
position: relative; position: relative;
} }
.device-status { .device-status {
width: 122rpx; width: 122rpx;
height: 52rpx; height: 52rpx;
font-size: 26rpx; font-size: 26rpx;
@ -281,26 +437,26 @@ export default {
right: 0rpx; right: 0rpx;
text-align: center; text-align: center;
line-height: 52rpx; line-height: 52rpx;
} }
.online { .online {
color: rgb(187, 230, 0); color: rgb(187, 230, 0);
} }
.unline { .unline {
color: rgba(255, 255, 255, 0.4); color: rgba(255, 255, 255, 0.4);
} }
.device-info { .device-info {
display: flex; display: flex;
justify-content: space-evenly; justify-content: space-evenly;
font-size: 26rpx; font-size: 26rpx;
color: rgba(255, 255, 255, 0.87); color: rgba(255, 255, 255, 0.87);
padding-top: 10rpx; padding-top: 10rpx;
position: relative; position: relative;
} }
.deviceIMG { .deviceIMG {
width: 100rpx; width: 100rpx;
height: 100rpx; height: 100rpx;
border-radius: 16rpx; border-radius: 16rpx;
@ -308,19 +464,19 @@ export default {
background-color: rgba(42, 42, 42, 0.6); background-color: rgba(42, 42, 42, 0.6);
display: flex; display: flex;
align-items: center; align-items: center;
} }
.IMG { .IMG {
width: 68rpx; width: 68rpx;
height: 50rpx; height: 50rpx;
margin-left: 17%; margin-left: 17%;
} }
.onlines { .onlines {
position: relative; position: relative;
} }
.onlines::before { .onlines::before {
content: ''; content: '';
position: absolute; position: absolute;
width: 15rpx; width: 15rpx;
@ -329,13 +485,13 @@ export default {
border-radius: 50%; border-radius: 50%;
top: 20rpx; top: 20rpx;
left: -20rpx left: -20rpx
} }
.unlines { .unlines {
position: relative; position: relative;
} }
.unlines::before { .unlines::before {
content: ''; content: '';
position: absolute; position: absolute;
width: 15rpx; width: 15rpx;
@ -344,9 +500,9 @@ export default {
border-radius: 50%; border-radius: 50%;
top: 20rpx; top: 20rpx;
left: -20rpx left: -20rpx
} }
.line { .line {
width: 2rpx; width: 2rpx;
height: 24rpx; height: 24rpx;
background: linear-gradient(90deg, background: linear-gradient(90deg,
@ -354,58 +510,60 @@ export default {
rgb(255, 255, 255) 50%, rgb(255, 255, 255) 50%,
rgba(255, 255, 255, 0) 100%); rgba(255, 255, 255, 0) 100%);
margin-top: 12rpx; margin-top: 12rpx;
} }
.ql-editor { .ql-editor {
color: rgba(255, 255, 255, 0.6); color: rgba(255, 255, 255, 0.6);
font-size: 30rpx; font-size: 30rpx;
} }
.ql-input { .ql-input {
width: 95.9%; width: 95.9%;
height: 200rpx; height: 200rpx;
margin-top: 30rpx; margin-top: 30rpx;
box-sizing: border-box; box-sizing: border-box;
padding: 30rpx; padding: 20rpx;
border-radius: 16rpx; border-radius: 16rpx;
background: rgb(26, 26, 26); background: rgb(26, 26, 26);
} }
.textarea { .textarea {
color: rgba(255, 255, 255, 0.8); color: rgba(255, 255, 255, 0.8);
background: rgba(42, 42, 42, 1); background: rgba(42, 42, 42, 1);
border-radius: 16rpx; border-radius: 16rpx;
padding: 10rpx; padding: 10rpx;
height: 150rpx; height: 150rpx;
} width: 100%;
}
.editInfmation { .editInfmation {
padding: 20rpx; padding: 20rpx;
border-radius: 40rpx 40rpx 0px 0px; border-radius: 40rpx 40rpx 0px 0px;
background: rgba(28, 28, 28, 1); background: rgba(28, 28, 28, 1);
position: fixed; position: fixed;
bottom: 50rpx; bottom: 20rpx;
box-sizing: border-box; box-sizing: border-box;
} width: 100%;
}
.login-btn { .login-btn {
margin-top: 30rpx; margin-top: 30rpx;
background-color: rgb(187, 230, 0); background-color: rgb(187, 230, 0);
color: rgb(35, 35, 35); color: rgb(35, 35, 35);
border-radius: 50rpx; border-radius: 50rpx;
width: 90%; width: 90%;
} }
.checkbox.disabled { .checkbox.disabled {
opacity: 0.5; opacity: 0.5;
background-color: rgba(255, 255, 255, 0.1) !important; background-color: rgba(255, 255, 255, 0.1) !important;
border-color: rgba(255, 255, 255, 0.2) !important; border-color: rgba(255, 255, 255, 0.2) !important;
pointer-events: none; pointer-events: none;
/* 阻止点击事件 */ /* 阻止点击事件 */
} }
/* 可选:离线设备的卡片整体置灰 */ /* 可选:离线设备的卡片整体置灰 */
.device-card[data-offline="true"] { .device-card[data-offline="true"] {
opacity: 0.6; opacity: 0.6;
} }
</style> </style>