From dadad6ed194f88dceff90dcaa6c20d6513bf0282 Mon Sep 17 00:00:00 2001 From: fengerli <528575642@qq.com> Date: Wed, 12 Nov 2025 09:51:35 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E6=B7=BB=E5=8A=A0token=E8=BF=87=E6=9C=9F?= =?UTF-8?q?=EF=BC=8C=E8=B7=B3=E8=BD=AC=E5=88=B0=E7=99=BB=E5=BD=95=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/6075/6075.js | 20 +++- pages/210/deviceControl/index.vue | 7 +- pages/6075/BJQ6075.vue | 155 +++++++++++++++++++++++++---- pages/6170/deviceControl/index.vue | 1 + utils/request.js | 102 +++++++++++-------- 5 files changed, 217 insertions(+), 68 deletions(-) diff --git a/api/6075/6075.js b/api/6075/6075.js index 2c20546..63540cf 100644 --- a/api/6075/6075.js +++ b/api/6075/6075.js @@ -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({ diff --git a/pages/210/deviceControl/index.vue b/pages/210/deviceControl/index.vue index 80f02b9..80be925 100644 --- a/pages/210/deviceControl/index.vue +++ b/pages/210/deviceControl/index.vue @@ -238,10 +238,11 @@ + + - - + diff --git a/pages/6075/BJQ6075.vue b/pages/6075/BJQ6075.vue index 146bf60..6acfe98 100644 --- a/pages/6075/BJQ6075.vue +++ b/pages/6075/BJQ6075.vue @@ -35,7 +35,13 @@ - + + 设备疑似受到外力碰撞! + + + + @@ -44,13 +50,16 @@ 设备状态 - {{ deviceInfo.onlineStatus === 0 ? '离线' : deviceInfo.onlineStatus === 2 ? '故障' : '在线' }} + {{ deviceInfo.onlineStatus === 0 ? '离线' : deviceInfo.onlineStatus === 2 ? '故障' : '在线' }} 定位信息 - {{ deviceInfo && deviceInfo.longitude ? Number(deviceInfo.longitude).toFixed(4) : '' }} - {{ deviceInfo && deviceInfo.latitude ? Number(deviceInfo.latitude).toFixed(4) : '' }} + + {{ deviceInfo && deviceInfo.longitude ? Number(deviceInfo.longitude).toFixed(4) : '' }} + {{ deviceInfo && deviceInfo.latitude ? Number(deviceInfo.latitude).toFixed(4) : '' }} + @@ -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%; diff --git a/pages/6170/deviceControl/index.vue b/pages/6170/deviceControl/index.vue index 4e84187..0c2ab74 100644 --- a/pages/6170/deviceControl/index.vue +++ b/pages/6170/deviceControl/index.vue @@ -536,6 +536,7 @@ }, // 灯光模式的确认 handleSumbit() { + if (this.deviceInfo.onlineStatus !== 1) { uni.showToast({ title: '设备已离线', diff --git a/utils/request.js b/utils/request.js index 681b921..a25cc90 100644 --- a/utils/request.js +++ b/utils/request.js @@ -2,51 +2,69 @@ import config from '../config/index.js'; export const env = 'production'; //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 default request; +export const clientid = () => uni.getStorageSync('clientID'); +export default request; \ No newline at end of file From 04083446e705be1dd97f546c37b9911b42c45474 Mon Sep 17 00:00:00 2001 From: fengerli <528575642@qq.com> Date: Mon, 17 Nov 2025 09:06:03 +0800 Subject: [PATCH 2/4] 1 --- et --hard id | 268 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 268 insertions(+) create mode 100644 et --hard id diff --git a/et --hard id b/et --hard id new file mode 100644 index 0000000..ef19f9c --- /dev/null +++ b/et --hard id @@ -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 +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 +Date: Fri Nov 7 12:16:10 2025 +0800 + + 合并线上代码 + +commit 2493bb7113fd21e64836ed912ff9ff72ed0fcd1e +Author: liub +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 +Date: Thu Oct 30 11:10:57 2025 +0800 + + 蓝牙开始、结束搜索添加状态判定 + +commit bd56ca997bb95078cf9b1ff7e32791af34dc3670 (liubiao-new-20250827) +Author: liub +Date: Mon Oct 27 13:00:34 2025 +0800 + + 修复7305标签未闭合问题 + +commit cf60414d7686194f35f41e6f1cf1dfe8f6e89765 +Author: liub +Date: Mon Oct 27 11:51:38 2025 +0800 + + 蓝牙断开连接变成异步操作 + +commit 61ed91695f15decff77a9fec9d7af3f7fae0226a +Author: liub +Date: Mon Oct 27 10:52:17 2025 +0800 + + 蓝牙模块添加在web平台默认成功方便调试功能,4877功能完成 + +commit d37ccfeabc9324872b686eb581ce33246fc1bb5d +Author: liub +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 +Date: Fri Oct 24 11:08:32 2025 +0800 + + 修复蓝牙设备6155/7305全局弹窗与详情弹窗重复出现的问题 + + # Conflicts: + # pages/7305/BJQ7305.vue + +commit a5c6faa9dac8cadbaf6ea9d745e43bca9d48395c +Author: liub +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 +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 +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 +Date: Thu Oct 23 16:36:48 2025 +0800 + + 修改蓝牙接收数据处理逻辑,改成配置式,避免if无限增多 + +commit 738ce209a60 \ No newline at end of file From c8ea753b8e2050d5280939ca5445454668959221 Mon Sep 17 00:00:00 2001 From: fengerli <528575642@qq.com> Date: Mon, 17 Nov 2025 09:29:05 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E6=81=A2=E5=A4=8D7305=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E5=86=B2=E7=AA=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../TextToHex/textToDotMatrixFor7305.vue | 198 ++++-------------- 1 file changed, 37 insertions(+), 161 deletions(-) diff --git a/components/TextToHex/textToDotMatrixFor7305.vue b/components/TextToHex/textToDotMatrixFor7305.vue index 307b03b..7160bf5 100644 --- a/components/TextToHex/textToDotMatrixFor7305.vue +++ b/components/TextToHex/textToDotMatrixFor7305.vue @@ -1,6 +1,6 @@ @@ -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列(右侧预留1px),12行(底部预留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; - } + const charHeight = 12; + const pixels = []; + for (let i = 0; i < imageData.length; i += 4) { + const R = imageData[i]; + pixels.push(R < 128 ? 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 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,22 +165,14 @@ }; 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; } @@ -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; } \ No newline at end of file From 1ba22c7aaeafd78501f83d53608ddbaa89dafff0 Mon Sep 17 00:00:00 2001 From: fengerli <528575642@qq.com> Date: Mon, 17 Nov 2025 10:20:54 +0800 Subject: [PATCH 4/4] =?UTF-8?q?210=E8=87=AA=E5=8A=A8=E6=8A=A5=E8=AD=A6?= =?UTF-8?q?=EF=BC=8C=E6=89=8B=E5=8A=A8=E6=8A=A5=E8=AD=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/210/deviceControl/index.vue | 337 ++++++++++++++---------------- 1 file changed, 156 insertions(+), 181 deletions(-) diff --git a/pages/210/deviceControl/index.vue b/pages/210/deviceControl/index.vue index 80be925..f6dce42 100644 --- a/pages/210/deviceControl/index.vue +++ b/pages/210/deviceControl/index.vue @@ -39,15 +39,24 @@ - 设备状态 + 设备名称 运行中 + + 蓝牙名称 + FB-Site_02 + + + 蓝牙状态 + 未连接 + + 联机状态 联机 - 定位信息 + 定位信 114.72 30.28 @@ -69,63 +78,6 @@ - - 确定 - - - + +