Merge branch 'new-20250827' of http://47.107.152.87:3000/liubiao/APP into new-20250827

This commit is contained in:
liub
2025-11-17 15:31:14 +08:00
7 changed files with 673 additions and 405 deletions

View File

@ -6,7 +6,7 @@ export function deviceDetail(id) {
})
}
// 获取设备分享详细信息
export function deviceShareId(id) {
export function deviceShareId (id) {
return request({
url: `/app/bjq6075/device/getShareInfo/${id}`,
method: 'get',
@ -28,7 +28,7 @@ export function deviceSendMessage(data) {
data: data
})
}
// 灯光模式设置
// 灯光模式设置
export function lightModeSettings(data) {
return request({
url: `/app/bjq6075/device/lightModeSettings`,
@ -36,6 +36,14 @@ export function lightModeSettings(data) {
data: data
})
}
// 辅灯模式设置
export function auxiliaryLightModeSettings(data) {
return request({
url: `/app/bjq6075/device/auxiliaryLightModeSettings`,
method: 'post',
data: data
})
}
// 激光模式设置
export function laserModeSettings(data) {
return request({
@ -52,6 +60,14 @@ export function lightBrightnessSettings(data) {
data: data
})
}
// 声光报警
export function salaModeSettings(data) {
return request({
url: `/app/bjq6075/device/salaModeSettings`,
method: 'post',
data: data
})
}
// 地图逆解析
export function mapReverseGeocoding(data) {
return request({

View File

@ -1,6 +1,6 @@
<template>
<view>
<canvas canvas-id="reusableCanvas" :width="currentCanvasWidth" :height="currentCanvasHeight"
<canvas type="2d" canvas-id="reusableCanvas" :width="currentCanvasWidth" :height="currentCanvasHeight"
class="offscreen-canvas"></canvas>
</view>
</template>
@ -27,16 +27,6 @@
color: {
type: String,
default: "#000000"
},
// 二值化阈值0~1越大越细默认偏清晰
threshold: {
type: Number,
default: 0.45
},
// 是否启用轻度笔画修复3x3 膨胀);默认关闭以避免变粗
sharpen: {
type: Boolean,
default: false
}
},
data() {
@ -58,16 +48,6 @@
this.ctx = uni.createCanvasContext('reusableCanvas', this);
},
methods: {
/**
* 外部可调用:复位画布为纯背景并立即提交
*/
async resetCanvas() {
if (!this.ctx) return;
this.clearCanvas();
await new Promise((resolve) => {
this.ctx.draw(true, () => setTimeout(resolve, 30));
});
},
/**
* 估算单行文本所需的Canvas宽度
*/
@ -79,8 +59,6 @@
* 清除Canvas内容
*/
clearCanvas() {
// 先清除,再用背景色填充,确保无残留
this.ctx.clearRect(0, 0, this.currentCanvasWidth, this.currentCanvasHeight);
this.ctx.setFillStyle(this.bgColor);
this.ctx.fillRect(0, 0, this.currentCanvasWidth, this.currentCanvasHeight);
},
@ -89,11 +67,6 @@
* 复用单个Canvas处理所有文本行
*/
async drawAndGetPixels() {
// 发送前:确保画布处于干净背景态
await this.resetCanvas();
// 超采样比例(提高分辨率再降采样,减少模糊)
const SCALE = 3;
const PADDING_X = 1 * SCALE; // 左侧预留像素,避免首字裁剪
let binaryToHex = (binaryArray) => {
if (!Array.isArray(binaryArray) || binaryArray.length !== 8) {
throw new Error("输入必须是包含8个元素的二进制数组");
@ -117,107 +90,25 @@
return hexString;
}
let convertCharToMatrix = (drawResult, item) => {
// 设备端使用13x13点阵渲染保持输出13列×13行但只在内部采样12×12保留右侧与底部1像素缓冲
let convertCharToMatrix = (imageData, item) => {
const charWidth = 13;
const charHeight = 13;
const effectiveWidth = 12; // 仅采样前12列
const effectiveHeight = 12; // 仅采样前12行
const { pixelData, width, height } = drawResult;
// 将高分辨率像素降采样为13x13的布尔矩阵
const target = new Array(charWidth * charHeight).fill(0);
const threshold = Math.max(0.2, Math.min(0.8, this.threshold || 0.45));
// 确保采样区域严格对齐从PADDING_X开始只采样12列右侧预留1px12行底部预留1px
// 字符实际绘制区域从PADDING_X开始宽度为12*SCALE
const charStartX = PADDING_X;
const charEndX = PADDING_X + effectiveWidth * SCALE; // 仅采样到第12列
for (let y = 0; y < charHeight; y++) {
for (let x = 0; x < charWidth; x++) {
// 超出有效采样区域第13列或第13行直接置0作为缓冲
if (x >= effectiveWidth || y >= effectiveHeight) {
target[y * charWidth + x] = 0;
continue;
}
let onCount = 0;
let total = 0;
// 采样区域字符从PADDING_X开始绘制每列宽度为SCALE
const startX = PADDING_X + x * SCALE;
const startY = y * SCALE;
for (let sy = 0; sy < SCALE; sy++) {
for (let sx = 0; sx < SCALE; sx++) {
const px = startX + sx;
const py = startY + sy;
// 边界检查确保不超出Canvas边界且不超出字符实际绘制区域
if (px < 0 || py < 0 || px >= width || py >= height) {
// 边界外视为背景(黑色)
continue;
}
// 额外检查:确保不采样到字符右侧的残留区域
if (px >= charEndX) {
// 超出字符区域,视为背景
continue;
}
const idx = (py * width + px) * 4;
const R = pixelData[idx];
const G = pixelData[idx + 1];
const B = pixelData[idx + 2];
const A = pixelData[idx + 3] || 255;
// 计算亮度
const luminance = 0.299 * R + 0.587 * G + 0.114 * B;
const alpha = A / 255;
// 背景是黑色,文字是白色,所以判断亮色(>=128为文字点
if (luminance >= 128 && alpha > 0.5) onCount++;
total++;
}
}
// 当亮色占比超过阈值时判为1至少需要采样到一些像素
target[y * charWidth + x] = (total > 0 && onCount / total >= threshold) ? 1 : 0;
}
}
// 轻度笔画修复:可选 3x3 膨胀(启用时阈值更严格,避免变粗)
if (this.sharpen) {
const dilated = target.slice();
for (let y = 0; y < effectiveHeight; y++) {
for (let x = 0; x < effectiveWidth; x++) {
const idx = y * charWidth + x;
if (target[idx] === 1) continue;
let neighbors = 0;
for (let dy = -1; dy <= 1; dy++) {
for (let dx = -1; dx <= 1; dx++) {
if (dx === 0 && dy === 0) continue;
const nx = x + dx;
const ny = y + dy;
if (nx < 0 || ny < 0 || nx >= effectiveWidth || ny >= effectiveHeight) continue;
if (target[ny * charWidth + nx] === 1) neighbors++;
}
}
// 使用更严格的邻居门限,避免整体变粗
if (neighbors >= 5) {
dilated[idx] = 1;
}
}
}
for (let i = 0; i < target.length; i++) target[i] = dilated[i];
const charHeight = 12;
const pixels = [];
for (let i = 0; i < imageData.length; i += 4) {
const R = imageData[i];
pixels.push(R < 128 ? 1 : 0);
}
const lowBytes = new Array(charWidth).fill(0);
const highBytes = new Array(charWidth).fill(0);
// 按列打包每列13行分成上下两字节低字节0-7行8行高字节8-12行5行
for (let col = 0; col < charWidth; col++) {
for (let row = 0; row < charHeight; row++) {
const pixel = target[row * charWidth + col];
const pixel = pixels[row * charWidth + col];
if (pixel === 1) {
if (row < 8) {
// 低字节0-7行从低位到高位
lowBytes[col] |= (1 << row);
} else {
// 高字节8-12行从低位到高位使用5位剩余3位未使用
highBytes[col] |= (1 << (row - 8));
}
}
@ -230,32 +121,34 @@
let result = {};
let ctx = this.ctx;
// 1. 动态调整Canvas尺寸(高分辨率)
// 设备端使用13x13点阵渲染
this.currentCanvasWidth = 13 * SCALE + PADDING_X;
this.currentCanvasHeight = 13 * SCALE;
// 1. 动态调整Canvas尺寸
this.currentCanvasWidth = 13;
this.currentCanvasHeight = 12;
// 2. 清空Canvas绘制背景
this.clearCanvas();
// 3. 设置文字样式(整数像素对齐,顶部基线,避免首字裁剪)
// 3. 设置文字样式
ctx.setFillStyle(this.color);
ctx.setTextBaseline('top');
ctx.setTextAlign('left');
const fs = Math.max(1, Math.round(this.fontSize)) * SCALE;
ctx.setFontSize(fs);
ctx.font = `${fs}px "PingFangBold", "PingFang SC", Arial, sans-serif`;
ctx.setTextBaseline('middle');
// ctx.setTextAlign('center')
ctx.setFontSize(this.fontSize);
ctx.font = `${this.fontSize}px "PingFangBold", "PingFang SC", Arial, sans-serif`;
// 4. 绘制单个字符(每个字符独立绘制在固定位置)
// 确保字符始终从PADDING_X开始绘制Y坐标为0保证采样一致性
const charX = PADDING_X;
const charY = 0;
ctx.fillText(textLine, charX, charY);
// 4. 绘制当前行文本
let currentX = 0;
let currentY = this.fontSize / 2 + 1;
for (let j = 0; j < textLine.length; j++) {
let char = textLine[j];
ctx.fillText(char, currentX, currentY);
// 按实际字符宽度计算间距
let charWidth = ctx.measureText(char).width;
currentX += charWidth;
}
// 5. 异步绘制并获取像素数据(串行处理避免冲突)
const grabPixels = () => new Promise((resolve, reject) => {
// 立即绘制并给一点缓冲时间,避免取像素过早
ctx.draw(true, () => {
await new Promise((resolve, reject) => {
ctx.draw(false, () => {
setTimeout(() => {
uni.canvasGetImageData({
canvasId: 'reusableCanvas',
@ -272,23 +165,15 @@
};
resolve();
},
fail: err => reject(err)
fail: err => {
// console.error(`处理第${i+1}行失败:`, err);
reject(err)
}
});
}, 70);
}, 100);
});
});
await grabPixels();
// 一次性校验:若像素全黑或明显异常,重绘重取一次
let nonZero = false;
for (let i = 0; i < result.pixelData.length; i += 4) {
if (result.pixelData[i] || result.pixelData[i+1] || result.pixelData[i+2]) { nonZero = true; break; }
}
if (!nonZero) {
await new Promise(r => setTimeout(r, 50));
await grabPixels();
}
return result;
}
let arr = [];
@ -299,23 +184,13 @@
let item = this.validTxts[i];
// console.log("item=", item);
for (var j = 0; j < item.length; j++) {
let char = item[j];
let result = await drawTxt(char);
let matrix = convertCharToMatrix(result, item);
// 调试:打印每个字符的点阵数据
console.log(`[点阵生成] 字符"${char}" 点阵数据:`, matrix.map(b => '0x' + b.toString(16).padStart(2, '0')).join(' '));
linePixls.push(matrix);
// 在字符间增加轻微延时,避免相邻提取竞争(尤其是末字符)
await new Promise(r => setTimeout(r, 20));
let result = await drawTxt(item[j]);
linePixls.push(convertCharToMatrix(result.pixelData, item));
}
// console.log("hexs=", linePixls.join(","));
arr.push(linePixls);
// 每行结束再等一会,提高末字符稳定性
await new Promise(r => setTimeout(r, 40));
}
// 发送后:再次清空画布,避免残留影响下一次
await this.resetCanvas();
return arr;
}
}
@ -327,5 +202,6 @@
position: fixed;
left: -9999px;
top: -9999px;
visibility: hidden;
}
</style>

268
et --hard id Normal file
View File

@ -0,0 +1,268 @@
commit c14da42ce5e3a1ce49d73681df28e66982dedba2 (HEAD -> main)
Author: fengerli <528575642@qq.com>
Date: Mon Nov 17 08:55:48 2025 +0800
210页面开发
commit dadad6ed194f88dceff90dcaa6c20d6513bf0282 (origin/main, origin/HEAD)
Author: fengerli <528575642@qq.com>
Date: Wed Nov 12 09:51:35 2025 +0800
添加token过期跳转到登录页
commit 426fdeddee783a8a551d683fb88d6ce2d6a9b9a1
Merge: 968d7a6 f835e25
Author: fengerli <528575642@qq.com>
Date: Sat Nov 8 10:33:20 2025 +0800
Merge branch 'main' of http://47.107.152.87:3000/dyf/APP
commit 968d7a613dfa6c8be53520c99c01d1a889110b13
Author: fengerli <528575642@qq.com>
Date: Sat Nov 8 10:33:00 2025 +0800
6075页面功能开发
commit f835e25bbb7497f6545713cade4b032de17e11d1
Merge: b8ce162 012eca6
Author: dyf <974332738@qq.com>
Date: Sat Nov 8 10:32:38 2025 +0800
Merge pull request 'new-20250827 一些小优化' (#22) from liubiao/APP:new-20250827 into main
Reviewed-on: http://47.107.152.87:3000/dyf/APP/pulls/22
commit 012eca69853acd92a2bab85721ed99c85e0b7969
Merge: 623a474 b8ce162
Author: liub <itliubiao@qq.com>
Date: Fri Nov 7 13:08:05 2025 +0800
Merge branch 'new-20250827' of http://47.107.152.87:3000/liubiao/APP into new-20250827
# Conflicts:
# pages.json
# pages/100/HBY100.vue
# pages/6075/BJQ6075.vue
# pages/7305/BJQ7305.vue
# utils/BleReceive.js
commit 623a47466a6fef7c3fe40cfe5c1d52f85ac8d478
Author: liub <itliubiao@qq.com>
Date: Fri Nov 7 12:16:10 2025 +0800
合并线上代码
commit 2493bb7113fd21e64836ed912ff9ff72ed0fcd1e
Author: liub <itliubiao@qq.com>
Date: Fri Nov 7 11:57:35 2025 +0800
完成100
commit b8ce1621b45e40c3ff14d5d0ddaed3b362526d58
Merge: c81a4d1 27d212e
Author: fengerli <528575642@qq.com>
Date: Thu Nov 6 08:47:45 2025 +0800
Merge branch 'main' of http://47.107.152.87:3000/dyf/APP
commit c81a4d1903eb32ed784b97e33d29076e46fb1531
Author: fengerli <528575642@qq.com>
Date: Thu Nov 6 08:46:27 2025 +0800
6075设备控制页
commit 27d212e7dc9dcf61f361bd633482d5f26cde4886
Author: 微微一笑 <709648985@qq.com>
Date: Wed Nov 5 19:18:05 2025 +0800
继续优化7305
commit 9037ef6ac31cfdcbe273c47ed79b75bfccbf2877
Merge: a30a631 2b72cc1
Author: 微微一笑 <709648985@qq.com>
Date: Wed Nov 5 11:17:11 2025 +0800
Merge branch 'main' of http://47.107.152.87:3000/dyf/APP
commit a30a631ea647b0a0615e0c78d06de90f872d4990
Author: 微微一笑 <709648985@qq.com>
Date: Wed Nov 5 11:17:08 2025 +0800
改成13*13符合设备端
commit 2b72cc1a5cbe2a9e5923a262ea6cafe0413cbc1c
Merge: 77be45f a0c883f
Author: fengerli <528575642@qq.com>
Date: Wed Nov 5 11:13:35 2025 +0800
Merge branch 'main' of http://47.107.152.87:3000/dyf/APP
commit 77be45f1f3bf43dd7c5184a6ba196da7d5a92a02
Author: fengerli <528575642@qq.com>
Date: Wed Nov 5 11:13:32 2025 +0800
6075
commit a0c883f4e3dfafa6805090eaebaffec811f50aec
Author: 微微一笑 <709648985@qq.com>
Date: Wed Nov 5 10:22:17 2025 +0800
优化蓝牙连接7305同步状态
commit 9313ec01060e32c7160f61e6a557ed53a4277e86
Merge: ca6345e d06cd6c
Author: fengerli <528575642@qq.com>
Date: Wed Nov 5 08:48:15 2025 +0800
Merge branch 'main' of http://47.107.152.87:3000/dyf/APP
commit ca6345ee3e8572415e1c3454f4fe9f696da8c303
Author: fengerli <528575642@qq.com>
Date: Wed Nov 5 08:48:13 2025 +0800
6075页面开发
commit d06cd6cdfdf94321f5257891a85516b066ff8014
Author: 微微一笑 <709648985@qq.com>
Date: Tue Nov 4 19:30:47 2025 +0800
修复复杂字体渲染设备端乱序问题
commit 2218ca06501de44ad9ffdb7fbbb09d0733a5ba9e
Author: 微微一笑 <709648985@qq.com>
Date: Sat Nov 1 17:32:03 2025 +0800
修改输入框文本
commit 500b461bdd86a7c352e11af1e4827f9f1bb33ebb
Author: 微微一笑 <709648985@qq.com>
Date: Sat Nov 1 17:21:45 2025 +0800
修复7305设备上报问题
commit 3526f28d067bbcfb1f91bd2f86faa478f5f23794
Author: 微微一笑 <709648985@qq.com>
Date: Fri Oct 31 15:35:03 2025 +0800
修复蓝牙传输数据
commit 3eeffdb62c82e61a3de86766e4ac1c075bf28287
Merge: 317c762 bd56ca9
Author: fengerli <528575642@qq.com>
Date: Fri Oct 31 11:15:39 2025 +0800
Merge branch 'liubiao-new-20250827'
commit 317c762edc62551c2045415b0f4e598b0772a622
Author: fengerli <528575642@qq.com>
Date: Fri Oct 31 11:13:07 2025 +0800
7305文件报错
commit c39cbcb34d1929b2abb177f59538aaaae34dd292
Author: liub <itliubiao@qq.com>
Date: Thu Oct 30 11:10:57 2025 +0800
蓝牙开始、结束搜索添加状态判定
commit bd56ca997bb95078cf9b1ff7e32791af34dc3670 (liubiao-new-20250827)
Author: liub <itliubiao@qq.com>
Date: Mon Oct 27 13:00:34 2025 +0800
修复7305标签未闭合问题
commit cf60414d7686194f35f41e6f1cf1dfe8f6e89765
Author: liub <itliubiao@qq.com>
Date: Mon Oct 27 11:51:38 2025 +0800
蓝牙断开连接变成异步操作
commit 61ed91695f15decff77a9fec9d7af3f7fae0226a
Author: liub <itliubiao@qq.com>
Date: Mon Oct 27 10:52:17 2025 +0800
蓝牙模块添加在web平台默认成功方便调试功能,4877功能完成
commit d37ccfeabc9324872b686eb581ce33246fc1bb5d
Author: liub <itliubiao@qq.com>
Date: Fri Oct 24 17:21:18 2025 +0800
完成BJQ4877功能开发
commit 0909d9f023c6e3db7d65c025954b2626d6f1615f
Merge: 1d8b3b4 b20a93d
Author: liubiao <3909916335@qq.com>
Date: Fri Oct 24 11:46:02 2025 +0800
merge upstream
commit b20a93dd2854fef472eca51fd2a2934cba43ec59
Author: 微微一笑 <709648985@qq.com>
Date: Fri Oct 24 11:42:56 2025 +0800
修复传输时序问题
commit 1d8b3b4a9a7ed1030ce97b1ebb9121e1ceed365a
Merge: a5c6faa fa64e7f
Author: liub <itliubiao@qq.com>
Date: Fri Oct 24 11:08:32 2025 +0800
修复蓝牙设备6155/7305全局弹窗与详情弹窗重复出现的问题
# Conflicts:
# pages/7305/BJQ7305.vue
commit a5c6faa9dac8cadbaf6ea9d745e43bca9d48395c
Author: liub <itliubiao@qq.com>
Date: Fri Oct 24 11:04:36 2025 +0800
* 修复蓝牙设备6155/7305全局弹窗与详情弹窗重复出现的问题
* 修复蓝牙设备6155/7305全局弹窗与详情弹窗重复出现的问题
* 修复蓝牙设备6155/7305全局弹窗与详情弹窗重复出现的问题
* 修复蓝牙设备6155/7305全局弹窗与详情弹窗重复出现的问题
* 修复蓝牙设备6155/7305全局弹窗与详情弹窗重复出现的问题
* 修复蓝牙设备6155/7305全局弹窗与详情弹窗重复出现的问题
* 修复蓝牙设备6155/7305全局弹窗与详情弹窗重复出现的问题
* 修复蓝牙设备6155/7305全局弹窗与详情弹窗重复出现的问题
修复蓝牙设备6155/7305全局弹窗与详情弹窗重复出现的问题
commit 15ba241317a9ecc46bbb7022b4ec3638bfa00a4e
Author: liub <itliubiao@qq.com>
Date: Fri Oct 24 11:00:35 2025 +0800
修复蓝牙设备6155/7305全局弹窗与详情弹窗重复出现的问题
commit fa64e7f1fc9eb4b24e9bf6eab269e718299aabce
Merge: 0033649 1de958d
Author: liubiao <3909916335@qq.com>
Date: Fri Oct 24 10:57:08 2025 +0800
merge upstream
commit 45328120c1b552b483b325cad2511ab274305006
Author: liub <itliubiao@qq.com>
Date: Fri Oct 24 10:56:37 2025 +0800
修复6155/7305全局订阅与详情订阅重复弹窗
commit 1de958df20014e6a858d1a0da9e277766518c96c
Author: 微微一笑 <709648985@qq.com>
Date: Fri Oct 24 10:29:46 2025 +0800
修复优化7305设备屏幕点阵取模兼容设备端填坑
commit 0033649677964eb94ea930ba76f5f1a9020cffa3
Author: liub <itliubiao@qq.com>
Date: Thu Oct 23 16:36:48 2025 +0800
修改蓝牙接收数据处理逻辑改成配置式避免if无限增多
commit 738ce209a60

View File

@ -39,15 +39,24 @@
<!-- 设备基本信息 -->
<view class="info-card">
<view class="info-row">
<text class="info-label">设备状态</text>
<text class="info-label">设备名称</text>
<text class="info-value status-running">运行中</text>
</view>
<view class="info-row">
<text class="info-label">蓝牙名称</text>
<text class="info-value status-running">FB-Site_02</text>
</view>
<view class="info-row">
<text class="info-label">蓝牙状态</text>
<text class="info-value status-running">未连接</text>
</view>
<view class="hr"></view>
<view class="info-row">
<text class="info-label">联机状态</text>
<text class="info-value status-greend">联机</text>
</view>
<view class="info-row">
<text class="info-label">定位信</text>
<text class="info-label">定位信</text>
<view class="info-value status-running" @click="gpsPosition">
<view class="info-value status-running">114.72 30.28</view>
<view class="info-value status-running">
@ -69,63 +78,6 @@
</view>
</view>
</view>
<!-- 灯光模式选择 -->
<!-- <view class="mode-section">
<view class="mode-buttons">
<view class="mode-v1">
<view class="mode-v2" @click="selectMode">
<image src="/static/images/210/lj.png" class="setIMG"></image>
<view>
<view class="battery-v2">联机设备</view>
</view>
</view>
</view>
<view class="mode-v1">
<view class="mode-v2" @click="uploadStartup">
<image src="/static/images/common/path7.png" class="setIMG" mode="aspectFit"></image>
<view>
<view class="battery-v2">开机画面</view>
<view class="mode-v3">上传</view>
</view>
</view>
</view>
<view class="mode-v1">
<view class="mode-v2" @click="automaticAlarm">
<image src="/static/images/210/zd.png" class="setIMG" mode="aspectFit"></image>
<view>
<view class="battery-v2">自动报警</view>
</view>
</view>
</view>
<view class="mode-v1">
<view class="mode-v2" @click="anualAlarm">
<image src="/static/images/210/zd-HL.png" class="setIMG" mode="aspectFit"></image>
<view>
<view class="battery-v2">手动报警</view>
</view>
</view>
</view>
<view class="mode-v1">
<view class="mode-v2">
<image src="/static/images/210/bj.png" class="setIMG" mode="aspectFit"></image>
<view>
<view class="battery-v2">报警声音</view>
<view class="mode-v3">上传</view>
</view>
</view>
</view>
<view class="mode-v1">
<view class="mode-v2" @click="alarmTime">
<image src="/static/images/210/time.png" class="setIMG" mode="aspectFit"></image>
<view>
<view class="battery-v2">报警时长</view>
<view class="mode-v3">{{alarmTimeDisplay }}</view>
</view>
</view>
</view>
</view>
</view> -->
<view class="mode-section">
<view class="mode-buttons">
<view v-for="(item, index) in modeItems" :key="index" class="mode-v1"
@ -240,119 +192,15 @@
</view>
</view>
<!-- ======各个弹框类型======= -->
<CustomPopup :show="currentPopup.show" ="currentPopup.config" @confirm="handleConfirm"
@cancel="handleCancel" />
<CustomPopupTXT :show="currentPopup.show" v-bind="currentPopup.config" @confirm="handleConfirm"
@cancel="handleCancel" class="custom-popup-txt" />
</view>
</view>
</template>
<script>
// 弹框配置中心
const POPUP_CONFIGS = {
// 人员信息发送
person: {
config: {
icon: '/static/images/common/sendSucc.png',
message: '信息发送成功',
showCancel: false
},
confirm() {
return true; // 直接关闭
}
import CustomPopupTXT from '@/components/CustomPopup/CustomPopup.vue'
},
// 上传开机log
logo: {
config: {
icon: '/static/images/common/upload.png',
message: '上传成功',
showCancel: false
},
confirm() {
return true; // 直接关闭
}
},
// 电量低于20%.提示框
bettery: {
config: {
title: '设备电量低于20%',
titleColor: 'rgba(224, 52, 52, 1)',
message: '请及时充电',
icon: '/static/images/common/path.png',
popupBorder: '1rpx solid rgba(224, 52, 52, 0.3)',
confirmBtnBg: 'rgba(224, 52, 52, 1)',
showCancel: true
},
confirm() {
return true; // 直接关闭
}
},
// 解除报警关闭的那个提示
cancel: {
config: {
titleColor: 'rgba(224, 52, 52, 1)',
icon: '/static/images/6170/svg.png',
popupBorder: '1rpx solid rgba(224, 52, 52, 0.3)',
confirmBtnBg: 'rgba(224, 52, 52, 1)',
showCancel: true //取消按钮
},
confirm() {
console.log('解除报警确认');
}
},
// 手动报警弹框
del: {
config: {
message: '确定开启报警?',
icon: '/static/images/210/bj_1.png',
popupBorder: '1rpx solid rgba(255, 200, 78, 1)',
confirmBtnBg: 'rgba(255, 200, 78, 1)',
showCancel: true
},
confirm() {
return 'alarmCountdown'; //点击确认,再次弹框,解除报警,再次报警的类型
}
},
// 手动报警再次弹框 再次报警,解除报警指令
alarmCountdown: {
config: {
title: '报警倒计时',
icon: '/static/images/6170/svg.png',
message: '59秒',
popupBorder: '1rpx solid rgba(224, 52, 52, 1)',
confirmBtnBg: 'rgba(224, 52, 52, 1)',
cancelBtnColor:"rgba(224, 52, 52, 1)",
confirmBtnColor:"rgba(255, 255, 255, 0.87)",
confirmText: '解除报警',
cancelText:"再次报警",
showCancel: true //取消按钮
},
confirm() {
console.log('解除报警确认');
}
},
// 自动报警
autoAlarm: {
config: {
icon: '/static/images/6170/svg.png',
title: '报警信息',
message: '002号设备(ID:123456)\n出现报警', // 使用\n换行
showCountdown: true,
countdownTime: 59,
confirmText: '解除报警',
popupBorder: '1rpx solid rgba(224, 52, 52, 0.3)',
confirmBtnBg: 'rgba(224, 52, 52, 1)',
confirmBtnColor: "rgba(255, 255, 255, 0.87)",
showCancel: false,
},
confirm() {
console.log('自动报警解除报警的弹框');
}
}
}
import MqttClient from '@/utils/mqtt.js';
import {
deviceDetail,
@ -372,6 +220,9 @@
clientid
} from '@/utils/request'
export default {
components: {
CustomPopupTXT
},
data() {
return {
selectedIndex: -1, // Track currently selected index
@ -381,8 +232,8 @@
subTitle: ""
},
{
image: "/static/images/common/path7.png",
title: "开机画面",
image: "/static/images/210/bj.png",
title: "报警声音",
subTitle: "上传"
},
{
@ -396,8 +247,8 @@
subTitle: ""
},
{
image: "/static/images/210/bj.png",
title: "报警声音",
image: "/static/images/common/path7.png",
title: "开机画面",
subTitle: "上传"
},
{
@ -449,6 +300,118 @@
radioSelected: 0, // -1表示未选中任何项
deviceType: '',
popupType: '', //弹框类型
// 弹框配置中心
POPUP_CONFIGS: {
// 人员信息发送
person: {
config: {
icon: '/static/images/common/sendSucc.png',
message: '信息发送成功',
showCancel: false
},
confirm() {
return true; // 直接关闭
}
},
// 上传开机log
logo: {
config: {
icon: '/static/images/common/upload.png',
message: '上传成功',
showCancel: false
},
confirm() {
return true; // 直接关闭
}
},
// 电量低于20%.提示框
bettery: {
config: {
show: true, // 必须显式设置为true
showIcon: true, // 显示图标
title: '设备电量低于20%',
titleColor: 'rgba(224, 52, 52, 1)',
message: '请及时充电',
icon: '/static/images/common/path.png',
popupBorder: '1rpx solid rgba(224, 52, 52, 0.3)',
confirmBtnBg: 'rgba(224, 52, 52, 1)',
showCancel: true
},
confirm() {
return true; // 直接关闭
}
},
// 解除报警关闭的那个提示
cancel: {
config: {
show: true, // 必须显式设置为true
showIcon: true, // 显示图标
titleColor: 'rgba(224, 52, 52, 1)',
icon: '/static/images/6170/svg.png',
popupBorder: '1rpx solid rgba(224, 52, 52, 0.3)',
confirmBtnBg: 'rgba(224, 52, 52, 1)',
showCancel: true //取消按钮
},
confirm() {
console.log('解除报警确认');
}
},
// 手动报警弹框
del: {
config: {
show: true, // 必须显式设置为true
showIcon: true, // 显示图标
message: '确定开启报警?',
icon: '/static/images/210/bj_1.png',
popupBorder: '1rpx solid rgba(255, 200, 78, 1)',
confirmBtnBg: 'rgba(255, 200, 78, 1)',
showCancel: true
},
confirm() {
return 'alarmCountdown'; //点击确认,再次弹框,解除报警,再次报警的类型
}
},
// 手动报警再次弹框 再次报警,解除报警指令
alarmCountdown: {
config: {
show: true, // 必须显式设置为true
showIcon: true, // 显示图标
title: '报警倒计时',
icon: '/static/images/6170/svg.png',
message: '59秒',
popupBorder: '1rpx solid rgba(224, 52, 52, 1)',
confirmBtnBg: 'rgba(224, 52, 52, 1)',
cancelBtnColor: "rgba(224, 52, 52, 1)",
confirmBtnColor: "rgba(255, 255, 255, 0.87)",
confirmText: '解除报警',
cancelText: "再次报警",
showCancel: true //取消按钮
},
confirm() {
console.log('解除报警确认');
}
},
// 自动报警
autoAlarm: {
config: {
show: true, // 必须显式设置为true
showIcon: true, // 显示图标
icon: '/static/images/6170/svg.png',
title: '报警信息',
message: '002号设备(ID:123456)\n出现报警', // 使用\n换行
showCountdown: true,
countdownTime: 59,
confirmText: '解除报警',
popupBorder: '1rpx solid rgba(224, 52, 52, 0.3)',
confirmBtnBg: 'rgba(224, 52, 52, 1)',
confirmBtnColor: "rgba(255, 255, 255, 0.87)",
showCancel: false,
},
confirm() {
console.log('自动报警解除报警的弹框');
}
}
}
}
},
methods: {
@ -461,17 +424,18 @@
showPopup(type) {
this.currentPopup = {
show: true,
config: POPUP_CONFIGS[type].config,
callback: POPUP_CONFIGS[type].confirm
config: this.POPUP_CONFIGS[type].config,
callback: this.POPUP_CONFIGS[type].confirm
}
console.log(type, 'typetype');
},
handleConfirm() {
if (this.currentPopup.callback) {
const nextPopupType = this.currentPopup.callback(); // 执行回调并获取下一个弹框类型
this.currentPopup.show = false; // 关闭当前弹框
if (nextPopupType) {
this.showPopup(nextPopupType); // 打开下一个弹框
}
const nextPopupType = this.currentPopup.callback(); // 执行回调并获取下一个弹框类型
this.currentPopup.show = false; // 关闭当前弹框
if (nextPopupType) {
this.showPopup(nextPopupType); // 打开下一个弹框
}
} else {
this.currentPopup.show = false; // 默认关闭
}
@ -486,8 +450,8 @@
case 0:
this.selectMode();
break;
case 1:
this.uploadStartup();
case 1: // 报警声音
this.soundAlarm();
break;
case 2:
this.automaticAlarm();
@ -495,6 +459,9 @@
case 3:
this.manualAlarm();
break;
case 4:
this.uploadStartup();
break;
case 5:
this.alarmTime();
break;
@ -507,6 +474,10 @@
handleRadioSelect(index) {
this.radioSelected = index;
console.log('选中了单选选项:', this.radioList[index]);
},
// 报警声音
soundAlarm() {
},
// 自动报警
automaticAlarm() {
@ -1047,6 +1018,11 @@
margin-bottom: 20rpx;
}
.hr {
border-bottom: 2rpx solid rgba(255, 255, 255, 0.04);
margin-bottom: 10rpx;
}
.info-label {
font-size: 28rpx;
color: rgba(255, 255, 255, 0.87);

View File

@ -35,7 +35,13 @@
<view>
</view>
</view>
<view class="callpolice">
<view class="">设备疑似受到外力碰撞</view>
<view>
<uni-icons type="closeempty" size="15" color="rgba(255, 255, 255, 0.9)"
></uni-icons>
</view>
</view>
<!-- 设备基本信息 -->
<view class="info-card">
<view class="info-row">
@ -44,13 +50,16 @@
</view>
<view class="info-row">
<text class="info-label">设备状态</text>
<text class="info-value status-running">{{ deviceInfo.onlineStatus === 0 ? '离线' : deviceInfo.onlineStatus === 2 ? '故障' : '在线' }}</text>
<text
class="info-value status-running">{{ deviceInfo.onlineStatus === 0 ? '离线' : deviceInfo.onlineStatus === 2 ? '故障' : '在线' }}</text>
</view>
<view class="info-row">
<text class="info-label">定位信息</text>
<view class="info-value status-running" @click="gpsPosition">
<view class="info-value status-running"> {{ deviceInfo && deviceInfo.longitude ? Number(deviceInfo.longitude).toFixed(4) : '' }}
{{ deviceInfo && deviceInfo.latitude ? Number(deviceInfo.latitude).toFixed(4) : '' }}</view>
<view class="info-value status-running">
{{ deviceInfo && deviceInfo.longitude ? Number(deviceInfo.longitude).toFixed(4) : '' }}
{{ deviceInfo && deviceInfo.latitude ? Number(deviceInfo.latitude).toFixed(4) : '' }}
</view>
<view class="info-value status-running">
<uni-icons @click="toggleForm" type="location" size="17"
color="rgba(255, 255, 255, 0.8)" style="vertical-align: bottom;" />
@ -293,7 +302,7 @@
icon: '/static/images/210/bj_1.png',
message: '确定开启设备声光报警?',
confirmBtnBg: 'rgba(255, 200, 78, 1)',
popupBorder:'1rpx solid rgba(255, 200, 78, 0.3)',
popupBorder: '1rpx solid rgba(255, 200, 78, 0.3)',
showCancel: true
},
confirm() {
@ -308,8 +317,10 @@
registerPersonInfo,
deviceSendMessage,
deviceShareId,
lightModeSettings, //灯模式设置
lightModeSettings, //灯模式设置
auxiliaryLightModeSettings, //辅灯模式
laserModeSettings, //激光模式设置
salaModeSettings, //声光报警
mapReverseGeocoding //地图逆解析
} from '@/api/6075/6075.js'
import {
@ -361,10 +372,10 @@
selectedImage: null, // 添加这个变量来存储选择的图片
file: '',
selectedItemIndex: 0,
radioList: ['M', 'S'],
radioSelected: 0, // -1表示未选中任何项
deviceType: '',
popupType: '', //弹框类型
pendingMainMode: null, // 选中的索引
items: [],
}
},
computed: {
@ -424,19 +435,53 @@
url: '/pages/common/map/index'
})
},
// 激光模式
lasermode() {
this.lightModeC = true
},
// 声光报警
audible() {
this.showPopup('audibleAlarm');
},
// 激光模式
lasermode() {
this.lightModeC = true;
},
// 激光确认框提交
handleBtn() {
if (this.deviceInfo.onlineStatus !== 1) {
uni.showToast({
title: '设备已离线',
icon: 'none'
});
return;
}
const instructValue = this.isLaserOn ? 0 : 1;
let data = {
deviceId: this.computedDeviceId,
instructValue: instructValue,
deviceImei: this.itemInfo.deviceImei,
typeName: this.itemInfo.typeName,
};
laserModeSettings(data).then((res) => {
if (res.code == 200) {
uni.showToast({
icon: 'none',
title: res.msg
});
// 更新状态
this.isLaserOn = !this.isLaserOn;
this.currentlaserMode = this.isLaserOn ? "开启" : "关闭";
this.lightModeC = false;
} else {
uni.showToast({
title: res.msg,
icon: 'none'
});
}
})
},
//激光取消
handleDisagree() {
this.lightModeC = false
},
// 取消按钮
handleBtn() {
handleDisagree() {
this.lightModeC = false
},
// 主灯模式
@ -531,7 +576,6 @@
this.isFormExpanded = !this.isFormExpanded;
},
onItemClick(index) {
console.log(index, 'index');
const item = this.items[index];
this.selectedItemIndex = index;
this.items = this.items.map((item, i) => ({
@ -539,14 +583,73 @@
selected: i === index
}));
this.pendingMainMode = item.text;
// 主灯
this.currentMainMode = item.text;
// 辅灯
this.currentSubMode = item.text;
console.log(this.pendingMainMode, 'this.pendingMainModethis.pendingMainMode');
},
// 灯光模式的确认
handleSumbit() {
if (this.deviceInfo.onlineStatus !== 1) {
uni.showToast({
title: '设备已离线',
icon: 'none'
});
return;
}
if (this.popupTitle == '主灯模式') {
if (this.selectedItemIndex === null) return;
const selectedItem = this.items[this.selectedItemIndex];
let data = {
deviceId: this.computedDeviceId,
instructValue: selectedItem.instructValue,
deviceImei: this.itemInfo.deviceImei,
typeName: this.itemInfo.typeName,
};
lightModeSettings(data).then((res) => {
if (res.code == 200) {
this.currentMainMode = this.pendingMainMode;
this.selectedItemIndex = selectedItem;
uni.showToast({
title: res.msg,
icon: 'none'
})
uni.hideLoading();
this.lightModeA = false;
} else {
uni.showToast({
title: res.msg,
icon: 'none'
})
uni.hideLoading();
}
})
} else {
if (this.selectedItemIndex === null) return;
const selectedItem = this.items[this.selectedItemIndex];
let data = {
deviceId: this.computedDeviceId,
instructValue: selectedItem.instructValue,
deviceImei: this.itemInfo.deviceImei,
typeName: this.itemInfo.typeName,
};
auxiliaryLightModeSettings(data).then((res) => {
if (res.code == 200) {
this.currentSubMode = this.pendingMainMode;
this.selectedItemIndex = selectedItem;
uni.showToast({
title: res.msg,
icon: 'none'
})
uni.hideLoading();
this.lightModeA = false;
} else {
uni.showToast({
title: res.msg,
icon: 'none'
})
uni.hideLoading();
}
})
}
this.lightModeA = false
},
// 上传开机画面
@ -605,7 +708,7 @@
});
uni.uploadFile({
url: baseURL + '/app/device/uploadLogo',
url: baseURL + '/app/bjq6075/device/uploadLogo',
filePath: this.selectedImage,
name: 'file',
formData: {
@ -1136,7 +1239,17 @@
margin-left: 40rpx;
}
.callpolice {
display: flex;
justify-content: space-between;
border-radius: 16rpx;
background: rgba(224, 52, 52, 1);
padding: 15rpx;
margin-bottom: 15rpx;
color: #fff;
line-height: 35rpx;
font-size: 26rpx;
}
.example-body {
position: absolute;
left: 50%;

View File

@ -536,6 +536,7 @@
},
// 灯光模式的确认
handleSumbit() {
if (this.deviceInfo.onlineStatus !== 1) {
uni.showToast({
title: '设备已离线',

View File

@ -2,51 +2,69 @@ import config from '../config/index.js';
export const env = 'development'; //production development //开发of线上 改这里就行
const BASE = config[env];
const request = (options) => {
console.log("options"+JSON.stringify(options),BASE.BASE_URL)
return new Promise((resolve, reject) => {
// 处理GET请求参数
let url = BASE.BASE_URL + options.url;
console.log("url"+url)
if (options.method === 'GET' && options.data) {
// 使用qs序列化参数
const params = Object.keys(options.data)
.map(key => `${encodeURIComponent(key)}=${encodeURIComponent(options.data[key])}`)
.join('&');
url += `?${params}`;
}
console.log("options" + JSON.stringify(options), BASE.BASE_URL)
return new Promise((resolve, reject) => {
// 处理GET请求参数
let url = BASE.BASE_URL + options.url;
console.log("url" + url)
if (options.method === 'GET' && options.data) {
// 使用qs序列化参数
const params = Object.keys(options.data)
.map(key => `${encodeURIComponent(key)}=${encodeURIComponent(options.data[key])}`)
.join('&');
url += `?${params}`;
}
const config = {
url: url,
method: options.method || 'GET',
data: options.method !== 'GET' ? options.data : {},
header: options.header || {},
timeout: 30000,
success: (res) => {
// console.log("res=",res);
resolve(res.data);
},
fail: (err) => {
console.log("ex=",err);
reject(err);
}
};
const config = {
url: url,
method: options.method || 'GET',
data: options.method !== 'GET' ? options.data : {},
header: options.header || {},
timeout: 30000,
success: (res) => {
console.log(res, 'resss');
if (res.data.code === 401) {
uni.removeStorageSync('token');
uni.removeStorageSync('clientID');
uni.showToast({
title: '登录已过期,请重新登录',
icon: 'none',
duration: 2000,
complete: () => {
setTimeout(() => {
uni.reLaunch({
url: '/pages/common/login/index'
});
}, 3000);
}
});
// 返回一个pending的Promise中断当前的Promise链
return new Promise(() => { });
}
resolve(res.data);
},
fail: (err) => {
console.log("ex=", err);
reject(err);
}
};
if (!options.url.includes('/login')) {
const token = uni.getStorageSync('token');
const clientid = uni.getStorageSync('clientID');
if (token) {
config.header['Authorization'] = 'Bearer ' + token;
config.header['clientid'] = clientid;
}
}
if (!config.header['Content-Type']) {
config.header['Content-Type'] = 'application/json';
}
uni.request(config);
});
if (!options.url.includes('/login')) {
const token = uni.getStorageSync('token');
const clientid = uni.getStorageSync('clientID');
if (token) {
config.header['Authorization'] = 'Bearer ' + token;
config.header['clientid'] = clientid;
}
}
if (!config.header['Content-Type']) {
config.header['Content-Type'] = 'application/json';
}
uni.request(config);
});
};
// 导出基础URL以便其他地方使用
export const baseURL = BASE.BASE_URL;
export const getToken = () => uni.getStorageSync('token'); // 获取token的方法
export const clientid =() => uni.getStorageSync('clientID');
export const clientid = () => uni.getStorageSync('clientID');
export default request;