diff --git a/scripts/gen-tabbar-icons.cjs b/scripts/gen-tabbar-icons.cjs new file mode 100644 index 0000000..0469fb3 --- /dev/null +++ b/scripts/gen-tabbar-icons.cjs @@ -0,0 +1,243 @@ +/** + * 生成 uni-app 原生 tabBar 图标(81x81 PNG,RGBA) + * 输出: + * src/static/icon/home.png 首页-未选中 #555555 + * src/static/icon/home_a.png 首页-选中 #24afd6 + * src/static/icon/apps.png 应用-未选中 #555555 + * src/static/icon/apps_a.png 应用-选中 #24afd6 + * + * 用法:node scripts/gen-tabbar-icons.cjs + */ +const fs = require('fs'); +const path = require('path'); +const zlib = require('zlib'); + +const SIZE = 81; +const SS = 4; // 超采样倍数,用于抗锯齿 + +/* ---------------- PNG 编码 ---------------- */ + +const CRC_TABLE = (() => { + const table = new Int32Array(256); + for (let n = 0; n < 256; n++) { + let c = n; + for (let k = 0; k < 8; k++) { + c = c & 1 ? 0xedb88320 ^ (c >>> 1) : c >>> 1; + } + table[n] = c; + } + return table; +})(); + +function crc32(buf) { + let crc = -1; + for (let i = 0; i < buf.length; i++) { + crc = CRC_TABLE[(crc ^ buf[i]) & 0xff] ^ (crc >>> 8); + } + return (crc ^ -1) >>> 0; +} + +function chunk(type, data) { + const typeBuf = Buffer.from(type, 'ascii'); + const lenBuf = Buffer.alloc(4); + lenBuf.writeUInt32BE(data.length, 0); + const crcBuf = Buffer.alloc(4); + crcBuf.writeUInt32BE(crc32(Buffer.concat([typeBuf, data])), 0); + return Buffer.concat([lenBuf, typeBuf, data, crcBuf]); +} + +function encodePNG(width, height, rgba) { + const sig = Buffer.from([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]); + + const ihdr = Buffer.alloc(13); + ihdr.writeUInt32BE(width, 0); + ihdr.writeUInt32BE(height, 4); + ihdr[8] = 8; // bit depth + ihdr[9] = 6; // color type: RGBA + ihdr[10] = 0; // compression + ihdr[11] = 0; // filter + ihdr[12] = 0; // interlace + + const stride = width * 4; + const raw = Buffer.alloc((stride + 1) * height); + for (let y = 0; y < height; y++) { + raw[y * (stride + 1)] = 0; // filter: None + rgba.copy(raw, y * (stride + 1) + 1, y * stride, (y + 1) * stride); + } + + const idat = zlib.deflateSync(raw, { level: 9 }); + + return Buffer.concat([sig, chunk('IHDR', ihdr), chunk('IDAT', idat), chunk('IEND', Buffer.alloc(0))]); +} + +/* ---------------- 图形绘制(线条风格) ---------------- */ + +const STROKE_HALF = 3; // 线宽 6px 的一半(相对 7px 更柔和) + +function roundedRectSDF(px, py, cx, cy, halfW, halfH, radius) { + const qx = Math.abs(px - cx) - (halfW - radius); + const qy = Math.abs(py - cy) - (halfH - radius); + const outside = Math.hypot(Math.max(qx, 0), Math.max(qy, 0)); + const inside = Math.min(Math.max(qx, qy), 0); + return outside + inside - radius; +} + +// 圆角矩形描边(line style) +function roundedRectStroke(px, py, cx, cy, halfW, halfH, radius) { + return Math.abs(roundedRectSDF(px, py, cx, cy, halfW, halfH, radius)) <= STROKE_HALF; +} + +// 点到线段的距离(带圆头端点) +function segmentHit(px, py, x1, y1, x2, y2) { + const dx = x2 - x1; + const dy = y2 - y1; + const lenSq = dx * dx + dy * dy; + let t = lenSq === 0 ? 0 : ((px - x1) * dx + (py - y1) * dy) / lenSq; + t = Math.max(0, Math.min(1, t)); + const nx = x1 + t * dx; + const ny = y1 + t * dy; + return Math.hypot(px - nx, py - ny) <= STROKE_HALF; +} + +function polylineHit(x, y, points, closed = false) { + for (let i = 0; i < points.length - 1; i++) { + const [x1, y1] = points[i]; + const [x2, y2] = points[i + 1]; + if (segmentHit(x, y, x1, y1, x2, y2)) return true; + } + if (closed && points.length > 2) { + const [x1, y1] = points[points.length - 1]; + const [x2, y2] = points[0]; + if (segmentHit(x, y, x1, y1, x2, y2)) return true; + } + return false; +} + +// 首页:带飞檐的屋顶 + 墙体 + 拱形门(线条风格) +function homeHit(x, y) { + // 屋顶:两侧檐口略宽于墙体 + const apex = [40.5, 13]; + const eaveLeft = [11, 41]; + const eaveRight = [70, 41]; + const roof = [eaveLeft, apex, eaveRight]; + + // 墙体顶部落在屋顶斜线上,避免多出一条横线 + const wallLeft = 19; + const wallRight = 62; + const wallBottom = 73; + const slope = (apex[1] - eaveLeft[1]) / (apex[0] - eaveLeft[0]); + const wallTopY = apex[1] + (wallLeft - apex[0]) * slope; + const walls = [ + [wallLeft, wallTopY], + [wallLeft, wallBottom], + [wallRight, wallBottom], + [wallRight, wallTopY] + ]; + + // 拱形门:两侧竖线 + 上方半圆 + const doorHalf = 6.5; + const doorCenterX = (wallLeft + wallRight) / 2; + const doorTopY = 61.5; + const archSteps = 14; + const arch = []; + for (let i = 0; i <= archSteps; i++) { + const t = Math.PI - (Math.PI * i) / archSteps; + arch.push([doorCenterX + doorHalf * Math.cos(t), doorTopY - doorHalf * Math.sin(t)]); + } + const door = [[doorCenterX - doorHalf, wallBottom], ...arch, [doorCenterX + doorHalf, wallBottom]]; + + return polylineHit(x, y, roof) || polylineHit(x, y, walls) || polylineHit(x, y, door); +} + +// 应用:2x2 空心圆角方块(描边间留 3px 空隙,外框与首页图标对齐) +function appsHit(x, y) { + const half = 11.5; + const r = 5.5; + const centers = [ + [24.5, 27], + [56.5, 27], + [24.5, 59], + [56.5, 59] + ]; + return centers.some(([cx, cy]) => roundedRectStroke(x, y, cx, cy, half, half, r)); +} + +// 我的:头部圆形 + 肩部拱形(线条风格) +function mimeHit(x, y) { + // 头部圆环 + const headR = 10; + const headCY = 23; + const headDist = Math.hypot(x - 40.5, y - headCY); + if (Math.abs(headDist - headR) <= STROKE_HALF) return true; + + // 肩部:两侧竖线 + 上方椭圆拱(比正圆更贴合人像比例) + const shoulderCY = 59; + const rx = 24; + const ry = 15; + const leftX = 40.5 - rx; + const rightX = 40.5 + rx; + const bottomY = 73; + if (segmentHit(x, y, leftX, bottomY, leftX, shoulderCY)) return true; + if (segmentHit(x, y, rightX, shoulderCY, rightX, bottomY)) return true; + + const steps = 18; + const arch = []; + for (let i = 0; i <= steps; i++) { + const t = Math.PI - (Math.PI * i) / steps; + arch.push([40.5 + rx * Math.cos(t), shoulderCY - ry * Math.sin(t)]); + } + return polylineHit(x, y, arch); +} + +function render(hitTest, hexColor) { + const r = parseInt(hexColor.slice(1, 3), 16); + const g = parseInt(hexColor.slice(3, 5), 16); + const b = parseInt(hexColor.slice(5, 7), 16); + + const rgba = Buffer.alloc(SIZE * SIZE * 4, 0); + const step = 1 / SS; + + for (let y = 0; y < SIZE; y++) { + for (let x = 0; x < SIZE; x++) { + let hits = 0; + for (let sy = 0; sy < SS; sy++) { + for (let sx = 0; sx < SS; sx++) { + const px = x + (sx + 0.5) * step; + const py = y + (sy + 0.5) * step; + if (hitTest(px, py)) hits++; + } + } + if (!hits) continue; + const coverage = hits / (SS * SS); + const idx = (y * SIZE + x) * 4; + rgba[idx] = r; + rgba[idx + 1] = g; + rgba[idx + 2] = b; + rgba[idx + 3] = Math.round(coverage * 255); + } + } + + return encodePNG(SIZE, SIZE, rgba); +} + +/* ---------------- 输出 ---------------- */ + +const outputDir = path.join(__dirname, '..', 'src', 'static', 'icon'); +// 与“我的”图标保持一致(mime.png / mime_a.png 的主色) +const GRAY = '#999999'; +const ACTIVE = '#106eff'; + +const targets = [ + ['home.png', homeHit, GRAY], + ['home_a.png', homeHit, ACTIVE], + ['apps.png', appsHit, GRAY], + ['apps_a.png', appsHit, ACTIVE], + ['mime.png', mimeHit, GRAY], + ['mime_a.png', mimeHit, ACTIVE] +]; + +for (const [name, hitTest, color] of targets) { + const filePath = path.join(outputDir, name); + fs.writeFileSync(filePath, render(hitTest, color)); + console.log('generated:', filePath); +} diff --git a/src/App.vue b/src/App.vue index fddb17f..92c17fe 100644 --- a/src/App.vue +++ b/src/App.vue @@ -84,4 +84,10 @@ export default { .uni-system-preview-image { z-index: 10100 !important; } + +/* 底部导航栏去除顶部分隔线(tabBar.backgroundColor 为白色,borderStyle 已设为 white, + 这里再兜底把 H5 渲染的 1px 边框元素隐藏;App 端为原生 tabBar,由 borderStyle 控制)。 */ +uni-tabbar .uni-tabbar-border { + display: none !important; +} \ No newline at end of file diff --git a/src/core/store/modules/setting.js b/src/core/store/modules/setting.js index e171ec0..bcaeae5 100644 --- a/src/core/store/modules/setting.js +++ b/src/core/store/modules/setting.js @@ -5,8 +5,8 @@ import http from "../../request"; // 默认键值对设置 const defaultSettings = { // 广播相关 - 'broadcast.action': 'com.pda.scan.RESULT', - 'broadcast.key': 'scan_data', + 'broadcast.action': 'android.intent.action.SCANRESULT', + 'broadcast.key': 'value', // 扫描相关 'scan.sound': 'true', diff --git a/src/pages.json b/src/pages.json index 61fd28d..a529886 100644 --- a/src/pages.json +++ b/src/pages.json @@ -11,13 +11,15 @@ "path" : "pages/oa/index", "style" : { - "titleNView": false + "titleNView": false, + "backgroundColor": "#f2f8ff" } }, { "path": "pages/index/index", "style": { - "titleNView": false + "titleNView": false, + "backgroundColor": "#f2f8ff" } }, { @@ -29,7 +31,8 @@ { "path": "pages/user/index", "style": { - "titleNView": false + "titleNView": false, + "backgroundColor": "#f2f8ff" } }, { @@ -380,20 +383,20 @@ }, "tabBar": { "borderStyle": "white", - "backgroundColor": "#333", - "color": "#555", - "selectedColor": "#24afd6", + "backgroundColor": "#FFFFFF", + "color": "#999999", + "selectedColor": "#106eff", "list": [{ - "text": "作业", + "text": "首页", "pagePath": "pages/index/index", - "iconPath": "static/icon/index.png", - "selectedIconPath": "static/icon/index_a.png" + "iconPath": "static/icon/home.png", + "selectedIconPath": "static/icon/home_a.png" }, { - "text": "工单", + "text": "应用", "pagePath": "pages/oa/index", - "iconPath": "static/icon/oa.png", - "selectedIconPath": "static/icon/oa_a.png" + "iconPath": "static/icon/apps.png", + "selectedIconPath": "static/icon/apps_a.png" }, { "text": "我的", diff --git a/src/pages/home/edit-quick-actions.vue b/src/pages/home/edit-quick-actions.vue index 09d9ab5..2f36d45 100644 --- a/src/pages/home/edit-quick-actions.vue +++ b/src/pages/home/edit-quick-actions.vue @@ -49,7 +49,12 @@ - + + + 正在加载功能列表... + + + 暂无可用功能 @@ -110,6 +115,7 @@ leftNavTargetId: '', isEditMode: false, selectedKeys: [], + isLoading: true, FIXED_MENU_KEY: 'fixed_home_menus' } }, @@ -170,7 +176,12 @@ } }, async onLoad() { - await this.loadAllActions(); + this.isLoading = true; + try { + await this.loadAllActions(); + } finally { + this.isLoading = false; + } }, methods: { async loadAllActions() { @@ -716,4 +727,13 @@ color: #999; } } + + .loading-state { + flex-direction: column; + align-items: center; + + .empty-text { + margin-top: 20rpx; + } + } diff --git a/src/pages/index/index.vue b/src/pages/index/index.vue index 6d6197e..7440c2e 100644 --- a/src/pages/index/index.vue +++ b/src/pages/index/index.vue @@ -3,19 +3,20 @@ - - - - - {{ userInfo.store_name || '选择主体' }} - {{ userInfo.employees_name || '---' }} - - + + + + {{ item.value }} + {{ item.label }} + + + + - + @@ -25,6 +26,7 @@ + @@ -1582,77 +1584,50 @@ .pda-home { display: flex; flex-direction: column; - background: #f8f9fa; + /* App 端 webview 高度已扣除原生 tabBar,100vh 即为 tabBar 顶边以上高度 */ + min-height: 100vh; + /* #ifdef H5 */ + /* H5 的 100vh 包含 tabBar 区域,扣除底部导航高度,避免内容被 tabBar 遮挡 */ + min-height: calc(100vh - var(--window-bottom, 0px)); + /* #endif */ + // 顶部蓝色向下逐渐过渡到页面浅蓝,形成层次 + background: linear-gradient( + 180deg, + #106eff 0%, + #3d80ff 240rpx, + #a9c8ff 480rpx, + #f2f8ff 760rpx + ); } - // 紧凑型头部 + // 紧凑型头部(透明,叠在页面顶部渐变上) .compact-header { - padding: 12rpx 24rpx 16rpx; - background: #ffffff; - border-bottom: 1rpx solid #f0f2f5; + position: relative; + padding: 16rpx 24rpx 20rpx; + + // 数据条与跑马灯之间的间距(数据条被 v-if 隐藏时自动失效) + .stat-strip + .org-switcher { + margin-top: 16rpx; + } .org-switcher { display: flex; align-items: center; - .org-block { - display: flex; - align-items: center; - flex: 0 1 auto; - max-width: 46%; - min-width: 0; - padding: 4rpx 0; - - &:active { - opacity: 0.7; - } - } - - .org-arrow { - flex-shrink: 0; - margin-left: 6rpx; - } - - .org-info { - flex: 1; - min-width: 0; - - .org-name { - font-size: 32rpx; - font-weight: 600; - color: #1f2329; - display: block; - line-height: 1.3; - overflow: hidden; - white-space: nowrap; - text-overflow: ellipsis; - } - - .org-id { - font-size: 24rpx; - color: #9aa0a6; - display: block; - line-height: 1.3; - overflow: hidden; - white-space: nowrap; - text-overflow: ellipsis; - } - } - .news-wrapper { flex: 1; min-width: 0; - margin-left: 16rpx; overflow: hidden; .news-pill { display: flex; align-items: center; height: 56rpx; - padding: 0 20rpx; - background: #f2f7ff; - border: 0; + padding: 0 18rpx; + background: rgba(255, 255, 255, 0.16); + border: 1rpx solid rgba(255, 255, 255, 0.22); border-radius: 28rpx; + box-shadow: inset 0 1rpx 0 rgba(255, 255, 255, 0.25), 0 4rpx 12rpx rgba(6, 45, 120, 0.10); box-sizing: border-box; overflow: hidden; @@ -1663,6 +1638,11 @@ margin-right: 10rpx; } + &__arrow { + flex-shrink: 0; + margin-left: 10rpx; + } + &__body { flex: 1; min-width: 0; @@ -1692,7 +1672,7 @@ white-space: nowrap; padding-right: 60rpx; font-size: 26rpx; - color: #2979ff; + color: #ffffff; } } } @@ -1700,6 +1680,53 @@ } } + // 顶部导航栏:通知信息弹窗的数据内容 + .stat-strip { + display: flex; + align-items: stretch; + + .stat-item { + flex: 1; + min-width: 0; + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + padding: 14rpx 8rpx; + background: rgba(255, 255, 255, 0.14); + border: 1rpx solid rgba(255, 255, 255, 0.22); + border-radius: 14rpx; + box-shadow: inset 0 1rpx 0 rgba(255, 255, 255, 0.25), 0 6rpx 16rpx rgba(6, 45, 120, 0.12); + + & + .stat-item { + margin-left: 12rpx; + } + + &:active { + background: rgba(255, 255, 255, 0.26); + } + + &__value { + font-size: 36rpx; + font-weight: 600; + color: #ffffff; + line-height: 1.1; + font-variant-numeric: tabular-nums; + } + + &__label { + margin-top: 8rpx; + max-width: 100%; + font-size: 22rpx; + color: rgba(255, 255, 255, 0.78); + line-height: 1.2; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + } + } + } + } // 顶部公告无缝滚动 diff --git a/src/pages/oa/index.vue b/src/pages/oa/index.vue index 8183fd0..1ad8dca 100644 --- a/src/pages/oa/index.vue +++ b/src/pages/oa/index.vue @@ -1,5 +1,5 @@ @@ -18,5 +18,8 @@ diff --git a/src/pages/settings/broadcastSettings.vue b/src/pages/settings/broadcastSettings.vue index 0da25f2..eed89e6 100644 --- a/src/pages/settings/broadcastSettings.vue +++ b/src/pages/settings/broadcastSettings.vue @@ -21,7 +21,7 @@ 广播名 (Action) - @@ -35,7 +35,7 @@ 数据键名 (Key) - diff --git a/src/pages/settings/index.vue b/src/pages/settings/index.vue index 40a4371..d7466ee 100644 --- a/src/pages/settings/index.vue +++ b/src/pages/settings/index.vue @@ -32,29 +32,12 @@ - - - - - 退出登录 - - - - - - - - 确认退出登录? - 退出后将需要重新登录 - -