Compare commits

..

242 Commits
ming ... main

Author SHA1 Message Date
7c90d2f498 feat(receiving): 收货管理模块界面优化,统一字号与状态色
- 收货详情/收货单信息(info-container)
  * 表单标签、输入框、单选、文本域、状态标签字号统一为 36rpx
  * 状态色统一:收货中-橙、已完成-绿、已取消-红
  * 备注框由 u-input 改为 u-textarea 长文本
  * 打印按钮字号 36rpx,并增加与收货单号框的间隔
  * 物流单号相机按钮调大
  * 货主选择框样式对齐新建页,单选选项增加间隔
- 新建收货任务(receivingCreate)
  * 表单字号统一 36rpx
  * 货主选择改为底部弹窗,来货照片与装卸信息优化
- 收货列表(receiving)
  * 新增状态/货主/日期筛选弹窗与创建收货任务入口
  * 状态标签按状态着色
  * 界面字号统一
- 收货明细/清单(detail-container、receivingList)
  * 空状态提示字号 34rpx
  * 明细状态色统一,标题字号调整
- random-storage
  * 样式微调:增加底部间距与分隔线
2026-11-17 18:11:53 +08:00
1469179ff2 feat(仓储): 优化随机入库列表与上架作业页面样式与交互
random-storage.vue(入库单列表页)
- 搜索框启用搜索按钮,移除「默认仅显示待审核」提示与汇总栏
- 放大卡片字号:单号38rpx、元信息/创建时间34rpx、详情行36rpx,单号加粗改为 bold
- 状态标签36rpx、收货单徽标34rpx,标签列加宽且不换行
- 修复旧真机 flex gap 不生效:面板/卡片间距改用显式 margin

random-storage-shelf.vue(上架作业页)
- 搜索框新增搜索按钮;已入/总数面板与搜索框合并,并与顶部标题栏连成一体
- 商品多条码支持展开/收起(>2 默认显示前2条),条码分隔符改为顿号
- 提示弹窗改为自定义弹窗(参考完成盘点弹窗样式),退出/取消入库确认按钮为红色
- 更多操作、设置、容器列表、入库进度、明细信息等弹窗样式统一优化(顶部圆角、右上角关闭图标、字号统一)
- 底部商品序号格改用 scroll-view 滚动,并加显式高度兜底,兼容旧真机
- 加粗样式由 font-weight:600 统一改为 bold;全面修复旧真机 flex gap 不生效的间隔问题
2026-11-16 17:59:29 +08:00
d8437120bc feat(商品/复核): 条码超3个默认收起并支持展开收起
- 商品查询/商品详情/订单复核列表:商品条码超过 3 个时默认收起,仅显示前 3 个,右侧显示「展开/收起」
- 订单复核详情:展开/收起按钮移至条码文本前固定位置,避免条码过多时按钮被推到末尾;字号调整为 36rpx
- 商品详情:展开后条码区域限制最大高度并支持内部滚动,同时动态测量固定头部高度撑开占位,避免溢出遮挡
- 商品查询:切换展开后刷新库存区定位,保证悬浮表头位置正确;字号调整为 36rpx
2026-11-15 18:15:10 +08:00
1a429a5261 feat(订单复核): 优化SN序列号录入与删除交互
- SN 删除增加二次确认弹窗,避免误删;删除/录入结果带语音播报
- SN 录入完成进度行新增绿色完成态样式
- 未匹配商品条码时不再自动录入 SN,仅弹窗内可录入
- 播报文案由"数据一致"改为"录入成功",并新增 speakSnRecorded 事件按商品去重播报复核要求
- SN 弹窗样式统一(round 圆角、字号加粗等)
- 波次策略列表过滤禁用项后再排序,并默认选中首个启用项
- 版本升级至 1.0.144
2026-11-15 15:56:27 +08:00
liufumingren
82e2722dc0 版本升级 2026-11-13 23:45:49 +08:00
liufumingren
5a86f3ea9d feat(订单复核): 支持扫码SN序列号规则校验
- scanOrder 返回的 stock.sn_code_rules 归一化后写入商品项,随 goodsList 传入 ReviewDetail
- 扫码/手动录入 SN 时按 prefix/suffix 匹配:keep_mode=strip 截取剩余部分作为 SN,full 保留整段
- 不符合序列号规则的内容不录入 SN 列表,Toast 并语音播报“非SN码”
- 未配置规则时保持原有整段作为 SN 的行为

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-11-13 23:44:37 +08:00
9f914e149b chore(release): 版本升级 1.0.142 + SN 弹窗最新录入置顶
- 版本升级:1.0.141 → 1.0.142(package.json / src/manifest.json 同步 versionName、versionCode)
- SN 录入弹窗:新录入的 SN 码显示在列表最前面(最新置顶),
  便于查看最近扫描结果

涉及文件:
  package.json
  src/manifest.json
  src/pages/work/order/order-review-comps/ReviewDetail.vue
2026-11-13 19:44:34 +08:00
55af204fc7 chore(release): 版本升级 1.0.141 + 订单复核SN序列号管理 + 页面样式统一
【版本】
- package.json version: 1.0.140 → 1.0.141
- src/manifest.json versionName: 1.0.141 / versionCode: 1000141

【订单复核 - 序列号管理】
- 散单波次策略 waveStrategyList 查询新增 strategy_type=3(SN序列号管理)
- 订单复核接入 need_sn:
  - need_sn=Y 商品按录入的 SN 数量控制复核进度(扫描+手动录入、SN 去重)
  - 确认复核提交 sn_map(stock_id → SN 列表),SN 未录齐时拦截提交
  - 列表卡片展示 SN 进度(x/y · 录入/已完成)
- 订单复核详情:商品条码超过 3 个默认收起,新增展开/收起按钮(不影响条码匹配)
- SN 录入弹窗:输入框字号 36rpx、maxlength 500;打开弹窗时不播报「数据一致」
- 修复:自动复核成功后未清空详情数据(复核成功先清空详情,返回列表时重置 detailInfo)

【页面样式/交互统一】
- 工作台配置:状态筛选改 filter-group(启用绿/禁用橙),绑定弹窗样式统一,字号加大
- 团购/散单波次策略:底部按钮统一 action-btn、卡片标题与 label/value 字号统一
- 库存调拨:筛选项字号/颜色调整
- 退件扫描备注弹窗:字号、滚动区高度限制、删除按钮改红色警示

涉及文件:
  package.json
  src/manifest.json
  src/pages/configuration/Workbench.vue
  src/pages/warehouse/inventoryTransfer.vue
  src/pages/work/order/gBWaveStrategy.vue
  src/pages/work/order/scatter-wave-strategy.vue
  src/pages/work/order/order-review.vue
  src/pages/work/order/order-review-comps/ReviewDetail.vue
  src/pages/work/order/returnRecord-comps/ReturnScanPanel.vue
2026-11-13 19:01:19 +08:00
b8da08bdbb feat(收件任务/退件登记/复核): 优化页面样式交互,修复真机下拉刷新转圈
收件任务页 src/pages/work/order/returnRecord.vue
- 右上角「新建」按钮:字号 36rpx、自适应宽度、绝对定位右对齐垂直居中、圆角 8rpx
- 「我的任务/全部任务」筛选改为等宽胶囊按钮(参考库存盘点页),激活态实心蓝底白字加粗
- 任务卡片:批次号过长换行、加粗统一 bold、字号调整(登记数/标题 36rpx、创建人时间 30rpx)
- 任务卡片留白与退件登记面板统一(16rpx),修正卡片连成一片问题
- 删除任务确认弹窗改为自定义弹窗(参考完成盘点弹窗:居中+标题+灰底内容区+取消/删除)
- 修复真机下拉刷新一直转圈

退件登记页 src/pages/work/order/returnRecord-comps/ReturnScanPanel.vue
- 右上角「…」更多按钮替换为「输入框」按钮,直接切换手动输入
- 扫码输入区替换为统一 SearchBar 组件
- 扫描记录面板优化:标题加蓝色竖条、列表改灰底白卡、间距对齐统一
- 记录行:备注独立一行可换行、备注字号 36rpx 黑色、运单号取消加粗、备注与姓名时间互换位置
- 加粗统一 bold(替换 600)
- 空态提示字号 32rpx;整体左右留白统一 16rpx
- 修复真机下拉刷新一直转圈

全部功能页 src/pages/home/edit-quick-actions.vue
- 编辑按钮样式改为参考分拣缺货补货页刷新按钮(padding 14rpx 28rpx、圆角 8rpx、字号 36rpx)

复核页 src/pages/work/order/order-review.vue
- 拦截横幅:组单模式显示「该波次有拦截订单」,移除「查看」入口
- 多处 u-popup 的 border-radius 属性修正为 round
- 打印设置弹窗重构:参考面单补打页样式(固定高度、顶部圆角裁切、居中标题、输入框字号 36rpx)
- 打印台回车匹配:仅精确匹配才绑定,过滤后仅剩一个才自动选中,否则提示「未匹配到打印台」
- 样式微调:拦截横幅文字 32→36rpx、设置弹窗圆角 16→20rpx、gap 改 margin 兼容旧真机
2026-11-12 17:59:29 +08:00
bbfd474028 style: 统一页面顶部与弹窗风格、修复打印台绑定误绑与软键盘问题
- 拆单页(splitOrder)
  · 打印台绑定弹窗统一圆角/标题/关闭按钮布局,字号、标签颜色统一
  · 输入框内容字号 36rpx,打印台行去掉分隔线,弹窗高度调整为 450rpx
  · 修复回车确认误绑首个模糊匹配项(改为精确匹配优先)

- 分拣缺货补货页(replenishShorts)
  · 选择货主弹窗标题样式统一(居中标题,去掉底部分隔线)

- 称重页(weighing)
  · 顶部与空态参考绑定包材页,内容字号对齐
  · 连秤/蓝牙秤面板/设置重量等按钮字号统一
  · 连接蓝牙秤弹窗去掉按名称连接,改为搜索框按关键字筛选(统一 SearchBar)
  · 设置重量成功后不再自动激活软键盘
  · 称重重量输入框字号恢复 56rpx

- 订单复核页(order-review)
  · 顶部改为自定义标题栏(参考绑定包材),按钮改实心风格
  · 拦截信息升级为横幅(位于搜索框下方)
  · 连接蓝牙秤弹窗参考称重页

- 面单补打页(labelReprint)
  · 顶部样式参考拆单页,搜索框置顶
  · 去掉打印台本地存储
  · 打印台绑定弹窗样式参考拆单页,修复回车误绑
  · 模式切换按钮改蓝色主题、字号 38rpx
  · 日志面板白底黑字、时间去掉 GMT、统一字体
2026-11-11 18:09:40 +08:00
dc554f9a9e refactor: 搜索框组件化统一重构,新增拆单页面功能
一、新增共享搜索组件 SearchBar
- 新增 src/components/SearchBar/SearchBar.vue
- 将各页面内联的「搜索输入 + 扫码按钮 + 搜索按钮」统一封装
- 支持 input-font-size / search-text-font-size / show-scan /
  show-search / focus / disabled / scan-icon 等属性
- 统一输入框与搜索文字字号为 34rpx

二、各页面搜索框接入 SearchBar 组件(删除重复样式代码)
- 首页快捷操作、工作台配置
- 商品查询、库位查询、库内转移、随机上架、收货及子组件
- 盘点相关组件(工具栏、搜索面板、明细选择、记录新增、实盘数量)
- 订单复核、复核列表、称重、包材绑定、拦截登记
- 散单/团单拣货详情、退单记录、发货标签、打印补打、缺货补货

三、通用样式调整
- page-nav 页面标题字号 32rpx -> 36rpx

四、拆单页面(src/pages/packing/splitOrder.vue)功能完善
- 未绑定按钮字号与输入框按钮统一为 36rpx
- 未查询时显示空态提示(参考绑定包材页面),并固定定位避免跳动
- 修复空态遮挡导致搜索输入框无法聚焦的问题
- 快递号面板样式参考拦截登记页面,子单号标签白底黑字并对齐
- 面板与操作按钮分隔,左右留白统一 24rpx
- 子单号列表支持滚动查看(最大高度 400rpx)
- 拆单按钮改为蓝色、36rpx、不加粗
- 拆单数量弹窗参考完成盘点弹窗(640rpx、20rpx 圆角、88rpx 按钮),
  新增右上角关闭图标,点击遮罩不关闭
- 拆单失败时从 order.detail 日志提取「子单号分配」失败 message,
  使用自定义 u-popup 弹窗完整展示失败信息
2026-11-10 18:20:38 +08:00
b95ac35d39 fix(ui): 修复真机加粗失效并统一 PDA 页面字号与布局
- 库存盘点:font-weight 600 统一改为 bold,修复真机无加粗效果
- 库存盘点:移除右上角「...」操作菜单,改为「完成盘点」「空库位」直接按钮
- 库存盘点:顶部标题栏字号统一 36rpx,搜索输入框字号 34rpx,提示字号 28→30rpx
- 拦截登记:顶部导航重构为自定义 header(返回/标题/输入框开关/重置)
- 拦截登记:搜索框改为 u-search 圆角样式并新增「搜索」按钮
- 拦截登记:信息面板标签 32→36rpx、值 32→40rpx,与搜索框间隔调整为 60rpx
- 拦截登记:拦截失败提示优化,区分「非拦截订单」等文案
- 库位查询:标题/搜索/计数半格样式调整,浅色背景深色文字、下划线强调
- 其他:page-nav 右侧宽度改 min-width;首页/个人中心弹窗圆角 24→20rpx;多处标题字号 32→36rpx
2026-11-09 17:59:23 +08:00
cd5b6a0e63 版本号升级 1.0.140 + 盘点/补货页面字号与状态色调整
- 升级应用版本号至 1.0.140(package.json、manifest.json)
- 盘点列表工具栏:状态筛选激活态按状态色调显示(待盘点=蓝/盘点中=橙/已完成=绿),并与卡片状态色保持一致
- 盘点列表工具栏:搜索框、筛选按钮字号调整(30→34rpx)
- 盘点汇总面板:分组标题字号调整(30→32rpx)
- 盘点详情页:tabs 文字字号调整为 34rpx
- 补货短少页:列表文字字号调整(34→36rpx)
2026-11-08 17:30:37 +08:00
422231132e feat: 补货页重构 + 蓝牙秤主动读轮询 + 版本升级至 1.0.139
- 分拣缺货补货页(replenishShorts)整体重构
  - 头部布局重排,货主/商品名称字段对调
  - 搜索框改用 u-search,新增"搜索"按钮
  - 货主抽屉改为底部弹窗(round 圆角),选中项换图标
  - 底部翻页改用 pagination 组件
  - 状态标签新增蓝色填充样式(primary-fill)
  - 全局字号、间距等样式优化

- 蓝牙电子秤(bluetoothScale)新增主动读轮询
  - 发现可读特征值(readables)并随设备保存
  - 连接后无 notify 推送时,周期 read 获取重量
  - 解析时区分 read 与 notify 数据来源,共用解析路径
  - 断开连接时清理轮询定时器

- 首页快捷操作(edit-quick-actions)图标名校验
  - 非法图标名统一回退为 grid
  - 头部标题等字号调整

- 分页组件(pagination)总数样式优化,数字蓝色加粗

- 版本号 1.0.137 → 1.0.139 (manifest + package)
2026-11-08 14:48:11 +08:00
a5cedd525f feat(UI): 退出/退出登录/清空记录弹窗统一改造 + 设置与广播页视觉优化
- 新增全局退出应用确认弹窗:新增 app Vuex 模块(exitConfirmVisible),
  APP 退出事件由 uni.showModal 改为 commit('app/showExitConfirm'),
  首页 index.vue 渲染自定义退出确认弹窗(取消/退出)
- 「我的」退出登录确认弹窗由 u-modal 改为自定义 UI,新增退出中 loading 状态
- 广播设置页 UI 重构:参数设置面板增加标题/标签圆点/输入框样式/「当前生效」标签,
  读取扫描结果布局调整,清空扫描记录改为二次确认弹窗
- 设置/帮助支持页:账号安全、设备查找、扫描音效、问题报障、意见反馈、
  帮助手册、操作信息等标记为「暂未开放」,点击提示不再做登录检查跳转
- uView 适配:main.js 将 uView 引入提前到 App 之前(easycom 依赖 uni.$u);
  u-loading 改为 u-loading-icon;u-cell_title/u-btn 类名适配为 u-cell__title-text/u-button;
  图标统一改用 icon-style
- 首页全部功能页编辑按钮样式调整;仓库选择器 StoreSelector 字号调大
- 视觉统一:设置/帮助/关于等页面背景统一为 #f7f8fa,卡片圆角/阴影统一,
  多页面字号整体调大
- 移除登录后 getCartList/getUserData 的冗余调度调用
2026-11-06 18:00:23 +08:00
64a2602317 feat: 首页/我的/设置界面改版 + 仓库切换 + 帮助支持 + 沉浸式状态栏
首页与状态栏
- manifest.json 开启沉浸式状态栏(immersed:true),首页 .status_bar 与顶部渐变同色 #106eff
- pages.json 首页增加 navigationBarTextStyle:"white"(状态栏前景色白色)
- 首页常用功能九宫格改版:卡片高度自适应、两行菜单名不裁剪、长按排序/管理移除、拖拽预览、骨架屏、跑马灯后台暂停

我的页
- 新增仓库切换弹窗组件 StoreSelector,顶部账号卡片/门店名点击切换仓库
- 修复原“个人资料”跳转死路由(profile 不存在 → 404)
- 操作列表 5 项合并为「帮助与支持」入口,修复 u-cell 图标不渲染问题

设置页
- 新增「帮助与支持」二级页 helpSupport(问题报障/意见反馈/帮助手册/操作信息/网络检测)
- 精简 settings 列表(移除登录信息块与声音通知块)
- 关于页改版为「检查更新」,支持 autoCheck=1 自动检查,浅蓝背景

主入口
- main.js 停用未完成的悬浮消息浮窗初始化 initializeFloatWindow()
2026-11-05 18:00:38 +08:00
ab03288d67 feat(ui): 重构底部导航与首页/个人中心视觉,退出登录入口迁移至「我的」
## 底部导航
- tabBar 配色调整为白底 #FFFFFF、未选中 #999999、选中 #106eff
- 页签重命名:「作业」改为「首页」,「工单」改为「应用」
- 新增 home/apps 及其选中态图标,补充 scripts/gen-tabbar-icons.cjs 生成脚本
- 隐藏 H5 端 tabBar 顶部分隔线;首页、应用、我的页面背景统一为 #f2f8ff

## 首页
- 原机构/人员切换区域调整为通知数据条 stat-strip,数据与通知弹窗同源,支持点击打开弹窗
- 头部改为透明层叠于蓝色渐变背景之上;通告跑马灯调整为半透明胶囊、白色文字并补充跳转箭头
- 页面最小高度设为 100vh,H5 端扣除 --window-bottom,避免内容被 tabBar 遮挡

## 个人中心
- 资料卡调整为蓝色渐变卡片,补充圆角、投影与装饰元素
- 操作列表改为白色圆角卡片,单元格补充箭头并去除末项分隔线
- 新增底部固定「退出登录」按钮,包含二次确认弹窗与加载态,H5 端适配 tabBar 高度

## 其他
- 设置页移除退出登录按钮及其逻辑与样式,能力迁移至个人中心
- edit-quick-actions 在功能列表加载期间展示加载态
- 扫描广播默认值调整为 action=android.intent.action.SCANRESULT、key=value

## 影响面
- 退出登录入口由设置页变更为个人中心页面底部
- 未自定义广播配置的终端,升级后将使用新的默认广播 Action 与 Key
2026-11-04 18:18:10 +08:00
ee6e52ff40 feat(ui): 优化全部功能页布局与交互体验
调整全部功能页菜单名称字号和字重,统一与首页常用功能菜单一致
放大左侧导航按钮字号和点击区域,提升分类选择时的可操作性
调整右侧字母索引按钮间距和热区,优化快速定位体验
细化页面内留白设计,修正搜索区、导航区与功能列表之间的间距问题
参考商品查询页搜索框风格,更新为圆角浅灰输入框,并保留独立搜索按钮
去掉扫描图标,仅保留搜索入口,保持页面更简洁、交互更聚焦
优化头部与内容区分隔逻辑,提升页面整体视觉一致性
2026-11-03 18:00:33 +08:00
263adfb759 fix(更新弹窗+调试脚本): 兼容旧真机 flex gap 与 dev 打包参数被吞
- 更新弹窗/登录页/关于页统一移除 flex gap,改用兄弟选择器 margin 控制间距,
  修复旧机型 WebView 不支持 gap 导致版本号、信息行、提示、按钮之间无间距
- :deep(.u-button) 改为 ::v-deep,兼容旧真机样式穿透;关于页补上按钮 flex:1
- dev-adb 打包由 npm run android:pack:raw -- -Dev -NoUpload 改为直接执行
  android-offline/pack.ps1 -Dev -NoUpload,避免 PowerShell 吞掉 -- 使参数失效,
  打包成发行包并覆盖正式 APK、dev 目录无产物导致装回旧包
2026-10-30 18:16:28 +08:00
liufumingren
106162d43f feat(盘点): 库位模式商品行接入待拣货标记,未拣完置灰录入框
space 视图(stock.check.workData / workDataSpaceDetails)的 goods 子项已返回
picking_completed / locked_quantity,据此补齐库位模式的静态拣货提示:

- countModel.normalizeSpaceWorkRow:goods 子项输出 pickingPending/lockedQuantity,
  录入单元带 pickingPending;库位行输出 pickingPendingCount
- CountWorkCard:子项显示红色「待拣货」标记 + 「拣货未完成(锁定 N)」,
  未拣完时不再渲染输入框,改为只读「待拣货」
- inventoryCountSpace:顶部提示「N 项商品尚未完成拣货,仅这些商品暂不能上报」,
  handleWorkReport 按商品拦截并语音播报
- 拦截粒度仅为商品行:同库位其他商品照常录入,库位行本身不拦截
- 无 picking_completed 字段(普通盘点/旧后端)时行为不变
- 版本升级至 1.0.137

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-10-28 16:58:54 +08:00
liufumingren
d5607f58b1 feat(盘点): 接入 0.3.320 静态拣货完成标记,未拣完禁止上报
后端 stock.check.workData / workDataDetail 对 is_static=1 返回
picking_completed(1=已完成拣货 / 0=未完成)与明盘下的 locked_quantity,
report 对「静态任务 + 该商品仍有锁定量」直接拒绝。

- countModel:新增 pickPickingMeta,goods 行与商品钻取统一输出
  hasPickingFlag / pickingCompleted / pickingPending / lockedQuantity
- CountGoodsCard:未拣完显示「待拣货」标记与「拣货未完成(锁定 N)」提示
- inventoryCountGoods:概况卡标记与提示、顶部黄条说明;openEntryPopup 与
  submitReport 拦截并语音播报,避免录完数量才被后端拒绝
- 普通盘点/库位任务后端不返回该字段,行为不变
- 版本升级至 1.0.136(package.json + manifest.json)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-10-28 16:33:22 +08:00
liufumingren
9c3ee18cdd Merge origin/main:并入 0.3.318 账面口径,保留未盘库位占位行
线上 f4c40e4 与本地的 stock_id 入口/workDataDetail 改造重叠且为超集,
冲突文件(countModel.js、inventoryCountDetail.vue、inventoryCountGoods.vue)
取线上版本为基准,仅补回本地独有逻辑:

- countModel.normalizeGoodsDetailInfo:库位明细保留未盘占位行(checked 标记、
  实盘置空),记账条数/最近上报仍只统计已盘库位;allLocations 明细ID映射沿用线上
- inventoryCountGoods:resolveHasChecked 改为「有记录 或 存在已盘库位」,
  「共 N 条」按已盘库位数统计
- apis.js 注释同步(detail_id 可选、商品钻取 summary+rows)
- 版本升级至 1.0.135

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-10-28 16:25:31 +08:00
liufumingren
66ca2107b2 chore(release): 版本升级至 1.0.134
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-10-28 16:23:12 +08:00
f4c40e454b feat(盘点): 适配 0.3.318 账面口径(快照/当前库存)并兼容商品视图 stock_id 入口
- countModel: 新增 is_static / book_source / storage_quantity / snapshot_quantity 归一化
- countModel: resolveBookMeta 统一输出「账面(快照)|账面(当前库存)」标签及另一口径提示
  (静态盘点提示当前库存,普通盘点提示基准快照,不一致时才显示)
- countModel: workDataDetail 兼容 0.3.309+ 的 { summary, rows[] } 商品钻取结构,保留旧 locations 结构
- countModel: buildReportParams 的 detail_id 改为可选,支持仅用 stock_id + space_id 由服务端反查明细
- countModel: goods 视图行优先以 stock_id 作为行标识;已盘库位识别补充 status=checked / is_checked
- countModel: 任务/列表归一化透出 isStatic / isStaticText(静态盘点标识)
- inventoryCountDetail: 作业行归一化传入任务级 is_static 兜底;goods 行无 detail_id 时改用 stock_id 进入商品作业页
- inventoryCountGoods: 支持 stock_id 路由与 workDataDetail 入参(id + detail_id/stock_id)
- inventoryCountGoods: 多库位商品上报按所选库位(space_id/location_code)取对应 detail_id
- inventoryCountSpace: 读取 check.is_static 作为 space 视图商品行的口径兜底
- CountWorkCard / CountGoodsCard / CountLocationDetail: 展示账面来源标签与另一口径提示
- CountSummaryPanel: 新增「盘点性质」(静态盘点/普通盘点)
- CountRecordCard: 静态盘点任务显示「静态」标签

兼容性:旧后端无 is_static/book_source 时按「当前库存」展示,数量与上报逻辑不变;
盲盘、库位任务、状态机与分页流程未改动。

验证:countModel.js ESLint 通过;8 个改动 Vue 文件的 script 语法与模板编译通过。
2026-10-28 16:14:01 +08:00
liufumingren
d57cc44bdd feat(盘点): 商品模式上报改为任务ID+stock_id,不再传 detail_id
- 商品视图点击改用 stock_id 进入商品作业页(goods 汇总视图行不再返回明细ID)
- 商品作业页 workDataDetail 改传 id + stock_id,并适配 summary + rows 新返回结构
- check.report 商品模式只传 id + stock_id + space_id,detail_id 改为可选(库位明细行仍必传)
- 库位/space 模式上报逻辑保持不变

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-10-28 07:36:33 +08:00
liufumingren
a4bfd09bff chore(release): 发布上传配置改为本地文件,不再纳入版本管理
config/deploy.json 含服务器地址、远程目录与私钥路径,且路径指向提交者本机,
其他人打包执行 pack.ps1 的发布步骤会因私钥不存在而中断。

- git rm --cached config/deploy.json(本地文件保留)
- .gitignore 增加 config/deploy.json,与 config/android.json 同口径
- 模板仍由 config/deploy.example.json 提供,README 已说明 deploy.json 不提交

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-10-28 00:13:12 +08:00
liufumingren
3cf709c196 fix(盘点): 商品作业页展示未盘库位占位行,恢复待盘库位可见性
- normalizeGoodsDetailInfo 不再过滤未盘库位:每个库位带 checked 标记,
  未盘行实盘按 -- 展示(后端 quantity 回 0,直接用会误算「账实相符」),不参与盈亏
- recordCount / lastCheckedAt 仍只统计真实作业记录,口径不变
- 商品作业页 resolveHasChecked 改为「有记录 或 存在已盘库位」,
  避免占位行导致卡片误显示已盘 0
- 「共 N 条」按已盘库位数统计,未盘占位行不计入

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-10-28 00:08:22 +08:00
630f2a3a3c feat(库存盘点): 详情页新增盘点明细选择器
- 新增 CountDetailPicker 盘点明细选择组件
- inventoryCountDetail 接入明细选择流程
- countModel 补充明细选择相关共享口径
- apis 调整盘点相关接口定义
2026-10-27 18:22:29 +08:00
002fdbf455 feat(盘点): 盘点上报接口接入 space_id 库位ID并增加数量上限校验,版本升级至 1.0.132
- check.report 上报新增 space_id(wms_location_space.id)必传,兼容
  spaceId/location_id/locationId/space_id 多种写法,按库位ID精确落库
- countModel 各视图(space/goods/location/商品详情)统一补充 spaceId、
  locationId 字段,并在 buildWorkUnit 中透传库位ID
- 各盘点页(Detail/Goods/Location/Space)提交时补传 space_id,缺失时
  弹窗提示「缺少库位ID(space_id)」
- 实盘数量增加上限校验(0~2147483647),防止超出 int 范围导致上报失败
- package.json / manifest.json 版本号升级至 1.0.132(versionCode 1000132)
2026-10-26 17:58:26 +08:00
245bbc9287 fix: 修复蓝牙秤重量解析错误并升级版本至 1.0.131
蓝牙秤解析修复(src/core/store/modules/bluetoothScale.js):
- HC-06 类 '=' 帧协议改为“整数部分 + 小数部分”合并后整串逆序,
  修复实际 1523g 被解析成 523.1g 的问题(=325.100 → 1523g)

APK 版本对齐(android-offline/prepare.cjs):
- 打包注入时把 www/manifest.json 的应用版本强制对齐到 package.json,
  修复应用内 plus.runtime.getProperty 读到旧版本导致反复弹更新

版本号升级:
- package.json:1.0.128 → 1.0.131
- manifest.json:versionName 1.0.127 → 1.0.131 / versionCode 1000131

今日打包统计(src/pages/packing/packMode.vue):
- 统计统一在 onShow 拉取,onLoad 不再重复请求
- 完成打包后刷新今日统计
- 打开统计面板时强制刷新
2026-10-24 18:00:32 +08:00
7090396cf0 feat(称重): 优化蓝牙电子秤连接稳定性并支持 HC-06/08 协议
- 支持 HC-06/HC-08 类 BLE 电子秤协议:帧头 '=' + 数字,整数部分按固件逆序解析,单位按 g、视为稳定读数;兼容旧秤 ST/GS/WT/NET/OK 标志,不误反转
- 发现并订阅全部可订阅特征(不再只看首个),订阅前先关闭再开启通知强制重写 CCCD,规避安卓 GATT 缓存导致“已连接但收不到数据”
- 服务发现增加重试(3 次),规避同名设备切换后 getBLEDeviceServices 返回空/旧缓存
- 新增“已连接但无数据”看门狗:3 秒未收到数据自动强制重连(最多 2 次)
- 扫描优先连接“正在广播”的匹配设备,解决同名多设备(新旧秤都叫 HC-06)连到旧设备的问题
- 连接互斥锁增加超时兜底,防止个别机型连接 API 卡死导致锁永不释放
- 断开后延迟等待系统完成 GATT 断开,切换设备后清空旧秤残留读数
- 称重页新增“原始数据”展示,便于排查读数问题
- 版本号升级 1.0.127 -> 1.0.128
2026-10-23 20:16:10 +08:00
e21e9d7464 fix(订单复核): 自动读秤打开弹窗时实时重量未回填称重输入框
- 抽取 tryAutoFillWeighFromScale() 复用自动回填逻辑
- 称重弹窗打开且「已连接+自动读秤」时立即回填当前重量,
  修复秤在弹窗打开前已稳定读数时 scaleWeight 不再变化、
  watcher 不再触发导致「实时重量有值但输入框未回填」的问题
- 版本号 1.0.125 → 1.0.127
2026-10-17 18:03:29 +08:00
445e4aa209 feat(蓝牙秤): 订单复核页接入蓝牙秤,修复连接切换/扫描问题与老机型弹窗间隔
- 订单复核页 order-review.vue 称重弹窗接入蓝牙秤(复用 bluetoothScale store):
  - 称重行新增「读秤/连秤」按钮,蓝牙秤状态卡(实时重量/自动读秤/连接/断开/设备管理)
  - 新增蓝牙秤连接弹窗(按名称连接/扫描设备列表)与断开二次确认弹窗
  - 导航栏右侧新增「蓝牙秤/已连」入口,复核开始前可提前手动连接
  - 读秤/自动读秤回填(单位 g),带 1g 抖动阈值与编辑保护,回填前先失焦避免输入框不刷新
  - 连接弹窗与按钮样式对齐称重页 weighing.vue

- bluetoothScale store 模块修复:
  - 切换设备改为单连接:连接前先断开旧设备,manualDisconnect 阻止自动重连争抢
  - already-connect 分支改为重新发现服务并重新订阅通知,切回仍连接设备也能稳定收数
  - 扫描列表合并已配对设备 + 本地持久化历史连接设备(WMS_BT_SCALE_HISTORY),
    解决切换设备后扫描找不到之前连接过的设备

- 老机型 flex gap 兼容(改用 margin):
  - order-review.vue 称重/包材/断开确认/扫描数量弹窗底部按钮
  - ReviewDetail.vue 无条码复核弹窗底部按钮
2026-10-16 17:59:47 +08:00
fb14f89aef feat(order): 称重页接入蓝牙电子秤并优化显示与交互
- 新增 bluetoothScale store 模块:BLE 扫描、按完整名称精确连接、
  设备连接(服务/特征发现 + 订阅通知)、重量解析(kg/g、稳定标志)、
  断线自动重连、手动断开
- 新增蓝牙秤演示页 bluetoothScale.vue(扫描/连接/实时重量/原始数据/日志)
- 称重页 weighing.vue 接入蓝牙秤:
  - 称重重量行新增「连秤/读秤」按钮,支持读取重量回填输入框
  - 新增蓝牙秤状态卡:连接状态、实时重量、自动读秤开关、连接/断开/设备管理
  - 新增「连接蓝牙秤」弹窗:设备扫描列表 + 按完整名称连接
- 显示与交互优化:
  - 蓝牙秤状态卡与弹窗字体整体调大
  - 旧真机 flex gap 兼容(改用显式 margin 留间隔)
  - 合并「设备管理」与「连接蓝牙秤」重复入口(未连接只显示连接,已连接显示断开+设备管理)
  - 操作按钮改为浅色背景+彩色文字,并放大高度与字号
  - 连接弹窗布局对齐盘点操作弹窗(居中标题、顶部圆角、底部按钮样式)
  - 断开蓝牙秤增加二次确认弹窗
  - 默认开启自动读秤;实时重量改黑色且不加粗;称重重量字号与实时重量一致
2026-10-15 18:12:30 +08:00
dc4c0cd0e5 feat(bluetoothScale): 新增蓝牙电子秤接入与演示页
基于 uni-app BLE 实现电子秤「扫描 → 按完整名称精确匹配连接 → 订阅通知 → 解析重量」完整流程。

- 新增 bluetoothScale Vuex 模块(bluetoothScale.js):
  蓝牙初始化、设备扫描、按名称连接、BLE 服务/特征值发现、通知订阅、重量解析
- 新增蓝牙秤演示页(bluetoothScale.vue):
  实时重量显示、原始数据/HEX 核对、扫描设备列表、操作日志
- 注册 bluetoothScale 模块到 store/index.js
- 注册页面路由到 pages.json
- 设置页新增「蓝牙秤演示」入口

说明:纯新增改动,不影响现有业务流程;仅支持 BLE,经典蓝牙 SPP 需另引原生插件。
2026-10-13 18:15:17 +08:00
ee00ca7661 feat: 版本升级至 1.0.125,修复库存盘点下拉刷新卡死,优化退料单页面 UI
1. 版本号升级 1.0.124 -> 1.0.125
   - package.json、src/manifest.json

2. 修复库存盘点页下拉刷新卡死问题
   - App 端原生 refresher 需先收到 true 再收到 false 才会收回,
     请求过快时 true/false 被渲染层合并,导致真机下拉一直转圈
   - 改为 await $nextTick() 后延迟 300ms 再关闭 refreshing
   - 涉及:inventoryCount、inventoryCountDetail、inventoryCountGoods、
     inventoryCountLocation、inventoryCountSpace

3. 退料单页面 UI 优化
   - 搜索框由 u-input 改为 u-search 圆角样式,搜索按钮绝对定位于框内右侧
   - 任务卡、弹窗、扫描记录整体字体放大,提升真机可读性
   - 编号/单号/备注等长文本由单行省略改为完整换行显示
   - 扫描记录列表增加斑马纹(偶数行浅灰背景),导出按钮改为蓝色实底
   - 备注弹窗输入框与按钮等高对齐,旧真机不支持 flex gap 改用 margin
   - u-popup 圆角改用组件 round 属性,移除手写圆角样式
2026-10-11 17:37:05 +08:00
88a034553d feat(盘点): 优化盘点录入体验并升级版本至 1.0.124
- 版本号: package.json 与 manifest.json 同步升级 1.0.123 → 1.0.124
- 盘点录入弹窗(CountRecordAddPopup): 打开后自动聚焦实盘数量输入框并弹出软键盘;
  键盘弹出时仅上移弹窗自身、且仅在数量输入框聚焦时上移, 不推整页;
  搜索框右侧新增"搜索"按钮与分隔线; 新增 locationName 属性, 副标题显示库位名称; 整体字号调大
- 库位录入弹窗(CountSpaceEntryPopup): 搜索框右侧新增"搜索"按钮; 副标题改为显示库位条码;
  键盘弹出仅数量输入框聚焦时上移; 查询无结果时语音播报"无记录"; 头部布局改为纵向居中
- 宫格列表(CountLocationGrid): 库位模式格子改为两行布局(库位名换行/数量+状态), 样式微调
- 库位明细(CountLocationDetail): zebra 行副标题颜色与区块数量字号调大
- 工作卡片(CountWorkCard): 子级标签 margin 微调
- countModel: 库位作业副标题仅显示条码; 库存搜索条码优先取 barcodes 数组、规格优先取 sku_property;
  库位搜索新增 customBarcode 字段
- 盘点明细页(inventoryCountDetail): recordAddTarget 新增 locationName; tab 切换文字字号调大
- 盘点商品页(inventoryCountGoods): 删除成功/失败增加语音播报
- 盘点库位页(inventoryCountLocation): 移除冗余"库位"行仅保留库位名称; 删除成功/失败增加语音播报
- 盘点库位作业页(inventoryCountSpace): 盲盘接口不返回数量时本地记录上报数量并在重拉后回填;
  未找到商品时语音播报"无记录"
- 分页组件(pagination): 总数信息字号调大
2026-10-10 18:02:01 +08:00
2119e9dfc9 feat(inventory-count): 盘点模块 UI 优化与已盘/差异口径修正
- 已盘判定改为「状态=checked 或有作业记录 或实盘>0」,实盘=0 视为未盘
- 差异统一按「实盘-账面」计算,不信任后端 diff_quantity;未盘项不显示差异
- 新增 isCheckedLocation,库位明细与已盘库位数只统计真正已盘的库位,过滤任务占位项
- 商品副标题条形码提前到规格之前
- 空库位登记弹窗键盘适配:弹窗自身随键盘上移,不整页上推;聚焦延时与 @open 再聚焦
- 全模块字号加大、层级重排:任务卡片/宫格/库位明细/商品卡/汇总面板
- 库位明细负边距斑马纹铺满整行;任务卡片移除 stripe
- 状态筛选由横向滚动改为等宽分布铺满整行
- 库位宫格 space 视图重排:商品数与状态同行、已盘进度独占一行
- 汇总面板货主字段上移,最近上报靠右,实盘数量黑色
- 收货页样式微调
2026-10-09 18:22:39 +08:00
48e2438416 fix(盘点): 库位标记空库位补语音播报,返回列表复位关键字
- 盘点详情页:从库位明细页返回时清空扫描关键字,作业列表恢复显示全部库位
- 盘点详情页/库位页:新增 speakMessage 语音播报(复用全局 $tools.speakText,受语音开关控制)
- 标记空库位:上报成功后播报「已标记空库位」,失败播报「标记失败」
- 标记空库位:确认弹窗优先展示库位名称(locationName → locationCode → detailId)
- 标记空库位:上报入参补齐 detailId
- 完成盘点:成功/失败/异常均增加语音播报(统一播报「盘点完成/盘点失败」,盘盈盘亏仅弹窗展示)
2026-10-08 18:00:15 +08:00
17787988d3 fix(盘点+退件): 修复货主乱码与库位展示,优化导出二维码真机兼容
盘点:
- 货主名称安全解码,修复真机显示百分号编码乱码
- 盘点类型补充 store/all 文案与色调
- 库位与库位名称展示位置互换(宫格/明细/登记弹窗/盘点记录)
- 商品记录副标题改为显示条码
- 列表携带货主名称到详情页兜底,移除库位卡片冗余行

退件:
- 导出二维码改为纯 JS 生成 PNG data URL,兼容旧 WebView 缺失 TextEncoder 与无 canvas 环境
- 长按二维码支持保存到系统相册
2026-10-07 18:21:06 +08:00
db90efa0cb chore: 版本升至 1.0.123,商品图片维护回滚逻辑优化,新增发布上传配置
商品图片编辑/维护(edit.vue、itemMaint.vue):
- 图片未变化时直接放行返回,不再每次返回都发 ReferenceFile 请求(修复需点两次返回)
- 返回键/返回按钮先拦截,回滚完成后再 navigateBack,避免页面提前销毁导致回滚中断、图片停留在删除后状态
- navigateBack 增加 success/fail 均未触发的静默失效重试兜底
- 保存成功后同步初始快照,避免保存后返回被误回滚到保存前图片
- itemMaint 图片查询支持多候选 id 兜底(查询页传入 id/stock_id 优先),修复按条码重查不到商品时图片不显示

商品查询页(query.vue):
- 跳转维护页时附带 id/stock_id 参数,供图片查询兜底
- 图片缩略图增加 :key 强制刷新

发布上传(config/deploy.json、deploy.example.json):
- 新增部署配置,打包结束后自动生成 latest.json 并用 scp 上传 APK + 版本清单
- config/README.md 补充 deploy.json 字段说明

测试包构建脚本(dev-adb.cjs):
- 不注入地址时(--prod-api / 未配置开发地址)显式删除继承的环境变量,避免终端残留 VUE_APP_API_BASE_OVERRIDE/URL 把开发地址带进包

文档(README.md):
- 更新测试包命令用法,说明 npm 10 下 -- 参数会被吞、需直接用 node 调用脚本

其他:
- package.json、manifest.json 版本号 1.0.122 → 1.0.123
- 新增 scripts/_argtest.cjs(打印 argv,调试用)
2026-10-06 19:30:29 +08:00
liufumingren
e8db7a2293 feat: 退件收件任务模块(列表/扫码登记/扫描记录/导出)+ 库存盘点作业页完善
- 退件收件:returnRecord 改为收件任务列表(默认只看本人创建、可切全部、新建任务默认「用户名 当天日期」、左滑删除),扫码登记抽到 ReturnScanPanel 组件并由 returnRecordScan 页面承载,登记带 return_received_task_id

- 扫描记录:按任务 ID 过滤、底部剩余空间独立滚动(上拉/点击加载更多、下拉刷新)、标题显示任务登记总条数、原单退回显示货主名、常用备注抽屉(localStorage)、导出(异步任务+进度轮询+二维码/复制链接)

- 库存盘点:库位/商品/单库位作业页拆分与 workDataDetail/workDataSpaceDetails/recordList 接入;App.vue 图片预览层 z-index、auth-guard 整页启动路由修复;apis.js 补 returnReceivedTask/returnReceived.list/export 与漏登记保护
2026-10-06 04:49:40 +08:00
7c6aedfa6d feat(product): 商品维护页表单与图片管理重构,打包优先使用最新编译产物
打包优化:
- prepare.cjs 优先使用 CLI 最新编译产物 dist/build/app-plus,
  unpackage/resources 仅作兜底,避免旧代码打入 APK

商品图片管理重构(itemMaint/edit/detail/query/uploadImgCos):
- 统一图片 URL 与 fileId 提取逻辑,支持嵌套 file 对象及
  file_url/file_id 等字段,消除多处重复解析
- getImages 请求参数简化为 type + id,移除冗余的
  business_id/stock_id/business_type
- 商品编辑/维护页进入时拉取最新图片并记录初始快照与文件 ID,
  返回时通过 ReferenceFile 回滚图片引用,避免未保存即改动图片
- 保存成功后通过事件 + storage 通知商品查询页刷新缓存

商品维护页(itemMaint):
- 表单移除"有效期"快捷选择,保质期改用商品原始数据;
  新增"净重 NET_WEIGHT"字段
- 新增扫描与提示语音播报,页面隐藏/卸载时自动停止播报
- 调整输入框 placeholder 颜色、保存按钮宽度、表单卡片
  边框圆角阴影、字段标签宽度等样式
2026-10-05 18:26:29 +08:00
liufumingren
fd3228eac3 refactor(warehouse): 盘点列表/详情拆分复用组件并新增库位明细子页
- 抽出 inventoryCount-comps/:countModel 纯函数 + 记录卡片/工具栏/汇总面板/搜索面板/明细面板/宫格/添加商品弹窗等

- 新增 pages/warehouse/inventoryCountLocation 库位明细子页(workDataDetail + 扫码预填添加商品 + 左滑删除记录)

- apis.js 补 result / workData / workDataDetail / recordDelete / addDetail / addLocationDetail 别名

- pages.json 注册新页面
2026-10-05 02:47:24 +08:00
liufumingren
c924b5c0fb fix(ui): uicon 图标字体改本地加载,去掉 alicdn 外链
- u-icon.vue:nvue 与 H5/小程序都改读 static/fonts/uicon-iconfont.ttf

- index.vue:@font-face 同步改本地路径,避免弱网下图标闪空
2026-10-05 02:47:23 +08:00
liufumingren
f137ff9ec6 docs: 补充终端中文乱码的处理说明(chcp 65001) 2026-10-02 22:15:43 +08:00
liufumingren
6b3779ca6a feat(dev): dev:adb 多设备交互选择 + 记住上次设备
- 设备选择优先级:--serial= > 上次选择的设备(.dev-adb.local.json,不提交) > 单设备自动 > 多设备交互选择
- 非 TTY 环境(如某些任务脚本)给出 --serial 的明确提示,不再直接退出
- .gitignore 忽略 .dev-adb.local.json;README 补充设备选择说明
2026-10-02 22:15:32 +08:00
liufumingren
e93faeda0a feat(dev): 真机 console 转发到 logcat + dev:adb 支持 watch
- 新增 src/core/utils/dev-log.js:测试包用 plus.android 桥接 android.util.Log,把 console 输出写到 logcat 的 jsLog tag(离线 release 包默认不转发 JS 日志);仅 VUE_APP_JS_LOG_TO_LOGCAT=1 时生效,发行包中被常量折叠
- main.js 挂载该桥接;scripts/dev-adb.cjs 注入开关、logcat 过滤加 jsLog,并新增默认开启的文件监听(改动自动重编重装)、--once 单次模式
- README 更正真机日志说明
2026-10-02 22:10:01 +08:00
liufumingren
34263169ed feat(apk): 增加测试模式(dev:adb 注入开发环境接口地址)
- scripts/dev-adb.cjs:编译期注入 VUE_APP_API_BASE_OVERRIDE(默认取 .env.development.local),打包到 release/android/dev 并可选装机启动
- pack.ps1 新增 -Dev:产物 _dev 后缀 + 单独目录,不覆盖发行包、不触发发布上传
- package.json 新增 dev:adb / build:app-plus:dev
- README 补充两种模式的接口地址来源、正反向校验与真机日志查看方式
2026-10-02 21:57:15 +08:00
liufumingren
1067352c4c fix(apk): 补齐蓝牙模块(aar + dcloud_properties feature)
- libs 增加 Bluetooth-release.aar(从离线 SDK 的 SDK/libs 复制)
- dcloud_properties.xml 增加 <feature name=Bluetooth>,与线上云打包包逐行对齐
- 文档补充:离线打包的模块(aar)处理方式、核对与验证方法
2026-10-02 21:49:14 +08:00
liufumingren
807b545506 fix(apk): 清理重复的 BootReceiver 源文件并修正 keystore 别名
- 删除 com/gztbyc/sandan/BootReceiver.java(重复类导致 javac 报错)
- 别名修正为 __uni__0b3dad3(DCloud 规则:__uni__ + appid 小写)
- config/README 与 example 补充别名规则说明
2026-10-02 21:36:23 +08:00
liufumingren
3251be25a4 chore(apk): 填入 appKey 与别名,appid 注入产物更新为 __UNI__0B3DAD3 2026-10-02 21:27:24 +08:00
liufumingren
f9327397d6 chore(apk): 版本对齐到 1.0.122 并补充打包文档
- package.json 与 src/manifest.json 版本同步为 1.0.122 / versionCode 1000122
- prepare.cjs 增加版本一致性校验(两处不一致时告警)
- 文档补充:版本号单一来源与云打包 versionCode 差异、图标/启动图来源、appKey 与证书指纹匹配
2026-10-02 21:20:14 +08:00
liufumingren
bf44b33abd chore(apk): 用生产 APK 提取的正式图标与启动图替换占位素材 2026-10-02 21:16:45 +08:00
liufumingren
06d58a5a71 chore(apk): 移植 Android 离线打包流水线(命令行出 APK,无需 HBuilderX)
- android-offline/:DCloud 离线集成工程(simpleDemo/libs 含 5+ Runtime aar)+ pack.ps1 + prepare.cjs
- 包名 com.gztbyc.pda_wms、appId __UNI__0B3DAD3、BootReceiver 迁到新包名目录
- AndroidManifest 补齐权限(与 src/manifest.json 对齐)、新增蓝牙权限与 usesCleartextTraffic(生产接口为 http)
- prepare.cjs 默认资源目录改为 dist/build/app-plus,注入到 assets/apps/__UNI__0B3DAD3/www 并对齐 compilerVersion
- config/:android.example.json 模板 + README(appKey 与 appId/包名/证书指纹绑定说明);android.json 与 keystore 均不提交
- scripts/build-apk.cjs + npm run build:apk / android:pack:raw:生产编译(含地址校验)→ gradle 出包到 release/android
- .gitignore 忽略 keystore、config/android.json、SDK、生成的 www 与 release
2026-10-02 21:12:15 +08:00
liufumingren
ba33f9c59a fix(env): 生产地址防呆,避免开发地址打进正式包
- src/env.js:生产构建固定 PROD_API_BASE,开发地址只从 .env.development.local 注入,源码不再保留内网地址字面量
- 新增 scripts/check-build-env.cjs:扫描产物含内网地址或缺生产域名即中止构建,已挂到 build:h5 / build:app-plus,另有 npm run check:env
- 新增 .env.example 模板;开发变量改用 mode 专属的 .env.development.local(.env.local 在 production 模式也会被加载并注入客户端代码)
- README 补充接口地址与环境变量防呆说明
2026-10-02 20:17:23 +08:00
liufumingren
5ae92e0f63 chore(cli): 由 HBuilderX 工程迁移为 uni-app Vue2 CLI 脚手架工程
- 业务源码统一迁入 src/,H5 模板移到 public/index.html
- 新增 @vue/cli 4.5 + @dcloudio 2.0.2-5020620260917001 全套依赖与 scripts
- 保留 vue.config.js 的 ROUTES 注入(uni-simple-router 运行时依赖)
- 新增 scripts/node-compat.cjs 兼容 Node 23+ 移除的 util.isRegExp 等 API
- README 补充构建/运行/回退说明
2026-10-02 19:45:18 +08:00
8318b3a688 feat: 新增商品信息维护页及作业要求(打包/拣货/复核)字段
- 新增 pages/work/product/itemMaint 维护页并在 pages.json 注册
- 商品查询页新增「维护信息」入口,扫码带出商品后跳转
- edit/detail 页新增拣货、复核要求字段,支持要求合并/拆分切换
- 首页与快捷操作拦截「商品信息维护」,仅限商品查询页使用
2026-10-02 17:59:25 +08:00
4d33fc3241 fix(复核): 确认复核接口弱网防重入与错误提示区分网络/业务失败
- 新增 confirmRechecking 防重入标记,请求进行中忽略重复触发,避免弱网下重复复核/重复发货
- confirmRecheck 请求改为 10s 快速失败 + 关闭全局 toast,由本地统一处理错误
- 新增 handleConfirmRecheckError 区分网络异常与业务失败:网络异常提示结果未确认并语音播报,业务失败展示原始提示
- doGroupShip/afterPackageBinding 失败统一复用 handleConfirmRecheckError
2026-10-02 11:43:45 +08:00
031fb0c5b6 feat(复核/打包/拣货): 统一语音播报顺序与去重,移除要求前缀,新增取消拣货二次确认
复核发货(pages/work/order/order-review.vue、order-review-comps/ReviewDetail.vue)
- 语音播报顺序调整为:复核命中商品 → 播报"数据一致" → 播报该商品复核要求内容
- 移除进入详情时统一播报复核要求;包材匹配成功改为直接播报"数据一致"
- 同一商品(按商品 id 去重)仅播报一次复核要求,数量>1 多次扫码不重复播报
- 进入详情时语音播报免复核商品(need_recheck=N)的打包要求,按文本去重播报一次
- 商品卡片移除"复核要求:"标签前缀,仅显示要求内容
- ReviewDetail 的 speakDataConsistent 事件携带命中商品

打包模式(pages/packing/packMode.vue)
- 语音播报顺序调整为:核实命中商品 → 播报"数据一致" → 播报该商品打包要求 → 全部核实后执行打包
- 移除查询订单成功后统一播报打包要求
- 新增 groupPackQueued 标志:语音播报结束后再执行打包,防止播报期间被误判为上报失败重传
- 商品条目移除"打包要求:"标签前缀,仅显示要求内容

拣货(pages/work/order/picking.vue)
- 移除"拣货要求:"标签前缀,仅显示要求内容
- 新增取消拣货二次确认弹窗(确认取消拣货任务)
- 操作弹窗按钮间距样式调整(gap 改为 margin-left)
2026-10-01 18:19:06 +08:00
27f4d178aa feat(拣货/复核/打包): 新增拣货要求与复核要求展示、语音播报及样式优化
- 拣货页:新增拣货要求横幅与弹窗展示,兼容 pick_mode 5 与 2/3/4 两种字段来源;
  显示哪个商品即播报该商品拣货要求,去重串行、只播一次;弹窗样式优化
- 复核发货页:进入详情去重串行播报复核要求,「数据一致」排队到复核要求播报完成后;
  复核要求字段优先取 recheck_requirements
- 复核详情组件:「包装」改为「复核要求」,要求行改浅红底标签,字号调大;
  「数据一致」改为事件上抛由父组件排队播报
- 打包模式页:新增打包要求标签展示与语音播报(去重串行、数据一致排队播报);
  扫描重复跳过增加失败态豁免;重查失败恢复待重传状态;映射补充 packing_requirements
2026-09-30 18:41:57 +08:00
liufumingren
cb17d9bf2f fix(packMode): 弱网下打包提交失败卡死与上报失败自动恢复
- 请求层增加硬超时兜底:uni.request 超时不可靠时主动 abort 并透传失败原因
- 打包/查询/完成打包请求显式 15s 超时,失败后必定恢复界面可操作
- 上报失败弹出重新上传弹窗,点击重传成功后自动关闭
- 提交开始打包收到服务器错误时自动重查订单换新 key 并重新提交(限一次)
- 团购重查后恢复核实进度自动重新提交;支持扫描商品/长按商品手动重传
2026-09-30 01:27:27 +08:00
ee497b1700 refactor(inventoryCount): 优化盘点列表与详情逻辑
- 盘点列表从详情页返回时自动刷新,保证状态与详情操作一致
- 默认列表仅展示 approved/checking/completed/cancelled 四种状态,过滤 created/submitted/rejected
- 详情页移除提交审核入口(删除按钮、canSubmit 计算属性及 handleSubmitAudit 方法)
- 盘点数量字段兼容 checked_quantity,回退 check_quantity(涉及列表行解析与回填两处)
2026-09-29 18:03:34 +08:00
d518be2c36 feat: 新增库存盘点功能
- 新增库存盘点任务列表页与明细页(pages/warehouse/inventoryCount*.vue)
- 注册盘点页面路由(pages.json)
- 新增 stock.check 接口组:list/detail/report/finish/submit/cancel
- 首页与快捷操作菜单新增「库存盘点」入口跳转
- 商品查询页库存改为可用数量+锁定数量计算展示
2026-09-29 15:55:37 +08:00
6b3262019f git commit -m "移库记录页优化与首页通知弹窗修复:卡片斑马纹、筛选选中态实心化、切换先清空再加载;首页欢迎语点击不弹窗" 2026-09-29 11:26:56 +08:00
7070aac1ca feat(首页): 欢迎语新增未领料波次并优化公告条与通知弹窗
- 新增未领料波次字段(order.wave.confirmPrintUnclaimedWaveCount),
  仅当同时拥有「领取快递面单」与「订单拣货」菜单时展示
- 顶部公告条改为自定义无缝滚动,消除首尾空白
- 「看板统计」弹窗更名为「通知信息」,调大字体并修复3列布局
2026-09-29 10:50:50 +08:00
c443f7ccae feat(home): 首页看板统计与通知栏改造
- 新增 dashboard.storeStats 看板接口(core/request/apis.js)
- 首页顶部欢迎语改为按用户菜单动态展示看板统计
  - 有「复核发货」菜单:今日订单、已复核
  - 有「订单拣货」菜单:今日订单、未拣货
  - 两者都有:今日订单、未拣货、已复核
- 点击通知区域弹出「看板统计」弹窗,展示项与通知栏一致(均按菜单控制)
- 修复通知栏与仓库主体布局,仓库名不再被压缩,并调大两者间距
2026-09-28 20:09:43 +08:00
428f06ebd3 feat: 新增移库记录页面
- 新增 pages/warehouse/inventoryTransfer.vue:支持按商品条码/名称/操作人搜索、
  扫码查询、移入/移出类型筛选、分页列表(展示商品、数量、移出/移入库位、操作人等)
- pages.json 注册 pages/warehouse/inventoryTransfer 路由
- core/request/apis.js 新增 warehouse.getSpaceInfo、storage.transaction.list 接口
- pages/index/index.vue、pages/home/edit-quick-actions.vue:工作台「移库记录」
  菜单点击跳转到移库记录页

  refactor: 重构称重页查询与校验逻辑

- 改用 common.toOrder + order.detail 查询,替代原 scanOrder 分支逻辑
- 按波次号前缀区分散单/团单(B 开头视为团单),新增 isGroupOrder 状态
- 增加称重前置校验:未拣货、未复核禁止称重;散单未打包禁止称重
- 商品净重统一取订单详情 items_weight,运单匹配成功才回填称重重量
- 提取 clearOrderData 复用清空逻辑
2026-09-27 18:02:08 +08:00
2eb9cbfc1b feat: 大团购打包时长闸门、无任务自动登出与加急退回提示
packMode.vue:
- 新增大团购打包时长闸门倒计时条:packOrder 返回 wait_seconds/start_time 后展示,归零自动隐藏;恢复进行中任务时续上倒计时
- 扫描其它波次订单返回「打包时长不足」时,保留当前订单上下文不覆盖,提示后允许继续扫描本波次
- 打包上报携带波次范围 wave_scope 字段
- 新增 30 分钟无新打包任务自动登出:自动结束最后打包任务、下线全部成员、清空本地状态(不退出打包模式页面)

returnRecord.vue:
- 新增加急退回订单提示条,并针对加急订单优化语音播报(成功「加急订单,登记成功」、幂等「加急订单,已登记」)
2026-09-24 14:22:59 +08:00
11e8fa2ed4 feat(packMode): 打包台操作员批量下线与拣货信息展示优化
- 订单摘要新增拣货人字段展示,商品种类/总数合并展示
- 在线操作员列表支持勾选多人批量下线(全选/取消全选/底部批量下线条)
- 商品明细条码改为全部条码以「、」连接展示
- 绑定/移除成功语音播报成员姓名,移除后自动关闭操作员弹窗
- 优化操作员弹窗及扫描区字体字号,适配 PDA 大屏显示
2026-09-23 13:27:51 +08:00
a670d8e93c 修改打包模式页面 2026-09-22 18:04:08 +08:00
e960571703 修改打包模式页面 2026-09-22 17:39:02 +08:00
1f72dc3ee3 修改打包模式页面 2026-09-22 16:23:48 +08:00
3f2b7fa5d0 修改打包模式页面 2026-09-21 18:20:27 +08:00
79676c33ef 修改领料页面 2026-09-20 13:41:53 +08:00
524da0b7e5 修改复核发货页面 2026-09-19 17:39:16 +08:00
fe7dde14ed 修改商品查询页面 2026-09-16 15:58:27 +08:00
1dc754ea30 修改商品查询页面 2026-09-16 13:46:55 +08:00
83408c968e 修改商品查询页面 2026-09-15 19:48:31 +08:00
4d271c47f0 修改库位查询页面 2026-09-14 18:01:56 +08:00
6913373362 新增库位查询页面 2026-09-13 17:55:56 +08:00
55b96d25be 修改打包模块页面 2026-09-11 18:23:42 +08:00
b51a149d15 修改复核发货页面 2026-09-10 18:04:04 +08:00
163fbc86a7 修改绑定工作台、散单,团购波次策略、打包模式页面 2026-09-08 17:45:41 +08:00
86b93002f7 修改打包模式页面 2026-09-07 18:40:17 +08:00
692d0620a5 新增配置--绑定工作台、打包模式 2026-09-06 22:15:11 +08:00
b0abe2234e 修改打包模块、散单、团购拣货详情 2026-09-05 16:04:13 +08:00
0431271fff 修改登录、打包模块页面 2026-09-04 20:44:26 +08:00
a448958e47 修改复核发货、散单拣货详情、商品查询页面 2026-09-04 15:46:44 +08:00
1c0f6a9451 修改随机入库页面 2026-09-03 16:25:52 +08:00
2be017d58f 修改订单拣货页面 2026-09-03 13:42:44 +08:00
28bad8a62e 修改商品查询页面 2026-08-30 17:52:14 +08:00
5fd9db9ee0 修改复核发货页面 2026-08-30 10:05:51 +08:00
e956e36e71 修改订单拣货。复核发货页面 2026-08-29 20:24:39 +08:00
34015dc564 修改复核发货页面 2026-08-29 11:27:35 +08:00
512ed452e4 修改复核发货、分拣缺货补货页面 2026-08-28 17:51:05 +08:00
b543d6e977 修改复核发货页面 2026-08-25 17:37:05 +08:00
9d35721b2e 修改复核发货页面 2026-08-25 13:42:48 +08:00
24d455a2e8 修改订单拣货页面 2026-08-25 10:46:04 +08:00
9672a315b6 修改复核发货、散单、团单波次策略 2026-08-23 17:16:55 +08:00
9580129c48 修改订单拣货页面 2026-08-22 18:55:53 +08:00
a665fb40ed 修改复核发货页面 2026-08-22 17:57:59 +08:00
9ec654692e 新增领取快递面单页面、修改拣货记录页面 2026-08-20 17:53:30 +08:00
3054caf08c 新增拣货记录页面 2026-08-19 18:31:58 +08:00
522cca5259 修改订单复核页面 2026-08-18 18:07:27 +08:00
876e13c495 修改复核发货、订单拣货、关于页面 2026-08-17 17:58:47 +08:00
b2d6172f16 修改订单复核、退件记录页面 2026-08-15 18:04:55 +08:00
3174c068db 修改订单复核页面 2026-08-14 16:51:20 +08:00
a1a68d9cb3 新增拦截登记、退件记录页面 2026-08-13 17:58:43 +08:00
edd932fa49 修改关于页面 2026-08-12 14:55:47 +08:00
45694c1942 修改商品查询页面 2026-08-12 14:08:50 +08:00
2aecd0e863 修改商品查询、关于页面 2026-08-11 17:57:43 +08:00
95651ccb19 修改订单复核、商品查询页面 2026-08-10 17:58:06 +08:00
205d48984b 修改商品查询、分拣缺货补货页面 2026-08-09 18:05:45 +08:00
5aa29019b4 修改订单复核页面 2026-08-07 17:33:21 +08:00
70dd419632 修改商品查询、订单复核页面 2026-08-06 18:38:18 +08:00
6c80c0b65f 修改订单拣货、复核发货页面 2026-08-05 19:44:44 +08:00
207631e7ef 修改订单拣货页面 2026-08-04 13:36:10 +08:00
ec5dd24860 修改称重、订单拣货页面 2026-08-03 20:16:23 +08:00
a8d495346e 修改订单拣货页面 2026-08-03 11:24:33 +08:00
b92d796805 修改绑定包材页面 2026-08-02 20:41:52 +08:00
2a7847de15 修改复核发货,面单补打功能 2026-07-31 19:08:07 +08:00
c290eecc2b 修改订单复核页面 2026-07-31 17:00:00 +08:00
3d5d96b2ee 修改订单复核,绑定包材页面 2026-07-30 16:28:20 +08:00
941d9d30e9 修改拆单、面单补打页面 2026-07-29 21:11:18 +08:00
5795083c3f 修改拆单页面 2026-07-28 18:28:43 +08:00
569f32e2dc 新增拆单页面 2026-07-27 18:20:15 +08:00
8ebf3108a8 修改订单拣货、称重模块、复核列表、修改商品页面,重量单位统一为g 2026-07-26 17:29:52 +08:00
63d40b2f7f 修改订单拣货页面 2026-07-25 18:18:47 +08:00
aae10716d3 修改复核发货页面 2026-07-23 16:50:00 +08:00
a5715794a7 修改订单拣货页面 2026-07-22 18:17:26 +08:00
c195ba9e83 修改订单拣货、复核发货、修改商品页面 2026-07-22 16:47:29 +08:00
2335ee8fd9 修改复核列表、复核发货页面 2026-07-20 18:09:21 +08:00
9cf1b2331c 修改复核列表页面 2026-07-19 18:17:38 +08:00
bdb44a385b 修改复核列表、商品查询页面 2026-07-18 17:28:12 +08:00
f063287083 修改复核列表页面 2026-07-17 18:22:00 +08:00
788ee2e1e4 新增复核列表页面 2026-07-17 16:05:58 +08:00
4002c9feeb 修改绑定包材、复核发货页面 2026-07-16 18:13:06 +08:00
840dd35a10 新增绑定包材页面 2026-07-15 17:58:15 +08:00
001f9ebee9 修改复核发货的散单D型波次 2026-07-13 17:59:33 +08:00
37a962d27a 修改称重、复核发货页面 2026-07-12 16:05:58 +08:00
e08fa1c8ce 修改订单拣货、复核发货页面 2026-07-11 18:39:09 +08:00
4ec92d81c7 修改复核发货页面 2026-07-10 20:22:30 +08:00
0d9397a904 修改复核发货页面 2026-07-10 14:45:22 +08:00
de85ae5a1e 修改复核发货页面 2026-07-09 18:04:00 +08:00
dc7f8a67a1 修改称重、订单拣货、复核发货页面 2026-07-09 17:04:46 +08:00
28b16a6cd5 新增称重页面 2026-07-08 17:58:35 +08:00
e7086daddc 修改分拣缺货补货、复核发货页面 2026-07-06 17:31:20 +08:00
93826c96ff 修改分拣缺货补货页面 2026-07-05 18:20:19 +08:00
8a7007ccb1 修改分拣缺货补货页面 2026-07-04 17:59:01 +08:00
08e91f06e6 修改复核发货、面单补打页面 2026-07-04 15:01:48 +08:00
37715ce396 修改上架作业、面单补打、复核发货页面 2026-07-04 14:09:23 +08:00
4d98e54b8e 修改订单复核的称重接口 2026-07-03 17:32:00 +08:00
533ad0a856 修改订单复核页面 2026-07-03 15:56:12 +08:00
6de6c0db7a 修改订单复核,新增分拣缺货补货页面 2026-07-03 14:21:03 +08:00
9342ce0c56 修改复核发货的推荐包材的绑定,面单补打功能 2026-07-02 15:35:10 +08:00
815b82528d 修改随机入库、上架作业页面 2026-07-01 18:19:20 +08:00
b06e4300d0 修改商品查询、面单补打页面 2026-06-28 18:52:48 +08:00
5a509540c3 新整面单补打页面 2026-06-27 18:22:03 +08:00
439255445e 修改复核模块 2026-06-26 15:11:07 +08:00
79bce45ab3 修改拣货,复核发货模块;常用,全部功能页字体大小 2026-06-26 10:53:29 +08:00
4e9dadca94 修改拣货、复核模块 2026-06-25 20:12:01 +08:00
507da99f92 修改拣货、复核模块 2026-06-24 20:35:16 +08:00
aabf9a217d 修改拣货模块,条码显示 2026-06-23 21:01:47 +08:00
df7ba01211 新增随机入库模块,修改散单复核模块 2026-06-23 18:43:08 +08:00
2aef552697 新增随机入库模块 2026-06-22 20:38:08 +08:00
4f09cb6141 修改复核模块的包材 2026-06-22 15:29:16 +08:00
4747c2d1e7 修改页面路径 2026-06-22 13:30:37 +08:00
b5f366cdbb 修改复核模块 2026-06-21 19:01:07 +08:00
2e934c02b5 复核修正 2026-06-20 03:01:36 +08:00
260c6b505a 修改包材 2026-06-17 19:28:10 +08:00
3b380f4761 修改复核模块的包材功能 2026-06-17 17:18:13 +08:00
348d1e8cc7 修改拣货模块 2026-06-17 16:17:41 +08:00
b54d70b497 修改拣货模块 2026-06-17 15:01:31 +08:00
502a4df4cb 修改拣货、复核发货模块,新增包材 2026-06-16 15:52:49 +08:00
ddc61a3ac8 修改拣货。复核发货模块 2026-06-15 18:41:30 +08:00
6c2f8895a6 新增打印日志:订单复核的打印功能 2026-06-14 19:28:40 +08:00
f49411c428 修改订单复核模块 2026-06-14 16:37:35 +08:00
7105e4570a 修改商品查询条码支持模糊查询,库存列表修改样式,修改订单复核模块 2026-06-12 17:59:23 +08:00
2da51c98f6 修改订单复核模块 2026-06-12 14:10:32 +08:00
4692f0d12d 修改订单商品详情页 2026-06-11 18:55:18 +08:00
0c22b24489 修改订单复核、订单商品详情页 2026-06-10 21:09:56 +08:00
173771f60c 修改订单复核页面 2026-06-09 18:20:45 +08:00
66ee3043f5 修改库位显示为库位名称 2026-06-09 16:33:43 +08:00
31eb640fc3 修改拣货、复核发货模块 2026-06-07 17:58:42 +08:00
1999865c88 修改拣货模块 2026-06-06 17:58:30 +08:00
30067969c8 修改拣货模块 2026-06-05 17:59:18 +08:00
99f7c15f6c 修改拣货模块 2026-06-04 21:20:49 +08:00
68adb6ade0 新增散单复核发货页 2026-06-03 18:26:22 +08:00
5a6d95914e 修改散单、团购拣货页面的打印、底部分页功能 2026-06-02 17:56:37 +08:00
2e41d72791 修改散单拣货详情、团购拣货页面的打印、底部分页功能 2026-05-31 18:22:39 +08:00
9821d1c577 修改散单拣货详情页面的打印功能 2026-05-30 17:58:47 +08:00
cbb173ba16 新增接口调用:print.getList 2026-05-29 18:21:30 +08:00
565d4ded5b 修改散单拣货详情、拣货商品详情页 2026-05-22 17:55:01 +08:00
745a556a7e 修改散单拣货详情页 2026-05-21 18:16:19 +08:00
6f5495c097 优化收货功能 2026-05-21 11:36:23 +08:00
03c5d46067 优化、修复收货功能 2026-05-20 17:59:02 +08:00
b3d545b1c8 feat: 新增团购拣货详情页面并完善拣货流程入口 2026-05-12 17:56:51 +08:00
32759f820c feat(order-picking): 完善拣货页任务流程与菜单交互 2026-05-11 17:57:30 +08:00
liufumingren
c8a3344b7a 0510刘付明仁提交,优化散单策略列表和团购策略列表,和拣货列表,拣货列表尚未完成。
Co-authored-by: Copilot <copilot@github.com>
2026-05-10 03:58:36 +08:00
2d6ffc0451 feat: 优化拣货页面字号与标签显示 2026-05-09 18:23:17 +08:00
e127694fe4 feat: add scatter picking detail pages 2026-05-08 18:20:44 +08:00
2fb2b089eb feat: 新增散单波次策略页面并完善订单拣货流程 2026-05-07 18:20:41 +08:00
52e7d21a99 chore: 提交收货明细页修改 2026-05-06 17:52:07 +08:00
104423eec4 feat(picking): integrate pick.query and enhance picking flow 2026-05-05 18:31:25 +08:00
3ad222a2d2 chore(storage): update receiving detail and relocation pages 2026-05-04 18:20:37 +08:00
7d81508255 feat(order-picking): add picking mode and picking detail workflow 2026-05-04 18:19:05 +08:00
39543305a3 fix: 调整收货与移库语音提示文案 2026-04-29 13:28:14 +08:00
183cc2ebea fix: 修复商品图片上传删除关联与取消语音逻辑 2026-04-28 18:25:32 +08:00
8852fcc839 feat: 更新收货相关页面与信息容器 2026-04-27 18:25:19 +08:00
42fee4319d feat(receiving): 完善收货流程语音提示交互 2026-04-25 17:15:53 +08:00
7c7639a1e9 新增设置语音播报开关并完善收货列表语音播报逻辑 2026-04-24 17:57:40 +08:00
eaa0d03207 完善商品编辑与查询交互:图片删除关联修复、语音播报优化、保存校验与提示顺序调整 2026-04-24 16:21:47 +08:00
08b4275c8b 修复商品编辑页返回键回退逻辑,防止多退一层,保证图片回滚一致性 2026-04-23 15:45:11 +08:00
72179ce679 fix(upload): 调整COS上传流程实现 2026-04-22 18:03:25 +08:00
af356d2ba2 fix(receiving): 修复收货商品信息同步与展示问题 2026-04-22 14:36:41 +08:00
3fbd27c72c fix: optimize receiving UI and stabilize COS image upload 2026-04-21 18:23:36 +08:00
518ceefb91 feat: 优化收货清单固定头部交互 2026-04-20 18:26:04 +08:00
5b7559953d feat: 完善商品修改流程与移库语音播报 2026-04-17 17:18:35 +08:00
a18eb08408 Adjust relocation flow and product query UI 2026-04-16 18:20:39 +08:00
4bc4120c55 feat: 商品查询库存样式与移库页优化 2026-04-15 18:24:10 +08:00
ebc955a7aa chore: 提交当前代码修改 2026-04-14 18:41:39 +08:00
aea322298b feat: optimize product query and receiving filters 2026-04-11 17:50:40 +08:00
0b529d9f28 feat: 调整商品查询表头与收货箱数录入 2026-04-10 15:02:20 +08:00
154b2d7b2a feat: 优化商品查询与收货任务流程 2026-04-09 18:23:34 +08:00
dcd8ae4f68 feat: 优化移库与搜索交互 2026-04-08 14:12:08 +08:00
9c92291bd0 feat: improve quick actions and receiving scan 2026-04-07 17:25:58 +08:00
ebee728cd2 feat: improve quick actions long press management 2026-04-06 18:20:41 +08:00
446ae7d273 feat: optimize quick actions drag sorting and scan input 2026-04-04 18:28:30 +08:00
4ba720b4c7 feat: improve auth guard and manual scan flow 2026-04-04 09:43:30 +08:00
962d7157fc feat: add login update flow and debug logging 2026-03-31 20:07:53 +08:00
4502a4f673 feat(store): add device info module with base device collection 2026-03-30 17:55:10 +08:00
3762a36433 feat: optimize product query and detail pages 2026-03-30 15:23:28 +08:00
6d7a1bd28d feat: 优化商品查询页布局与详情跳转 2026-03-28 18:24:53 +08:00
5305f77560 feat: 新增商品查询入口并优化菜单路由匹配
- 新增 stock.warehouse.search 接口并在收货详情中切换为仓库维度搜索

- 优化用户菜单路径校验,兼容 component/path 及前导斜杠、.vue 后缀

- 首页与全部功能页对商品查询菜单统一跳转到 /pages/work/product/query

- pages.json 注册商品查询页面路由
2026-03-27 16:01:35 +08:00
34adbce776 fix(product-query): 修复多商品列表滚动到底部时抬头被遮挡问题,改为 flex 布局并优化滚动容器高度计算,增加商品查询页面实现,支持关键字与扫商品条码触发查询;展示商品名称,商品编码/条码/SKU/库存信息,补充空状态与异常提示,扫描或者输入的条码去空格处理。 2026-03-27 15:44:44 +08:00
fb1573b2a5 feat(home): 新增全部功能页与常用功能编辑同步
- 新增 pages/home/edit-quick-actions 页面与路由配置

- 全部功能页支持搜索、首字母导航、父子菜单展示、编辑常用(最多24个)

- 首页常用功能改为读取 fixed_home_menus 并与最新权限菜单对齐

- user 模块统一菜单归一化逻辑并打印接口菜单列表

- 引入 pinyin-pro 处理中文首字母分组
2026-03-26 16:00:09 +08:00
2a05daba98 docs: add follow-up notes for badge-login and router fixes
- remove hardcoded login credentials\n- enable auto badge scan on login page\n- skip badge info/confirm step and login directly\n- fix first-login no-redirect issue\n- fix unexpected exit confirmation on app startup
2026-03-25 16:53:08 +08:00
8ec1cf70b5 fix(login): streamline badge login flow and router exit handling 2026-03-25 16:23:05 +08:00
992d556083 chore(login): remove hardcoded credentials from login form 2026-03-25 14:55:14 +08:00
dca6d0f4e2 fix: 修复登录跳转与token失效处理 2026-03-24 18:23:12 +08:00
006a976a76 feat: 完善扫码登录鉴权与跳转处理 2026-03-24 15:54:29 +08:00
708 changed files with 78401 additions and 4180 deletions

11
.env.example Normal file
View File

@ -0,0 +1,11 @@
# 环境变量模板:复制为 .env.development.local 并填写真实值(该文件不提交 git)
#
# 生效范围:仅 NODE_ENV=development 的构建(npm run dev:h5 / dev:app-plus)
# 发布构建(npm run build:h5 / build:app-plus)固定使用 src/env.js 中的
# PROD_API_BASE,不会读取本文件的地址,详见 src/env.js 顶部说明。
#
# ⚠️ 不要用 .env.local:它在 production 模式同样会被加载,并会被构建工具注入到
# 客户端代码里,导致内网地址出现在正式包中(scripts/check-build-env.cjs 会中止构建)。
# ⚠️ 不要把 VUE_APP_API_BASE_OVERRIDE 写进 .env* 文件:它只允许由命令行显式注入。
VUE_APP_API_BASE_URL=http://your-server-ip:6060
VUE_APP_IMG_URL=https://ye4s.file.gzxunren.com

6
.eslintignore Normal file
View File

@ -0,0 +1,6 @@
node_modules/
dist/
unpackage/
uni_modules/
.hbuilderx/
*.min.js

20
.eslintrc.cjs Normal file
View File

@ -0,0 +1,20 @@
module.exports = {
root: true,
env: {
browser: true,
node: true,
es2021: true
},
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module'
},
ignorePatterns: [
'node_modules/',
'dist/',
'unpackage/',
'uni_modules/',
'.hbuilderx/'
],
rules: {}
};

22
.gitignore vendored
View File

@ -21,6 +21,9 @@ yarn-error.log*
.env.local .env.local
.env.*.local .env.*.local
# dev:adb 记住的目标设备(本地状态)
.dev-adb.local.json
# VSCode # VSCode
.vscode/ .vscode/
@ -38,4 +41,23 @@ yarn-error.log*
# 静态资源缓存 # 静态资源缓存
static/uview/ static/uview/
# ===== Android 离线打包(详见 android-offline/README.md) =====
# 签名密钥与本地配置(含密码)不提交
android-offline/keystore/
config/android.json
# 发布上传配置(含服务器地址与私钥路径,每台机器不同;模板见 config/deploy.example.json)
config/deploy.json
# DCloud 离线 SDK(体积大,按需下载解压,勿提交)
android-offline/SDK/
# 原生工程的本地产物(工程源码本身提交,保证发布基座一致)
android-offline/HBuilder-Integrate-AS/local.properties
android-offline/HBuilder-Integrate-AS/.gradle/
android-offline/HBuilder-Integrate-AS/.idea/
android-offline/HBuilder-Integrate-AS/**/build/
android-offline/HBuilder-Integrate-AS/**/*.iml
# 打包时拷入的 App 资源(由 dist/build/app-plus 生成)
android-offline/HBuilder-Integrate-AS/simpleDemo/src/main/assets/apps/__UNI__0B3DAD3/
# APK / exe 产物
release/
# 其他可根据实际情况添加 # 其他可根据实际情况添加

15
.hbuilderx/launch.json Normal file
View File

@ -0,0 +1,15 @@
{
"version" : "1.0",
"configurations" : [
{
"customPlaygroundType" : "local",
"packageName" : "com.gztbyc.pda_wms",
"playground" : "standard",
"type" : "uni-app:app-android"
},
{
"playground" : "standard",
"type" : "uni-app:app-ios"
}
]
}

1
.npmrc Normal file
View File

@ -0,0 +1 @@
registry=https://registry.npmmirror.com

34
App.vue
View File

@ -1,34 +0,0 @@
<script>
export default {
onLaunch() {
},
onShow() {
},
methods: {
}
}
</script>
<style lang="scss">
/* 每个页面公共css */
@import "@/uni_modules/uview-ui/index.scss";
@import "common/demo.scss";
.status_bar {
height: var(--status-bar-height);
background-color: #FFFFFF;
}
.normar_container{
height:100vh;
display:flex;
flex-direction: column;
background-color: #f8f8f8;
}
</style>

164
README.md
View File

@ -1 +1,163 @@
天豹云仓的WMS_PDA项目 天豹云仓的WMS_PDA项目
## 文件说明
- `day.log`:日报记录文件,用于按天填写工作内容(今日完成、进行中、明日计划、问题与风险、备注)。
## API接口文档
- `http://192.168.11.56:6060/api/docs/system/raw`
## 接口文档与登录接口关系
### 1)接口文档(后端)
- 接口文档定义了后端可调用的 method、参数和返回结构。
- 前端并不直接写死所有 URL,而是通过本地接口映射表进行统一管理。
### 2)本地接口映射(前端“接口文档”)
- 文件:`core/request/apis.js`
- 作用:把业务别名映射为请求配置(`path/url`、`method`、`auth`)
登录相关映射:
- `user.login`
- `path: "user.login"`
- 用于账号密码登录
- `user.loginByUuid`
- `url: "https://ye4s.wms.gztbyc.com/index/wms/wms/loginByUuid"`
- 用于扫码/工牌 UUID 登录
- `user.info`
- `path: "user.info"`
- 用于拿登录后的用户信息
### 3)请求封装与实际调用关系
#### 3.1 请求入口
- 文件:`core/request/index.js`
- 统一入口:`http('user.login', data)` / `http('user.loginByUuid', data)`
#### 3.2 URL组装规则
- 文件:`core/request/request.js`
- 若配置中有 `path`:实际请求变为 `API_URL?method={path}&v=1.0&timestamp=...`
- 若配置中有完整 `url`:直接请求该 URL(如 `loginByUuid`)
#### 3.3 公共请求头
- 文件:`core/request/request.js`
- 默认头包含:
- `platform: pda`
- `project: warehouse`
> 注意:若后端提示 `project 不支持`,优先检查这里的 `project` 与业务参数中的 `project` 是否一致。
### 4)登录调用链(账号密码)
1. 页面发起:`pages/login/index.vue` -> `this.$store.dispatch('login', loginForm)`
2. 状态层处理:`core/store/modules/user.js` -> `actions.login`
3. 接口调用:`http('user.login', { username, password, device, project })`
4. 返回处理:从响应拿 `token`,调用 `setToken(token)` 写入本地
5. 页面跳转:登录页切换到 `/pages/index/index`
### 5)登录调用链(扫码/工牌)
1. 页面监听广播:`pages/login/index.vue`(`broadcast/setCallbacks` + `onResult`)
2. 获取扫码结果:`result.data`(通常是 UUID 或包含 UUID 的编码串)
3. 点击确认登录:调用 `loginByUuid(uuid)`
4. 接口调用:`http('user.loginByUuid', { uuid })`
5. 返回处理:提取 token 后 `setToken(token)`
6. 页面跳转:切换到 `/pages/index/index`
### 6)常见错误与关系定位
- 报错:`project 不支持`
- 关联:`core/request/request.js` 默认请求头 + `core/store/modules/user.js` 的 `state.app.project`
- 报错:`登录成功但未返回token`
- 关联:后端返回结构与前端 token 提取逻辑不一致
- 报错:`用户信息加载失败`
- 关联:`user.info` 接口失败、token 无效或参数不匹配
### 7)建议的排查顺序
1. 先看 `apis.js` 映射是否正确(`path/url`)
2. 再看请求头和业务参数中的 `project/device` 是否与后端一致
3. 再看接口返回结构是否包含 token
4. 最后看登录后是否成功调用 `user.info`
## 构建与运行(uni-app Vue2 CLI 工程)
> 本项目已从 HBuilderX 工程迁移为 `@vue/cli` 脚手架工程(2026-10-02):
> 业务源码全部位于 `src/`,H5 模板由 `public/index.html` 提供(即原根目录的 `template.h5.html`)。
### 命令
| 命令 | 作用 | 产物 |
| --- | --- | --- |
| `npm run dev:h5` | H5 开发服务器(默认 http://localhost:8080) | 内存编译 |
| `npm run build:h5` | H5 生产构建 | `dist/build/h5` |
| `npm run dev:app-plus` | App 资源监听编译 | `dist/dev/app-plus` |
| `npm run build:app-plus` | App 生产构建 | `dist/build/app-plus` |
| `npm run build:apk` | Android **发行包**(生产地址 + 产物地址校验) | `release/android/wms-pda_v*.apk` |
| `npm run dev:adb` | Android **测试包**(注入开发地址)→ 装机 → 启动 | `release/android/dev/wms-pda_v*_dev.apk` |
| `npm run android:pack:raw` | 仅打包(用现有 `dist/build/app-plus`,不重编前端) | 同上 |
| `npm run check:env` | 手动校验产物接口地址 | - |
| `npm run lint` | ESLint 自动修复 | - |
### App 端如何选择接口环境(测试模式)
| 场景 | 命令 | 接口地址来源 |
| --- | --- | --- |
| 发行包 | `npm run build:apk` | `src/env.js` 的 `PROD_API_BASE`(固定),构建后强制校验产物不含内网地址 |
| 测试包 | `npm run dev:adb` | 默认 `.env.development.local` 的 `VUE_APP_API_BASE_URL` |
| 测试包(指定后端) | `node scripts/dev-adb.cjs --api=http://x.x.x.x:6060` | 显式注入指定地址(优先级最高) |
| 测试包(与发行一致) | `node scripts/dev-adb.cjs --prod-api` | 不注入,指向生产(用于排查线上问题) |
> ⚠️ 带参数时请直接用 `node scripts/dev-adb.cjs <参数>`:Windows + npm 10 下 `npm run dev:adb -- <参数>` 的 `--` 参数会被 npm 吞掉、不传给脚本(`--prod-api` 会因此失效并回落到开发地址)。不带参数的 `npm run dev:adb` 不受影响。
- 注入方式:编译期命令行环境变量 `VUE_APP_API_BASE_OVERRIDE`(**不写入任何 .env 文件、不落盘**),在 `src/env.js` 中优先级最高。与工作台项目的 `VITE_API_BASE_OVERRIDE` 是同一套思路。
- 测试包产物单独放 `release/android/dev/` 且文件名带 `_dev`,**不会覆盖发行包**,也不会触发发布上传(自动加 `-Dev -NoUpload`)。
- 设备选择:命令行 `--serial=` > 上次选择的设备(记在 `.dev-adb.local.json`,不提交)> 只有一台时自动选中 > 多台时交互选择。示例:`node scripts/dev-adb.cjs --prod-api --serial=4235737`。
- 若在 cmd / 默认代码页(936)的窗口里运行看到中文乱码:先执行 `chcp 65001`(VS Code 内置终端、Windows Terminal 默认无需处理)。
- 两道校验方向相反:发行包**反向**校验(产物中不得出现 `192.168.x.x`/`127.0.0.1`);测试包**正向**校验(产物中必须出现注入的地址,否则中止,避免装成生产包却以为在测开发环境)。
- 真机 JS 日志:**离线 release 包默认不会把 `console.log` 输出到 logcat**(HBuilderX「运行到手机」靠的是 debug 基座)。测试包由 `src/core/utils/dev-log.js` 用 `plus.android` 桥接 `android.util.Log`,把 console 转发到 logcat 的 `jsLog` tag(`dev:adb` 会自动注入开关并实时跟随打印):
```powershell
& "$env:ANDROID_HOME\platform-tools\adb.exe" -s <序列号> logcat jsLog:V UniConsole:V UniViewConsole:V *:S
```
### App 端调试与打包
- CLI 不提供「运行到手机」:`build:app-plus` 只产出 App 资源,用 HBuilderX 导入 `dist/build/app-plus` 运行(或使用自定义基座、离线打包)。
- 正式云打包仍建议走 HBuilderX;`src/manifest.json` 中的 appid、模块、权限配置均保持原样。
### 注意事项
- **Node 版本**:当前在 Node 24 下构建,依赖两个脚本内开关——`--openssl-legacy-provider`(webpack 4 需要)与 `--require=./scripts/node-compat.cjs`(补回 Node 23+ 移除的 `util.isRegExp` 等历史 API)。若改用 Node 16/18,这两项会自动变成无害的空操作。
- **`ROUTES` 常量**:由根目录 `vue.config.js`(`uni-read-pages` + DefinePlugin)注入,`uni-simple-router` 内部依赖它;缺失会在运行时抛 `ReferenceError: ROUTES is not defined`,请勿删除该配置。
- **@dcloudio 版本必须整体一致**:当前锁定 `2.0.2-5020620260917001`(Vue2 线),升级时需全量同版本替换。
- **依赖镜像**:`.npmrc` 指向 `registry.npmmirror.com`。
- `src/pages/componentsA|B|C` 是 uView 官方示例页(含 67 个 `.nvue` 文件),未被 `pages.json` 注册、不参与编译,可按需删除。
### 接口地址与环境变量(防呆)
| 场景 | 地址来源 | 命令 |
| --- | --- | --- |
| 发布构建(H5 / App) | `src/env.js` 的 `PROD_API_BASE`(固定,不采用 .env 文件里的地址) | `npm run build:h5` / `build:app-plus` |
| 本地开发 | `.env.development.local` 的 `VUE_APP_API_BASE_URL`(git 不跟踪) | `npm run dev:h5` / `dev:app-plus` |
| 临时指向指定后端 | 命令行显式注入 `VUE_APP_API_BASE_OVERRIDE`(不落盘) | 见下 |
- 首次拉取代码后:复制 `.env.example` 为 `.env.development.local` 并填写内网地址。
- 临时改后端(不写任何文件):`npx cross-env UNI_PLATFORM=h5 NODE_ENV=development VUE_APP_API_BASE_OVERRIDE=http://192.168.1.10:6060 vue-cli-service uni-serve`
- **两道防线**:
1. 生产构建只认 `PROD_API_BASE`,源码里也不再保留任何内网地址字面量;
2. `npm run build:h5` / `build:app-plus` 结束后自动执行 `scripts/check-build-env.cjs`,产物中出现 `192.168.x.x` / `127.0.0.1`,或缺少生产域名 `qimen.wms.gztbyc.com`,即**构建失败**。手动校验:`npm run check:env`。
- ⚠️ 开发地址**不要**写进 `.env.local`:该文件在 production 模式同样会被加载,并会被构建工具注入到客户端代码里(会被上面的校验拦下,但没必要绕这一圈)。
- 现场排查设备连的是哪个后端:可用 `pages/settings/networkTest` 页面查看/测试接口地址。
### 回退方式
原 HBuilderX 工程完整备份在 `d:\WMS_PDA_bak_20261002-1936`(含 `node_modules`、`.hbuilderx`、`template.h5.html`、`vue.config.js`、`package.json`、`package-lock.json`)。需要回退时,把备份内容覆盖回项目根目录即可。

View File

@ -0,0 +1,28 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
maven {url 'https://maven.aliyun.com/repository/google'}
maven {url 'https://maven.aliyun.com/repository/gradle-plugin'}
maven {url 'https://maven.aliyun.com/repository/public'}
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:8.7.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
maven {url 'https://maven.aliyun.com/repository/google'}
maven {url 'https://maven.aliyun.com/repository/gradle-plugin'}
maven {url 'https://maven.aliyun.com/repository/public'}
google()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}

View File

@ -0,0 +1,20 @@
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx1536m
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
android.useAndroidX=true
android.enableJetifier=true

View File

@ -0,0 +1,6 @@
#Mon Dec 28 18:07:31 CST 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://mirrors.cloud.tencent.com/gradle/gradle-8.11.1-bin.zip

View File

@ -0,0 +1,172 @@
#!/usr/bin/env sh
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn () {
echo "$*"
}
die () {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Escape application args
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=$(save "$@")
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
cd "$(dirname "$0")"
fi
exec "$JAVACMD" "$@"

View File

@ -0,0 +1,84 @@
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega

View File

@ -0,0 +1 @@
include ':simpleDemo'

View File

@ -0,0 +1,97 @@
apply plugin: 'com.android.application'
// ===== 统一配置:动态读取项目根 config/android.json 与 package.json(见 config/README.md)=====
// 本文件不包含任何密码/包名等可变配置,可直接提交 git。
def projectRoot = file('../../..')
def cfgFile = new File(projectRoot, 'config/android.json')
if (!cfgFile.exists()) {
throw new GradleException('config/android.json not found. Copy config/android.example.json to config/android.json first. See config/README.md')
}
def cfg = new groovy.json.JsonSlurper().parseText(cfgFile.getText('UTF-8'))
def pkgFile = new File(projectRoot, 'package.json')
def pkg = new groovy.json.JsonSlurper().parseText(pkgFile.getText('UTF-8'))
def versionNameValue = pkg.version
def versionParts = versionNameValue.tokenize('.')
if (versionParts.size() < 3) {
throw new GradleException("package.json version must be three-part X.Y.Z, got: ${versionNameValue}")
}
// versionCode = X*1000000 + Y*1000 + Z (each part 0-999)
def versionCodeValue = versionParts[0].toInteger() * 1000000 + versionParts[1].toInteger() * 1000 + versionParts[2].toInteger()
android {
compileSdkVersion 35
buildToolsVersion '35.0.0'
namespace cfg.packageName
defaultConfig {
applicationId cfg.packageName
minSdkVersion 21
targetSdkVersion 33
versionCode versionCodeValue
versionName versionNameValue
multiDexEnabled true
resValue 'string', 'app_name', cfg.appName
manifestPlaceholders = [
'dcloud_appkey': cfg.appKey ?: ''
]
ndk {
abiFilters = cfg.abis
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
signingConfigs {
config {
keyAlias cfg.signing.keyAlias
keyPassword cfg.signing.keyPassword
storeFile file('../../../' + cfg.signing.keystore)
storePassword cfg.signing.storePassword
v1SigningEnabled true
v2SigningEnabled true
}
}
buildTypes {
debug {
signingConfig signingConfigs.config
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
release {
signingConfig signingConfigs.config
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
aaptOptions {
additionalParameters '--auto-add-overlay'
ignoreAssetsPattern "!.svn:!.git:.*:!CVS:!thumbs.db:!picasa.ini:!*.scc:*~"
}
}
// 每次构建前从 config 生成 dcloud_control.xml(appid)
task generateDcloudControl {
doLast {
def controlFile = file('src/main/assets/data/dcloud_control.xml')
controlFile.parentFile.mkdirs()
controlFile.setText("<hbuilder>\n<apps>\n <app appid=\"${cfg.appId}\" appver=\"\"/>\n</apps>\n</hbuilder>\n", 'UTF-8')
}
}
preBuild.dependsOn generateDcloudControl
dependencies {
implementation fileTree(dir: 'libs', include: ['*.aar', '*.jar'], exclude: [])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.localbroadcastmanager:localbroadcastmanager:1.0.0'
implementation 'androidx.core:core:1.1.0'
implementation "androidx.fragment:fragment:1.1.0"
implementation 'androidx.recyclerview:recyclerview:1.1.0'
implementation 'com.facebook.fresco:fresco:2.5.0'
implementation "com.facebook.fresco:animated-gif:2.5.0"
implementation 'com.github.bumptech.glide:glide:4.9.0'
implementation 'com.alibaba:fastjson:1.2.83'
implementation 'androidx.webkit:webkit:1.5.0'
}

View File

@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile

View File

@ -0,0 +1,102 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<!-- 应用内更新安装 APK:
INSTALL_PACKAGES 为 5+ Runtime plus.runtime.install 静默安装路径所需声明(非系统应用实际仍走 UI 安装器);
REQUEST_INSTALL_PACKAGES 为 Android 8+ 未知来源安装授权,7.x 及以下仅依赖全局未知来源开关 -->
<uses-permission android:name="android.permission.INSTALL_PACKAGES" />
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
<!-- ===== 以下权限集与 src/manifest.json 的 app-plus.distribute.android.permissions 保持一致 =====
离线打包不会读取 manifest.json 的权限声明,必须在此处显式声明,
增删权限时请同步两处,否则会出现「云打包能用、离线包缺权限」的差异。 -->
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.FLASHLIGHT" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_CONTACTS" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" />
<!-- 日志/文件:DCloud base 运行时与打印/图片上传相关 -->
<uses-permission android:name="android.permission.READ_LOGS" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<!-- 蓝牙打印/扫码枪:Android 12(API31) 起需用 BLUETOOTH_SCAN/CONNECT 取代 BLUETOOTH/BLUETOOTH_ADMIN -->
<uses-permission android:name="android.permission.BLUETOOTH" android:maxSdkVersion="30" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" android:maxSdkVersion="30" />
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" android:usesPermissionFlags="neverForLocation" />
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
<uses-feature android:name="android.hardware.camera" android:required="false" />
<uses-feature android:name="android.hardware.camera.autofocus" android:required="false" />
<application
android:allowBackup="true"
android:allowClearUserData="true"
android:icon="@drawable/icon"
android:label="@string/app_name"
android:largeHeap="true"
android:extractNativeLibs="true"
android:supportsRtl="true"
android:usesCleartextTraffic="true">
<activity
android:name="io.dcloud.PandoraEntry"
android:configChanges="orientation|keyboardHidden|keyboard|navigation"
android:label="@string/app_name"
android:launchMode="singleTask"
android:hardwareAccelerated="true"
android:theme="@style/TranslucentTheme"
android:screenOrientation="user"
android:exported="true"
android:windowSoftInputMode="adjustResize" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="io.dcloud.PandoraEntryActivity"
android:launchMode="singleTask"
android:configChanges="orientation|keyboardHidden|screenSize|mcc|mnc|fontScale|keyboard|smallestScreenSize|screenLayout|screenSize|uiMode"
android:hardwareAccelerated="true"
android:permission="com.miui.securitycenter.permission.AppPermissionsEditor"
android:screenOrientation="user"
android:theme="@style/DCloudTheme"
android:exported="true"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<action android:name="android.intent.action.VIEW" />
<data android:scheme=" " />
</intent-filter>
</activity>
<meta-data
android:name="dcloud_appkey"
android:value="${dcloud_appkey}" />
<!-- 开机自启:系统启动完成后自动拉起应用(见 BootReceiver.java) -->
<receiver
android:name=".BootReceiver"
android:enabled="true"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.QUICKBOOT_POWERON" />
</intent-filter>
</receiver>
</application>
</manifest>

View File

@ -0,0 +1,5 @@
<hbuilder>
<apps>
<app appid="__UNI__0B3DAD3" appver=""/>
</apps>
</hbuilder>

View File

@ -0,0 +1,92 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
<meta name="HandheldFriendly" content="true"/>
<meta name="MobileOptimized" content="320"/>
<title>Error</title>
<script type="text/javascript">
// H5 plus事件处理
var ws=null;
function plusReady(){
// Android处理返回键
plus.key.addEventListener('backbutton',function(){
(history.length==1)&&ws.close();
var c=setTimeout(function(){
ws.close();
},1000);
window.onbeforeunload=function(){
clearTimeout(c);
}
history.go(-2);
},false);
ws=plus.webview.currentWebview();
}
if(window.plus){
plusReady();
}else{
document.addEventListener('plusready',plusReady,false);
}
document.addEventListener('touchstart',function(){
return false;
},true);
// 禁止选择
document.oncontextmenu=function(){
return false;
};
// 获取错误信息
document.addEventListener("error",function(e){
info.innerText="请求的页面("+e.url+")无法打开";
console.log("请求的页面无法打开:"+e.href);
},false);
</script>
<style>
*{
-webkit-user-select: none;
}
html,body{
margin: 0px;
padding: 0px;
width: 100%;
height: 100%;
text-align: center;
word-break: break-all;
-webkit-touch-callout:none;
-webkit-tap-highlight-color:rgba(0,0,0,0);
}
.button{
width: 50%;
font-size: 18px;
font-weight: normal;
text-decoration: none;
text-align: center;
padding: .5em 0em;
margin: .5em auto;
color: #333333;
background-color: #EEEEEE;
border: 1px solid #CCCCCC;
-webkit-border-radius: 5px;
border-radius: 5px;
}
.button:active{
background-color: #CCCCCC;
}
</style>
</head>
<body>
<div style="width:100%;height:20%;"></div>
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 512 512" style="height:20%;width:30%">
<g id="icomoon-ignore">
<line stroke-width="1" x1="" y1="" x2="" y2="" stroke="#449FDB" opacity=""></line>
</g>
<path d="M256 0c-141.385 0-256 114.615-256 256s114.615 256 256 256 256-114.615 256-256-114.615-256-256-256zM352 128c17.673 0 32 14.327 32 32s-14.327 32-32 32-32-14.327-32-32 14.327-32 32-32zM160 128c17.673 0 32 14.327 32 32s-14.327 32-32 32-32-14.327-32-32 14.327-32 32-32zM352.049 390.37c-19.587-32.574-55.272-54.37-96.049-54.37s-76.462 21.796-96.049 54.37l-41.164-24.698c27.98-46.535 78.958-77.672 137.213-77.672s109.232 31.137 137.213 77.672l-41.164 24.698z" fill="#666666"></path>
</svg>
<p style="font-size:18px;font-weight:bolder;">We're sorry ...</p>
<p id="info" style="font-size:12px;"></p>
<!--<div class="button" onclick="history.back()">Retry</div>-->
<div class="button" onclick="if(history.length == 1){ws.close();}else{ws.back();ws.back();}">Back</div>
<div class="button" onclick="ws.close()">Close</div>
<div class="button" onclick="plus.runtime.restart()">Restart</div>
</body>
</html>

View File

@ -0,0 +1,46 @@
<properties>
<features>
<feature name="Barcode" value="io.dcloud.feature.barcode2.BarcodeFeatureImpl"/>
<feature name="Bluetooth" value="io.dcloud.feature.bluetooth.BluetoothFeature"/>
<feature name="Maps" value="io.dcloud.js.map.amap.JsMapPluginImpl"/>
<!--<feature name="Maps" value="io.dcloud.js.map.JsMapPluginImpl"/>-->
<feature name="Contacts" value="io.dcloud.feature.contacts.ContactsFeatureImpl"/>
<feature name="Messaging" value="io.dcloud.adapter.messaging.MessagingPluginImpl"/>
<feature name="Camera" value="io.dcloud.js.camera.CameraFeatureImpl"/>
<feature name="Console" value="io.dcloud.feature.pdr.LoggerFeatureImpl"/>
<feature name="Device" value="io.dcloud.feature.device.DeviceFeatureImpl"/>
<feature name="File" value="io.dcloud.js.file.FileFeatureImpl"/>
<feature name="Proximity" value="io.dcloud.feature.sensor.ProximityFeatureImpl"/>
<feature name="Storage" value="io.dcloud.feature.pdr.NStorageFeatureImpl"/>
<feature name="Cache" value="io.dcloud.feature.pdr.CoreCacheFeatureImpl"/>
<feature name="Invocation" value="io.dcloud.invocation.Invocation"/>
<feature name="Navigator" value="io.dcloud.feature.ui.navigator.NavigatorUIFeatureImpl"/>
<feature name="NativeUI" value="io.dcloud.feature.ui.nativeui.NativeUIFeatureImpl"/>
<feature name="UI" value="io.dcloud.feature.ui.UIFeatureImpl">
<module name="Navigator" value="io.dcloud.feature.ui.NavView"/>
</feature>
<feature name="Gallery" value="io.dcloud.js.gallery.GalleryFeatureImpl"/>
<feature name="Downloader" value="io.dcloud.net.DownloaderFeatureImpl"/>
<feature name="Uploader" value="io.dcloud.net.UploadFeature"/>
<feature name="Zip" value="io.dcloud.feature.pdr.ZipFeature"/>
<feature name="Audio" value="io.dcloud.feature.audio.AudioFeatureImpl"/>
<feature name="Runtime" value="io.dcloud.feature.pdr.RuntimeFeatureImpl"/>
<feature name="VideoPlayer" value="io.dcloud.media.MediaFeatureImpl"/>
<feature name="LivePusher" value="io.dcloud.media.live.LiveMediaFeatureImpl"/>
<feature name="XMLHttpRequest" value="io.dcloud.net.XMLHttpRequestFeature"/>
<feature name="Statistic" value="io.dcloud.feature.statistics.StatisticsFeatureImpl"/>
<feature name="Accelerometer" value="io.dcloud.feature.sensor.AccelerometerFeatureImpl"/>
<feature name="Orientation" value="io.dcloud.feature.sensor.OrientationFeatureImpl"/>
<feature name="NativeObj" value="io.dcloud.feature.nativeObj.FeatureImpl"/>
<feature name="Geolocation" value="io.dcloud.js.geolocation.GeolocationFeatureImpl"/>
<feature name="Stream" value="io.dcloud.appstream.js.StreamAppFeatureImpl"/>
<feature name="plugintest" value="com.example.H5PlusPlugin.PGPlugintest"/>
</features>
<services>
<service name="push" value="io.dcloud.feature.aps.APSFeatureImpl"/>
<service name="Statistic" value="io.dcloud.feature.statistics.StatisticsBootImpl"/>
<service name="Downloader" value="io.dcloud.net.DownloaderBootImpl"/>
<!--<service name="Maps" value="io.dcloud.js.map.MapInitImpl"/>-->
</services>
</properties>

View File

@ -0,0 +1,34 @@
package com.gztbyc.pda_wms;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
/**
* 开机自启:监听系统开机完成广播,自动拉起应用。
* 说明:Android 3.1+ 要求应用至少被用户启动过一次后,BOOT_COMPLETED 才会送达。
*/
public class BootReceiver extends BroadcastReceiver {
private static final String ACTION_QUICKBOOT_POWERON = "android.intent.action.QUICKBOOT_POWERON";
@Override
public void onReceive(Context context, Intent intent) {
if (intent == null || intent.getAction() == null) {
return;
}
final String action = intent.getAction();
if (!Intent.ACTION_BOOT_COMPLETED.equals(action) && !ACTION_QUICKBOOT_POWERON.equals(action)) {
return;
}
try {
Intent launch = context.getPackageManager().getLaunchIntentForPackage(context.getPackageName());
if (launch != null) {
launch.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
context.startActivity(launch);
}
} catch (Exception e) {
// 启动失败不阻断系统广播
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

View File

@ -0,0 +1,3 @@
<resources>
<!-- app_name 由 build.gradle 从 config/android.json 动态注入(resValue),此处不再定义 -->
</resources>

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="DCloudActivityTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowNoTitle">true</item>
<item name="android:colorEdgeEffect">#333333</item>
<item name="android:windowBackground">@color/ime_background</item>
<item name="android:forceDarkAllowed">false</item>
</style>
</resources>

101
android-offline/README.md Normal file
View File

@ -0,0 +1,101 @@
# Android 离线打包(WMS_PDA)
本目录是 DCloud 官方 **Android 离线打包**集成工程,用于在本地用命令行出 APK(不需要 Android Studio,也不依赖 DCloud 云打包)。
## 目录
| 路径 | 说明 | git |
|---|---|---|
| `HBuilder-Integrate-AS/` | Android Studio 集成工程,**已提交**(保证发布基座一致)。包名/版本/签名/应用名/appid/appKey 全部由 `simpleDemo/build.gradle` 在构建时从 `config/android.json` 与根 `package.json` 动态读取,工程内不含任何密码 | ✅ |
| `HBuilder-Integrate-AS/simpleDemo/libs/` | 5+ Runtime 等 aar(`lib.5plus.base-release.aar`、`uniapp-v8-release.aar`、`breakpad`、`install-apk` 等) | ✅ |
| `keystore/` | 签名密钥文件 | ❌ (忽略) |
| `icon/` `splash/` | 图标与启动图源文件,`prepare.cjs` 用它们覆盖 `res/` 下同名资源 | ✅ |
| `SDK/` | DCloud 离线 SDK 解压目录(体积大,约 165MB),仅在需要额外原生模块时才下载 | ❌ (忽略) |
| `pack.ps1` | 命令行打包主脚本(JDK/SDK 探测 → 注入 → `gradlew assembleRelease`) | ✅ |
| `prepare.cjs` | 注入 App 资源、覆盖图标/启动图、对齐 `compilerVersion` | ✅ |
## 一键打包
```powershell
npm run build:apk # 发行包:生产编译 + 产物地址校验 + 离线打包
npm run build:apk -- -Clean # gradle 全量重编
npm run build:apk -- -NoInject # 跳过资源注入(已注入过时用)
npm run android:pack:raw # 跳过前端编译,仅用现有 dist/build/app-plus 打包
npm run dev:adb # 测试包:注入开发地址 → 打包 → 装机 → 启动(产物进 release/android/dev)
npm run dev:adb -- --prod-api # 测试包但指向生产(排查线上问题时用)
npm run dev:adb -- --api=http://192.168.1.10:6060 --no-install
```
产物:`release/android/wms-pda_v{版本}_release.apk`(测试包为 `release/android/dev/wms-pda_v{版本}_release_dev.apk`)。版本唯一来源是根 `package.json` 的 `version`(X.Y.Z),`versionCode` 自动推导为 `X*1000000 + Y*1000 + Z`。
> ⚠ **版本号要两处同步**:`package.json.version` 与 `src/manifest.json` 的 `versionName`/`versionCode`(后者供 HBuilderX 云打包使用)。`prepare.cjs` 会在打包前校验两者并告警,避免云包/离线包版本号不一致。
>
> 历名包在线上的 `versionCode` 是云打包时手工填的小数字(如 1.0.121 → 125),而离线方案会得到 `1000122` 这类值。**今后统一用 `package.json` 推导,不要再手工填小数字**,否则切回云打包时会变成「降级安装」被系统拦下。
## 图标与启动图
| 文件 | 来源 | 尺寸 |
|---|---|---|
| `icon/app-icon.png` | 从线上 APK(v1.0.121)`res/9T.png` 提取 | 512×512 |
| `splash/splash.png` | 从线上 APK `res/-u.png` 提取 | 1242×2208(竖屏) |
`prepare.cjs` 会把它们覆盖到 `simpleDemo/src/main/res/drawable/{icon,splash}.png`。有更高清的原始图标(如 1024×1024)时直接覆盖 `icon/app-icon.png` 即可。
从任意 APK 里重新取素材的办法:
```powershell
# 解包 APK 后用 aapt2 查出图标文件名,再按尺寸挑最大的一张
& "$env:ANDROID_HOME\build-tools\35.0.0\aapt2.exe" dump badging <apk路径> | Select-String 'application-icon'
```
环境要求:JDK 17+(脚本会自动探测 `JAVA_HOME`、Android Studio JBR 等常见位置)、Android SDK(`ANDROID_HOME`/`ANDROID_SDK_ROOT`/`local.properties` 任一即可)。
## 与云打包的差异(重要)
- **签名不同**:云打包用的是 DCloud 的证书,本地离线打包用 `config/android.json` 配置的 keystore。若此前对外发布过云打包版本,切换后**签名不一致、无法覆盖安装**(需先卸载重装);若包名+签名已被第三方 SDK/推送/应用商店绑定,需要重新登记。
- **权限来自 AndroidManifest**:离线打包**不会**读取 `src/manifest.json` 的权限声明,权限必须写在 `HBuilder-Integrate-AS/simpleDemo/src/main/AndroidManifest.xml`。增删权限时请两处同步,否则会出现「云打包能用、离线包缺权限」的差异。
- **明文 HTTP**:生产接口是 `http://qimen.wms.gztbyc.com`,所以 `<application>` 上显式声明了 `android:usesCleartextTraffic="true"`(Android 9+ 默认禁止明文 HTTP)。日后切 HTTPS 可移除。
- **appKey 校验**:`appKey` 与 `appId` + 包名 + 证书 SHA-256 严格绑定,不匹配时 APK 能装能开但启动白屏提示「未配置appkey或配置错误」。详见 `config/README.md`。
- **Runtime 版本提示**:`prepare.cjs` 会把 www 内 `manifest.json`/`app-config-service.js` 的 `compilerVersion` 对齐到 `config/android.json` 的 `runtimeVersion`,用于消除启动时「本应用使用 HBuilderX %s 编译,而手机端 SDK 版本是 %s」的提示。
## 5+ 模块(aar)与 manifest 里勾选的模块
离线打包**不会**自动带上 `src/manifest.json` 里勾选的模块,必须同时满足两个条件:
1. 该模块的 aar 放进 `HBuilder-Integrate-AS/simpleDemo/libs/`;
2. 在 `simpleDemo/src/main/assets/data/dcloud_properties.xml` 里声明对应 `<feature>`。
否则运行时才报错(例如蓝牙会提示「缺少蓝牙模块」,且代码里找不到该文案——它来自 5+ 运行时)。
当前已包含:
| 模块 | 提供物 | 备注 |
|---|---|---|
| Bluetooth(蓝牙打印 / 蓝牙扫码枪) | `libs/Bluetooth-release.aar` + `<feature name="Bluetooth" value="io.dcloud.feature.bluetooth.BluetoothFeature"/>` | 从离线 SDK 的 `SDK/libs/` 复制;本工程最初缺这一项(骨架克隆自不使用蓝牙的项目) |
| Barcode / Camera / File / Storage / Console 等 | `libs/lib.5plus.base-release.aar` | 基础运行时自带 |
| Webview-x5 | 未单独引入 | 已比对线上云打包 APK:其原生库与本工程完全一致(无 X5 专属 so),故保持一致 |
新增其他模块时:到离线 SDK 的 `SDK/libs/` 找同名 aar(命名通常是 `<模块>-release.aar`,如 `geolocation-amap-release.aar`、`share-weixin-release.aar`、`speech-release.aar`),复制到 `libs/`,并在 `dcloud_properties.xml` 增加同名 `<feature>` 行——**类名最快来源是从已发布的云端 APK 里抄**:
```powershell
# 解包云端 APK 后对比两份配置,差异即为缺失的模块声明
# (线上包 assets/data/dcloud_properties.xml vs 本工程同名文件)
```
验证模块是否真的打进包里:
```powershell
tar -xf release\android\wms-pda_v*.apk -C $env:TEMP\apkchk
findstr /m /c:"io/dcloud/feature/bluetooth" $env:TEMP\apkchk\*.dex
```
## 首次使用清单
1. 在 `config/android.json` 填 `appKey`、`keyAlias`、`storePassword`、`keyPassword`(该文件不提交 git);
2. 把对应证书放入 `android-offline/keystore/`;
3. `npm run build:apk`。
> ⚠️ **`appKey` 必须与签名证书指纹匹配**。线上已发布 APK(云打包,签名证书 SHA-256 `d9689a9b…25d6ff`)内的 appKey 为 `f523d8541674ad75105fa604f5a51a54`——它**只对该 SHA-256 对应的证书有效**。若本地离线打包用的是自有 keystore(`android-offline/keystore/` 里那把),需先比对指纹,不一致则到 dev.dcloud.net.cn 重新申请,否则 APK 启动会白屏提示「未配置appkey或配置错误」。比对办法见 `config/README.md`。
> 发布上传(scp + `latest.json`)在 `pack.ps1` 内,但只有存在 `config/deploy.json` 时才会执行;本仓库不提供该文件,因此默认不会上传。

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

View File

@ -0,0 +1,3 @@
app-icon.png 已生成(1024x1024,深蓝渐变 + 包裹箱 + 扫描线,无文字)。
如需重新生成或调整设计,编辑 scripts/gen-android-assets.ps1 后运行:
powershell -NoProfile -ExecutionPolicy Bypass -File scripts\gen-android-assets.ps1

View File

@ -0,0 +1,54 @@
# html5plus runtime 使用许可协议
本协议是数字天堂(北京)网络技术有限公司(以下称“DCloud”)与您之间达成的关于html5plus runtime及相关配套软件(以下简称本软件)的协议。
本协议签订地点为中华人民共和国北京市海淀区。
您使用本软件即视为您已阅读并同意受本协议的约束。
## 定义
html5plus runtime,即DCloud公司提供的App端引擎,该引擎可用于5+App、wap2app、uni-app的App端打包,及5+sdk、uni小程序sdk等离线打包用sdk。
本软件包含iOS版和Android版。
本软件包括很多模块,包括DCloud的uni统计、uni-AD、uniPush等业务的客户端sdk部分,也属于本产品的模块。但这些模块都可以由您自行选择是否启用。
## 知识产权及使用授权
您可以自由下载、使用、复制本软件而不需要向DCloud付费。无时间和地域限制。
DCloud所拥有的知识产权,包括但不限于商标、专利、著作权、商业秘密、专有数据、源码,并不发生转移或共享。
您使用本软件开发的代码及输出物,即手机端移动应用,其知识产权归属您所有。
类似于您开发的应用内嵌了jvm或.net framework,虽然您的java代码的著作权属于您,但jvm等三方runtime的知识产权仍归原作者所有。
如果DCloud开源了某些代码,这些代码会有单独的开源许可协议并提供在github等网站的DCloud官方账号下。您可以在遵守这些开源协议的基础上使用DCloud开源的代码。
本软件可能会使用第三方软件或技术,例如三方开源代码,这类使用已经确保遵循这些三方软件的授权协议。详细的列表在本软件目录下的ThirdPartyNotices文件中查阅。
特别的,如果您使用uni小程序sdk,该产品的授权范围仅限制在原生App中将某个栏目或模块进行小程序化而使用,不可用于将uni-app前端代码打包成App。
您不得破解、反编译、逆向工程本软件,不得破解或劫持本软件网络请求,不得对DCloud服务进行网络攻击,不得利用DCloud系统漏洞谋利或侵害DCloud利益,不得替换、删改本软件自带的非用户自定义文件。
未经书面许可您不可利用DCloud产品的全部或部分文件、模块、组件来制作与DCloud争夺用户的产品。
## 隐私条款
DCloud尊重用户隐私,遵循国家对数据隐私保护的相关法律法规,并在此公开所有本软件会上报DCloud服务器的数据清单,以及说明数据采集的必要性。
1. 异常崩溃、错误日志
本软件发生错误异常、崩溃时,会将错误信息发送给DCloud服务器。
这些信息除了错误内容,也包括应用基本信息(如appid、包名)和环境信息(如设备型号、os名称、版本、网络类型等)。
同时DCloud会提供web界面供您查看了解崩溃情况。您可以分析错误在什么情况下产生,不同设备的崩溃率分布情况,并进行改进。
由于开发者的代码为前端代码,无法捕获原生异常和崩溃。如果DCloud不提供此信息,您将无法了解相关情况,所以采集和输出报告是帮助您顺利使用本软件的必要举措。
2. 启动速度性能分析
本软件每次启动会记录启动时长,也包括上述应用基本信息和环境信息。
同时DCloud会提供web界面供你了解相关性能报表。您可以分析在不同的设备、网络环境下您的应用的启动速度是否异常,并进行改进。
由于开发者的代码为前端代码,无法记录App初始启动计时点。如果DCloud不提供此信息,您将无法了解相关情况,所以采集和输出报告是帮助您顺利使用本软件的必要举措。
3. 本软件不会采集用户的短信、通讯录、相册、剪贴板信息,不会采集用户的摄像头、麦克风数据。
4. 除非国家法律法规规定或得到您的许可,否则DCloud不会将采集的数据授权给任何第三方。
5. 如果您使用了DCloud的其他联网业务,比如uni统计、uni-AD、uniPush,这些业务的隐私条款不包括在本协议中。
## 安全
您理解并同意,本软件同其他软件一样,无法承诺绝对的安全性。
当DCloud发现本软件的任何安全漏洞时,将及时在[社区](https://ask.dcloud.net.cn/explore/)发送公告,并将及时发布紧急更新补丁和升级推送通知。
## 免责声明和违约条款
您在使用本软件前应进行有效评估,DCloud不因您使用本软件而承担任何法律责任或经济赔偿责任。
如果您违反本协议,包括但不限于破解本软件,DCloud将有权停止您使用本软件,造成的损失由您自行承担。
如果您给DCloud造成重大损失,或者在接收到DCloud的停止违约通知后拒不改正,DCloud将有权停止对您的DCloud所有产品和服务的使用授权,罚没您在DCloud所有产品服务中的预付款项和应收款项,因此造成的损失由您自行承担。
如果您的行为产生法律问题,DCloud有权追责您的法律责任。
## 协议修订
根据发展,DCloud可能会对本协议进行修改。修改时,DCloud会在产品或者网页中显著的位置发布相关信息以便及时通知到用户。如果您选择继续使用本软件,即表示您同意接受这些修改。
## 联系我们
若您对本软件有任何疑问、意见和建议,欢迎联系我们:[网站](https://DCloud.io)
若您对本协议有任何不满,希望更改条款,可以通过与 bd@dcloud.io 沟通,商谈您需要的付费版使用协议。

338
android-offline/pack.ps1 Normal file
View File

@ -0,0 +1,338 @@
# Command-line APK packaging for WMS_PDA (no Android Studio needed).
# Flow: detect JDK/SDK -> inject config (prepare.cjs) -> gradlew assembleRelease -> copy APK to release/android/
#
# 发布上传默认关闭:未提供 config/deploy.json 时会跳过(本仓库不提供该文件)。
#
# Usage:
# .\pack.ps1 # package release APK
# .\pack.ps1 -Clean # full rebuild
# .\pack.ps1 -Timestamp # keep timestamped artifact name
# .\pack.ps1 -VersionName "1.0.2" # override version (written back to package.json; versionCode auto-derived)
# .\pack.ps1 -VersionCode 10002 # manually set versionCode (rarely needed)
# .\pack.ps1 -NoInject # skip prepare.cjs injection (already injected)
# .\pack.ps1 -NoUpload # package only, skip publish upload (scp + latest.json)
# .\pack.ps1 -JavaHome '...' -AndroidSdk '...'
param(
[switch]$Clean,
[switch]$Timestamp,
[switch]$NoInject,
[switch]$NoUpload,
[switch]$Dev,
[string]$VersionName = "",
[string]$VersionCode = "",
[string]$JavaHome = "",
[string]$AndroidSdk = ""
)
$ErrorActionPreference = 'Stop'
# ============ paths ============
$root = Split-Path -Parent $MyInvocation.MyCommand.Path
$projRoot = Split-Path -Parent $root
Set-Location $root
$asDir = Join-Path $root 'HBuilder-Integrate-AS'
$module = 'simpleDemo'
$appFile = 'wms-pda'
$gradlew = Join-Path $asDir 'gradlew.bat'
$distDir = Join-Path $projRoot 'release\android'
# -Dev: 真机调试包(接口地址可能指向开发环境),单独目录 + 文件名后缀,绝不覆盖发行包
if ($Dev) { $distDir = Join-Path $distDir 'dev' }
$apkSource = Join-Path $asDir "$module\build\outputs\apk\release\$module-release.apk"
$buildGradle = Join-Path $asDir "$module\build.gradle"
$configPath = Join-Path $projRoot 'config\android.json'
# ============ JDK detect (JDK 17+ required) ============
function Get-JavaMajorVersion([string]$javaExe) {
$prev = $ErrorActionPreference
$ErrorActionPreference = 'Continue'
try {
$out = (cmd /c "`"$javaExe`" -version 2>&1" | Out-String)
} finally {
$ErrorActionPreference = $prev
}
if ($out -match 'version\s+"1\.(\d+)') { return [int]$Matches[1] }
if ($out -match 'version\s+"(\d+)') { return [int]$Matches[1] }
return 0
}
$jdkCandidates = @()
if ($JavaHome) { $jdkCandidates += $JavaHome }
if ($env:JAVA_HOME) { $jdkCandidates += $env:JAVA_HOME }
$jdkCandidates += @(
"$env:LOCALAPPDATA\Programs\EclipseAdoptium",
"$env:LOCALAPPDATA\Programs\Android Studio\jbr",
"C:\Program Files\Android\Android Studio\jbr",
"D:\Program Files\Android\Android Studio\jbr",
"$env:USERPROFILE\.jdks",
"C:\Program Files\Java",
"C:\Program Files\Eclipse Adoptium"
)
$selectedJava = ""
foreach ($c in $jdkCandidates) {
if (-not $c) { continue }
$javaExe = Join-Path $c 'bin\java.exe'
if (-not (Test-Path $javaExe)) {
$found = Get-ChildItem $c -Recurse -Filter java.exe -ErrorAction SilentlyContinue | Select-Object -First 1
if ($found) { $javaExe = $found.FullName }
}
if (Test-Path $javaExe) {
$major = Get-JavaMajorVersion $javaExe
if ($major -ge 17) {
$selectedJava = Split-Path -Parent (Split-Path -Parent $javaExe)
break
}
}
}
if ($selectedJava -and (Test-Path (Join-Path $selectedJava 'bin\java.exe'))) {
$JavaHome = $selectedJava
$env:JAVA_HOME = $JavaHome
$env:Path = "$JavaHome\bin;$env:Path"
} else {
Write-Host ""
Write-Host "[error] JDK 17+ not found. Install JDK 17+ (or Android Studio JBR) or use -JavaHome '...'." -ForegroundColor Red
exit 1
}
# ============ Android SDK detect ============
if (-not $AndroidSdk) { $AndroidSdk = $env:ANDROID_HOME }
if (-not $AndroidSdk) { $AndroidSdk = $env:ANDROID_SDK_ROOT }
$localProps = Join-Path $asDir 'local.properties'
if (-not $AndroidSdk -and (Test-Path $localProps)) {
$line = Select-String -Path $localProps -Pattern '^sdk\.dir=(.+)$'
if ($line) { $AndroidSdk = [regex]::Replace($line.Matches[0].Groups[1].Value, '\\([\\:])', '$1') }
}
if (-not $AndroidSdk -or -not (Test-Path (Join-Path $AndroidSdk 'platform-tools'))) {
$sdkCandidates = @(
"$env:LOCALAPPDATA\Android\Sdk",
"$env:USERPROFILE\AppData\Local\Android\Sdk",
"C:\Android\Sdk",
"D:\Android\Sdk"
)
foreach ($c in $sdkCandidates) {
if (Test-Path (Join-Path $c 'platform-tools')) { $AndroidSdk = $c; break }
}
}
if ($AndroidSdk -and (Test-Path (Join-Path $AndroidSdk 'platform-tools'))) {
$env:ANDROID_HOME = $AndroidSdk
$env:ANDROID_SDK_ROOT = $AndroidSdk
$escaped = $AndroidSdk -replace '\\', '\\'
$sdkLine = "sdk.dir=$escaped"
if (Test-Path $localProps) {
$props = Get-Content $localProps -Raw
if ($props -match '(?m)^sdk\.dir=') {
$props = $props -replace '(?m)^sdk\.dir=.*$', $sdkLine
} else {
$props = $props.TrimEnd() + "`r`n" + $sdkLine + "`r`n"
}
Set-Content -Path $localProps -Value $props -Encoding ASCII
} else {
Set-Content -Path $localProps -Value $sdkLine -Encoding ASCII
}
} else {
Write-Host ""
Write-Host "[error] Android SDK not found. Set ANDROID_HOME or use -AndroidSdk." -ForegroundColor Red
exit 1
}
# ============ pre-check ============
if (-not (Test-Path $gradlew)) { Write-Host "[error] gradlew not found: $gradlew" -ForegroundColor Red; exit 1 }
if (-not (Test-Path $configPath)) { Write-Host "[error] config/android.json not found. Copy config/android.example.json to config/android.json first." -ForegroundColor Red; exit 1 }
if (-not (Test-Path $buildGradle)) { Write-Host "[error] build.gradle not found: $buildGradle" -ForegroundColor Red; exit 1 }
# ============ version: single source of truth = package.json ============
# versionName = package.json "version" (X.Y.Z, three-part)
# versionCode = X*1000000 + Y*1000 + Z (derived; each part must be 0-999)
$pkgPath = Join-Path $projRoot 'package.json'
if (-not (Test-Path $pkgPath)) { Write-Host "[error] package.json not found: $pkgPath" -ForegroundColor Red; exit 1 }
$pkg = Get-Content $pkgPath -Raw -Encoding UTF8 | ConvertFrom-Json
$verName = [string]$pkg.version
# -VersionName overrides and writes back to package.json (keeps exe/apk in sync)
if ($VersionName) {
$verName = $VersionName
$raw = [System.IO.File]::ReadAllText($pkgPath, [System.Text.Encoding]::UTF8)
$raw = $raw -replace '("version"\s*:\s*")[^"]*(")', ('${1}' + $VersionName + '${2}')
[System.IO.File]::WriteAllText($pkgPath, $raw, (New-Object System.Text.UTF8Encoding($false)))
Write-Host ""
Write-Host "[update] version written back to package.json -> $VersionName" -ForegroundColor Cyan
}
# versionCode: explicit -VersionCode wins, otherwise derived from X.Y.Z
if ($VersionCode) {
$verCode = $VersionCode
} else {
$parts = @($verName -split '\.')
if ($parts.Count -lt 3) {
Write-Host "[error] version '$verName' must be three-part (X.Y.Z)" -ForegroundColor Red
exit 1
}
$numX = [int]$parts[0]
$numY = [int]$parts[1]
$numZ = [int]$parts[2]
if ($numX -gt 999 -or $numY -gt 999 -or $numZ -gt 999) {
Write-Host "[error] each part of version '$verName' must be 0-999 (e.g. 1.0.101 is ok, 1.0.1000 is not)" -ForegroundColor Red
exit 1
}
$verCode = [string]($numX * 1000000 + $numY * 1000 + $numZ)
Write-Host ""
Write-Host "[info] versionCode derived: $verName -> $verCode" -ForegroundColor DarkGray
}
$cfg = Get-Content $configPath -Raw -Encoding UTF8 | ConvertFrom-Json
Write-Host ""
Write-Host "================== uni-app Android packaging ==================" -ForegroundColor Cyan
Write-Host " project : $root"
Write-Host " appid : $($cfg.appId)"
Write-Host " version : $verName ($verCode)"
Write-Host " build : release"
Write-Host " JDK : $($env:JAVA_HOME)"
Write-Host " AndroidSDK: $($env:ANDROID_HOME)"
Write-Host "===============================================================" -ForegroundColor Cyan
# ============ step 1: inject (prepare.cjs) ============
if (-not $NoInject) {
Write-Host ""
Write-Host "[step 1/3] inject config + www resources (prepare.cjs) ..." -ForegroundColor Yellow
node (Join-Path $root 'prepare.cjs')
if ($LASTEXITCODE -ne 0) {
Write-Host "[error] prepare.cjs failed" -ForegroundColor Red
exit 1
}
} else {
Write-Host ""
Write-Host "[step 1/3] -NoInject specified, skip prepare.cjs" -ForegroundColor DarkGray
}
# ============ step 2: gradle build ============
$step = 2
if ($Clean) {
Write-Host ""
Write-Host "[step 2/3] gradle clean ..." -ForegroundColor Yellow
Push-Location $asDir
& $gradlew clean --console=plain
$cleanCode = $LASTEXITCODE
Pop-Location
if ($cleanCode -ne 0) { Write-Host "[error] clean failed" -ForegroundColor Red; exit 1 }
$step = 3
}
Write-Host ""
Write-Host "[step $step/3] gradle assembleRelease ..." -ForegroundColor Yellow
Push-Location $asDir
& $gradlew assembleRelease --console=plain
$buildCode = $LASTEXITCODE
Pop-Location
if ($buildCode -ne 0) {
Write-Host "[error] packaging failed (gradle exit code $buildCode)" -ForegroundColor Red
exit 1
}
# ============ step 3: copy artifact ============
if (-not (Test-Path $apkSource)) {
Write-Host "[error] APK not found: $apkSource" -ForegroundColor Red
exit 1
}
if (-not (Test-Path $distDir)) { New-Item -ItemType Directory -Path $distDir -Force | Out-Null }
$apkSuffix = ''
if ($Dev) { $apkSuffix = '_dev' }
if ($Timestamp) {
$stamp = Get-Date -Format 'yyyyMMdd_HHmmss'
$apkName = "${appFile}_v${verName}_release${apkSuffix}_${stamp}.apk"
} else {
$apkName = "${appFile}_v${verName}_release${apkSuffix}.apk"
}
$apkDest = Join-Path $distDir $apkName
Copy-Item -Path $apkSource -Destination $apkDest -Force
$apkSize = [math]::Round((Get-Item $apkDest).Length / 1MB, 2)
Write-Host ""
Write-Host "================== packaging done ==================" -ForegroundColor Green
Write-Host " artifact : $apkDest"
Write-Host " size : ${apkSize} MB"
Write-Host " version : $verName ($verCode)"
Write-Host "===================================================" -ForegroundColor Green
# ============ publish upload (scp + latest.json, same flow as sandan project) ============
$deployCfgPath = Join-Path $projRoot 'config\deploy.json'
if ($NoUpload -or $Dev) {
Write-Host ""
Write-Host "[hint] -NoUpload/-Dev specified, skip publish upload" -ForegroundColor DarkGray
} elseif (-not (Test-Path $deployCfgPath)) {
Write-Host ""
Write-Host "[hint] config/deploy.json not found, skip publish upload (copy config/deploy.example.json and fill real values)" -ForegroundColor DarkGray
} else {
$dcfg = Get-Content $deployCfgPath -Raw -Encoding UTF8 | ConvertFrom-Json
$dcfg = $dcfg.android
if (-not $dcfg) {
Write-Host "[error] config/deploy.json missing android section" -ForegroundColor Red
exit 1
}
$dHost = [string]$dcfg.host
$dUser = [string]$dcfg.user
$dKey = [string]$dcfg.keyPath
$dRemDir = ([string]$dcfg.remoteDir).TrimEnd('/')
$dUrlPre = [string]$dcfg.downloadUrlPrefix
$dPort = 22
if ($dcfg.port) { $dPort = [int]$dcfg.port }
$dLatest = 'latest.json'
if ($dcfg.latestJsonName) { $dLatest = [string]$dcfg.latestJsonName }
if ($dUrlPre -and -not $dUrlPre.EndsWith('/')) { $dUrlPre = $dUrlPre + '/' }
$missing = @()
if (-not $dHost) { $missing += 'host' }
if (-not $dUser) { $missing += 'user' }
if (-not $dRemDir) { $missing += 'remoteDir' }
if (-not $dUrlPre) { $missing += 'downloadUrlPrefix' }
if ($missing.Count -gt 0) {
Write-Host "[error] config/deploy.json missing fields: $($missing -join ', ')" -ForegroundColor Red
exit 1
}
if ($dKey -and -not (Test-Path $dKey)) {
Write-Host "[error] SSH key not found: $dKey" -ForegroundColor Red
exit 1
}
# generate latest.json (same directory as the APK)
$sha256 = (Get-FileHash -Path $apkDest -Algorithm SHA256).Hash
$dlUrl = "$dUrlPre$apkName"
$publishedAt = (Get-Date).ToUniversalTime().ToString('yyyy-MM-ddTHH:mm:ssZ')
$latest = [ordered]@{
version = $verName
file = $apkName
url = $dlUrl
sha256 = $sha256
publishedAtUtc = $publishedAt
}
$latestPath = Join-Path $distDir $dLatest
[System.IO.File]::WriteAllText($latestPath, ($latest | ConvertTo-Json), (New-Object System.Text.UTF8Encoding($false)))
Write-Host ""
Write-Host "[publish] upload to ${dUser}@${dHost}:${dRemDir}/ ..." -ForegroundColor Yellow
$scpArgs = @('-i', $dKey, '-P', "$dPort", '-o', 'StrictHostKeyChecking=accept-new')
& scp @scpArgs $apkDest "${dUser}@${dHost}:${dRemDir}/"
if ($LASTEXITCODE -ne 0) {
Write-Host "[error] APK upload failed (scp exit code $LASTEXITCODE)" -ForegroundColor Red
exit 1
}
& scp @scpArgs $latestPath "${dUser}@${dHost}:${dRemDir}/"
if ($LASTEXITCODE -ne 0) {
Write-Host "[error] $dLatest upload failed (scp exit code $LASTEXITCODE)" -ForegroundColor Red
exit 1
}
Write-Host ""
Write-Host "================== publish done ==================" -ForegroundColor Green
Write-Host " download : $dlUrl"
Write-Host " sha256 : $sha256"
Write-Host " updated : ${dRemDir}/${dLatest}"
Write-Host "=================================================" -ForegroundColor Green
}
exit 0

209
android-offline/prepare.cjs Normal file
View File

@ -0,0 +1,209 @@
/**
* Android 离线打包准备脚本
* 职责:校验 config/android.json、拷贝 App 资源(www)、覆盖图标/启动图。
* 包名/版本/签名/应用名/appid/appKey 等由 simpleDemo/build.gradle 在构建时动态读取
* config/android.json 与 package.json,本脚本不再写入工程文件。
*
* 用法:
* node android-offline/prepare.cjs
* node android-offline/prepare.cjs <wwwSource> # 可选:覆盖 www 资源目录
*/
const fs = require('fs')
const path = require('path')
const ROOT = path.resolve(__dirname, '..')
const OFFLINE_DIR = __dirname
const CONFIG_PATH = path.join(ROOT, 'config', 'android.json')
const log = (...args) => console.log('[prepare]', ...args)
const warn = (...args) => console.warn('[prepare][警告]', ...args)
// ---------- 1. 读取配置 ----------
let config
try {
config = JSON.parse(fs.readFileSync(CONFIG_PATH, 'utf-8'))
} catch (error) {
if (error.code === 'ENOENT') {
console.error(`[prepare][错误] 未找到配置文件: ${CONFIG_PATH}`)
console.error('请复制 config/android.example.json 为 config/android.json 并填写(appKey、signing 等),详见 config/README.md')
} else {
console.error(`[prepare][错误] 配置文件解析失败 ${CONFIG_PATH}: ${error.message}`)
}
process.exit(1)
}
const required = ['appId', 'appName', 'packageName']
for (const key of required) {
if (!config[key]) {
console.error(`[prepare][错误] config.json 缺少必填项: ${key}`)
process.exit(1)
}
}
// ---------- 1.5 版本一致性校验 ----------
// 离线包的 versionName/versionCode 由 simpleDemo/build.gradle 从 package.json 推导
// (versionCode = X*1000000 + Y*1000 + Z);而 src/manifest.json 的 versionName/versionCode
// 是 HBuilderX 云打包使用的值。两者必须一致,否则同一版本会出现两个 APK 版本号,
// 应用内更新提示、版本排查都会对不上号。
// 注:编译产物 www/manifest.json 内含 version.name/version.code(来自 src/manifest.json)。
// plus.runtime.getProperty(appid).version 读的正是这个值,不是 Android 原生 versionName。
// 因此除一致性校验外,下面还会把注入 APK 的 www/manifest.json 版本强制对齐到 package.json。
try {
const pkgVersion = JSON.parse(fs.readFileSync(path.join(ROOT, 'package.json'), 'utf-8')).version
const [x, y, z] = String(pkgVersion).split('.').map((n) => parseInt(n, 10))
const expectedCode = x * 1000000 + y * 1000 + z
const manifestText = fs.readFileSync(path.join(ROOT, 'src', 'manifest.json'), 'utf-8')
const mVersion = (manifestText.match(/"versionName"\s*:\s*"([^"]*)"/) || [])[1]
const mCode = Number((manifestText.match(/"versionCode"\s*:\s*(\d+)/) || [])[1])
log(`版本: package.json=${pkgVersion} (versionCode ${expectedCode}) | src/manifest.json=${mVersion} (versionCode ${mCode})`)
if (mVersion !== pkgVersion || mCode !== expectedCode) {
warn('package.json 与 src/manifest.json 版本号不一致,请两处同步(否则云打包/离线包会出现不同版本号)')
}
} catch (error) {
warn(`版本一致性校验已跳过: ${error.message}`)
}
// ---------- 2. 定位 SDK 工程 ----------
const AS_DIR = path.join(OFFLINE_DIR, 'HBuilder-Integrate-AS')
const DEMO_DIR = path.join(AS_DIR, 'simpleDemo')
if (!fs.existsSync(AS_DIR)) {
console.error('[prepare][错误] 未找到离线 SDK 工程: ' + AS_DIR)
console.error('请先下载离线 SDK 并解压到 android-offline/ 目录,详见 README.md')
process.exit(1)
}
if (!fs.existsSync(DEMO_DIR)) {
console.error('[prepare][错误] 未找到 simpleDemo 工程: ' + DEMO_DIR)
process.exit(1)
}
let failed = false
// ---------- 3. 签名配置预检(Gradle 构建时从 config 动态读取) ----------
if (!config.signing || !config.signing.keystore) {
warn('config/android.json 中 signing.keystore 为空,Gradle 构建时将因缺少签名配置而失败')
} else if (!fs.existsSync(path.resolve(ROOT, config.signing.keystore))) {
warn(`签名文件不存在: ${path.resolve(ROOT, config.signing.keystore)}`)
}
if (!config.appKey) {
warn('config/android.json 中 appKey 为空,请到 https://dev.dcloud.net.cn 申请后填写')
}
// ---------- 4. 拷贝 App 资源到 assets/apps/{appId}/www ----------
const wwwTarget = path.join(DEMO_DIR, 'src', 'main', 'assets', 'apps', config.appId, 'www')
// 可选外部 www 源覆盖:node prepare.cjs <wwwSource>;其次用 config.android.json 的 wwwSource
const wwwOverride = process.argv[2] ? path.resolve(ROOT, process.argv[2]) : ''
const candidates = [
...(wwwOverride ? [wwwOverride] : []),
...(config.wwwSource ? [path.resolve(ROOT, config.wwwSource)] : []),
// 优先使用 CLI 最新编译产物(dist/build/app-plus)。
// unpackage/resources 是 HBuilderX 本地打包产物,可能已过期,仅作兜底,
// 避免把旧代码打进 APK。
path.join(ROOT, 'dist', 'build', 'app-plus'),
path.join(ROOT, 'unpackage', 'resources', config.appId, 'www'),
]
const wwwSource = candidates.find((dir) => fs.existsSync(dir))
if (!wwwSource) {
failed = true
console.error('[prepare][错误] 未找到 App 资源,请先执行 npm run build:app-plus(或 HBuilderX 生成本地打包资源)')
} else {
fs.rmSync(wwwTarget, { recursive: true, force: true })
fs.cpSync(wwwSource, wwwTarget, { recursive: true })
log(`✓ 拷贝 App 资源: ${path.relative(ROOT, wwwSource)} -> assets/apps/${config.appId}/www`)
}
// ---------- 4.5 对齐编译器版本(隐藏"HTML5+ Runtime 版本不一致"提示) ----------
// CLI 构建资源时写入的 compilerVersion(如 5.07)与离线 SDK Runtime 版本不一致时,
// 启动会弹"本应用使用HBuilderX %s 编译,而手机端SDK版本是 %s"对话框。
// 此处把 www 内 manifest.json / app-config-service.js 的 compilerVersion 对齐到
// config/android.json 的 runtimeVersion(默认 5.24,与离线 SDK 一致),即可消除提示。
const runtimeVersion = config.runtimeVersion || '5.24'
function alignCompilerVersion (filePath) {
try {
if (!fs.existsSync(filePath)) return
let text = fs.readFileSync(filePath, 'utf-8')
const re = /"compilerVersion"\s*:\s*"[^"]*"/g
text = text.replace(re, '"compilerVersion": "' + runtimeVersion + '"')
fs.writeFileSync(filePath, text, 'utf-8')
log(`✓ 对齐 compilerVersion -> ${runtimeVersion}: ${path.relative(ROOT, filePath)}`)
} catch (e) {
warn(`对齐 compilerVersion 失败 ${filePath}: ${e.message}`)
}
}
alignCompilerVersion(path.join(wwwTarget, 'manifest.json'))
alignCompilerVersion(path.join(wwwTarget, 'app-config-service.js'))
// ---------- 4.6 对齐 www/manifest.json 的应用版本(防止应用内读旧版本反复弹更新) ----------
// plus.runtime.getProperty(appid).version 读取的是 www/manifest.json 的 version.name,
// 而非 Android 原生 versionName。若 src/manifest.json 忘记与 package.json 同步,
// 会出现 APK 系统版本是新的、但应用内读到的仍是旧版本,导致“已更新却反复弹更新”。
// 此处把注入 APK 的 www/manifest.json 版本强制对齐到 package.json(唯一版本源)。
function alignAppVersion (filePath) {
try {
if (!fs.existsSync(filePath)) return
const pkg = JSON.parse(fs.readFileSync(path.join(ROOT, 'package.json'), 'utf-8'))
const parts = String(pkg.version).split('.').map((n) => parseInt(n, 10) || 0)
const code = (parts[0] || 0) * 1000000 + (parts[1] || 0) * 1000 + (parts[2] || 0)
let text = fs.readFileSync(filePath, 'utf-8')
const replaced = text.replace(
/"version"\s*:\s*\{[^}]*\}/,
`"version":{"name":"${pkg.version}","code":${code}}`
)
if (replaced !== text) {
fs.writeFileSync(filePath, replaced, 'utf-8')
log(`✓ 对齐应用版本 -> ${pkg.version} (code ${code}): ${path.relative(ROOT, filePath)}`)
}
} catch (e) {
warn(`对齐应用版本失败 ${filePath}: ${e.message}`)
}
}
alignAppVersion(path.join(wwwTarget, 'manifest.json'))
// ---------- 9. 覆盖图标与启动图 ----------
function findResFiles(pattern) {
const resDir = path.join(DEMO_DIR, 'src', 'main', 'res')
const hits = []
if (!fs.existsSync(resDir)) return hits
const walk = (dir) => {
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
const full = path.join(dir, entry.name)
if (entry.isDirectory()) walk(full)
else if (pattern.test(entry.name)) hits.push(full)
}
}
walk(resDir)
return hits
}
function applyImage(cfgPath, patterns, desc) {
if (!cfgPath) return
const image = path.resolve(ROOT, cfgPath)
if (!fs.existsSync(image)) {
warn(`${desc}不存在,跳过: ${image}`)
return
}
const targets = findResFiles(patterns)
if (targets.length === 0) {
warn(`${desc}: 未在 res 下找到目标文件(正则: ${patterns}),请手动替换`)
return
}
for (const target of targets) {
fs.copyFileSync(image, target)
log(`✓ 覆盖${desc}: ${path.relative(ROOT, target)}`)
}
}
applyImage(config.icon, /^(icon\.png|ic_launcher(\.png)?)$/i, '应用图标')
applyImage(config.splash, /^splash(\.png|_screen\.png)?$/i, '启动图')
// ---------- 5. 总结 ----------
console.log('\n[prepare] 完成' + (failed ? '(部分失败,请查看上方错误)' : ''))
console.log('后续:包名/版本/签名/应用名/appid/appKey 由 Gradle 构建时从 config/android.json 与 package.json 动态读取')
if (!failed) process.exit(0)
process.exit(1)

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,99 @@
**项目集成需要添加msa_mdid_1.0.13.aar文件,以便获取移动智能设备标识公共服务平台提供的匿名设备标识符[OAID](https://www.html5plus.org/doc/zh_cn/device.html#plus.device.getOAID)、开发者匿名设备标识符VAID、及应用匿名设备标识符AAID,可用于解决Android10无法获取设备标识(如IMEI、IMSI、Wi-Fi MAC地址等)的问题**
## 2.8.1.80296_20200722
1. 离线sdk不再支持wap2app应用,云打包不受影响。
2. 离线sdk不再支持JS/NVUE文件原生混淆加密,云打包不受影响。
3. 新增uniapp-v8-release.aar,调整 JS引擎默认从 jscore 改为 V8,提升运算性能 [详情](https://ask.dcloud.net.cn/article/37465) **注意:uniapp-v8-release.aar与uniapp-release.aar只能同时使用一个,重复会导致编译失败。**
## 2.7.11.80231_20200602
1. 新增debug-server-release.aar,生成自定义基座时使用,生成正式包时需删除。
2. 新增aps-igexin-fcm-release.aar,使用方式可参考[文档](https://nativesupport.dcloud.net.cn/AppDocs/usemodule/androidModuleConfig/push)
## 2.7.0.80159_20200506
1. 自定义组件编译模式下线,应用默认以v3编译模式运行。并在manifest去除相关概念。后续版本dcloud1.dat、dcloud2.dat也不在需要。
## 2.6.0.74021_20200224
1. 新增腾讯X5内核,使用时只需添加webview-x5-release.aar和weex_webview-x5-release.aar即可。
## 2.5.4.72919_20200108
1. 添加uniAd模块,具体配置可参考文件Feature-Android.xls或链接 https://ask.dcloud.net.cn/article/36814
## 2.4.6.71983_20191211
1. 添加amap-gp-libs-release.aar,供上传google play使用,注意:amap-gp-libs-release.aar与amap-libs-release.aar互斥,二者使用时只能选其一。
## 2.4.2.71156_20191115
1. 更新uni-app依赖,去掉bindingX相关依赖。新版依赖如下,可以参考项目实例。
~~~
/*uniapp所需库-----------------------开始*/
implementation 'com.android.support:recyclerview-v7:26.1.0'
implementation 'com.facebook.fresco:fresco:1.13.0'
implementation "com.facebook.fresco:animated-gif:1.13.0"
/*uniapp所需库-----------------------结束*/
~~~
## 2.3.5.70306_20191018
1. 新增aps-unipush-gp-release.aar和aps-igexin-gp-release.aar,解决个推或UniPush上传谷歌市场失败的问题,注意:谷歌版个推与原个推存在类冲突,若出现冲突,删掉一个即可。
2. 更新uni-app依赖,去掉okhttp相关依赖。新版依赖如下,可以参考项目实例。
~~~
/*uniapp所需库-----------------------开始*/
implementation 'com.android.support:recyclerview-v7:26.1.0'
implementation 'com.alibaba.android:bindingx-core:1.0.3'
implementation 'com.alibaba.android:bindingx_weex_plugin:1.0.3'
implementation 'com.facebook.fresco:fresco:1.13.0'
implementation "com.facebook.fresco:animated-gif:1.13.0"
/*uniapp所需库-----------------------结束*/
~~~
3. 若出现以dc.okio或dc.suqareup.okhttp的类冲突,删除libs目录下dc-okhttp-2.7.5.jar、dc-okhttp-ws-2.7.5.jar、dc-okio-1.6.0.jar即可。
4. 本版删掉sina-libs-release.aar,集成时只需集成openDefault-4.4.1.aar即可。
5. google play版个推在原个推配置上需添加如下内容
~~~
<service
android:name="io.dcloud.feature.apsGt.GTPushDevService"
android:exported="true"
android:label="PushService"
android:process=":pushservice" />
<activity
android:name="com.igexin.sdk.PrivacyActivity"
android:exported="false"/>
~~~
## 1.9.9.69546_20190920
1. 更新依赖,默认需添加fastjson依赖
~~~
implementation 'com.alibaba:fastjson:1.1.46.android'
~~~
## 1.9.9.67817_20190812
1. 离线SDK已支持64位处理器,[Android平台配置支持的CPU类型(64位)](http://ask.dcloud.net.cn/article/36195)
2. 添加map、live-pusher、video等component,具体集成方式参考Feature-Android.xls。
3. 将gif库提取为专门的aar使用,您可以引入android-gif-drawable-release@1.2.17.aar或者引用远程仓库文件。
4. 鉴于新浪和支付宝SDK升级缘故,对应所需库也发生了变化,详情见Feature-Android.xls。
## 1.9.9.67034_20190729
1. barcode改进,相应配置发生变化
~~~
<feature name="Barcode" value="io.dcloud.feature.barcode2.BarcodeFeatureImpl"/>
~~~
2. gallery改进,图片预览更流畅,需集成gallery-dmcBig-release.aar文件(非必须添加),具体显示效果可参考HBuilderX中基座gallery模块。
3. 录制mp3格式音频需集成audio-mp3aac-release.aar文件(非必须添加)。
4. 基座添加glide依赖,集成SDK时必须添加。
5. 集成uni-app时必须添加如下依赖。
~~~
implementation 'com.android.support:recyclerview-v7:26.1.0'
implementation 'com.alibaba.android:bindingx-core:1.0.3'
implementation 'com.alibaba.android:bindingx_weex_plugin:1.0.3'
implementation 'com.squareup.okhttp:okhttp:2.3.0'
implementation 'com.squareup.okhttp:okhttp-ws:2.3.0'
implementation 'com.alibaba:fastjson:1.1.46.android'
implementation 'com.facebook.fresco:fresco:1.13.0'
implementation "com.facebook.fresco:animated-gif:1.13.0"
~~~
6. 新增sqlite模块,配置方式
~~~
<feature name="Sqlite" value="io.dcloud.feature.sqlite.DataBaseFeature"/>
~~~
7. 自定义组件模式下和集成uni-app时必须添加uniapp-release.aar
8. 新增混淆配置文件,可参考SDK目录下proguard.cfg文件进行配置。
本sdk的使用许可,详见HBuilder X使用许可协议

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

View File

@ -0,0 +1,3 @@
splash.png 已生成(1920x1080 横屏,深蓝渐变 + 包裹箱 + 底部进度条,无文字)。
如需重新生成或调整设计,编辑 scripts/gen-android-assets.ps1 后运行:
powershell -NoProfile -ExecutionPolicy Bypass -File scripts\gen-android-assets.ps1

81
babel.config.js Normal file
View File

@ -0,0 +1,81 @@
const webpack = require('webpack')
const plugins = []
if (process.env.UNI_OPT_TREESHAKINGNG) {
plugins.push(require('@dcloudio/vue-cli-plugin-uni-optimize/packages/babel-plugin-uni-api/index.js'))
}
if (
(
process.env.UNI_PLATFORM === 'app-plus' &&
process.env.UNI_USING_V8
) ||
(
process.env.UNI_PLATFORM === 'h5' &&
process.env.UNI_H5_BROWSER === 'builtin'
)
) {
const path = require('path')
const isWin = /^win/.test(process.platform)
const normalizePath = path => (isWin ? path.replace(/\\/g, '/') : path)
const input = normalizePath(process.env.UNI_INPUT_DIR)
try {
plugins.push([
require('@dcloudio/vue-cli-plugin-hbuilderx/packages/babel-plugin-console'),
{
file (file) {
file = normalizePath(file)
if (file.indexOf(input) === 0) {
return path.relative(input, file)
}
return false
}
}
])
} catch (e) { }
}
process.UNI_LIBRARIES = process.UNI_LIBRARIES || ['@dcloudio/uni-ui']
process.UNI_LIBRARIES.forEach(libraryName => {
plugins.push([
'import',
{
'libraryName': libraryName,
'customName': (name) => {
return `${libraryName}/lib/${name}/${name}`
}
}
])
})
if (process.env.UNI_PLATFORM !== 'h5') {
plugins.push('@babel/plugin-transform-runtime')
}
const config = {
presets: [
[
'@vue/app',
{
modules: webpack.version[0] > 4 ? 'auto' : 'commonjs',
useBuiltIns: process.env.UNI_PLATFORM === 'h5' ? 'usage' : 'entry'
}
]
],
plugins
}
const UNI_H5_TEST = '**/@dcloudio/uni-h5/dist/index.umd.min.js'
if (process.env.NODE_ENV === 'production') {
config.overrides = [{
test: UNI_H5_TEST,
compact: true,
}]
} else {
config.ignore = [UNI_H5_TEST]
}
module.exports = config

View File

@ -1,405 +0,0 @@
<template>
<u-upload
ref="uUploadRef"
:fileList="fileList"
:maxCount="maxCount"
:multiple="multiple"
:disabled="disabled"
@afterRead="handleAfterRead"
@delete="handleDelete"
>
</u-upload>
</template>
<script>
export default {
name: "UploadImgCos",
props: {
business_type: {
type: String,
required: true
},
business_id: {
type: Number,
required: true
},
value: {
type: Array,
default: () => []
},
maxCount: {
type: Number,
default: 6
},
multiple: {
type: Boolean,
default: true
},
disabled: {
type: Boolean,
default: false
}
},
data() {
return {
internalFileList: [],
// 记录正在上传的文件,用于避免重复上传
uploadingFiles: new Set()
};
},
computed: {
fileList: {
get() {
return this.internalFileList;
},
set(value) {
this.internalFileList = value;
}
}
},
watch: {
value: {
immediate: true,
handler(newVal) {
this.formatFileList(newVal);
}
}
},
methods: {
/**
* 格式化文件列表
*/
formatFileList(externalList) {
if (!externalList || !Array.isArray(externalList)) {
this.internalFileList = [];
return;
}
this.internalFileList = externalList.map(item => {
if (item.status) {
return item;
}
return {
url: item.url || item.path || '',
name: item.name || this.extractFileName(item.url) || '',
status: 'success',
message: '',
id: item.id || item.fileId || ''
};
});
},
/**
* 提取文件名
*/
extractFileName(filePath) {
if (!filePath || typeof filePath !== 'string') return null;
return filePath.split(/[\\/]/).pop();
},
/**
* 获取文件MD5
*/
async getFileMd5(filePath) {
return new Promise((resolve, reject) => {
uni.getFileInfo({
filePath,
digestAlgorithm: "md5",
success: resolve,
fail: reject
});
});
},
/**
* 处理文件选择
*/
async handleAfterRead(event) {
if (this.disabled) return;
const { file, name } = event;
const files = Array.isArray(file) ? file : [file];
// 检查数量限制
const remainingSlots = this.maxCount - this.fileList.length;
if (remainingSlots <= 0) {
uni.showToast({
title: `最多只能上传${this.maxCount}个文件`,
icon: 'none'
});
return;
}
const filesToUpload = files.slice(0, remainingSlots);
// 添加文件到列表(初始状态为pending)
const startIndex = this.fileList.length;
filesToUpload.forEach((file) => {
this.fileList.push({
...file,
status: "pending",
message: "等待上传"
});
});
// 串行上传
for (let i = 0; i < filesToUpload.length; i++) {
const fileIndex = startIndex + i;
await this.processFileUpload(filesToUpload[i], fileIndex);
}
},
/**
* 处理单个文件上传流程
*/
async processFileUpload(file, fileIndex) {
try {
// 检查是否已经在上传
const fileKey = `${file.url}_${file.size}`;
if (this.uploadingFiles.has(fileKey)) {
return;
}
this.uploadingFiles.add(fileKey);
// 1. 获取文件MD5
const fileInfo = await this.getFileMd5(file.url);
const fileName = this.extractFileName(file.url) || file.name;
// 2. 更新状态为上传中
this.fileList[fileIndex] = {
...file,
status: "uploading",
message: "上传中",
md5: fileInfo.digest
};
// 3. 获取COS上传配置
const uploadConfig = await this.$http('common.getCOSUploadConfig', {
data: {
fileName,
fileSize: fileInfo.size,
fileType: file.type,
id: this.business_id,
md5: fileInfo.digest,
type: this.business_type,
}
});
const configData = uploadConfig.data;
if (!configData) {
throw new Error("获取上传配置失败");
}
// 4. 执行COS上传(这里不会返回响应数据)
await this.uploadToCOS(file.url, configData, fileIndex);
// 5. 通知后端上传完成
const notifyResult = await this.notifyUploadComplete(configData.fileInfo, fileIndex);
// 6. 更新状态为成功
if (notifyResult.data?.data) {
const { fileUrl, fileId } = notifyResult.data.data;
this.fileList[fileIndex] = {
...this.fileList[fileIndex],
status: "success",
message: "",
url: fileUrl,
id: fileId,
successUrl: fileUrl // 保存成功后的URL
};
// 7. 关联文件
await this.referenceFiles();
// 触发成功事件
this.$emit('upload-success', {
file: this.fileList[fileIndex],
index: fileIndex
});
}
} catch (error) {
console.error("上传流程失败:", error);
this.fileList[fileIndex] = {
...this.fileList[fileIndex],
status: "error",
message: error.message || "上传失败"
};
} finally {
// 清理上传记录
const fileKey = `${file.url}_${file.size}`;
this.uploadingFiles.delete(fileKey);
}
},
/**
* 上传文件到COS(关键修改:不需要处理响应)
*/
uploadToCOS(filePath, config, fileIndex) {
return new Promise((resolve, reject) => {
// COS上传不会返回数据,所以这里只是发起请求
const uploadTask = uni.uploadFile({
url: config.uploadUrl, // 应该从config中获取
filePath: filePath,
name: 'file',
formData: config.data,
// COS上传成功不会有响应体,只会有状态码
success: (res) => {
// 注意:COS返回的HTTP状态码成功通常是204或200,但没有响应体
if (res.statusCode === 200 || res.statusCode === 204) {
resolve();
} else {
reject(new Error(`COS上传失败,状态码: ${res.statusCode}`));
}
},
fail: (error) => {
reject(new Error("COS上传请求失败"));
}
});
// 可以监听上传进度
uploadTask.onProgressUpdate = (res) => {
this.fileList[fileIndex] = {
...this.fileList[fileIndex],
progress: res.progress,
message: `上传中 ${res.progress}%`
};
// 触发进度事件
this.$emit('upload-progress', {
index: fileIndex,
progress: res.progress,
totalBytesSent: res.totalBytesSent,
totalBytesExpectedToSend: res.totalBytesExpectedToSend
});
};
});
},
/**
* 通知后端上传完成
*/
async notifyUploadComplete(config, fileIndex) {
try {
// 调用后端接口,通知COS上传已完成
const response = await this.$http('common.uploadSuccessNotify', {
...config,
fileInfo: {
fileName: config.fileName,
fileSize: config.fileSize,
fileType: config.fileType,
md5: config.md5
}
});
return response;
} catch (error) {
console.error("上传完成通知失败:", error);
throw error;
}
},
/**
* 关联文件
*/
async referenceFiles() {
console.log("this.fileList",this.fileList);
try {
// 获取所有成功的文件(包括之前已经关联的)
const validFiles = this.fileList
.filter(item => item.status === "success" && item.id)
.map(item => ({ file_id: item.id }));
if (validFiles.length === 0) {
// 如果没有成功文件,也要通知后端清空关联
const response = await this.$http('common.ReferenceFile', {
id: this.business_id,
type: this.business_type,
images: []
});
// 更新外部绑定
this.$emit('change', this.fileList);
this.$emit('input', this.fileList);
return response;
}
const response = await this.$http('common.ReferenceFile', {
id: this.business_id,
type: this.business_type,
images: validFiles
});
// 更新外部绑定
this.$emit('change', this.fileList);
this.$emit('input', this.fileList);
return response;
} catch (error) {
console.error("关联文件失败:", error);
throw error;
}
},
/**
* 处理删除 - 修正版本
*/
async handleDelete(index) {
const deletedFile = this.fileList[index];
// 从列表中移除
this.fileList.splice(index, 1);
// 立即更新UI
this.$emit('delete', {
file: deletedFile,
index
});
// 更新外部绑定(立即更新,不等待)
this.$emit('change', this.fileList);
this.$emit('input', this.fileList);
// 异步更新文件关联
try {
await this.referenceFiles();
} catch (error) {
console.error("删除后重新关联失败:", error);
// 这里可以选择给用户提示,但不阻塞UI
}
},
/**
* 手动上传
*/
upload() {
if (this.$refs.uUploadRef && !this.disabled) {
this.$refs.uUploadRef.chooseFile();
}
},
/**
* 获取上传成功的文件
*/
getSuccessFiles() {
return this.fileList.filter(item => item.status === "success");
},
/**
* 清空文件
*/
clearFiles() {
this.fileList = [];
this.$emit('input', []);
this.$emit('change', []);
}
}
};
</script>
<style scoped>
</style>

73
config/README.md Normal file
View File

@ -0,0 +1,73 @@
# config 目录说明
本目录存放打包/发布相关配置。**含密码等敏感信息的一律不提交 git**,配套的 `*.example.json` 模板提交。
| 文件 | 说明 | 是否提交 |
|---|---|---|
| `android.json` | Android 离线打包本地配置(appKey、签名密码等) | ❌ |
| `android.example.json` | 上述配置的模板,首次使用复制为 `android.json` | ✅ |
| `deploy.json` | 发布上传配置(scp 目标、下载地址前缀等),存在时打包结束自动上传 APK + `latest.json` | ❌ |
| `deploy.example.json` | 上述配置的模板,首次使用复制为 `deploy.json` | ✅ |
## android.json 字段
| 字段 | 说明 |
|---|---|
| `appId` | uni-app appid。**本项目为 `__UNI__0B3DAD3`,不要与工作台/散单的 `__UNI__900BDC1` 混用** |
| `appKey` | DCloud 离线打包 Key,**按 `appId + packageName + 签名证书 SHA-256` 三者绑定** |
| `appName` | 桌面显示的应用名(构建时写入 `resValue app_name`) |
| `packageName` | Android 包名(`applicationId` 与 gradle `namespace` 都由它决定,发布后不可更改) |
| `abis` | CPU 架构。此处与 `src/manifest.json` 的 `abiFilters` 保持一致(`armeabi-v7a`、`arm64-v8a`) |
| `icon` / `splash` | 图标/启动图路径(相对项目根),`prepare.cjs` 会用它们覆盖 `res/` 下的同名资源 |
| `wwwSource` | App 资源目录。留空则依次尝试 `dist/build/app-plus`(CLI 最新编译产物)、`unpackage/resources/<appId>/www`(HBuilderX 本地打包产物,仅作兜底) |
| `runtimeVersion` | 离线 SDK 的 5+ Runtime 版本。`prepare.cjs` 会把 www 内 `manifest.json`/`app-config-service.js` 的 `compilerVersion` 对齐到该值,避免启动时弹「HBuilderX %s 编译 / 手机端 SDK %s」提示 |
| `signing.keystore` | 签名文件路径(相对项目根),放在 `android-offline/keystore/`(该目录 git 不跟踪) |
| `signing.storePassword` / `keyAlias` / `keyPassword` | 签名密码与别名,**自己填写,不要提交**。DCloud 下发的 keystore(PKCS12)别名固定为 `__uni__` + appid 小写,本项目即 `__uni__0b3dad3`;PKCS12 的 `storePassword` 与 `keyPassword` 必须相同 |
## appKey 务必与三者一致
`appKey` 失效的典型表现:APK 能装能开,但启动即白屏并提示「未配置appkey或配置错误」。此时按顺序核对:
1. `appId` 是否为 `__UNI__0B3DAD3`;
2. `packageName` 是否与申请 Key 时填写的包名一致;
3. 证书 SHA-256 是否与申请 Key 时使用的一致:
```
keytool -list -v -keystore android-offline\keystore\<你的证书> -alias <别名>
```
输出里的 `SHA256:` 即为指纹。
需要更换包名或证书时,要先去 https://dev.dcloud.net.cn → 应用详情 → Android → 离线打包 Key 管理 重新申请(需填包名与证书 SHA-256)。
### 当前已知指纹(用于快速判断是否需要重新申请 Key)
| 用途 | 证书 SHA-256 | appKey |
|---|---|---|
| 线上已发布 APK(DCloud 云打包签名) | `d9689a9ba66e55e3002508b6ea9bb3bc086a2ba541df9cb86cdde43d6c25d6ff` | `f523d8541674ad75105fa604f5a51a54` |
| 本地离线打包(自有 keystore) | 用下面命令查,**与左栏不一致就必须重新申请** | 重新申请后填入本文件 |
```powershell
& "$env:JAVA_HOME\bin\keytool.exe" -list -v -keystore "d:\WMS_PDA\android-offline\keystore\<证书文件>"
# 输出里的 SHA256: 即上表右栏要用的指纹
```
> 签名不同会导致**无法覆盖安装**已发布的云打包版本(需先卸载重装),这是切离线打包的必然代价。
## deploy.json 字段(发布上传)
打包结束后,`pack.ps1` 会检查 `config/deploy.json`:存在则生成 `latest.json`(版本、文件名、下载地址、SHA-256、发布时间)并用 `scp` 上传 APK 与 `latest.json`;不存在则跳过上传(仅打本地包)。加 `-NoUpload` 或 `-Dev` 也会跳过上传。
| 字段 | 必填 | 说明 |
|---|---|---|
| `host` | ✅ | scp 目标主机 IP/域名 |
| `user` | ✅ | SSH 用户名 |
| `remoteDir` | ✅ | 远程上传目录 |
| `downloadUrlPrefix` | ✅ | 下载 URL 前缀,与 APK 文件名拼接成完整下载地址写入 `latest.json` |
| `keyPath` | ⬜ | SSH 私钥路径,填写后会校验文件存在 |
| `port` | ⬜ | SSH 端口,默认 22 |
| `latestJsonName` | ⬜ | 版本清单文件名,默认 `latest.json` |
## 首次使用
1. 确认 `config/android.json` 已存在(本仓库已预填非敏感项),填写 `appKey`、`keyAlias`、`storePassword`、`keyPassword`;
2. 确认 `android-offline/keystore/` 下有对应 keystore;
3. 执行 `npm run build:apk`(= 生产编译 + 产物地址校验 + 离线打包)。

View File

@ -0,0 +1,17 @@
{
"appId": "__UNI__0B3DAD3",
"appKey": "",
"appName": "WMS_PDA",
"packageName": "com.gztbyc.pda_wms",
"abis": ["armeabi-v7a", "arm64-v8a"],
"icon": "android-offline/icon/app-icon.png",
"splash": "android-offline/splash/splash.png",
"wwwSource": "",
"runtimeVersion": "5.24",
"signing": {
"keystore": "android-offline/keystore/xxx.keystore",
"storePassword": "",
"keyAlias": "__uni__0b3dad3",
"keyPassword": ""
}
}

View File

@ -0,0 +1,11 @@
{
"android": {
"host": "your-server.example.com",
"user": "deploy",
"keyPath": "C:/Users/you/.ssh/id_rsa",
"port": 22,
"remoteDir": "/var/www/wms-pda/download",
"downloadUrlPrefix": "https://your-server.example.com/wms-pda/download",
"latestJsonName": "latest.json"
}
}

View File

@ -1,152 +0,0 @@
/**
* 接口列表文件
*/
export default {
/** 公共 ↓ **/
common: {
ping: {
path: "index.ping",
auth: false,
method: "POST",
isSystemApi: true
},
store: {
path: "index.loadStores",
auth: false,
method: "POST",
isSystemApi: true
},
getCOSUploadConfig: {
path: "index.getCOSUploadConfig",
auth: true,
method: "POST",
isSystemApi: true
},
uploadSuccessNotify: {
path: "index.uploadSuccessNotify",
auth: true,
method: "POST",
isSystemApi: true
},
ReferenceFile: {
path: "index.ReferenceFile",
auth: true,
method: "POST",
isSystemApi: true
},
searchSpace: {
path: "index.searchSpace",
auth: true,
method: "POST",
isSystemApi: true
},
listTemplatesByType: {
path: "setting.printTemplate.listTemplatesByType",
auth: true,
method: "POST",
isSystemApi: true
}
},
/** 用户 ↓ **/
user: {
info: {
path: "user.info",
auth: false,
method: "POST",
isSystemApi: true
},
login: {
path: "user.login",
auth: false,
method: "POST",
isSystemApi: true
},
changeRole: {
path: "user.changeRole",
auth: true,
method: "POST",
isSystemApi: true
}
},
storage: {
receiving: {
getReceivingList: {
path: "storage.receiving.getReceivingList",
auth: true,
method: "POST",
isSystemApi: true
},
create: {
path: "storage.receiving.create",
auth: true,
method: "POST",
isSystemApi: true
},
get: {
path: "storage.receiving.get",
auth: true,
method: "POST",
isSystemApi: true
},
addDetail: {
path: "storage.receiving.addDetail",
auth: true,
method: "POST",
isSystemApi: true
},
deleteDetail: {
path: "storage.receiving.deleteDetail",
auth: true,
method: "POST",
isSystemApi: true
},
detailChange: {
path: "storage.receiving.detailChange",
auth: true,
method: "POST",
isSystemApi: true
},
cancel: {
path: "storage.receiving.cancel",
auth: true,
method: "POST",
isSystemApi: true
},
completeReceiving: {
path: "storage.receiving.completeReceiving",
auth: true,
method: "POST",
isSystemApi: true
}
}
},
stock: {
search: {
path: "stock.search",
auth: true,
method: "POST",
isSystemApi: true
}
},
print: {
getList: {
path: "print.getList",
auth: true,
method: "POST",
isSystemApi: true
},
getComputerPrinter: {
path: "print.getComputerPrinter",
auth: true,
method: "POST",
isSystemApi: true
},
send:{
path: "print.send",
auth: true,
method: "POST",
isSystemApi: true
}
}
};

View File

@ -1,91 +0,0 @@
import coreRequest from './request'
import apiList from './apis.js'
import store from '@/core/store/index.js'
import { setToken,removeToken } from '../utils/auth';
import router from '@/core/router'
const Request = new coreRequest();
export default function http(
url,
data = {},
toastBefore = '', // 请求前加载提示
toastAfter = true, // 请求后错误提示
responseType = 'text'
) {
let api = getApiPath(url);
console.log(api);
/* 请求之前拦截器 */
Request.interceptor.request((config, cancel) => {
let token = uni.getStorageSync('token');
if (api.auth && !token) {
store.dispatch('logout');
uni.hideLoading()
throw (`暂未登录,已阻止此次API请求: '${api.url}'`);
}
token && Request.setConfig(config => {
config.header.authorization = `Bearer ${token}`
})
if (toastBefore !== '') {
uni.showLoading({
title: toastBefore,
mask: true
});
}
return config
});
/* 请求之后拦截器 */
Request.interceptor.response((res) => {
const headers = res.header;
console.log(res);
const response = res.data;
const token = headers?.authorization || headers?.Authorization // 新的token
if (token) {
const newToken = token.substring(7) // 去掉'Bearer '前缀
setToken(newToken)
}
uni.hideLoading();
if (response?.flag === "failure") {
if (toastAfter) {
uni.showToast({
title: response.message || '请求出错,稍后重试',
icon: 'none',
duration: 1000,
mask: true
});
}
}
// token过期注销
if (res.statusCode === 401) {
removeToken();
uni.showToast({
title: '登录已过期,请重新登录',
icon: 'none',
duration: 1000,
mask: true
});
uni.reLaunch('/pages/login/index')
}
return response
})
return Request.request({
url: api.url,
path: api.path,
data,
method: api.method,
responseType
})
}
// 组装接口路径
function getApiPath(url) {
let apiArray = url.split(".");
let api = apiList;
apiArray.forEach(v => {
api = api[v];
});
return api;
}

View File

@ -1,14 +0,0 @@
const TokenKey = 'token'
export function getToken() {
return uni.getStorageSync(TokenKey);
}
export function setToken(token) {
console.log("设置token");
return uni.setStorageSync(TokenKey,token);
}
export function removeToken() {
return uni.setStorageSync(TokenKey,'');
}

9
day.log Normal file
View File

@ -0,0 +1,9 @@
2026-03-23
统计口径:当前工作区不是 git 仓库,以下内容按文件最后修改时间整理。
一、今日完成
二、问题记录
暂无
三、后续计划

3
env.js
View File

@ -1,3 +0,0 @@
export const BASE_URL = 'http://192.168.11.56:6060' //后台根域名 https://demo.shopro.top
export const API_URL = `${BASE_URL}/system` //后台接口域名
export const IMG_URL = 'https://ye4s.file.gzxunren.com' //全局网络图片地址变量,css背景图片地址变量在uni.scss

View File

@ -1,16 +1,66 @@
{ {
"id": "uview-ui", "name": "wms-pda",
"version": "1.0.144",
"private": true,
"description": "天豹云仓 WMS_PDA(uni-app Vue2 + @vue/cli 4.5)",
"scripts": { "scripts": {
"serve": "npm run dev:h5",
"build": "npm run build:h5",
"dev:h5": "cross-env NODE_ENV=development UNI_PLATFORM=h5 NODE_OPTIONS=\"--openssl-legacy-provider --require=./scripts/node-compat.cjs\" vue-cli-service uni-serve",
"dev:app-plus": "cross-env NODE_ENV=development UNI_PLATFORM=app-plus NODE_OPTIONS=\"--openssl-legacy-provider --require=./scripts/node-compat.cjs\" vue-cli-service uni-build --watch",
"build:h5": "cross-env NODE_ENV=production UNI_PLATFORM=h5 NODE_OPTIONS=\"--openssl-legacy-provider --require=./scripts/node-compat.cjs\" vue-cli-service uni-build && node scripts/check-build-env.cjs dist/build/h5",
"build:app-plus": "cross-env NODE_ENV=production UNI_PLATFORM=app-plus NODE_OPTIONS=\"--openssl-legacy-provider --require=./scripts/node-compat.cjs\" vue-cli-service uni-build && node scripts/check-build-env.cjs dist/build/app-plus",
"build:apk": "node scripts/build-apk.cjs",
"dev:adb": "node scripts/dev-adb.cjs",
"build:app-plus:dev": "cross-env NODE_ENV=production UNI_PLATFORM=app-plus NODE_OPTIONS=\"--openssl-legacy-provider --require=./scripts/node-compat.cjs\" vue-cli-service uni-build",
"android:pack:raw": "powershell -NoProfile -ExecutionPolicy Bypass -File android-offline/pack.ps1",
"check:env": "node scripts/check-build-env.cjs",
"lint": "eslint . --fix",
"test": "eslint . --fix" "test": "eslint . --fix"
}, },
"dependencies": { "dependencies": {
"@dcloudio/uni-app": "2.0.2-5020620260917001",
"@dcloudio/uni-app-plus": "2.0.2-5020620260917001",
"@dcloudio/uni-h5": "2.0.2-5020620260917001",
"@dcloudio/uni-i18n": "2.0.2-5020620260917001",
"@dcloudio/uni-mp-vue": "2.0.2-5020620260917001",
"@dcloudio/uni-mp-weixin": "2.0.2-5020620260917001",
"@dcloudio/uni-stat": "2.0.2-5020620260917001",
"core-js": "^3.8.3",
"html2canvas": "^1.4.1", "html2canvas": "^1.4.1",
"pinyin-pro": "^3.28.0",
"qrcode": "^1.5.4", "qrcode": "^1.5.4",
"regenerator-runtime": "^0.12.1",
"uni-read-pages": "^1.0.5", "uni-read-pages": "^1.0.5",
"uqrcodejs": "^4.0.7" "uqrcodejs": "^4.0.7",
"vue": ">= 2.6.14 < 2.7",
"vuex": "^3.6.2"
}, },
"devDependencies": { "devDependencies": {
"@dcloudio/uni-cli-i18n": "2.0.2-5020620260917001",
"@dcloudio/uni-cli-shared": "2.0.2-5020620260917001",
"@dcloudio/uni-migration": "2.0.2-5020620260917001",
"@dcloudio/uni-template-compiler": "2.0.2-5020620260917001",
"@dcloudio/vue-cli-plugin-hbuilderx": "2.0.2-5020620260917001",
"@dcloudio/vue-cli-plugin-uni": "2.0.2-5020620260917001",
"@dcloudio/vue-cli-plugin-uni-optimize": "2.0.2-5020620260917001",
"@dcloudio/webpack-uni-mp-loader": "2.0.2-5020620260917001",
"@dcloudio/webpack-uni-pages-loader": "2.0.2-5020620260917001",
"@vue/cli-plugin-babel": "~4.5.0",
"@vue/cli-service": "~4.5.0",
"babel-plugin-import": "^1.11.0",
"copy-webpack-plugin": "^5.1.2",
"cross-env": "^7.0.2",
"eslint": "^8.2.0", "eslint": "^8.2.0",
"eslint-config-airbnb": "^19.0.0" "eslint-config-airbnb": "^19.0.0",
} "postcss": "^7.0.39",
"postcss-comment": "^2.0.0",
"sass": "~1.49.8",
"sass-loader": "^8.0.2",
"vue-template-compiler": ">= 2.6.14 < 2.7"
},
"browserslist": [
"Android >= 4.4",
"iOS >= 9"
]
} }

View File

@ -1,159 +0,0 @@
{
// "condition": { //模式配置,仅开发期间生效
// "current": 0, //当前激活的模式(list 的索引项)
// "list": [{
// "name": "test", //模式名称
// "path": "pages/componentsA/test/test", //启动页面,必选
// "query": "" //启动参数,在页面的onLoad函数里面得到
// }]
// },
"pages": [ //pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages
{
"path": "pages/login/index",
"style": {
"titleNView": false
}
},
{
"path" : "pages/oa/index",
"style" :
{
"titleNView": false
}
},
{
"path": "pages/index/index",
"style": {
"titleNView": false
}
},
{
"path": "pages/work/index",
"style": {
"titleNView": false
}
},
{
"path": "pages/user/index",
"style": {
"titleNView": false
}
},
{
"path": "pages/message/index",
"style": {
"titleNView": false
}
},
{
"path" : "pages/404",
"style" :
{
"titleNView": false
}
},
{
"path" : "pages/settings/broadcastSettings",
"style" :
{
"titleNView": false
}
},
{
"path" : "pages/settings/index",
"style" :
{
"titleNView": false
}
},
{
"path" : "pages/settings/networkTest",
"style" :
{
"titleNView": false
}
},
{
"path" : "pages/work/storage/receiving/receiving",
"meta": {
"auth": true
},
"style" :
{
"titleNView": false
}
},
{
"path" : "pages/work/storage/relocation",
"meta": {
"auth": true
},
"style" :
{
"titleNView": false
}
},
{
"path" : "pages/403",
"style" :
{
"titleNView": false
}
},
{
"path" : "pages/work/storage/receiving/receivingCreate",
"style" :
{
"titleNView": false
}
},
{
"path" : "pages/work/storage/receiving/receivingDetail",
"style" :
{
"titleNView": false
}
},
{
"path" : "pages/work/storage/receiving/receivingList",
"style" :
{
"titleNView": false
}
}
],
"globalStyle": {
"navigationBarTextStyle": "black",
"navigationBarTitleText": "WMS_PDA",
"navigationBarBackgroundColor": "#FFFFFF",
"backgroundColor": "#f8f8f8"
},
"tabBar": {
"borderStyle": "white",
"backgroundColor": "#333",
"color": "#555",
"selectedColor": "#24afd6",
"list": [{
"text": "作业",
"pagePath": "pages/index/index",
"iconPath": "static/icon/index.png",
"selectedIconPath": "static/icon/index_a.png"
},
{
"text": "工单",
"pagePath": "pages/oa/index",
"iconPath": "static/icon/oa.png",
"selectedIconPath": "static/icon/oa_a.png"
},
{
"text": "我的",
"pagePath": "pages/user/index",
"iconPath": "static/icon/mime.png",
"selectedIconPath": "static/icon/mime_a.png"
}
]
}
}

View File

@ -1,659 +0,0 @@
<template>
<view class="pda-home">
<view class="status_bar">
</view>
<view class="compact-header">
<!-- 主体切换 -->
<view class="org-switcher">
<view class="org-info" @click="showStoreSelector">
<text class="org-name">{{ userInfo.store_name || '选择主体' }}</text>
<text class="org-id">{{ userInfo.employees_name || '---' }}</text>
</view>
<u-icon @click="showStoreSelector" name="arrow-down" size="16" color="#666" v-if="userInfo.employees && userInfo.employees.length > 1"></u-icon>
<view class="news-wrapper" @click="toNewsPage">
<u-notice-bar :text="newsList[0]" mode="horizontal" bg-color="transparent" color="#666"
:font-size="12" :padding="0" :radius="0" :volume-icon="false" :more-icon="false" :speed="60"
:height="30" :autoplay="true"></u-notice-bar>
</view>
</view>
<!-- 消息区域 -->
<view class="header-actions">
</view>
</view>
<!-- 主内容区 -->
<scroll-view class="main-scroll" scroll-y :scroll-top="scrollTop" :show-scrollbar="false">
<!-- 快捷入口区域 -->
<view class="quick-section">
<view class="section-title-bar">
<view class="title-left">
<text class="section-title">常用功能</text>
</view>
<view class="title-right">
<u-icon name="grid" color="#2979ff" size="20"></u-icon>
<text class="edit-btn" @click="toEditPage">全部功能</text>
<text class="divider">|</text>
<text class="page-indicator">{{ currentPage }}/{{ totalPages }}</text>
</view>
</view>
<!-- 3行4列的快捷入口网格 -->
<view class="quick-grid-container">
<!-- 上一页按钮 -->
<view class="nav-arrow left-arrow" @click="prevPage" :class="{ disabled: currentPage === 1 }">
<u-icon name="arrow-left" size="20" color="#666"></u-icon>
</view>
<!-- 网格内容 -->
<view class="quick-grid-wrapper">
<!-- 空状态提示 -->
<view class="empty-state" v-if="!isLoading && quickActions.length === 0">
<u-icon name="grid" size="80" color="#ccc"></u-icon>
<text class="empty-text">暂无可用功能</text>
<text class="empty-hint">请联系仓库管理员检查授权</text>
</view>
<swiper v-else class="quick-swiper" :current="currentPage - 1" @change="onSwiperChange"
:duration="300">
<swiper-item v-for="(pageItems, pageIndex) in paginatedActions" :key="pageIndex">
<view class="grid-page">
<!-- 3行4列布局,共12个 -->
<view class="grid-item" v-for="(item, index) in pageItems" :key="index"
@click="toPath(item)">
<view class="item-icon-box" :style="{ background: item.color + '15' }">
<u-icon :name="item.icon" size="26" :color="item.color"></u-icon>
</view>
<text class="item-name">{{ item.name }}</text>
<u-badge v-if="item.badge && item.badge > 0" :count="item.badge" size="mini"
type="error" :offset="[-3, 3]" class="item-badge"></u-badge>
</view>
<!-- 填充空白项 -->
<view v-for="n in (12 - pageItems.length)" :key="'empty-' + n"
class="grid-item empty-item"></view>
</view>
</swiper-item>
</swiper>
</view>
<!-- 下一页按钮 -->
<view class="nav-arrow right-arrow" @click="nextPage"
:class="{ disabled: currentPage === totalPages }">
<u-icon name="arrow-right" size="20" color="#666"></u-icon>
</view>
</view>
<!-- 分页指示器 -->
<view class="pagination-dots">
<view v-for="n in totalPages" :key="n" class="pagination-dot"
:class="{ active: n === currentPage }"></view>
</view>
</view>
<!-- 加载状态 -->
<view class="loading-state" v-if="isLoading">
<text class="loading-text">加载中...</text>
</view>
</scroll-view>
</view>
</template>
<script>
export default {
data() {
return {
isLoading: true,
currentPage: 1,
scrollTop: 0,
userInfo: {},
newsList: [
'欢迎使用PDA仓库管理系统',
'请及时处理待办任务',
'祝您工作愉快'
],
unreadCount: 0,
quickActions: [],
pageSize: 12,
FIXED_MENU_KEY: 'fixed_home_menus'
}
},
computed: {
// 分页后的快捷入口
paginatedActions() {
const pages = [];
for (let i = 0; i < this.quickActions.length; i += this.pageSize) {
pages.push(this.quickActions.slice(i, i + this.pageSize));
}
return pages;
},
totalPages() {
return Math.ceil(this.quickActions.length / this.pageSize) || 1;
}
},
async onLoad() {
await this.loadUserInfo();
},
onShow() {
this.loadUserInfo();
},
methods: {
async loadUserInfo() {
// 等待用户信息加载
await new Promise(resolve => setTimeout(resolve, 100));
if (!this.$store.getters.user) {
console.log('等待用户信息...');
setTimeout(() => this.loadUserInfo(), 100);
return;
}
const userData = this.$store.getters.user;
if (userData) {
this.isLoading = false;
this.userInfo = userData;
this.refreshQuickActions();
}
},
// 刷新快捷入口
refreshQuickActions() {
this.isLoading = true;
try {
// 1. 获取用户当前可用的菜单
const userMenus = this.getUserMenus();
// 2. 从Vuex获取已固定的菜单
const savedFixedMenus = this.$store.getters[`setting/${this.FIXED_MENU_KEY}`] || [];
// 3. 如果有保存的固定菜单
if (savedFixedMenus && Array.isArray(savedFixedMenus) && savedFixedMenus.length > 0) {
// 验证用户是否还有这些菜单的权限
const validFixedMenus = this.validateAndFilterMenus(savedFixedMenus, userMenus);
if (validFixedMenus.length > 0) {
// 使用有效的固定菜单(不更新存储)
console.log('使用有效的固定菜单:', validFixedMenus);
this.quickActions = validFixedMenus;
return;
}
// 如果固定菜单全部失效,继续执行下面的逻辑
}
// 4. 如果没有有效的固定菜单,检查用户菜单
if (userMenus && userMenus.length > 0) {
console.log('从用户菜单生成快捷入口:', userMenus);
// 根据用户菜单生成快捷入口
this.quickActions = this.processMenus(userMenus);
} else {
// 5. 如果还是没有菜单,返回空数组
console.log('用户没有可用菜单');
this.quickActions = [];
}
} catch (error) {
console.error('刷新快捷入口失败:', error);
this.quickActions = [];
} finally {
this.isLoading = false;
}
},
// 辅助方法:验证和过滤菜单权限
validateAndFilterMenus(fixedMenus, userMenus) {
if (!fixedMenus || !userMenus) return [];
// 根据你的数据结构调整验证逻辑
// 假设菜单项有 id 或 code 作为唯一标识
return fixedMenus.filter(fixedMenu => {
// 检查用户菜单中是否包含这个固定菜单
return userMenus.some(userMenu => {
// 根据你的实际数据结构调整比对逻辑
// 示例1:如果有 id
if (fixedMenu.id && userMenu.id) {
return fixedMenu.id === userMenu.id;
}
// 示例2:如果有 menuCode
if (fixedMenu.menuCode && userMenu.menuCode) {
return fixedMenu.menuCode === userMenu.menuCode;
}
// 示例3:如果有 path
if (fixedMenu.path && userMenu.path) {
return fixedMenu.path === userMenu.path;
}
return false;
});
});
},
// 获取用户菜单
getUserMenus() {
const user = this.$store.getters.user;
if (!user) return [];
// 从用户信息中获取菜单
return user.menus || user.permissions || [];
},
// 处理菜单数据
processMenus(menus) {
// 1. 展平所有子菜单(使用 flatMap 替代 map + filter)
const allChildren = menus.flatMap(item =>
item.children || [] // 确保 children 存在,否则返回空数组
);
// 2. 过滤有效菜单并限制数量
const validMenus = allChildren.filter(menu =>
menu &&
menu.component &&
menu.component !== 'Layout' &&
menu.meta &&
menu.meta.title
).slice(0, 24); // 最多显示24个
// 3. 生成随机颜色的函数
const generateRandomColor = () => {
const colorPool = [
'#FF6B6B', '#4ECDC4', '#FFD166', '#06D6A0', '#118AB2',
'#EF476F', '#26547C', '#FFD166', '#06D6A0', '#118AB2',
'#7209B7', '#3A86FF', '#FB5607', '#8338EC', '#3A86FF'
];
return colorPool[Math.floor(Math.random() * colorPool.length)];
};
// 4. 转换为目标格式
return validMenus.map(menu => {
return {
id: menu.id || menu.menuId || Math.random().toString(36).substr(2, 9),
name: menu.meta?.title || '未命名菜单',
path: menu.path || '',
component: menu.component || '',
permissions: menu.permissions || [],
icon: menu.meta?.icon || '',
color: generateRandomColor(), // 随机颜色
isFixed: true // 标记为已固定
};
});
},
showStoreSelector() {
if (!this.userInfo.employees || this.userInfo.employees.length <= 1) {
return;
}
// 提取店铺名称列表
const storeList = this.userInfo.employees.map(emp => emp.store_name);
uni.showActionSheet({
itemList: storeList,
success: (res) => {
const selectedIndex = res.tapIndex;
if (selectedIndex >= 0 && selectedIndex < this.userInfo.employees.length) {
const selectedEmployee = this.userInfo.employees[selectedIndex];
this.handleStoreSwitch(selectedEmployee);
}
},
fail: (err) => {
console.log('用户取消选择', err);
}
});
},
async handleStoreSwitch(selectedEmployee) {
try {
// 显示加载中
uni.showLoading({
title: '切换中...',
mask: true
});
const result = await this.$store.dispatch('changeEmployee', selectedEmployee.id);
this.loadUserInfo();
} catch (error) {
uni.hideLoading();
}
},
toPath(item) {
if (!item || !item.component) {
uni.showToast({
title: '功能暂未开放',
icon: 'none',
duration: 1500
});
return;
}
uni.navigateTo({
url: item.component.startsWith('/') ? item.component : `/${item.component}`,
animationType: 'slide-in-right'
});
},
toMessagePage() {
uni.navigateTo({
url: '/pages/message/index'
});
},
toNewsPage() {
uni.switchTab({
url: '/pages/oa/index'
});
},
toEditPage() {
uni.navigateTo({
url: '/pages/home/edit-quick-actions'
});
},
prevPage() {
if (this.currentPage > 1) {
this.currentPage--;
}
},
nextPage() {
if (this.currentPage < this.totalPages) {
this.currentPage++;
}
},
onSwiperChange(e) {
this.currentPage = e.detail.current + 1;
}
}
}
</script>
<style lang="scss" scoped>
.pda-home {
display: flex;
flex-direction: column;
background: #f8f9fa;
}
// 紧凑型头部
.compact-header {
padding:0 20rpx;
background: white;
border-bottom: 1rpx solid #f0f0f0;
.org-switcher {
display: flex;
align-items: center;
margin-bottom: 6px;
.org-icon {
margin-right: 15rpx;
}
.org-info {
flex: 1;
.org-name {
font-size: 28rpx;
font-weight: 600;
color: #333;
display: block;
line-height: 1.4;
}
.org-id {
font-size: 22rpx;
color: #909399;
display: block;
}
}
}
.header-actions {
display: flex;
align-items: center;
justify-content: space-between;
.news-wrapper {
flex: 1;
margin-right: 20rpx;
overflow: hidden;
::v-deep .u-notice-bar {
height: 30rpx !important;
line-height: 30rpx !important;
}
}
.message-bell {
position: relative;
width: 60rpx;
height: 60rpx;
display: flex;
align-items: center;
justify-content: center;
border-radius: 50%;
&:active {
background: #f0f0f0;
}
}
}
}
// 主滚动区域
.main-scroll {
flex: 1;
overflow: hidden;
}
// 快捷入口区域
.quick-section {
padding: 20rpx 20rpx 30rpx;
background: white;
margin: 20rpx;
border-radius: 16rpx;
box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.05);
.section-title-bar {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 25rpx;
padding-bottom: 15rpx;
border-bottom: 1rpx solid #f0f0f0;
.title-left {
display: flex;
align-items: center;
.section-title {
font-size: 32rpx;
font-weight: 600;
color: #333;
margin-left: 10rpx;
}
}
.title-right {
display: flex;
align-items: center;
.edit-btn {
font-size: 24rpx;
color: #2979ff;
padding: 6rpx 12rpx;
border-radius: 6rpx;
&:active {
background: #f0f7ff;
}
}
.divider {
color: #e0e0e0;
margin: 0 15rpx;
}
.page-indicator {
font-size: 24rpx;
color: #909399;
}
}
}
}
// 网格容器
.quick-grid-container {
display: flex;
align-items: center;
margin-bottom: 20rpx;
.nav-arrow {
width: 20rpx;
height: 60rpx;
display: flex;
align-items: center;
justify-content: center;
border-radius: 50%;
background: #f8f9fa;
&:active:not(.disabled) {
background: #e9ecef;
}
&.disabled {
opacity: 0.3;
}
}
.quick-grid-wrapper {
flex: 1;
display: flex;
flex-direction: column;
align-items: center;
.quick-swiper {
width: 100%;
height: 540rpx; // 3行 × 180rpx
}
.grid-page {
display: grid;
grid-template-columns: repeat(4, 1fr);
grid-template-rows: repeat(3, 1fr);
gap: 10rpx;
padding: 0 10rpx;
.grid-item {
height: 170rpx;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
position: relative;
border-radius: 12rpx;
.item-icon-box {
width: 100rpx;
height: 100rpx;
border-radius: 20rpx;
display: flex;
align-items: center;
justify-content: center;
margin-bottom: 12rpx;
}
.item-name {
font-size: 30rpx;
font-weight: bold;
color: #333;
text-align: center;
line-height: 1.3;
padding: 0 5rpx;
}
.item-badge {
position: absolute;
top: 10rpx;
right: 10rpx;
}
&:active {
background: #f8f9fa;
}
&.empty-item {
opacity: 0;
}
}
}
}
}
// 分页指示器
.pagination-dots {
display: flex;
justify-content: center;
margin-top: 20rpx;
.pagination-dot {
width: 10rpx;
height: 10rpx;
border-radius: 50%;
background: #e0e0e0;
margin: 0 6rpx;
&.active {
background: #2979ff;
width: 30rpx;
border-radius: 5rpx;
}
}
}
// 加载状态
.loading-state {
padding: 100rpx 0;
display: flex;
flex-direction: column;
align-items: center;
.loading-text {
margin-top: 20rpx;
color: #909399;
font-size: 24rpx;
}
}
// 空状态提示
.empty-state {
padding: 80rpx 0;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
.empty-text {
display: block;
font-size: 32rpx;
color: #999;
margin-top: 30rpx;
margin-bottom: 15rpx;
}
.empty-hint {
display: block;
font-size: 26rpx;
color: #ccc;
}
}
</style>

View File

@ -1,310 +0,0 @@
<template>
<view class="login-container" :style="bgStyle">
<view class="form_box">
<view class="header-section">
<u--image
shape="circle"
:src="logo"
width="120rpx"
height="120rpx"
mode="aspectFit"
></u--image>
<text class="app-name">设备登录</text>
<text class="welcome-text">请选择登录方式</text>
</view>
<view class="login-methods">
<!-- 二维码登录 -->
<view class="method-card" @click="showQrCode = true">
<view class="method-icon">
<u-icon name="chat" size="60rpx" color="#2979ff"></u-icon>
</view>
<text class="method-title">账号登录</text>
<text class="method-desc">使用账号密码登录</text>
</view>
<!-- 广播扫描登录 -->
<view class="method-card" @click="startBroadcastScan">
<view class="method-icon">
<u-icon name="scan" size="60rpx" color="#19be6b"></u-icon>
</view>
<text class="method-title">扫描工牌登录</text>
<text class="method-desc">PDA直接扫描工牌登录</text>
</view>
</view>
<!-- 设备状态显示 -->
<view class="device-status" v-if="currentDevice">
<view class="status-card">
<view class="device-info">
<text class="device-name">{{ currentDevice.deviceName }}</text>
<text class="device-id">设备ID: {{ currentDevice.deviceId }}</text>
</view>
<u-button
type="primary"
text="确认登录"
size="small"
@click="confirmLogin"
></u-button>
</view>
</view>
</view>
<!-- 二维码登录弹窗 -->
<u-popup
:show="showQrCode"
mode="center"
round="10"
@close="showQrCode = false"
>
<view class="qr-popup">
<view class="popup-header">
<text class="popup-title">账号密码登录</text>
<u-icon name="close" size="24" @click="showQrCode = false"></u-icon>
</view>
<view class="qr-container">
<u--input
v-model="loginForm.username"
placeholder="请输入用户名"
border="bottom"
clearable
:customStyle="{ marginBottom: '40rpx' }"
></u--input>
<u--input
v-model="loginForm.password"
placeholder="请输入密码"
border="bottom"
clearable
:customStyle="{ marginBottom: '40rpx' }"
></u--input>
<u-button
type="primary"
text="登录"
@click="Login"
></u-button>
</view>
</view>
</u-popup>
<!-- 消息提示 -->
<u-toast ref="uToast"></u-toast>
<u-notify ref="uNotify"></u-notify>
</view>
</template>
<script>
export default {
data() {
return {
bgStyle: '',
logo: '/static/logo.png',
showQrCode: false,
showLoginConfirm: false,
scanning: false,
deviceCode: '',
currentDevice: null,
qrCodeTimer: null,
scanTimer: null,
loginData: {
deviceId: '',
deviceName: '',
loginType: '' // qrcode, broadcast, manual
},
loginForm: {
username: 'liufumingren',
password: '111111'
},
}
},
onLoad() {
const storageBg = uni.getStorageSync("bg");
const bgUrl = storageBg || "/static/loginbg.jpg";
this.bgStyle = `--bg-url: url(${bgUrl})`;
uni.hideTabBar();
},
onUnload() {
},
methods: {
async Login(){
console.log("login");
await this.$store.dispatch('login', this.loginForm)
uni.switchTab({
url:"/pages/index/index"
})
console.log("跳转页面");
},
startBroadcastScan(){
console.log("模拟登录");
uni.switchTab({
url:"/pages/work/index"
})
},
}
}
</script>
<style lang="scss" scoped>
.login-container {
width: 100vw;
height: 100vh;
background-image: var(--bg-url, url('@/static/loginbg.jpg'));
background-size: cover;
background-position: center;
background-repeat: no-repeat;
display: flex;
align-items: center;
justify-content: center;
position: relative;
flex-direction: row;
flex-wrap: wrap;
}
.form_box {
width: 90%;
margin-left:5%;
background: rgba(255, 255, 255, 0.95);
border-radius: 20rpx;
padding: 60rpx 40rpx;
backdrop-filter: blur(10px);
box-sizing: border-box;
}
.header-section {
text-align: center;
margin-bottom: 60rpx;
.app-name {
display: block;
font-size: 48rpx;
font-weight: bold;
color: #333;
margin-top: 20rpx;
}
.welcome-text {
display: block;
font-size: 28rpx;
color: #666;
margin-top: 10rpx;
}
}
.login-methods {
display: flex;
flex-direction: column;
gap: 30rpx;
}
.method-card {
background: #f8f9fa;
border-radius: 16rpx;
padding: 40rpx 30rpx;
text-align: center;
position: relative;
&:active {
background: #e9ecef;
}
.method-icon {
margin-bottom: 20rpx;
}
.method-title {
display: block;
font-size: 32rpx;
font-weight: 600;
color: #333;
margin-bottom: 10rpx;
}
.method-desc {
display: block;
font-size: 24rpx;
color: #666;
}
.scan-status {
margin-top: 20rpx;
}
}
.device-status {
margin-top: 40rpx;
.status-card {
background: #e7f3ff;
border-radius: 12rpx;
padding: 30rpx;
display: flex;
justify-content: space-between;
align-items: center;
.device-info {
flex: 1;
.device-name {
display: block;
font-size: 28rpx;
font-weight: 600;
color: #2979ff;
margin-bottom: 8rpx;
}
.device-id {
display: block;
font-size: 24rpx;
color: #666;
}
}
}
}
// 弹窗样式
.qr-popup, .input-popup {
width: 600rpx;
background: white;
border-radius: 20rpx;
padding: 40rpx;
.popup-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 40rpx;
.popup-title {
font-size: 36rpx;
font-weight: 600;
color: #333;
}
}
.qr-container {
text-align: center;
.qr-tip {
font-size: 26rpx;
color: #666;
}
}
.popup-footer {
text-align: center;
margin-top: 30rpx;
.refresh-text {
color: #2979ff;
font-size: 26rpx;
}
}
.input-container {
padding: 20rpx 0;
}
}
</style>

View File

@ -1,302 +0,0 @@
<template>
<view class="normar_container">
<page-nav title="设置"></page-nav>
<view class="settings-page">
<!-- 当前登录信息 -->
<view class="login-info">
<text class="login-title">当前登录工号:</text>
<text class="login-user">{{ userInfo.employees_name || '未登录' }}</text>
</view>
<!-- 设置列表 -->
<view class="settings-list">
<u-cell-group :border="false">
<u-cell v-for="(item, index) in operationList" :key="index" :title="item.title" :icon="item.icon"
:icon-color="item.iconColor" @click="handleOperationClick(item)">
<!-- 角标 -->
<template #right-icon>
<u-badge v-if="item.badge && item.badge > 0" :value="item.badge" type="error"
size="mini"></u-badge>
<u-icon v-else name="arrow-right" size="20" color="#ccc"></u-icon>
</template>
</u-cell>
</u-cell-group>
</view>
<!-- 底部登出按钮 -->
<view class="logout-section">
<u-button type="error" shape="circle" @click="showLogoutConfirm" :loading="logoutLoading">
退出登录
</u-button>
</view>
<!-- 登出确认弹窗 -->
<u-modal :show="showLogoutModal" :show-cancel-button="true" confirm-text="确定退出" cancel-text="取消"
@confirm="logout" @cancel="showLogoutModal = false">
<view class="modal-content">
<u-icon name="info-circle" size="60" color="#f0ad4e"></u-icon>
<text class="modal-title">确认退出登录?</text>
<text class="modal-desc">退出后将需要重新登录</text>
</view>
</u-modal>
</view>
</view>
</template>
<script>
export default {
data() {
return {
// 用户信息
userInfo: {},
// 设置列表数据
operationList: [{
title: '账号与安全',
icon: 'lock',
iconColor: '#4cd964',
pageName: 'accountSecurity',
url: '/pages/settings/accountSecurity',
needLogin: true
},
{
title: '广播设置',
icon: 'scan',
iconColor: '#dd524d',
pageName: 'broadcastSettings',
url: '/pages/settings/broadcastSettings'
},
{
title: '设备查找',
icon: 'search',
iconColor: '#007aff',
pageName: 'deviceSearch',
url: '/pages/settings/deviceSearch'
},
{
title: '扫描音效',
icon: 'bell',
iconColor: '#f0ad4e',
pageName: 'scanSound',
url: '/pages/settings/scanSound',
badge: 0
},
{
title: '关于',
icon: 'info-circle',
iconColor: '#808080',
pageName: 'about',
url: '/pages/settings/about'
}
],
// 登出相关
showLogoutModal: false,
logoutLoading: false
}
},
onShow() {
// 页面显示时加载用户信息
this.loadUserInfo();
},
methods: {
// 加载用户信息
loadUserInfo() {
const userData = this.$store.getters.user;
if (userData) {
this.userInfo = userData;
} else {
// 如果未登录,跳转到登录页
uni.reLaunch({
url: '/pages/login/login'
});
}
},
// 处理设置项点击
handleOperationClick(item) {
console.log('点击了:', item.title);
// 检查是否需要登录
if (item.needLogin && !this.checkLogin()) {
uni.showToast({
title: '请先登录',
icon: 'none'
});
return;
}
// 跳转到对应页面
this.navigateTo(item.pageName, item.url);
},
// 检查登录状态
checkLogin() {
const token = uni.getStorageSync('token');
return !!token;
},
// 页面跳转
navigateTo(pageName, customUrl = null) {
const routeMap = {
accountSecurity: '/pages/settings/accountSecurity',
broadcastSettings: '/pages/settings/broadcastSettings',
deviceSearch: '/pages/settings/deviceSearch',
scanSound: '/pages/settings/scanSound',
about: '/pages/settings/about'
};
const url = customUrl || routeMap[pageName];
if (!url) {
console.error('未找到页面路由:', pageName);
uni.showToast({
title: '页面不存在',
icon: 'error'
});
return;
}
uni.navigateTo({
url: url,
fail: (err) => {
console.error('跳转失败:', err);
uni.showToast({
title: '页面跳转失败',
icon: 'none'
});
}
});
},
// 显示登出确认弹窗
showLogoutConfirm() {
this.showLogoutModal = true;
},
// 登出
async logout() {
this.logoutLoading = true;
try {
// 调用登出 action
await this.$store.dispatch('logout');
// 登出成功提示
uni.showToast({
title: '已退出登录',
icon: 'success',
duration: 1500
});
} catch (error) {
console.error('登出失败:', error);
uni.showToast({
title: '登出失败,请重试',
icon: 'error'
});
} finally {
this.logoutLoading = false;
this.showLogoutModal = false;
}
}
}
}
</script>
<style lang="scss" scoped>
.settings-page {
background-color: #f8f8f8;
height: calc(100% - 44px - env(safe-area-inset-top));
// 页面标题
.page-header {
height: 120rpx;
background: linear-gradient(135deg, #4cd964, #5ac8fa);
display: flex;
align-items: center;
justify-content: center;
.page-title {
font-size: 40rpx;
font-weight: bold;
color: #fff;
text-align: center;
}
}
// 登录信息
.login-info {
background-color: #fff;
padding: 30rpx;
margin-bottom: 20rpx;
display: flex;
align-items: center;
justify-content: space-between;
border-bottom: 1px solid #f0f0f0;
.login-title {
font-size: 32rpx;
color: #333;
font-weight: 500;
}
.login-user {
font-size: 34rpx;
color: #4cd964;
font-weight: bold;
}
}
// 设置列表
.settings-list {
background-color: #fff;
margin-bottom: 20rpx;
::v-deep .u-cell {
padding: 10rpx 20rpx !important;
}
::v-deep .u-cell_title {
font-size: 34rpx !important;
}
}
// 登出按钮区域
.logout-section {
padding: 40rpx 30rpx;
::v-deep .u-btn {
height: 100rpx;
font-size: 36rpx;
display: flex;
align-items: center;
justify-content: center;
}
}
// 模态框内容
.modal-content {
padding: 40rpx 0;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
.modal-title {
font-size: 36rpx;
font-weight: bold;
color: #333;
margin-top: 30rpx;
margin-bottom: 20rpx;
}
.modal-desc {
font-size: 28rpx;
color: #666;
text-align: center;
}
}
}
</style>

View File

@ -1,353 +0,0 @@
<template>
<view class="personal-center">
<view class="status_bar">
</view>
<!-- 资料卡 -->
<view class="profile-card" @click="navigateTo('profile')">
<u-avatar :src="userInfo.avatar" size="60" mode="aspectFill"></u-avatar>
<view class="user-info">
<text class="user-name">{{ userInfo.employees_name }}</text>
<text class="user-id" @click.stop="showStoreSelector">
{{ userInfo.store_name }}
<u-icon style="display:inline-block; margin-left: 10rpx;" name="arrow-right" color="#FFF" size="12" v-if="userInfo.employees.length > 1"></u-icon>
</text>
</view>
</view>
<!-- 操作列表 - 使用数据循环 -->
<view class="operation-list">
<u-cell-group :border="false">
<!-- 使用 v-for 循环渲染列表项 -->
<u-cell
v-for="(item, index) in operationList"
:key="index"
:title="item.title"
:icon="item.icon"
:icon-color="item.iconColor"
@click="handleOperationClick(item)"
>
</u-cell>
</u-cell-group>
</view>
</view>
</template>
<script>
export default {
data() {
return {
// 用户信息
userInfo: {},
// 操作列表数据
operationList: [
{
title: '问题报障',
icon: 'order',
iconColor: '#4cd964',
pageName: 'problemGuarantee',
url: '/pages/personal/problemGuarantee',
needLogin: true
},
{
title: '意见反馈',
icon: 'email',
iconColor: '#dd524d',
pageName: 'feedback',
url: '/pages/personal/feedback'
},
{
title: '帮助手册',
icon: 'bookmark',
iconColor: '#007aff',
pageName: 'helpManual',
url: '/pages/personal/helpManual'
},
{
title: '操作信息',
icon: 'info-circle',
iconColor: '#f0ad4e',
pageName: 'operationInfo',
url: '/pages/personal/operationInfo',
badge: 3
},
{
title: '网络检测',
icon: 'wifi',
iconColor: '#10aeff',
pageName: 'networkTest',
url: '/pages/settings/networkTest'
},
{
title: '设置',
icon: 'setting',
iconColor: '#808080',
pageName: 'settings',
url: '/pages/settings/index'
}
],
// 当前选中的组织
currentOrg: null
}
},
onLoad() {
// 页面显示时更新数据
this.loadUserInfo();
},
onShow() {
// 页面显示时更新数据
this.loadUserInfo();
},
methods: {
// 加载用户信息
async loadUserInfo() {
if(!this.$store.getters.user){
setTimeout(() => this.loadUserInfo(), 100);
}
this.userInfo = this.$store.getters.user;
this.updateBadgeCount();
this.loadCurrentOrg();
},
// 从缓存加载当前组织
loadCurrentOrg() {
const savedOrg = uni.getStorageSync('pda_current_org');
if (savedOrg) {
this.currentOrg = savedOrg;
}
},
// 显示店铺选择器 - 使用 ActionSheet
showStoreSelector() {
// 从 userInfo.employees 生成选项列表
if (!this.userInfo.employees || this.userInfo.employees.length <= 1) {
return;
}
// 提取店铺名称列表
const storeList = this.userInfo.employees.map(emp => emp.store_name);
uni.showActionSheet({
itemList: storeList,
success: (res) => {
const selectedIndex = res.tapIndex;
if (selectedIndex >= 0 && selectedIndex < this.userInfo.employees.length) {
const selectedEmployee = this.userInfo.employees[selectedIndex];
this.handleStoreSwitch(selectedEmployee);
}
},
fail: (err) => {
console.log('用户取消选择', err);
}
});
},
// 处理店铺切换
async handleStoreSwitch(selectedEmployee) {
try {
// 显示加载中
uni.showLoading({
title: '切换中...',
mask: true
});
// 调用 store 的 action 切换员工
const result = await this.$store.dispatch('changeEmployee', selectedEmployee.id);
this.loadUserInfo();
} catch (error) {
console.error('切换失败:', error);
// 隐藏加载提示
uni.hideLoading();
// 显示错误提示
uni.showToast({
title: '切换失败,请重试',
icon: 'error',
duration: 2000
});
}
},
// 切换主体的函数(您需要实现的API函数)
async switchStore(employeeId) {
console.log('开始切换到员工ID:', employeeId);
// 这里调用您的后端API
// 示例:
// try {
// const response = await this.$api.store.switch({ employee_id: employeeId });
// return response.success || response.code === 200;
// } catch (error) {
// throw error;
// }
// 模拟API调用
return new Promise((resolve, reject) => {
setTimeout(() => {
console.log(`API: 已切换到员工ID: ${employeeId}`);
// 模拟成功
resolve(true);
// 如果需要模拟失败
// reject(new Error('切换失败'));
}, 800);
});
},
// 更新 store 中的用户信息
async updateStoreUserInfo(selectedEmployee) {
// 方法1: 调用 store 的 action
// await this.$store.dispatch('updateCurrentStore', selectedEmployee);
// 方法2: 直接更新(如果有相应 mutation)
// this.$store.commit('SET_CURRENT_STORE', selectedEmployee);
// 方法3: 更新本地用户信息对象
const updatedUser = {
...this.$store.getters.user,
store_name: selectedEmployee.store_name,
store_id: selectedEmployee.store_id,
current_employee_id: selectedEmployee.id
};
// 如果您有相应的 mutation
// this.$store.commit('UPDATE_USER_INFO', updatedUser);
console.log('更新用户信息为:', updatedUser);
},
// 重新加载页面数据(可选)
reloadPageData() {
console.log('重新加载页面数据...');
// 这里可以调用其他需要重新加载数据的方法
// 例如:this.loadOrders();
// this.loadStatistics();
},
// 其他方法保持不变...
updateBadgeCount() {
const unreadCount = 3;
this.operationList.forEach(item => {
if (item.pageName === 'operationInfo') {
item.badge = unreadCount;
}
});
},
handleOperationClick(item) {
console.log('点击了:', item.title);
if (item.needLogin && !this.checkLogin()) {
uni.showToast({
title: '请先登录',
icon: 'none'
});
uni.navigateTo({
url: '/pages/login/login'
});
return;
}
this.navigateTo(item.pageName, item.url);
},
checkLogin() {
const token = uni.getStorageSync('token');
return !!token;
},
navigateTo(pageName, customUrl = null) {
const routeMap = {
profile: '/pages/personal/profile',
problemGuarantee: '/pages/personal/problemGuarantee',
feedback: '/pages/personal/feedback',
helpManual: '/pages/personal/helpManual',
operationInfo: '/pages/personal/operationInfo',
networkTest: '/pages/personal/networkTest',
settings: '/pages/personal/settings'
};
const url = customUrl || routeMap[pageName];
if (!url) {
console.error('未找到页面路由:', pageName);
uni.showToast({
title: '页面不存在',
icon: 'error'
});
return;
}
console.log('跳转到:', url);
uni.navigateTo({
url: url,
fail: (err) => {
console.error('跳转失败:', err);
uni.showToast({
title: '页面跳转失败',
icon: 'none'
});
}
});
}
}
}
</script>
<style lang="scss" scoped>
.personal-center {
background-color: #f8f8f8;
// 资料卡样式
.profile-card {
display: flex;
align-items: center;
padding: 40rpx 30rpx;
background: linear-gradient(135deg, #4cd964, #5ac8fa);
color: #fff;
position: relative;
.user-info {
flex: 1;
margin-left: 30rpx;
display: flex;
flex-direction: column;
.user-name {
font-size: 36rpx;
font-weight: bold;
margin-bottom: 10rpx;
}
.user-id {
font-size: 30rpx;
opacity: 0.9;
margin-top: 8rpx;
display: flex;
align-items: center;
&:active {
opacity: 0.7;
}
}
}
}
// 操作列表样式
.operation-list {
margin-top: 20rpx;
background-color: #fff;
::v-deep .u-cell {
padding: 10rpx 20rpx !important;
}
::v-deep .u-cell_title {
font-size: 32rpx !important;
}
}
}
</style>

View File

@ -1,220 +0,0 @@
<template>
<scroll-view class="scroll-container" scroll-y v-if="receivingInfo">
<u-form :model="receivingInfo" :rules="rules" ref="infoFormRef" label-width="180rpx">
<view class="section">
<view class="section-title">基础信息</view>
<u-form-item label="收货单号">
<u-input v-model="receivingInfo.receiving_number" disabled />
<u-button style="width: 150rpx;" type="primary" @click="print">打印</u-button>
</u-form-item>
<u-form-item label="货主" prop="store_id">
<view>{{receivingInfo.store?receivingInfo.store.store_remask:'未设置'}}</view>
</u-form-item>
<u-form-item label="来货方式" prop="delivery_method">
<u-radio-group v-model="receivingInfo.delivery_method" disabled>
<u-radio v-for="item in deliveryMethods" :key="item.value" :name="item.value"
:label="item.label"></u-radio>
</u-radio-group>
</u-form-item>
<u-form-item v-if="receivingInfo.delivery_method === 'truck'" label="车牌号" prop="license_plate">
<u-input v-model="receivingInfo.license_plate" disabled placeholder="请输入车牌号" />
</u-form-item>
<u-form-item v-else-if="receivingInfo.delivery_method !== 'other'" label="物流单号" prop="tracking_number">
<u-input v-model="receivingInfo.tracking_number" placeholder="请输入物流单号" />
</u-form-item>
</view>
<view class="section" v-if="receivingInfo.id">
<view class="section-title">来货照片</view>
<uploadImgCos business_type="receiving" :value="receivingInfo.images" :business_id="receivingInfo.id" @change="$emit('change')"></uploadImgCos>
</view>
<view class="section">
<view class="section-title">装卸信息</view>
<u-form-item label="装卸方式" prop="loading_method">
<u-radio-group v-model="receivingInfo.loading_method" disabled>
<u-radio v-for="item in loadingMethods" :key="item.value" :name="item.value"
:label="item.label"></u-radio>
</u-radio-group>
</u-form-item>
<u-form-item label="总箱数" prop="total_boxes">
<u-input v-model="receivingInfo.total_boxes" disabled type="number" placeholder="请输入总箱数" />
</u-form-item>
<u-form-item label="总托盘数" prop="total_pallets">
<u-input v-model="receivingInfo.total_pallets" disabled type="number" placeholder="请输入总托盘数" />
</u-form-item>
<u-form-item label="录像设备">
<u-input v-model="receivingInfo.video_device_id" disabled placeholder="录像设备ID" />
</u-form-item>
</view>
<view class="section">
<view class="section-title">收货状态</view>
<u-form-item label="收货状态">
<u-tag :text="receivingInfo.status | statusFilter" :type="getStatusType(receivingInfo.status)" />
</u-form-item>
<u-form-item label="创建人">
<u-input v-model="receivingInfo.creator_name" disabled />
</u-form-item>
<u-form-item label="创建时间">
<u-input v-model="receivingInfo.created_at" disabled />
</u-form-item>
</view>
<view class="section">
<view class="section-title">备注信息</view>
<u-form-item label="备注">
<u-input v-model="receivingInfo.remark" type="textarea" placeholder="请输入备注" height="120" />
</u-form-item>
</view>
<view class="section">
<view class="section-title">收货码</view>
<view style="width: 100%;display: flex;flex-direction: column;align-items: center;">
<canvas id="qrcode" canvas-id="qrcode" style="width: 200px;height: 200px;"></canvas>
</view>
</view>
</u-form>
</scroll-view>
</template>
<script>
import UQRCode from 'uqrcodejs'
export default {
name: 'InfoContainer',
props: {
receivingInfo: {
type: Object,
required: true
},
qrcodeUrl: {
type: String,
default: ''
},
saving: {
type: Boolean,
default: false
}
},
data() {
return {
deliveryMethods: [{
value: 'truck',
label: '货车'
},
{
value: 'express',
label: '快递'
},
{
value: 'other',
label: '其他'
}
],
loadingMethods: [{
value: 'with_pallet',
label: '带托盘'
},
{
value: 'without_pallet',
label: '不带托盘'
}
],
rules: {}
};
},
mounted() {
console.log("onShow");
this.qrcode(this.receivingInfo.receiving_number);
},
filters: {
statusFilter(status) {
const map = {
'receiving': '收货中',
'completed': '已完成',
'cancelled': '已取消'
};
return map[status] || status;
}
},
watch:{
'receivingInfo.receiving_number':{
handler(newval){
console.log(newval);
this.qrcode(newval)
}
}
},
methods: {
qrcode(data){
var qr = new UQRCode();
qr.data = data;
qr.make();
var canvasContext = uni.createCanvasContext('qrcode', this); // 如果是组件,this必须传入
// 设置uQRCode实例的canvas上下文
qr.canvasContext = canvasContext;
// 调用绘制方法将二维码图案绘制到canvas上
qr.drawCanvas();
},
getStatusType(status) {
const map = {
'receiving': 'primary',
'completed': 'success',
'cancelled': 'error'
};
return map[status] || 'default';
},
validateForm() {
return this.$refs.infoFormRef.validate();
},
print(){
this.$emit('print',{type:"STOCK",value:{product_barcode:this.receivingInfo.receiving_number,product_name:this.receivingInfo.creator_name}})
}
}
};
</script>
<style scoped>
.scroll-container {
height: 100%;
}
.section {
background-color: #fff;
border-radius: 16rpx;
padding: 30rpx;
margin-bottom: 20rpx;
}
.section-title {
font-size: 32rpx;
font-weight: bold;
color: #333;
margin-bottom: 20rpx;
padding-bottom: 10rpx;
border-bottom: 2rpx solid #f0f0f0;
}
.action-buttons {
padding: 30rpx;
background: #fff;
border-radius: 16rpx;
}
.qrcode-image {
width: 200rpx;
height: 200rpx;
display: block;
margin: 0 auto;
}
</style>

View File

@ -1,786 +0,0 @@
<template>
<view class="receiving-list">
<view class="normar_container">
<page-nav :title="title"></page-nav>
<!-- 搜索和筛选区域 -->
<view class="search-filter">
<!-- 搜索框 -->
<view class="search-box">
<u-search v-model="searchKeyword" placeholder="搜索运单号、货主、商品条码、车牌" bg-color="#f5f5f5" shape="round"
:show-action="false" @search="handleSearch" @clear="handleSearch"></u-search>
</view>
<!-- 筛选按钮 -->
<view class="filter-actions">
<view class="filter-buttons">
<u-button size="mini" type="primary" plain @click="showFilterPopup">
筛选
</u-button>
<u-button size="mini" type="success" @click="createReceiving">
<u-icon name="plus" size="16"></u-icon>
新建收货
</u-button>
</view>
</view>
<!-- 状态标签 -->
<scroll-view class="status-tags" scroll-x :show-scrollbar="false">
<view class="status-tag" v-for="status in statusList" :key="status.value"
:class="{ active: activeStatus === status.value }" @click="changeStatus(status.value)">
<text class="tag-name">{{ status.label }}</text>
<u-badge :value="status.count" size="mini"></u-badge>
</view>
</scroll-view>
</view>
<!-- 收货列表 -->
<scroll-view class="receiving-list-content" scroll-y>
<!-- 列表为空提示 -->
<view class="empty-state" v-if="!loading && receivingList.length === 0">
<u-icon name="list-dot" size="100" color="#ccc"></u-icon>
<text class="empty-text">暂无收货任务</text>
<text class="empty-hint">点击"新建收货"开始创建收货单</text>
</view>
<!-- 收货单列表 -->
<view class="receiving-items">
<view class="receiving-item" v-for="item in receivingList" :key="item.id"
@click="viewReceivingDetail(item)">
<!-- 单号区域 -->
<view class="item-header">
<text class="order-no">{{ item.receiving_number }}</text>
<u-tag :text="getStatusText(item.status)" :type="getStatusType(item.status)"
size="mini"></u-tag>
</view>
<!-- 基本信息 -->
<view class="item-info">
<view class="info-row">
<u-icon name="home" size="16" color="#999"></u-icon>
<text class="info-label">货主:</text>
<text class="info-value">{{ item['store.store_remask'] || '--' }}</text>
</view>
<view class="info-row">
<u-icon name="car" size="16" color="#999"></u-icon>
<text class="info-label">车牌/运单:</text>
<text class="info-value">{{ item.license_plate || item.tracking_number || '--' }}</text>
</view>
<view class="info-row">
<u-icon name="account" size="16" color="#999"></u-icon>
<text class="info-label">创建人:</text>
<text class="info-value">{{ item['creator.real_name'] || '--' }}</text>
</view>
<view class="info-row" v-if="item.images && item.images.length>0">
<u-icon name="photo" size="16" color="#999"></u-icon>
<text class="info-label">照片:</text>
<span class="info-value" @click.stop="showImgs(item.images)">
<image class="miniImg" v-for="(url, index) in item.images" :key="index" :src="url"></image>
</span>
</view>
</view>
<!-- 操作按钮 -->
<view class="item-actions">
<view class="action-left">
<text class="create-time">创建:{{ formatRelativeTime(item.created_at) }}</text>
</view>
</view>
</view>
</view>
<!-- 底部安全区域 -->
<view class="safe-area-bottom"></view>
</scroll-view>
<pagination :pageNum.sync="currentPage" :pageSize="pageSize" :total="totalItems" :showTotal="true"
:prevText="'上一页'" :nextText="'下一页'" :showFirstLast="true" :firstText="'首页'" :lastText="'末页'"
@change="handlePageChange" />
</view>
<!-- 筛选弹出层 -->
<u-popup :show="filterVisible" mode="bottom" :closeable="true" border-radius="20" @close="filterVisible = false">
<view class="filter-popup">
<view class="popup-header">
<text class="popup-title">筛选条件</text>
</view>
<u--form class="filter-content" labelWidth="auto" labelPosition="left" :model="where" ref="uForm">
<u-form-item label="货主" prop="store" borderBottom @click="handleShowStore">
<view>{{storeName}}</view>
</u-form-item>
<u-form-item label="创建时间" borderBottom>
<view class="date-range" @click="showSelectDate = true">
<text>{{where.startDate}} - {{where.endDate}}</text>
</view>
</u-form-item>
<u-form-item label="" borderBottom>
<view class="quick-date-buttons">
<u-button size="small" :type="dateModel === 'today' ? 'primary' : 'default'" @click="setDateRange('today')">今日</u-button>
<u-button size="small" :type="dateModel === 'week' ? 'primary' : 'default'" @click="setDateRange('week')">本周</u-button>
<u-button size="small" :type="dateModel === 'month' ? 'primary' : 'default'" @click="setDateRange('month')">本月</u-button>
</view>
</u-form-item>
</u--form>
<view class="popup-actions">
<u-button type="default" shape="circle" @click="resetFilter">
重置
</u-button>
<u-button type="primary" shape="circle" @click="applyFilter">
确定
</u-button>
</view>
</view>
</u-popup>
<!-- 货主选择组件 -->
<inputAndSelect title="选择货主" :list="stores" :show="showStore" :value="storeId"
@change="handleStoreChange" @close="showStore=false"></inputAndSelect>
<!-- 时间选择器 -->
<u-calendar :show="showSelectDate" mode="range" @confirm="handleDateConfirm" @close="showSelectDate=false" :minDate="minDate" :maxDate="maxDate"></u-calendar>
<!-- 加载遮罩 -->
<u-loading-page :loading="loading" bg-color="rgba(255,255,255,0.9)"></u-loading-page>
</view>
</template>
<script>
export default {
data() {
return {
title: "收货列表",
// 搜索和筛选
searchKeyword: '',
activeStatus: 'all',
filterVisible: false,
storeName: "全部",
// 日期模式
dateModel: 'today',
minDate:(() => {
const now = new Date();
const sixMonthsAgo = new Date(now);
sixMonthsAgo.setMonth(now.getMonth() - 3);
return this.formatDate(sixMonthsAgo);
})(),
maxDate:this.formatDate(new Date()),
// 筛选条件
showSelectDate: false,
showStore: false,
// 列表数据
receivingList: [],
loading: false,
storeId:null,
refreshing: false,
pageSize: 20,
currentPage: 1,
totalItems: 0,
// 筛选条件
where: {
startDate: this.formatDate(new Date()),
endDate: this.formatDate(new Date()),
},
// 状态列表
statusList: [
{
label: '全部',
value: 'all',
count: 0
},
{
label: '收货中',
value: 'receiving',
count: 0
},
{
label: '已完成',
value: 'completed',
count: 0
},
{
label: '已取消',
value: 'cancelled',
count: 0
}
],
// 货主列表
stores: [],
}
},
onLoad() {
this.$store.dispatch('broadcast/setCallbacks', {
onResult: this.scan
});
this.$store.dispatch('broadcast/start');
},
onShow() {
this.$store.dispatch('broadcast/resume');
this.loadReceivingList();
},
onHide() {
this.$store.dispatch('broadcast/stop');
},
onUnload() {
this.$store.dispatch('broadcast/stop');
},
onPullDownRefresh() {
this.onRefresh();
},
watch: {
currentPage(newval) {
console.log('页码变化:', newval);
this.loadReceivingList();
}
},
methods: {
// 日期格式化函数
formatDate(date) {
const d = new Date(date);
const year = d.getFullYear();
const month = String(d.getMonth() + 1).padStart(2, '0');
const day = String(d.getDate()).padStart(2, '0');
return `${year}-${month}-${day}`;
},
// 获取日期范围
getDateRange(type) {
const now = new Date();
let startDate, endDate;
switch(type) {
case 'today':
startDate = endDate = now;
break;
case 'week':
// 本周一
const monday = new Date(now);
monday.setDate(now.getDate() - now.getDay() + 1);
startDate = monday;
endDate = now;
break;
case 'month':
// 本月第一天
const firstDay = new Date(now.getFullYear(), now.getMonth(), 1);
startDate = firstDay;
endDate = now;
break;
default:
startDate = endDate = now;
}
return {
startDate: this.formatDate(startDate),
endDate: this.formatDate(endDate)
};
},
// 设置日期范围
setDateRange(type) {
this.dateModel = type;
const dateRange = this.getDateRange(type);
this.where.startDate = dateRange.startDate;
this.where.endDate = dateRange.endDate;
},
// 时间选择确认
handleDateConfirm(data) {
console.log('选择的时间范围:', data);
this.where.startDate = data[0];
this.where.endDate = data[1];
this.dateModel = 'custom';
this.showSelectDate = false;
},
// 货主选择
handleStoreChange(option) {
if(!option){
this.storeName = "全部";
this.storeId = null;
}else{
this.storeName = option.label;
this.storeId = option.value;
}
this.showStore = false;
},
async scan(data) {
console.log("扫描数据:", data.data);
this.searchKeyword = data.data;
this.handleSearch();
},
async loadStore() {
try {
const res = await this.$http("common.store", {});
console.log("货主数据:", res);
if (res.stores) {
// 添加全部选项
this.stores = res.stores;
}
} catch (error) {
console.error('加载货主失败:', error);
}
},
// 加载收货列表
async loadReceivingList() {
if (this.loading) return;
this.loading = true;
try {
// 构建查询条件
const queryWhere = {};
this.loadStore();
// 添加基础筛选条件
if (this.storeId) {
queryWhere.store_id = {field:'store_id',operator:'eq',type:'number',value:this.storeId};
}
// 添加日期范围条件
if (this.where.startDate && this.where.endDate) {
queryWhere.created_at = {
field: "created_at",
type: "daterange",
operator: "between",
value: [this.where.startDate, this.where.endDate]
};
}
// 添加状态筛选
if (this.activeStatus !== 'all') {
queryWhere.status = {field:'status',operator:'eq',type:'string',value:this.activeStatus};
}
// 添加搜索条件
if (this.searchKeyword) {
queryWhere.quickWhere = {
value: this.searchKeyword
};
delete queryWhere.created_at;
delete queryWhere.store_id;
}
console.log('查询条件:', queryWhere);
const res = await this.$http("storage.receiving.getReceivingList", {
pagination: {
page: this.currentPage,
pageSize: this.pageSize,
},
where: queryWhere
});
if (res.code == "200") {
const {
list,
pagination,
summary
} = res.data;
const {
total,
page
} = pagination;
this.totalItems = total;
this.currentPage = page;
this.receivingList = list || [];
// 更新状态统计
if (summary) {
this.updateStatusCount(summary);
}
}
} catch (error) {
console.error('加载收货列表失败:', error);
uni.showToast({
title: '加载失败',
icon: 'error'
});
} finally {
this.loading = false;
this.refreshing = false;
uni.stopPullDownRefresh();
}
},
// 更新状态统计
updateStatusCount(summary) {
this.statusList = this.statusList.map(status => {
const count = summary[status.value] || 0;
return { ...status, count };
});
},
// 获取状态文本
getStatusText(status) {
const statusMap = {
'receiving': '收货中',
'completed': '已完成',
'cancelled': '已取消'
};
return statusMap[status] || '未知状态';
},
// 获取状态类型
getStatusType(status) {
const typeMap = {
'cancelled': 'warning',
'receiving': 'primary',
'completed': 'success',
};
return typeMap[status] || 'info';
},
handleShowStore(){
this.showStore = true;
console.log("显示选择货主")
},
// 搜索处理
handleSearch() {
this.currentPage = 1;
this.loadReceivingList();
},
// 状态切换
changeStatus(status) {
this.activeStatus = status;
this.currentPage = 1;
this.loadReceivingList();
},
// 下拉刷新
onRefresh() {
this.refreshing = true;
this.currentPage = 1;
this.loadReceivingList();
},
// 显示筛选弹窗
showFilterPopup() {
this.filterVisible = true;
},
// 重置筛选
resetFilter() {
this.where = {
store: 0,
startDate: this.formatDate(new Date()),
endDate: this.formatDate(new Date()),
};
this.storeName = "全部";
this.dateModel = 'today';
this.activeStatus = 'all';
this.searchKeyword = '';
},
// 应用筛选
applyFilter() {
this.filterVisible = false;
this.currentPage = 1;
this.loadReceivingList();
},
// 新建收货
createReceiving() {
this.$store.dispatch('broadcast/stop');
uni.navigateTo({
url: './receivingCreate',
animationType: 'slide-in-right'
});
},
// 查看收货详情
viewReceivingDetail(item) {
this.$store.dispatch('broadcast/stop');
uni.navigateTo({
url: `./receivingDetail?id=${item.id}`,
animationType: 'slide-in-right'
});
},
// 格式化相对时间
formatRelativeTime(timestamp) {
if (!timestamp) return '--';
const date = new Date(timestamp);
const now = new Date();
const diff = now - date;
if (diff < 60 * 1000) {
return '刚刚';
} else if (diff < 60 * 60 * 1000) {
const minutes = Math.floor(diff / (60 * 1000));
return `${minutes}分钟前`;
} else if (diff < 24 * 60 * 60 * 1000) {
const hours = Math.floor(diff / (60 * 60 * 1000));
return `${hours}小时前`;
} else if (diff < 30 * 24 * 60 * 60 * 1000) {
const days = Math.floor(diff / (24 * 60 * 60 * 1000));
return `${days}天前`;
} else {
return this.formatDate(date);
}
},
// 显示图片预览
showImgs(urls) {
if (!urls || urls.length === 0) return;
uni.previewImage({
urls: urls
});
},
handlePageChange(page) {
this.currentPage = page;
}
}
}
</script>
<style lang="scss" scoped>
.receiving-list {
min-height: 100vh;
background-color: #f8f8f8;
// 搜索和筛选区域
.search-filter {
background: white;
padding: 20rpx 30rpx;
border-bottom: 1rpx solid #f0f0f0;
.search-box {
margin-bottom: 20rpx;
}
.filter-actions {
margin-bottom: 20rpx;
.filter-buttons {
display: flex;
gap: 20rpx;
::v-deep .u-btn {
flex: 1;
}
}
}
.status-tags {
white-space: nowrap;
height: 70rpx;
.status-tag {
display: inline-flex;
align-items: center;
padding: 10rpx 30rpx;
margin-right: 20rpx;
background: #f5f5f5;
border-radius: 30rpx;
position: relative;
&.active {
background: #007aff;
.tag-name {
color: white;
}
}
.tag-name {
font-size: 30rpx;
color: #666;
}
}
}
}
// 收货列表内容
.receiving-list-content {
height: 100rpx;
flex: 1;
.empty-state {
padding: 100rpx 0;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
.empty-text {
display: block;
font-size: 40rpx;
color: #999;
margin-top: 30rpx;
margin-bottom: 15rpx;
}
.empty-hint {
display: block;
font-size: 30rpx;
color: #ccc;
}
}
.receiving-items {
padding: 20rpx;
.receiving-item {
background: white;
border-radius: 16rpx;
padding: 30rpx;
margin-bottom: 20rpx;
box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.05);
.item-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 25rpx;
padding-bottom: 15rpx;
border-bottom: 1rpx solid #f0f0f0;
.order-no {
font-size: 42rpx;
font-weight: 600;
color: #333;
}
}
.item-info {
margin-bottom: 25rpx;
.info-row {
display: flex;
align-items: center;
margin-bottom: 15rpx;
&:last-child {
margin-bottom: 0;
}
.info-label {
font-size: 32rpx;
color: #666;
margin-left: 10rpx;
margin-right: 15rpx;
min-width: 180rpx;
}
.info-value {
font-size: 30rpx;
color: #333;
flex: 1;
display: flex;
align-items: center;
flex-wrap: wrap;
.miniImg {
width: 60rpx;
height: 60rpx;
border-radius: 8rpx;
margin-right: 10rpx;
border: 1rpx solid #eee;
}
}
}
}
.item-actions {
display: flex;
justify-content: space-between;
align-items: center;
padding-top: 20rpx;
border-top: 1rpx solid #f0f0f0;
.create-time {
font-size: 32rpx;
color: #999;
}
.action-right {
display: flex;
gap: 15rpx;
::v-deep .u-btn {
height: 60rpx;
font-size: 30rpx;
}
}
}
}
}
.safe-area-bottom {
height: env(safe-area-inset-bottom);
}
}
// 筛选弹窗
.filter-popup {
padding-bottom: env(safe-area-inset-bottom);
.popup-header {
padding: 40rpx 30rpx 20rpx;
border-bottom: 1rpx solid #f0f0f0;
.popup-title {
font-size: 36rpx;
font-weight: 600;
color: #333;
}
}
.filter-content {
max-height: 800rpx;
padding: 30rpx;
.date-range {
font-size: 28rpx;
color: #333;
padding: 10rpx 0;
}
.quick-date-buttons {
display: flex;
gap: 20rpx;
::v-deep .u-btn {
flex: 1;
}
}
}
.popup-actions {
padding: 30rpx;
border-top: 1rpx solid #f0f0f0;
display: flex;
gap: 20rpx;
::v-deep .u-btn {
flex: 1;
height: 90rpx;
font-size: 32rpx;
}
}
}
}
.u-form-item__body__left {
width: 30%;
}
</style>

View File

@ -1,346 +0,0 @@
<template>
<view>
<view class="normar_container">
<page-nav title="新建收货任务"></page-nav>
<scroll-view class="container" scroll-y>
<u-form class="form_box" :model="formData" :rules="rules" ref="formRef" label-width="150rpx">
<!-- 基础信息 -->
<view class="section">
<view class="section-title">基础信息</view>
<!-- 店铺信息 -->
<u-form-item label="货主" @click="showStorePicker = true">
<u-input v-model="storeName" placeholder="请选择货主" />
</u-form-item>
<!-- 来货方式 -->
<u-form-item label="来货方式" prop="delivery_method" required>
<u-radio-group v-model="formData.delivery_method">
<u-radio v-for="item in deliveryMethods" :key="item.value" :name="item.value"
:label="item.label"></u-radio>
</u-radio-group>
</u-form-item>
<!-- 车牌号(货车时显示) -->
<u-form-item v-if="formData.delivery_method === 'truck'" label="车牌号" prop="license_plate">
<u-input v-model="formData.license_plate" placeholder="请输入车牌号" maxlength="20" />
</u-form-item>
<!-- 物流单号(非货车时显示) -->
<u-form-item v-if="formData.delivery_method !== 'truck' && formData.delivery_method !== 'other'"
label="物流单号" prop="tracking_number">
<u-input v-model="formData.tracking_number" placeholder="请输入快递/物流单号" maxlength="100" />
</u-form-item>
</view>
<!-- 装卸信息 -->
<view class="section">
<view class="section-title">装卸信息</view>
<!-- 装卸方式 -->
<u-form-item label="装卸方式" prop="loading_method" required>
<u-radio-group v-model="formData.loading_method">
<u-radio v-for="item in loadingMethods" :key="item.value" :name="item.value"
:label="item.label"></u-radio>
</u-radio-group>
</u-form-item>
<!-- 总箱数 -->
<u-form-item label="总箱数" prop="total_boxes">
<u-input v-model="formData.total_boxes" type="number" placeholder="请输入总箱数" />
</u-form-item>
<!-- 总托盘数 -->
<u-form-item label="总托盘数" prop="total_pallets">
<u-input v-model="formData.total_pallets" type="number" placeholder="请输入总托盘数" />
</u-form-item>
<!-- 录像设备 -->
<u-form-item label="录像设备">
<u-input v-model="formData.video_device_id" placeholder="直接扫描收货区录像码" maxlength="50" />
</u-form-item>
</view>
<!-- 备注信息 -->
<view class="section">
<view class="section-title">备注信息</view>
<u-form-item label="备注">
<u-input v-model="formData.remark" type="textarea" placeholder="请输入备注信息" height="120" />
</u-form-item>
</view>
</u-form>
</scroll-view>
<view class="submit-area">
<u-button type="primary" @click="handleSubmit" :loading="submitting">
创建收货任务
</u-button>
<u-button @click="handleReset">
重置
</u-button>
</view>
</view>
<!-- 货主选择器 -->
<inputAndSelect title="选择货主" :list="storeList" :show="showStorePicker" :value="formData.store_id"
@change="handleStoreChange" @close="showStorePicker=false"></inputAndSelect>
</view>
</template>
<script>
export default {
data() {
return {
storeName: "不设置",
formData: {
store_id: null,
delivery_method: 'truck',
license_plate: '',
tracking_number: '',
loading_method: 'with_pallet',
video_device_id: '',
total_boxes: '',
total_pallets: '',
remark: '',
status: 'receiving',
},
showStorePicker: false,
deliveryMethods: [{
value: 'truck',
label: '货车'
},
{
value: 'express',
label: '快递'
},
{
value: 'other',
label: '其他'
},
],
loadingMethods: [{
value: 'with_pallet',
label: '带托盘'
},
{
value: 'without_pallet',
label: '不带托盘'
},
],
storeList: [],
rules: {
'delivery_method': [{
required: true,
message: '请选择来货方式',
trigger: 'blur'
}],
'loading_method': [{
required: true,
message: '请选择装卸方式',
trigger: 'blur'
}],
'license_plate': [{
validator: (rule, value, callback) => {
if (this.formData.delivery_method === 'truck' && !value) {
callback(new Error('车牌号不能为空'));
} else {
callback();
}
},
trigger: 'blur'
}],
'tracking_number': [{
validator: (rule, value, callback) => {
const method = this.formData.delivery_method;
if (method === 'express' && !value) {
callback(new Error('物流单号不能为空'));
} else {
callback();
}
},
trigger: 'blur'
}],
'total_boxes': [{
type: 'number',
message: '箱数必须为数字',
trigger: 'blur'
}],
'total_pallets': [{
type: 'number',
message: '托盘数必须为数字',
trigger: 'blur'
}],
},
submitting: false,
};
},
methods: {
async loadStore() {
try {
const res = await this.$http("common.store", {});
if (res.stores) {
this.storeList = res.stores;
}
} catch (error) {
console.error('加载货主失败:', error);
}
},
async scan(data) {
// 解析广播扫描数据
// 携带REC标识头数据,自动填充录像设备
if (data && data.data) {
const scanText = data.data.trim();
// 检查是否包含REC标识头,不是则直接忽略
if (scanText.startsWith('REC')) {
// 提取REC后面的设备编号
// 格式可能为:REC-设备编号 或 REC设备编号
let deviceCode = '';
// 处理不同格式的REC标识
if (scanText.startsWith('REC-')) {
// 格式: REC-设备编号
deviceCode = scanText.substring(4).trim();
} else if (scanText.startsWith('REC')) {
// 格式: REC设备编号
deviceCode = scanText.substring(3).trim();
}
// 如果成功提取到设备编号
if (deviceCode) {
// 自动填充到录像设备字段
this.formData.video_device_id = deviceCode;
// 可选:给用户一个提示
uni.showToast({
title: `已扫描录像设备: ${deviceCode}`,
icon: 'success',
duration: 2000
});
}
// 如果没有提取到设备编号,也直接忽略,不提示用户
}
// 如果不是REC开头的扫描,直接忽略
}
},
async handleSubmit() {
try {
await this.$refs.formRef.validate();
this.submitting = true;
const submitData = {
...this.formData
};
const result = await this.$http("storage.receiving.create",submitData);
if(result.code==200){
uni.showToast({
title: '创建成功',
icon: 'success'
});
}else{
throw new Error("创建失败"+result.message);
}
setTimeout(() => {
uni.navigateTo({
url: `./receivingDetail?id=${result.id}`
});
}, 1500);
} catch (error) {
uni.showToast({
title: '创建失败'+error,
icon: 'error'
});
} finally {
this.submitting = false;
}
},
handleReset() {
uni.showModal({
title: '确认重置',
content: '确定要重置所有表单数据吗?',
success: (res) => {
if (res.confirm) {
this.$refs.formRef.resetFields();
this.storeName = "不设置";
this.formData.store_id = null;
}
}
});
},
handleStoreChange(option) {
if (!option) {
this.storeName = "不设置";
this.formData.store_id = null;
} else {
this.storeName = option.label;
this.formData.store_id = option.value;
}
this.showStorePicker = false;
},
},
onLoad() {
this.$store.dispatch('broadcast/setCallbacks', {
onResult: this.scan
});
this.$store.dispatch('broadcast/start');
this.loadStore();
},
onShow() {
this.$store.dispatch('broadcast/resume');
},
onHide() {
this.$store.dispatch('broadcast/pause');
},
onUnload() {
this.$store.dispatch('broadcast/stop');
}
};
</script>
<style lang="scss" scoped>
.container {
flex: 1;
height: 100rpx;
.form_box {
padding: 20rpx;
}
}
.section {
background-color: #fff;
border-radius: 16rpx;
padding: 30rpx;
margin-bottom: 30rpx;
.section-title {
font-size: 32rpx;
font-weight: bold;
color: #333;
margin-bottom: 30rpx;
padding-bottom: 20rpx;
border-bottom: 2rpx solid #f0f0f0;
}
}
.submit-area {
display: flex;
flex-direction: row;
padding: 20rpx;
gap: 20rpx;
border-top: 1px solid rgba(0, 0, 0, .3);
background-color: #FFF;
}
</style>

View File

@ -1,22 +0,0 @@
<template>
<view class="normar_container">
<page-nav title="移库作业"></page-nav>
</view>
</template>
<script>
export default {
data() {
return {
}
},
methods: {
}
}
</script>
<style>
</style>

27
postcss.config.js Normal file
View File

@ -0,0 +1,27 @@
const path = require('path')
const webpack = require('webpack')
const config = {
parser: require('postcss-comment'),
plugins: [
require('postcss-import')({
resolve (id, basedir, importOptions) {
if (id.startsWith('~@/')) {
return path.resolve(process.env.UNI_INPUT_DIR, id.substr(3))
} else if (id.startsWith('@/')) {
return path.resolve(process.env.UNI_INPUT_DIR, id.substr(2))
} else if (id.startsWith('/') && !id.startsWith('//')) {
return path.resolve(process.env.UNI_INPUT_DIR, id.substr(1))
}
return id
}
}),
require('autoprefixer')({
remove: process.env.UNI_PLATFORM !== 'h5'
}),
require('@dcloudio/vue-cli-plugin-uni/packages/postcss')
]
}
if (webpack.version[0] > 4) {
delete config.parser
}
module.exports = config

View File

@ -3,6 +3,7 @@
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta http-equiv="Permissions-Policy" content="unload=(self)">
<link rel="shortcut icon" type="image/x-icon" href="https://cdn.uviewui.com/uview/common/favicon.webp"> <link rel="shortcut icon" type="image/x-icon" href="https://cdn.uviewui.com/uview/common/favicon.webp">
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"> <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<title> <title>
@ -27,9 +28,6 @@
<link rel="stylesheet" href="<%= BASE_URL %>static/index.css" /> <link rel="stylesheet" href="<%= BASE_URL %>static/index.css" />
</head> </head>
<body> <body>
<!-- 该文件为 H5 平台的模板 HTML,并非应用入口。 -->
<!-- 请勿在此文件编写页面代码或直接运行此文件。 -->
<!-- 详见文档:https://uniapp.dcloud.io/collocation/manifest?id=h5-template -->
<noscript> <noscript>
<strong>本站点必须要开启JavaScript才能运行</strong> <strong>本站点必须要开启JavaScript才能运行</strong>
</noscript> </noscript>

1
scripts/_argtest.cjs Normal file
View File

@ -0,0 +1 @@
console.log('ARGV=' + JSON.stringify(process.argv.slice(2)))

63
scripts/build-apk.cjs Normal file
View File

@ -0,0 +1,63 @@
/**
* Android APK 一键打包(强制生产编译 + 产物地址校验)。
*
* 步骤:
* 1. `npm run build:app-plus` —— 生产编译。该命令内部已包含 `scripts/check-build-env.cjs`
* 的产物校验(含内网地址或缺少生产域名会直接失败),因此不会把开发地址打进 APK;
* 2. `android-offline/pack.ps1` —— 注入 App 资源/图标/启动图 + `gradlew assembleRelease`,
* 产物输出到 `release/android/wms-pda_v{版本}_release.apk`。
*
* 用法:
* npm run build:apk # 前端编译 + 打包
* npm run build:apk -- -Clean # gradle 全量重编
* npm run build:apk -- -NoInject # 跳过资源注入(已注入过时用)
* npm run build:apk -- -Timestamp # 产物名带时间戳
* npm run android:pack:raw # 跳过前端编译,直接用现有 dist/build/app-plus 打包
*
* 说明:
* - 发布上传(scp + latest.json)在 pack.ps1 内,且只有存在 `config/deploy.json` 时才会执行;
* 本仓库不提供该文件,故默认不会上传。
* - 版本号唯一来源是根 `package.json` 的 `version`(X.Y.Z),`versionCode` 自动推导为
* X*1000000 + Y*1000 + Z。
*/
const { spawnSync } = require('child_process')
const fs = require('fs')
const path = require('path')
const ROOT = path.resolve(__dirname, '..')
const APP_BUILD_DIR = path.join(ROOT, 'dist', 'build', 'app-plus')
const log = (...args) => console.log('[build-apk]', ...args)
function run(cmd, args) {
log(`$ ${cmd} ${args.join(' ')}`)
const res = spawnSync(cmd, args, {
cwd: ROOT,
stdio: 'inherit',
env: process.env,
shell: process.platform === 'win32',
})
return res.status === 0
}
// ---------- step 1: 生产编译(内部含产物地址校验) ----------
log('step 1/2: build:app-plus(生产编译 + 产物地址校验)...')
if (!run('npm', ['run', 'build:app-plus'])) {
console.error('[build-apk] ✗ build:app-plus 失败,终止')
process.exit(1)
}
if (!fs.existsSync(APP_BUILD_DIR)) {
console.error(`[build-apk] ✗ 未找到 App 构建产物: ${APP_BUILD_DIR}`)
process.exit(1)
}
// ---------- step 2: 离线打包(参数透传) ----------
const extraArgs = process.argv.slice(2)
const packArgs = ['run', 'android:pack:raw']
if (extraArgs.length) packArgs.push('--', ...extraArgs)
log(`step 2/2: android:pack:raw${extraArgs.length ? ' ' + extraArgs.join(' ') : ''} ...`)
if (!run('npm', packArgs)) {
console.error('[build-apk] ✗ android:pack:raw 失败')
process.exit(1)
}
log('✓ 打包完成,APK 见 release/android/')

105
scripts/check-build-env.cjs Normal file
View File

@ -0,0 +1,105 @@
/**
* 构建产物「接口地址」校验(防呆)
*
* 背景:本项目原 HBuilderX 工程里 src/env.js 的开发地址长期处于生效状态,
* 打正式包时会连内网测试库(曾在姊妹项目 wms_worker_station 造成过生产事故)。
* 本脚本在构建结束后扫描产物,做两道校验:
* 1. 产物中不得出现内网地址(192.168.x.x / 127.0.0.1)——否则说明开发地址进了包;
* 2. 产物中必须出现生产域名 PROD_HOST——否则说明生产地址根本没被编译进去
* (例如误用了 override、或 env.js 被改坏)。
* 任一条不满足即 exit 1,让 CI / 本地打包在「产物不可信」时就停下来。
*
* 用法:
* node scripts/check-build-env.cjs # 自动扫描已存在的产物目录
* node scripts/check-build-env.cjs dist/build/h5 # 只校验指定目录
* node scripts/check-build-env.cjs --allow-missing-prod # 跳过第 2 条(特殊域名场景)
*/
const fs = require('fs')
const path = require('path')
const ROOT = path.resolve(__dirname, '..')
const DEFAULT_TARGETS = [path.join(ROOT, 'dist', 'build', 'h5'), path.join(ROOT, 'dist', 'build', 'app-plus')]
const SCAN_EXTENSIONS = ['.js', '.html', '.json', '.css']
// 生产接口域名:必须与 src/env.js 的 PROD_API_BASE 保持一致
const PROD_HOST = 'qimen.wms.gztbyc.com'
// 内网地址特征(开发环境地址一旦出现在产物里就是事故)
const DEV_PATTERNS = [/192\.168\.\d{1,3}\.\d{1,3}/g, /127\.0\.0\.1/g]
const args = process.argv.slice(2)
const allowMissingProd = args.includes('--allow-missing-prod')
const explicitTargets = args.filter((arg) => !arg.startsWith('--'))
const log = (...rest) => console.log('[check-build-env]', ...rest)
function collectFiles(dir, out = []) {
if (!fs.existsSync(dir)) return out
for (const name of fs.readdirSync(dir)) {
const full = path.join(dir, name)
const stat = fs.statSync(full)
if (stat.isDirectory()) {
collectFiles(full, out)
} else if (SCAN_EXTENSIONS.includes(path.extname(name).toLowerCase())) {
out.push(full)
}
}
return out
}
const targets = (explicitTargets.length ? explicitTargets : DEFAULT_TARGETS)
.map((target) => path.resolve(ROOT, target))
.filter((dir) => fs.existsSync(dir))
if (!targets.length) {
console.error('[check-build-env] ✗ 未找到任何构建产物目录,请先执行构建(npm run build:h5 / build:app-plus)')
process.exit(1)
}
let failed = false
for (const dir of targets) {
const files = collectFiles(dir)
const rel = path.relative(ROOT, dir).replace(/\\/g, '/')
if (!files.length) {
log(`✗ ${rel} 为空目录,跳过`)
continue
}
const devHits = []
let hasProdHost = false
for (const file of files) {
const content = fs.readFileSync(file, 'utf-8')
if (content.includes(PROD_HOST)) hasProdHost = true
for (const pattern of DEV_PATTERNS) {
const matches = content.match(pattern)
if (matches) {
devHits.push({ file: path.relative(dir, file).replace(/\\/g, '/'), hits: Array.from(new Set(matches)) })
break
}
}
}
if (devHits.length) {
failed = true
console.error(`[check-build-env] ✗ ${rel} 中发现内网地址,产物不可用于发布:`)
devHits.forEach(({ file, hits }) => console.error(` - ${file}(${hits.join(', ')})`))
console.error(' 排查:src/env.js 是否被改回开发地址 / 是否误用 VUE_APP_API_BASE_OVERRIDE')
}
if (!hasProdHost && !allowMissingProd) {
failed = true
console.error(`[check-build-env] ✗ ${rel} 中未发现生产域名 ${PROD_HOST},产物不可用于发布`)
console.error(' 排查:src/env.js 的 PROD_API_BASE 是否被改动;如属特殊场景请加 --allow-missing-prod')
}
if (!devHits.length && (hasProdHost || allowMissingProd)) {
log(`✓ ${rel} 校验通过(${files.length} 个文件,无内网地址${hasProdHost ? `,含生产域名 ${PROD_HOST}` : ''})`)
}
}
if (failed) {
console.error('[check-build-env] ✗ 校验未通过,已中止')
process.exit(1)
}
log('全部产物校验通过')

446
scripts/dev-adb.cjs Normal file
View File

@ -0,0 +1,446 @@
/**
* 真机调试(测试模式):注入接口地址 → 编译 → 打包 → 装机 → 启动 → 跟随日志 → 监听改动自动重来。
*
* 与 `npm run build:apk` 的区别:
* - build:apk → 发行包。接口地址固定为 src/env.js 的 PROD_API_BASE,构建后强制校验产物不含内网地址。
* - dev:adb → 测试包。接口地址在编译期由本脚本注入(默认取 .env.development.local 的
* VUE_APP_API_BASE_URL),产物进 release/android/dev/*_dev.apk,绝不覆盖发行包。
*
* 注入方式(与工作台 wms_worker_station 一致):命令行环境变量 VUE_APP_API_BASE_OVERRIDE,
* 不写入任何 .env 文件、不落盘;在 src/env.js 中优先级高于生产常量,详见该文件顶部说明。
*
* 用法:
* npm run dev:adb # 默认:构建→装机→启动→跟随真机日志→监听改动自动重来
* npm run dev:adb -- --once # 只跑一遍(CI/脚本调用用,不监听)
* npm run dev:adb -- --prod-api # 不注入,产出与发行包一致的包(排查线上问题时用)
* npm run dev:adb -- --api=http://192.168.1.10:6060
* npm run dev:adb -- --no-install # 只编译 + 打包
* npm run dev:adb -- --no-launch # 装机后不自动启动
* npm run dev:adb -- --no-logcat # 不跟随真机日志
* npm run dev:adb -- --serial=4235737 # 多设备时指定目标设备
*
* 真机日志:release 包里 JS 的 console 走 UniConsole(逻辑层) / UniViewConsole(视图层) 两个 tag,
* 本脚本默认跟随这两个 tag 实时打印到控制台(出错行标红)。
*/
const { spawn, spawnSync } = require('child_process')
const fs = require('fs')
const path = require('path')
const readline = require('readline')
const ROOT = path.resolve(__dirname, '..')
const APP_BUILD_DIR = path.join(ROOT, 'dist', 'build', 'app-plus')
const DEV_APK_DIR = path.join(ROOT, 'release', 'android', 'dev')
const PACKAGE_NAME = 'com.gztbyc.pda_wms'
const argv = process.argv.slice(2)
const hasFlag = (name) => argv.includes(name)
const argValue = (name) => {
const hit = argv.find((a) => a.startsWith(`${name}=`))
return hit ? hit.slice(name.length + 1) : ''
}
const ONCE = hasFlag('--once') || hasFlag('--no-watch')
const NO_INSTALL = hasFlag('--no-install')
const NO_LAUNCH = hasFlag('--no-launch')
const NO_LOGCAT = hasFlag('--no-logcat')
const log = (msg) => console.log(`[dev:adb] ${msg}`)
// ---------- adb 探测 ----------
function detectAdb() {
const candidates = []
const home = process.env.ANDROID_HOME || process.env.ANDROID_SDK_ROOT || ''
if (home) candidates.push(path.join(home, 'platform-tools', process.platform === 'win32' ? 'adb.exe' : 'adb'))
if (process.env.LOCALAPPDATA) candidates.push(path.join(process.env.LOCALAPPDATA, 'Android', 'Sdk', 'platform-tools', 'adb.exe'))
candidates.push(process.platform === 'win32' ? 'adb.exe' : 'adb')
for (const c of candidates) {
const res = spawnSync(c, ['version'], { encoding: 'utf-8' })
if (res.status === 0 && /Android Debug Bridge/.test(res.stdout || '')) return c
}
return 'adb'
}
const ADB = detectAdb()
// ---------- 接口地址解析 ----------
function readEnvValue(file, key) {
try {
const text = fs.readFileSync(path.join(ROOT, file), 'utf-8')
for (const line of text.split(/\r?\n/)) {
const m = line.match(/^\s*([A-Za-z0-9_]+)\s*=\s*(.*)$/)
if (m && m[1] === key) return m[2].trim().replace(/^["']|["']$/g, '')
}
} catch (e) {
// 文件不存在视为未配置
}
return ''
}
function resolveApiTarget() {
if (hasFlag('--prod-api')) return { base: '', note: '--prod-api 指定,与发行包一致(生产地址)' }
const argApi = argValue('--api')
if (argApi) return { base: argApi, note: '命令行 --api 指定' }
const fromEnv = readEnvValue('.env.development.local', 'VUE_APP_API_BASE_URL') || readEnvValue('.env.local', 'VUE_APP_API_BASE_URL')
if (fromEnv) return { base: fromEnv, note: '.env.development.local 的 VUE_APP_API_BASE_URL' }
return { base: '', note: '未配置开发地址,沿用构建默认(生产地址)' }
}
const API_TARGET = resolveApiTarget()
const BUILD_ENV = {
...(API_TARGET.base
? { VUE_APP_API_BASE_OVERRIDE: API_TARGET.base }
// 不注入地址时(--prod-api / 未配置开发地址),显式删除继承的环境变量(null=删除),
// 避免终端里残留的 VUE_APP_API_BASE_OVERRIDE / VUE_APP_API_BASE_URL 把开发地址带进包
: { VUE_APP_API_BASE_OVERRIDE: null, VUE_APP_API_BASE_URL: null }),
// 测试包始终开启 JS→logcat 转发(发行包不注入该变量,见 src/core/utils/dev-log.js)
VUE_APP_JS_LOG_TO_LOGCAT: '1',
}
// ---------- 工具 ----------
function run(cmd, args, env) {
const mergedEnv = { ...process.env, ...(env || {}) }
// 值为 null 的变量表示「显式删除」,避免终端里继承的旧值被带进子进程
for (const key of Object.keys(env || {})) {
if (env[key] === null) delete mergedEnv[key]
}
const res = spawnSync(cmd, args, {
cwd: ROOT,
stdio: 'inherit',
env: mergedEnv,
shell: process.platform === 'win32',
})
if (res.error) {
console.error(`[dev:adb] 执行失败 ${cmd}: ${res.error.message}`)
return false
}
return res.status === 0
}
function collectFiles(dir, out = []) {
if (!fs.existsSync(dir)) return out
for (const name of fs.readdirSync(dir)) {
const full = path.join(dir, name)
if (fs.statSync(full).isDirectory()) collectFiles(full, out)
else if (/\.(js|html|json)$/i.test(name)) out.push(full)
}
return out
}
function findDevApk() {
if (!fs.existsSync(DEV_APK_DIR)) return null
const apks = fs.readdirSync(DEV_APK_DIR)
.filter((f) => f.endsWith('.apk'))
.map((f) => ({ name: f, mtime: fs.statSync(path.join(DEV_APK_DIR, f)).mtimeMs }))
if (!apks.length) return null
apks.sort((a, b) => b.mtime - a.mtime)
return path.join(DEV_APK_DIR, apks[0].name)
}
// ---------- 设备 ----------
// 上次选择的设备记在本文件里(不提交 git):多设备时自动选回它,避免每次都要选
const STATE_FILE = path.join(ROOT, '.dev-adb.local.json')
function readSavedSerial() {
try {
return JSON.parse(fs.readFileSync(STATE_FILE, 'utf-8')).serial || ''
} catch (e) {
return ''
}
}
function saveSerial(serial) {
try {
fs.writeFileSync(STATE_FILE, `${JSON.stringify({ serial }, null, 2)}\n`)
} catch (e) {
// 写入失败不影响流程
}
}
function listDevices() {
const res = spawnSync(ADB, ['devices', '-l'], { encoding: 'utf-8' })
const devices = []
for (const line of (res.stdout || '').split(/\r?\n/)) {
const m = line.trim().match(/^(\S+)\s+device\b(.*)$/)
if (m) devices.push({ serial: m[1], desc: m[2].trim() })
}
return devices
}
function ask(question) {
const rl = readline.createInterface({ input: process.stdin, output: process.stdout })
return new Promise((resolve) => {
rl.question(question, (answer) => {
rl.close()
resolve(String(answer || '').trim())
})
})
}
function printDevices(devices) {
devices.forEach((d, i) => console.error(` [${i + 1}] ${d.serial} ${d.desc}`))
}
async function pickDevice() {
const devices = listDevices()
if (!devices.length) {
console.error('[dev:adb] 未检测到已连接设备(USB 未插好、未授权,或无线调试未 adb connect)')
process.exit(1)
}
// 1. 命令行指定优先
const wanted = argValue('--serial')
if (wanted) {
const hit = devices.find((d) => d.serial === wanted)
if (!hit) {
console.error(`[dev:adb] 未找到设备 ${wanted},当前:${devices.map((d) => d.serial).join(', ')}`)
process.exit(1)
}
saveSerial(hit.serial)
return hit
}
// 2. 上次用过的设备仍然在线 → 直接用
const saved = readSavedSerial()
if (saved) {
const hit = devices.find((d) => d.serial === saved)
if (hit) {
log(`使用上次选择的设备: ${hit.serial} ${hit.desc}(可用 --serial= 更换)`)
return hit
}
}
// 3. 只有一台 → 自动选中
if (devices.length === 1) {
saveSerial(devices[0].serial)
return devices[0]
}
// 4. 多台 → 交互选择(与工作台 dev:adb 一致)
console.error('[dev:adb] 检测到多台设备:')
printDevices(devices)
if (!process.stdin.isTTY) {
console.error('[dev:adb] 当前终端不能交互,请用 --serial=<序列号> 指定,例如:')
console.error(` npm run dev:adb -- --serial=${devices[0].serial}`)
process.exit(1)
}
const answer = await ask(`请选择设备序号 [1-${devices.length}],默认 1: `)
const idx = answer ? Number(answer) - 1 : 0
if (!Number.isInteger(idx) || idx < 0 || idx >= devices.length) {
console.error(`[dev:adb] 无效序号: ${answer}`)
process.exit(1)
}
saveSerial(devices[idx].serial)
return devices[idx]
}
// ---------- 真机日志跟随 ----------
let logcatProc = null
let shuttingDown = false
function clearLogcat(serial) {
spawnSync(ADB, ['-s', serial, 'logcat', '-c'], { stdio: 'ignore' })
}
function startLogcat(serial) {
if (NO_LOGCAT || logcatProc || shuttingDown) return
clearLogcat(serial)
logcatProc = spawn(ADB, ['-s', serial, 'logcat', '-v', 'time', 'jsLog:V', 'UniConsole:V', 'UniViewConsole:V', '*:S'], {
stdio: ['ignore', 'pipe', 'inherit'],
})
let buf = ''
logcatProc.stdout.setEncoding('utf-8')
logcatProc.stdout.on('data', (chunk) => {
buf += chunk
let idx
while ((idx = buf.indexOf('\n')) >= 0) {
const line = buf.slice(0, idx).trim()
buf = buf.slice(idx + 1)
if (!line) continue
const isErr = / W\/| E\//.test(line)
console.log(isErr ? `\x1b[31m[真机] ${line}\x1b[0m` : `\x1b[36m[真机] ${line}\x1b[0m`)
}
})
logcatProc.on('exit', () => {
logcatProc = null
if (!shuttingDown) {
// adb 重连/设备重启后自动恢复跟随
setTimeout(() => startLogcat(serial), 3000)
}
})
log('真机 console 实时打印已开启(jsLog / UniConsole / UniViewConsole)')
}
process.on('SIGINT', () => {
shuttingDown = true
if (logcatProc) {
logcatProc.kill()
logcatProc = null
}
log('已退出监听的日志跟随')
process.exit(0)
})
// ---------- 构建 → 安装 → 启动 ----------
async function buildAndInstall(device, trigger) {
const serial = device.serial
const t0 = Date.now()
log(`开始构建(触发: ${trigger})`)
log(`接口地址 = ${API_TARGET.base || 'src/env.js 的 PROD_API_BASE(生产)'} 〔${API_TARGET.note}〕`)
// 1. 编译 App 资源(生产模式编译,但注入 override 指向测试环境)
if (!run('npm', ['run', 'build:app-plus:dev'], BUILD_ENV)) {
log('✗ 编译失败,跳过安装')
return false
}
// 2. 校验注入结果(正向:期望地址必须出现在产物里)
const files = collectFiles(APP_BUILD_DIR)
if (!files.length) {
log(`✗ 未找到构建产物: ${path.relative(ROOT, APP_BUILD_DIR)}`)
return false
}
if (API_TARGET.base) {
const host = API_TARGET.base.replace(/^https?:\/\//, '').replace(/\/.*$/, '')
const hit = files.find((f) => fs.readFileSync(f, 'utf-8').includes(host))
if (!hit) {
log(`✗ 产物中未找到注入的地址 ${API_TARGET.base},注入可能未生效,已中止`)
return false
}
log(`✓ 已确认产物使用 ${API_TARGET.base}`)
} else if (!run('node', ['scripts/check-build-env.cjs', 'dist/build/app-plus'])) {
log('✗ 产物地址校验未通过')
return false
}
// 3. 离线打包(-Dev:产物进 release/android/dev 且带 _dev 后缀,不触发发布上传)
// 注意:不要用 `npm run android:pack:raw -- -Dev -NoUpload`。
// PowerShell 会把 `--` 吞掉,`-Dev/-NoUpload` 随即被 npm 当作未知选项丢弃,
// 结果是打出「发行包」(覆盖 release/android/ 下的正式 APK),而 dev 目录没有新文件,
// 后面 findDevApk() 就会装回旧包,真机上看到的永远是老界面。
// 这里直接调 pack.ps1,参数一定生效。
if (!run('powershell', [
'-NoProfile',
'-ExecutionPolicy', 'Bypass',
'-File', path.join(ROOT, 'android-offline', 'pack.ps1'),
'-Dev',
'-NoUpload',
])) {
log('✗ 打包失败,跳过安装')
return false
}
const apk = findDevApk()
if (!apk) {
log(`✗ 未找到 APK: ${path.relative(ROOT, DEV_APK_DIR)}`)
return false
}
log(`APK: ${path.relative(ROOT, apk)}`)
if (NO_INSTALL) {
log(`✓ 编译 + 打包完成,耗时 ${((Date.now() - t0) / 1000).toFixed(1)}s(--no-install 未安装)`)
return true
}
// 4. 安装(设备忙时常见失败,重试 3 次)
for (let i = 0; i < 3; i++) {
if (spawnSync(ADB, ['-s', serial, 'install', '-r', apk], { stdio: 'inherit' }).status === 0) break
if (i === 2) {
log('✗ adb install 失败(已重试 3 次)')
return false
}
log(`安装失败,2 秒后重试 (${i + 1}/2)`)
await new Promise((r) => setTimeout(r, 2000))
}
// 5. 启动(先停进程,再用 monkey 拉起 launcher 入口最稳)
if (!NO_LAUNCH) {
if (!NO_LOGCAT) startLogcat(serial)
else clearLogcat(serial)
spawnSync(ADB, ['-s', serial, 'shell', 'am', 'force-stop', PACKAGE_NAME], { stdio: 'ignore' })
spawnSync(ADB, ['-s', serial, 'shell', 'monkey', '-p', PACKAGE_NAME, '-c', 'android.intent.category.LAUNCHER', '1'], { stdio: 'ignore' })
log('已启动应用')
}
log(`✓ 完成,耗时 ${((Date.now() - t0) / 1000).toFixed(1)}s`)
return true
}
let building = false
let pending = false
async function triggerBuild(device, trigger) {
if (building) {
pending = true
return
}
building = true
try {
await buildAndInstall(device, trigger)
} finally {
building = false
if (pending) {
pending = false
log('构建期间有新变更,继续构建...')
triggerBuild(device, 'pending')
}
}
}
// ---------- 目录监听 ----------
// 监听范围:src/(uni-app 前端)、原生 java、以及 src/main 直接子文件(AndroidManifest.xml)。
// 注意:不监听 src/main/assets(prepare 注入产物)与 res(图标/启动图覆盖产物),否则构建会自触发死循环。
const WATCH_ROOTS = [
{ dir: path.join(ROOT, 'src'), recursive: true },
{ dir: path.join(ROOT, 'android-offline', 'HBuilder-Integrate-AS', 'simpleDemo', 'src', 'main', 'java'), recursive: true },
{ dir: path.join(ROOT, 'android-offline', 'HBuilder-Integrate-AS', 'simpleDemo', 'src', 'main'), recursive: false },
]
const WATCH_EXTS = new Set(['.vue', '.js', '.ts', '.json', '.scss', '.css', '.cjs', '.ps1', '.xml', '.java', '.png', '.jpg', '.jpeg'])
const IGNORE_SEGMENTS = [`${path.sep}assets${path.sep}`, `${path.sep}unpackage${path.sep}`, `${path.sep}dist${path.sep}`, `${path.sep}node_modules${path.sep}`]
function startWatch(device) {
let timer = null
for (const root of WATCH_ROOTS) {
if (!fs.existsSync(root.dir)) {
log(`警告: 监听目录不存在: ${path.relative(ROOT, root.dir)}`)
continue
}
try {
fs.watch(root.dir, { recursive: root.recursive }, (event, filename) => {
const rel = filename ? path.join(root.dir, filename) : root.dir
if (IGNORE_SEGMENTS.some((seg) => rel.includes(seg))) return
if (filename && !WATCH_EXTS.has(path.extname(filename).toLowerCase())) return
if (timer) clearTimeout(timer)
timer = setTimeout(() => {
timer = null
triggerBuild(device, path.relative(ROOT, rel))
}, 800)
})
log(`监听中: ${path.relative(ROOT, root.dir)}${root.recursive ? '' : '(不递归)'}`)
} catch (e) {
log(`警告: 无法监听 ${root.dir}: ${e.message}`)
}
}
log('改动文件即自动重编重装(Ctrl+C 退出)')
}
// ---------- 主流程 ----------
async function main() {
const device = await pickDevice()
log(`目标设备: ${device.serial} ${device.desc}`)
await triggerBuild(device, '首次')
log(`单独查看真机日志:adb -s ${device.serial} logcat jsLog:V UniConsole:V UniViewConsole:V *:S`)
if (ONCE) {
if (NO_LOGCAT || NO_LAUNCH) {
log('--once 指定,不进入监听,结束')
} else {
log('--once 指定:不监听文件改动,但继续跟随真机日志(Ctrl+C 退出)')
}
return
}
startWatch(device)
}
main()

View File

@ -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);
}

52
scripts/node-compat.cjs Normal file
View File

@ -0,0 +1,52 @@
/**
* Node 兼容 shim(uni-app Vue2 工具链专用)
*
* 背景:Node 23+ 移除了历史遗留的 `util.isArray` / `util.isRegExp` 等 API,
* 而 uni-app Vue2 编译链依赖的 postcss-urlrewrite 等老包仍在调用它们,
* 在 Node 22+ 上执行 app-plus 构建会抛 `util.isRegExp is not a function`。
*
* 用法:通过 NODE_OPTIONS=--require=./scripts/node-compat.cjs 注入(见 package.json scripts)。
* 在 Node 16/18 下运行时所有 API 均存在,本文件自动变成空操作,无副作用。
*/
'use strict'
const util = require('util')
const toString = Object.prototype.toString
const shims = {
isArray: Array.isArray,
isBoolean: (v) => typeof v === 'boolean',
isBuffer: (v) => Buffer.isBuffer(v),
isDate: (v) => v instanceof Date,
isError: (v) => v instanceof Error || toString.call(v) === '[object Error]',
isFunction: (v) => typeof v === 'function',
isNull: (v) => v === null,
isNullOrUndefined: (v) => v === null || v === undefined,
isNumber: (v) => typeof v === 'number',
isObject: (v) => v !== null && typeof v === 'object',
isPrimitive: (v) => v === null || (typeof v !== 'object' && typeof v !== 'function'),
isRegExp: (v) => v instanceof RegExp,
isString: (v) => typeof v === 'string',
isSymbol: (v) => typeof v === 'symbol',
isUndefined: (v) => v === undefined
}
Object.keys(shims).forEach((name) => {
if (typeof util[name] !== 'function') {
util[name] = shims[name]
}
})
if (typeof util._extend !== 'function') {
util._extend = function _extend (target, source) {
if (source) {
for (const key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key]
}
}
}
return target
}
}

93
src/App.vue Normal file
View File

@ -0,0 +1,93 @@
<script>
import { getToken } from '@/core/utils/auth'
import { ensureEntry } from '@/core/utils/auth-guard'
let bootstrapping = false
let validatedToken = ''
// H5(history 模式)下,整页直接刷新/打开 packMode 等“非入口页”时 uni-app 不创建页面视图(白屏)。
// 该状态仅本次整页启动时自愈一次(页面缺失则回跳入口),避免重复触发。
let h5WhiteHealDone = false
export default {
onLaunch() {
this.bootstrapAuth()
},
onShow() {
this.bootstrapAuth()
this.h5WhiteScreenHeal()
},
methods: {
async bootstrapAuth() {
if (bootstrapping) {
return
}
const token = getToken()
const forceValidate = !!token && token !== validatedToken
bootstrapping = true
try {
const result = await ensureEntry(this.$store, forceValidate)
validatedToken = result.loggedIn ? token : ''
} finally {
bootstrapping = false
}
},
// H5 白屏自愈:manifest h5 路由为 history 模式时,若应用是“整页加载”方式
// 直接从 packMode 等非 tab、非入口页启动,uni-app 不会渲染出页面视图(uni-page),
// 且该会话内后续客户端跳转同样失效,页面会一直白屏(刷新也无法恢复)。
// 这里在启动后检测:uni-app 外壳已挂载但 uni-page 缺失 → 判定为白屏态,
// 整页回跳根路径让应用从入口正常启动,避免停留在白屏。真机/App 端不参与编译。
h5WhiteScreenHeal() {
// #ifdef H5
if (h5WhiteHealDone) return
h5WhiteHealDone = true
if (typeof window === 'undefined' || !window.location) return
const bootPath = window.location.pathname || '/'
// 入口页(根/登录页)本身可正常渲染,无需处理
if (bootPath === '/' || bootPath === '/pages/login/index') return
setTimeout(() => {
// 外壳 uni-app 已存在但页面视图 uni-page 缺失 → 白屏,回跳入口
const shell = document.querySelector('uni-app')
const page = document.querySelector('uni-page')
if (shell && !page) {
console.warn('[App] H5 深链接整页启动未渲染页面视图(白屏),自动回跳入口页:', bootPath)
window.location.replace('/')
}
}, 1500)
// #endif
}
}
}
</script>
<style lang="scss">
/* 每个页面公共css */
@import "@/uni_modules/uview-ui/index.scss";
@import "common/demo.scss";
.status_bar {
height: var(--status-bar-height);
background-color: #FFFFFF;
}
.normar_container{
height:100vh;
display:flex;
flex-direction: column;
background-color: #f8f8f8;
}
/* uni 系统图片预览层(uni.previewImage):
H5 下框架给 .uni-system-preview-image 的 z-index 只有 999,会被 uView 弹窗
(popup 默认 10075、toast 10090)盖住 —— 表现为"在弹窗里点图片预览看不到"。
这里统一抬高到所有业务弹层之上(App 端预览是原生全屏,不受此样式影响)。 */
.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;
}
</style>

3
src/androidPrivacy.json Normal file
View File

@ -0,0 +1,3 @@
{
"prompt" : "none"
}

View File

@ -0,0 +1,575 @@
<template>
<view v-if="showUpdateDialog" class="update-mask">
<view class="update-dialog">
<view class="update-header">
<text class="update-title">发现新版本</text>
<text class="update-version">当前 {{ currentAppVersion || '--' }} → 最新 {{ updateInfo.version || '--' }}</text>
</view>
<view class="update-body">
<view class="update-row">
<text class="update-label">安装包</text>
<text class="update-value">{{ updateInfo.file || '未提供文件名' }}</text>
</view>
<view v-if="updateInfo.publishedAtUtc" class="update-row">
<text class="update-label">发布时间</text>
<text class="update-value">{{ formatUpdateTime(updateInfo.publishedAtUtc) }}</text>
</view>
<view class="update-tip-box">
<text class="update-tip">检测到新版本,确认后将开始下载安装包。</text>
<text class="update-tip">下载完成后会自动打开文件。</text>
</view>
<view v-if="isDownloadingUpdate" class="update-progress-section">
<view class="update-progress-head">
<text class="update-progress-text">正在下载更新</text>
<text class="update-progress-text">{{ updateDownloadProgress }}%</text>
</view>
<view class="update-progress-bar">
<view class="update-progress-inner" :style="{ width: updateDownloadProgress + '%' }"></view>
</view>
</view>
<text v-if="updateErrorMessage" class="update-error">{{ updateErrorMessage }}</text>
</view>
<view class="update-actions">
<u-button
v-if="!isDownloadingUpdate"
plain
text="暂不更新"
@click="closeUpdateDialog"
></u-button>
<u-button
type="primary"
:loading="isDownloadingUpdate"
:disabled="isDownloadingUpdate"
:text="isDownloadingUpdate ? '下载中...' : '立即更新'"
@click="confirmUpdateDownload"
></u-button>
</view>
</view>
</view>
</template>
<script>
/**
* AppUpdateDialog 版本更新弹窗组件
* 复用登录页 checkForAppUpdate 的完整更新流程:
* 读取远端 latest.json → 比较版本 → 弹窗 → 下载 APK → plus.runtime.openFile 调用系统安装器
* 使用方法:
* <app-update-dialog ref="appUpdateDialog"></app-update-dialog>
* this.$refs.appUpdateDialog.checkForAppUpdate(true) // force=true 每次强制重新检查
*/
export default {
name: 'AppUpdateDialog',
data() {
return {
updateLogSeq: 0,
// 远端更新配置地址。注意:当前为 http 明文,Android 9+ 默认禁止明文流量,
// 若真机请求 latest.json 失败,建议与主接口(https://api.youzixy.com)保持一致改用 https。
updateConfigUrl: 'http://dl.wms.gztbyc.com/pda/latest.json',
currentAppVersion: '',
showUpdateDialog: false,
isCheckingUpdate: false,
isDownloadingUpdate: false,
updateDownloadProgress: 0,
updateErrorMessage: '',
hasCheckedUpdate: false,
updateTask: null,
updateInfo: {
version: '',
file: '',
url: '',
sha256: '',
publishedAtUtc: ''
}
};
},
methods: {
logUpdateStep(step, payload) {
this.updateLogSeq += 1;
const seq = String(this.updateLogSeq).padStart(2, '0');
if (typeof payload === 'undefined') {
console.log(`[update][${seq}] ${step}`);
return;
}
console.log(`[update][${seq}] ${step}`, payload);
},
/**
* 检查更新并弹窗
* @param {Boolean} force 为 true 时忽略 hasCheckedUpdate,强制重新检查远端配置
* @returns {Promise<Boolean>} 是否发现新版本并弹窗;检查失败时返回 false 且 updateErrorMessage 有值
*/
async checkForAppUpdate(force = false) {
this.logUpdateStep('checkForAppUpdate -> 开始执行', { force });
if (force) {
this.hasCheckedUpdate = false;
}
if (this.hasCheckedUpdate || this.isCheckingUpdate) {
this.logUpdateStep('checkForAppUpdate -> 已检查过或正在检查,直接返回', {
hasCheckedUpdate: this.hasCheckedUpdate,
isCheckingUpdate: this.isCheckingUpdate
});
return false;
}
if (typeof plus === 'undefined' || !plus.runtime) {
this.logUpdateStep('checkForAppUpdate -> 非 APP-PLUS 环境,跳过更新检查');
return false;
}
this.hasCheckedUpdate = true;
this.isCheckingUpdate = true;
this.updateErrorMessage = '';
this.logUpdateStep('checkForAppUpdate -> 状态已置为检查中');
try {
this.logUpdateStep('checkForAppUpdate -> 并行获取当前版本和远端配置');
const [currentVersion, latestInfoRaw] = await Promise.all([
this.getCurrentAppVersion(),
this.fetchLatestVersionInfo()
]);
const latestInfo = this.normalizeLatestInfo(latestInfoRaw);
this.currentAppVersion = currentVersion;
this.logUpdateStep('checkForAppUpdate -> 已拿到版本信息', {
currentVersion,
latestVersion: latestInfo && latestInfo.version ? latestInfo.version : ''
});
this.logUpdateStep('checkForAppUpdate -> 标准化后的远端配置', latestInfo || {});
if (!currentVersion) {
this.logUpdateStep('checkForAppUpdate -> 未获取到当前应用版本,无法比较', { currentVersion });
this.updateErrorMessage = '获取当前应用版本失败';
return false;
}
if (!latestInfo || !latestInfo.version || !latestInfo.url) {
this.logUpdateStep('checkForAppUpdate -> 远端配置缺少必要字段,结束', latestInfo || {});
return false;
}
const isNewer = this.isVersionNewer(latestInfo.version, currentVersion);
this.logUpdateStep('checkForAppUpdate -> 版本比较完成', {
latestVersion: latestInfo.version,
currentVersion,
isNewer
});
if (!isNewer) {
this.logUpdateStep('checkForAppUpdate -> 远端版本不高于当前版本,不弹窗');
return false;
}
this.updateInfo = {
version: String(latestInfo.version || '').trim(),
file: String(latestInfo.file || '').trim(),
url: String(latestInfo.url || '').trim(),
sha256: String(latestInfo.sha256 || '').trim(),
publishedAtUtc: String(latestInfo.publishedAtUtc || '').trim()
};
this.showUpdateDialog = true;
this.logUpdateStep('checkForAppUpdate -> 发现新版本,显示更新弹窗', this.updateInfo);
return true;
} catch (error) {
this.logUpdateStep('checkForAppUpdate -> 检查异常', error);
console.warn('[update] check failed:', error);
this.updateErrorMessage = error?.message || '更新检查失败';
return false;
} finally {
this.isCheckingUpdate = false;
this.logUpdateStep('checkForAppUpdate -> 结束,isCheckingUpdate=false');
}
},
fetchLatestVersionInfo() {
this.logUpdateStep('fetchLatestVersionInfo -> 发起请求', {
url: this.updateConfigUrl
});
return new Promise((resolve, reject) => {
uni.request({
url: this.updateConfigUrl,
method: 'GET',
timeout: 10000,
success: (res) => {
this.logUpdateStep('fetchLatestVersionInfo -> 请求成功', {
statusCode: res.statusCode
});
if (res.statusCode !== 200) {
this.logUpdateStep('fetchLatestVersionInfo -> 状态码异常,reject', {
statusCode: res.statusCode
});
reject(new Error(`更新配置获取失败: ${res.statusCode}`));
return;
}
try {
const data = typeof res.data === 'string' ? JSON.parse(res.data) : res.data;
this.logUpdateStep('fetchLatestVersionInfo -> 配置解析成功', data || {});
resolve(data || {});
} catch (parseError) {
this.logUpdateStep('fetchLatestVersionInfo -> 配置解析失败', parseError);
reject(parseError);
}
},
fail: (error) => {
this.logUpdateStep('fetchLatestVersionInfo -> 请求失败', error);
const message = error?.errMsg || error?.message || '更新配置获取失败';
reject(new Error(message));
}
});
});
},
normalizeLatestInfo(raw) {
const source = raw && typeof raw === 'object' ? raw : {};
const version = String(source.version || source.versionName || source.appVersion || '').trim();
const url = String(
source.url ||
source.downloadUrl ||
source.apkUrl ||
source.download_url ||
''
).trim();
const file = String(source.file || source.fileName || source.apkName || source.name || '').trim();
return {
...source,
version,
url,
file,
sha256: String(source.sha256 || source.md5 || '').trim(),
publishedAtUtc: String(source.publishedAtUtc || source.publishedAt || source.releaseTime || '').trim()
};
},
getCurrentAppVersion() {
this.logUpdateStep('getCurrentAppVersion -> 开始读取当前版本');
return new Promise((resolve) => {
if (typeof plus === 'undefined' || !plus.runtime) {
this.logUpdateStep('getCurrentAppVersion -> 非 APP-PLUS,返回空版本');
resolve('');
return;
}
let settled = false;
const timer = setTimeout(() => {
if (settled) return;
settled = true;
this.logUpdateStep('getCurrentAppVersion -> getProperty 回调超时,返回空版本');
resolve('');
}, 3000);
const done = (version) => {
if (settled) return;
settled = true;
clearTimeout(timer);
resolve(version);
};
try {
// 注意:plus.runtime.version 是 HTML5+ 运行时版本(如 3.x),不是应用版本,
// 数值可能比应用版本大,若用作比较会导致「永远认为已是最新、不弹窗」。
// 因此这里只取 info.version(manifest 的 versionName),读不到就返回空。
plus.runtime.getProperty(plus.runtime.appid, (info) => {
const version = String(info?.version || '').trim();
this.logUpdateStep('getCurrentAppVersion -> 读取成功', {
version,
appid: plus.runtime.appid
});
done(version);
});
} catch (error) {
this.logUpdateStep('getCurrentAppVersion -> 读取异常,返回空版本', { error });
done('');
}
});
},
isVersionNewer(latestVersion, currentVersion) {
const normalize = (version) => String(version || '')
.split('.')
.map(item => parseInt(item, 10) || 0);
const latest = normalize(latestVersion);
const current = normalize(currentVersion);
const maxLength = Math.max(latest.length, current.length);
for (let i = 0; i < maxLength; i++) {
const latestPart = latest[i] || 0;
const currentPart = current[i] || 0;
if (latestPart > currentPart) {
return true;
}
if (latestPart < currentPart) {
return false;
}
}
return false;
},
formatUpdateTime(value) {
if (!value) {
return '';
}
const date = new Date(value);
if (Number.isNaN(date.getTime())) {
return value;
}
const pad = (num) => String(num).padStart(2, '0');
return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())} ${pad(date.getHours())}:${pad(date.getMinutes())}`;
},
closeUpdateDialog() {
if (this.isDownloadingUpdate) {
this.logUpdateStep('closeUpdateDialog -> 下载中,禁止关闭弹窗');
return;
}
this.showUpdateDialog = false;
this.updateErrorMessage = '';
this.logUpdateStep('closeUpdateDialog -> 用户取消更新,弹窗关闭');
},
confirmUpdateDownload() {
if (this.isDownloadingUpdate) {
this.logUpdateStep('confirmUpdateDownload -> 已在下载中,忽略重复点击');
return;
}
this.logUpdateStep('confirmUpdateDownload -> 用户确认更新,准备下载');
this.startUpdateDownload();
},
startUpdateDownload() {
this.logUpdateStep('startUpdateDownload -> 开始下载流程', {
url: this.updateInfo.url,
file: this.updateInfo.file
});
if (!this.updateInfo.url) {
this.updateErrorMessage = '未获取到下载地址';
this.logUpdateStep('startUpdateDownload -> 缺少下载地址,终止');
return;
}
this.isDownloadingUpdate = true;
this.updateDownloadProgress = 0;
this.updateErrorMessage = '';
const downloadTask = uni.downloadFile({
url: this.updateInfo.url,
success: (res) => {
this.updateTask = null;
this.logUpdateStep('startUpdateDownload -> 下载完成回调', {
statusCode: res.statusCode,
tempFilePath: res.tempFilePath
});
if (res.statusCode !== 200 || !res.tempFilePath) {
this.isDownloadingUpdate = false;
this.updateErrorMessage = '安装包下载失败';
this.logUpdateStep('startUpdateDownload -> 下载结果无效,终止');
return;
}
this.updateDownloadProgress = 100;
this.logUpdateStep('startUpdateDownload -> 下载成功,准备打开文件');
this.openDownloadedFile(res.tempFilePath);
},
fail: (error) => {
this.updateTask = null;
this.isDownloadingUpdate = false;
this.updateErrorMessage = error?.errMsg || '安装包下载失败';
this.logUpdateStep('startUpdateDownload -> 下载失败', error);
}
});
this.updateTask = downloadTask;
this.logUpdateStep('startUpdateDownload -> downloadTask 已创建');
if (downloadTask && typeof downloadTask.onProgressUpdate === 'function') {
downloadTask.onProgressUpdate((progressEvent) => {
this.updateDownloadProgress = Number(progressEvent.progress || 0);
this.logUpdateStep('startUpdateDownload -> 下载进度', {
progress: this.updateDownloadProgress,
totalBytesWritten: progressEvent.totalBytesWritten,
totalBytesExpectedToWrite: progressEvent.totalBytesExpectedToWrite
});
});
} else {
this.logUpdateStep('startUpdateDownload -> 当前环境不支持进度回调');
}
},
openDownloadedFile(filePath) {
this.logUpdateStep('openDownloadedFile -> 尝试打开下载文件', {
filePath
});
if (typeof plus === 'undefined' || !plus.runtime || typeof plus.runtime.openFile !== 'function') {
this.updateTask = null;
this.isDownloadingUpdate = false;
this.updateErrorMessage = '当前环境不支持打开安装包';
this.logUpdateStep('openDownloadedFile -> 环境不支持 plus.runtime.openFile');
return;
}
try {
plus.runtime.openFile(filePath, {}, () => {
this.updateTask = null;
this.isDownloadingUpdate = false;
this.updateErrorMessage = '';
this.showUpdateDialog = false;
this.logUpdateStep('openDownloadedFile -> 文件打开成功,更新流程完成');
}, (error) => {
this.updateTask = null;
this.isDownloadingUpdate = false;
this.updateErrorMessage = error?.message || '文件已下载,但打开失败';
this.logUpdateStep('openDownloadedFile -> 文件打开失败', error);
});
} catch (error) {
this.updateTask = null;
this.isDownloadingUpdate = false;
this.updateErrorMessage = error?.message || '文件已下载,但打开失败';
this.logUpdateStep('openDownloadedFile -> 调用异常', error);
}
}
}
};
</script>
<style lang="scss" scoped>
.update-mask {
position: fixed;
left: 0;
top: 0;
right: 0;
bottom: 0;
background: rgba(0, 0, 0, 0.48);
display: flex;
align-items: center;
justify-content: center;
z-index: 9999;
padding: 32rpx;
box-sizing: border-box;
}
.update-dialog {
width: 100%;
max-width: 680rpx;
background: #fff;
border-radius: 24rpx;
padding: 36rpx;
box-sizing: border-box;
box-shadow: 0 24rpx 80rpx rgba(0, 0, 0, 0.18);
}
.update-header {
display: flex;
flex-direction: column;
margin-bottom: 28rpx;
}
.update-title {
font-size: 36rpx;
font-weight: 600;
color: #222;
}
/* 旧真机 WebView 不支持 flex gap,改用 margin 控制间距 */
.update-version {
margin-top: 10rpx;
font-size: 24rpx;
color: #5c6b77;
}
.update-body {
display: flex;
flex-direction: column;
}
.update-row {
display: flex;
justify-content: space-between;
align-items: flex-start;
}
.update-label {
margin-right: 20rpx;
font-size: 26rpx;
color: #86909c;
flex-shrink: 0;
}
.update-value {
font-size: 26rpx;
color: #333;
text-align: right;
word-break: break-all;
}
.update-tip-box {
background: #f6f9ff;
border-radius: 16rpx;
padding: 24rpx;
display: flex;
flex-direction: column;
}
.update-tip {
font-size: 26rpx;
line-height: 1.6;
color: #4e5969;
}
.update-tip + .update-tip {
margin-top: 12rpx;
}
/* 主体内各区块间距:不用 flex gap,兼容旧真机 */
.update-row + .update-row,
.update-tip-box,
.update-progress-section,
.update-error {
margin-top: 20rpx;
}
.update-progress-head {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 14rpx;
}
.update-progress-text {
font-size: 26rpx;
color: #333;
}
.update-progress-bar {
height: 18rpx;
background: #eef1f5;
border-radius: 999rpx;
overflow: hidden;
}
.update-progress-inner {
height: 100%;
background: linear-gradient(90deg, #2979ff, #19be6b);
border-radius: 999rpx;
transition: width 0.2s ease;
}
.update-error {
font-size: 24rpx;
color: #fa3534;
line-height: 1.6;
}
.update-actions {
display: flex;
margin-top: 32rpx;
}
.update-actions ::v-deep .u-button {
flex: 1;
}
/* 旧真机不支持 flex gap,按钮间距用兄弟选择器 margin 兜底 */
.update-actions ::v-deep .u-button + .u-button {
margin-left: 20rpx;
}
</style>

View File

@ -0,0 +1,204 @@
<template>
<view class="search-bar" :class="barClass">
<u-search
:value="value"
:placeholder="placeholder"
:bg-color="bgColor"
:disabled="disabled"
:focus="focus"
:input-style="inputStyleObj"
shape="round"
:show-action="false"
@input="handleInput"
@search="emitSearch"
@clear="emitClear"
></u-search>
<view class="search-actions">
<view v-if="showScan" class="scan-btn" :class="{ 'scan-btn--disabled': disabled }" @click="handleScanClick">
<u-icon :name="scanIcon" size="38rpx" :color="disabled ? '#c0c4cc' : '#2979ff'"></u-icon>
</view>
<view v-if="showScan && showSearch" class="search-divider"></view>
<view v-if="showSearch" class="search-btn" @click="emitSearch">
<text class="search-btn__text" :style="{ fontSize: searchTextFontSize }">{{ searchText }}</text>
</view>
</view>
</view>
</template>
<script>
export default {
name: 'SearchBar',
props: {
value: {
type: String,
default: ''
},
placeholder: {
type: String,
default: '请输入关键字'
},
showScan: {
type: Boolean,
default: true
},
showSearch: {
type: Boolean,
default: true
},
inputFontSize: {
type: String,
default: ''
},
searchTextFontSize: {
type: String,
default: '30rpx'
},
searchText: {
type: String,
default: '搜索'
},
scanIcon: {
type: String,
default: 'scan'
},
disabled: {
type: Boolean,
default: false
},
bgColor: {
type: String,
default: '#f5f5f5'
},
focus: {
type: Boolean,
default: false
}
},
computed: {
inputStyleObj() {
return this.inputFontSize ? { fontSize: this.inputFontSize } : {};
},
barClass() {
const cls = [];
if (this.showScan && this.showSearch) {
// 默认:扫码 + 搜索
} else if (!this.showScan && this.showSearch) {
cls.push('search-bar--no-scan');
} else if (this.showScan && !this.showSearch) {
cls.push('search-bar--scan-only');
} else {
cls.push('search-bar--no-actions');
}
return cls;
}
},
methods: {
handleInput(val) {
this.$emit('input', val);
},
handleScanClick() {
if (this.disabled) {
return;
}
this.$emit('scan');
},
emitSearch() {
this.$emit('search');
},
emitClear() {
this.$emit('clear');
}
}
};
</script>
<style lang="scss" scoped>
.search-bar {
position: relative;
flex: 1;
min-width: 0;
::v-deep .u-search {
width: 100%;
}
::v-deep .u-search__content {
padding-right: 200rpx;
}
::v-deep .u-search__content__close {
margin-right: 12rpx;
}
&--no-scan {
::v-deep .u-search__content {
padding-right: 110rpx;
}
}
&--scan-only {
::v-deep .u-search__content {
padding-right: 80rpx;
}
}
&--no-actions {
::v-deep .u-search__content {
padding-right: 20rpx;
}
}
.search-actions {
position: absolute;
right: 24rpx;
top: 50%;
transform: translateY(-50%);
height: 68rpx;
display: flex;
align-items: center;
}
.scan-btn {
height: 68rpx;
padding: 0 8rpx 0 4rpx;
display: flex;
align-items: center;
justify-content: center;
&:active {
opacity: 0.88;
}
&--disabled {
opacity: 0.7;
}
}
.search-divider {
width: 1rpx;
height: 28rpx;
background: #dcdfe6;
margin: 0 16rpx 0 10rpx;
}
.search-btn {
height: 68rpx;
padding: 0 8rpx;
display: flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
&__text {
font-size: 30rpx;
font-weight: 500;
color: #2979ff;
line-height: 1;
}
&:active {
opacity: 0.88;
}
}
}
</style>

View File

@ -0,0 +1,281 @@
<template>
<!-- 统一弹窗规范:底部圆角弹层 + 居中标题 + 内置关闭按钮 + 安全区留白 -->
<u-popup :show="show" mode="bottom" round="20" :closeable="true" :safe-area-inset-bottom="true"
:close-on-click-overlay="!switching" @close="handleClose">
<view class="store-selector">
<view class="selector-header">
<text class="selector-title">切换仓库</text>
<text class="selector-subtitle">共 {{ list.length }} 个可用仓库</text>
</view>
<view v-if="currentName" class="selector-current">
<view class="selector-current__icon">
<u-icon name="home-fill" color="#3a7afe" size="16"></u-icon>
</view>
<text class="selector-current__label">当前仓库</text>
<text class="selector-current__name">{{ currentName }}</text>
</view>
<scroll-view class="selector-body" scroll-y>
<view v-if="!list.length" class="selector-empty">
<u-icon name="home" color="#c8c9cc" size="56"></u-icon>
<text class="selector-empty__text">暂无可切换的仓库</text>
</view>
<view v-for="(item, index) in list" :key="item.id || index" class="store-item"
:class="{ 'is-current': isCurrent(item), 'is-switching': isSwitching(item) }"
@click="handleSelect(item)">
<view class="store-item__main">
<view class="store-item__name-row">
<text class="store-item__name">{{ item.store_name || '未命名仓库' }}</text>
<text v-if="isCurrent(item)" class="store-item__badge">当前</text>
</view>
<text v-if="getDesc(item)" class="store-item__desc">{{ getDesc(item) }}</text>
</view>
<view class="store-item__right">
<u-loading-icon v-if="isSwitching(item)" mode="circle" size="18" color="#3a7afe"></u-loading-icon>
<u-icon v-else-if="isCurrent(item)" name="checkmark-circle-fill" color="#3a7afe"
size="22"></u-icon>
<u-icon v-else name="checkmark-circle" color="#c8c9cc" size="22"></u-icon>
</view>
</view>
</scroll-view>
</view>
</u-popup>
</template>
<script>
/**
* 仓库切换弹窗
* - show:是否显示(配合 :show + @update:show 使用)
* - employees:可选仓库列表(user.employees,每项对应一个仓库/角色)
* - currentId:当前仓库对应的员工/角色 ID(user.employees_id)
* - switchingId:正在切换中的仓库 ID,用于行内 loading
* - select:点击某个仓库时触发,由页面负责调用切换接口
*/
export default {
name: 'StoreSelector',
props: {
show: {
type: Boolean,
default: false
},
employees: {
type: Array,
default: () => []
},
currentId: {
type: [String, Number],
default: ''
},
switchingId: {
type: [String, Number],
default: ''
}
},
computed: {
list() {
return Array.isArray(this.employees) ? this.employees : [];
},
currentName() {
const current = this.list.find(item => this.isCurrent(item));
return current ? current.store_name || '' : '';
},
switching() {
return this.switchingId !== '' && this.switchingId !== null && typeof this.switchingId !== 'undefined';
}
},
methods: {
isCurrent(item) {
if (!item) return false;
return String(item.id) === String(this.currentId);
},
isSwitching(item) {
if (!item || !this.switching) return false;
return String(item.id) === String(this.switchingId);
},
getDesc(item) {
return item.store_remask || item.store_code || '';
},
handleSelect(item) {
if (!item || this.switching) return;
if (this.isCurrent(item)) {
this.handleClose();
return;
}
this.$emit('select', item);
},
handleClose() {
if (this.switching) return;
this.$emit('update:show', false);
this.$emit('close');
}
}
}
</script>
<style lang="scss" scoped>
.store-selector {
display: flex;
flex-direction: column;
max-height: 70vh;
background-color: #fff;
/* 顶部圆角与 u-popup 的 round=20(20px)保持一致,并裁切内部白底/分隔线 */
border-radius: 20px 20px 0 0;
overflow: hidden;
}
// 与首页「通知信息」等弹窗保持一致:居中标题 + 底部细分隔线
.selector-header {
display: flex;
flex-direction: column;
align-items: center;
padding: 32rpx 30rpx 24rpx;
border-bottom: 1rpx solid #f0f0f0;
}
.selector-title {
font-size: 38rpx;
font-weight: 600;
color: #333;
}
.selector-subtitle {
margin-top: 8rpx;
font-size: 24rpx;
color: #909399;
}
// 当前仓库摘要
.selector-current {
display: flex;
align-items: center;
margin: 24rpx 30rpx 0;
padding: 20rpx 24rpx;
border-radius: 16rpx;
background-color: #f6f8fb;
&__icon {
width: 36rpx;
display: flex;
align-items: center;
justify-content: center;
margin-right: 12rpx;
}
&__label {
font-size: 24rpx;
color: #909399;
margin-right: 12rpx;
flex-shrink: 0;
}
&__name {
flex: 1;
min-width: 0;
font-size: 32rpx;
font-weight: 500;
color: #303133;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
}
.selector-body {
flex: 1;
max-height: 46vh;
box-sizing: border-box;
padding: 8rpx 30rpx 30rpx;
}
.selector-empty {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 80rpx 0;
&__text {
margin-top: 20rpx;
font-size: 30rpx;
color: #909399;
}
}
.store-item {
display: flex;
align-items: center;
padding: 26rpx 24rpx;
margin-top: 16rpx;
border-radius: 16rpx;
background-color: #f6f8fb;
border: 2rpx solid transparent;
transition: background-color 0.2s, border-color 0.2s;
&.is-current {
background-color: rgba(58, 122, 254, 0.08);
border-color: rgba(58, 122, 254, 0.35);
}
&.is-switching {
opacity: 0.75;
}
&:active {
background-color: #eef1f6;
}
&__main {
flex: 1;
min-width: 0;
display: flex;
flex-direction: column;
}
&__name-row {
display: flex;
align-items: center;
}
&__name {
font-size: 34rpx;
color: #303133;
font-weight: 500;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
&__badge {
margin-left: 12rpx;
padding: 0 10rpx;
height: 32rpx;
line-height: 32rpx;
border-radius: 8rpx;
font-size: 20rpx;
color: #3a7afe;
background-color: rgba(58, 122, 254, 0.14);
flex-shrink: 0;
}
&__desc {
margin-top: 6rpx;
font-size: 30rpx;
color: #909399;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
&__right {
margin-left: 16rpx;
width: 44rpx;
display: flex;
align-items: center;
justify-content: flex-end;
flex-shrink: 0;
}
}
</style>

View File

@ -11,13 +11,12 @@
<u-input <u-input
v-model="searchText" v-model="searchText"
placeholder="请输入关键词搜索" placeholder="请输入关键词搜索"
:border="searchBorder"
prefixIcon="search"
prefixIconStyle="color: #909399; font-size: 18px"
clearable clearable
@input="handleSearch" @input="handleSearch"
> ></u-input>
<template #prefix>
<u-icon name="search" size="18" color="#909399"></u-icon>
</template>
</u-input>
</view> </view>
<!-- 底部列表 --> <!-- 底部列表 -->
@ -26,13 +25,21 @@
scroll-y="true" scroll-y="true"
:style="{ height: listHeight + 'rpx' }" :style="{ height: listHeight + 'rpx' }"
> >
<view
v-if="showCreateAction"
class="list-item list-item--create"
@click="handleCreate"
>
<text class="item-text item-text--create">新增“{{ normalizedSearchText }}”</text>
<u-icon name="plus" color="#2979ff" size="22"></u-icon>
</view>
<view class="list-item" <view class="list-item"
v-for="item in filteredList" v-for="item in filteredList"
:key="item.value" :key="item.value"
:class="{ active: selectedValue === item.value }" :class="{ active: selectedValue === item.value }"
@click="handleSelect(item)" @click="handleSelect(item)"
> >
<text class="item-text">{{ item.label }}</text> <text class="item-text" :style="{ fontSize: itemFontSize + 'rpx' }">{{ item.label }}</text>
<u-icon <u-icon
v-if="selectedValue === item.value" v-if="selectedValue === item.value"
name="checkbox-mark" name="checkbox-mark"
@ -68,6 +75,37 @@
listHeight: { listHeight: {
type: Number, type: Number,
default: 600 default: 600
},
itemFontSize: {
type: Number,
default: 28
},
allowCreate: {
type: Boolean,
default: false
},
searchBorder: {
type: String,
default: 'surround'
}
},
computed: {
normalizedSearchText() {
return String(this.searchText || '').trim();
},
showCreateAction() {
if (!this.allowCreate || !this.normalizedSearchText) {
return false;
}
return !this.list.some(item => {
if (!item || typeof item !== 'object') {
return false;
}
const label = String(item.label || '').trim().toLowerCase();
return label === this.normalizedSearchText.toLowerCase();
});
} }
}, },
data() { data() {
@ -96,11 +134,41 @@
} }
}, },
methods: { methods: {
normalizeInputText(raw) {
if (typeof raw === 'string') {
return raw;
}
if (typeof raw === 'number') {
return String(raw);
}
if (raw && typeof raw === 'object') {
if (typeof raw.detail === 'string') {
return raw.detail;
}
if (raw.detail && typeof raw.detail.value === 'string') {
return raw.detail.value;
}
if (raw.target && typeof raw.target.value === 'string') {
return raw.target.value;
}
if (typeof raw.value === 'string') {
return raw.value;
}
}
return '';
},
handleClose() { handleClose() {
this.$emit('close'); this.$emit('close');
}, },
handleSearch() { handleSearch(raw) {
if (typeof raw !== 'undefined') {
const nextText = this.normalizeInputText(raw);
if (nextText !== this.searchText) {
this.searchText = nextText;
}
}
if (!this.searchText.trim()) { if (!this.searchText.trim()) {
this.filteredList = [...this.list]; this.filteredList = [...this.list];
return; return;
@ -126,6 +194,15 @@
this.$emit('change', null); this.$emit('change', null);
// 关闭弹窗 // 关闭弹窗
this.$emit('close'); this.$emit('close');
},
handleCreate() {
const value = this.normalizedSearchText;
if (!value) {
return;
}
this.$emit('create', value);
this.$emit('close');
} }
} }
} }
@ -163,6 +240,18 @@
background-color: #f5f7fa; background-color: #f5f7fa;
border-radius: 10rpx; border-radius: 10rpx;
padding: 0 20rpx; padding: 0 20rpx;
min-height: 84rpx;
display: flex;
align-items: center;
::v-deep .u-input {
height: 76rpx;
}
::v-deep .u-input__content {
height: 76rpx;
align-items: center;
}
} }
.quick-filter { .quick-filter {
@ -223,5 +312,14 @@
border-bottom: none; border-bottom: none;
} }
} }
.list-item--create {
background: #f4f8ff;
}
.item-text--create {
color: #2979ff !important;
font-weight: 600;
}
} }
</style> </style>

View File

@ -2,9 +2,12 @@
<view class="nav-wrap"> <view class="nav-wrap">
<view class="status_bar"></view> <view class="status_bar"></view>
<view class="nav-title"> <view class="nav-title">
<view class="left" @click="back"> <view class="left">
<u-icon v-if="showBack" name="arrow-left"></u-icon> <view class="left-back" @click="back">
<u-icon v-else name="home" @click="toHome"></u-icon> <u-icon v-if="effectiveShowBack" name="arrow-left"></u-icon>
<u-icon v-else name="home" @click="toHome"></u-icon>
</view>
<slot name="left"></slot>
</view> </view>
<view class="title">{{title}}</view> <view class="title">{{title}}</view>
<view class="right"> <view class="right">
@ -18,25 +21,39 @@
export default { export default {
props: { props: {
title: String, title: String,
showBack: {
type: Boolean,
default: undefined
}
}, },
data() { data() {
return { return {
showBack: true, // 默认显示返回按钮 internalShowBack: true, // 默认显示返回按钮
pagesLength: 0 pagesLength: 0
} }
}, },
computed: {
effectiveShowBack() {
// 如果父组件显式传了 showBack,优先使用;否则用自动检测值
return this.showBack !== undefined ? this.showBack : this.internalShowBack;
}
},
methods: { methods: {
checkPagesLength() { checkPagesLength() {
// 获取当前页面栈 // 获取当前页面栈
const pages = getCurrentPages(); const pages = getCurrentPages();
this.pagesLength = pages.length; this.pagesLength = pages.length;
this.showBack = pages.length > 1; this.internalShowBack = pages.length > 1;
console.log('当前页面栈长度:', pages.length, '显示返回按钮:', this.showBack); console.log('当前页面栈长度:', pages.length, '显示返回按钮:', this.internalShowBack);
}, },
back() { back() {
console.log("返回"); console.log("返回");
if (this.$listeners && this.$listeners.back) {
this.$emit('back');
return;
}
if (this.showBack) { if (this.effectiveShowBack) {
// 有上一页,正常返回 // 有上一页,正常返回
uni.navigateBack({ uni.navigateBack({
delta: 1, delta: 1,
@ -53,6 +70,12 @@
}, },
toHome() { toHome() {
console.log('跳转到首页'); console.log('跳转到首页');
const pages = getCurrentPages();
const currentRoute = pages.length ? `/${pages[pages.length - 1].route || ''}` : '';
if (currentRoute === '/pages/index/index') {
console.log('当前已在首页,取消重复跳转');
return;
}
// 根据你的路由配置调整首页路径 // 根据你的路由配置调整首页路径
// 假设首页是 tabBar 页面 // 假设首页是 tabBar 页面
@ -92,19 +115,28 @@
/* #endif */ /* #endif */
flex-direction: row; flex-direction: row;
align-items: center; align-items: center;
justify-content: flex-start; justify-content: space-between;
height:110rpx; height:110rpx;
line-height:110rpx; line-height:110rpx;
background: #FFF; background: #FFF;
justify-content: space-between;
padding:0 20rpx; padding:0 20rpx;
position: relative;
.left { .left {
width: 80rpx; min-width: 80rpx;
height: 80rpx; height: 80rpx;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: flex-start;
gap: 10rpx;
.left-back {
width: 80rpx;
height: 80rpx;
display: flex;
align-items: center;
justify-content: center;
}
.u-icon { .u-icon {
font-size: 40rpx; font-size: 40rpx;
@ -112,15 +144,20 @@
} }
.title { .title {
flex: 1; position: absolute;
text-align: center; left: 50%;
font-size: 32rpx; transform: translateX(-50%);
white-space: nowrap;
font-size: 36rpx;
font-weight: bold; font-weight: bold;
color: #333; color: #333;
} }
.right { .right {
width: 80rpx; min-width: 80rpx;
display: flex;
align-items: center;
justify-content: flex-end;
} }
} }

View File

@ -25,7 +25,7 @@
<!-- 总数显示(可选) --> <!-- 总数显示(可选) -->
<view v-if="showTotal" class="total-info"> <view v-if="showTotal" class="total-info">
总数:{{ total }} 总数:<text class="total-info__num">{{ total }}</text>
</view> </view>
</view> </view>
</template> </template>
@ -219,7 +219,14 @@ export default {
.total-info { .total-info {
margin-left: 40rpx; margin-left: 40rpx;
color: #909399; color: #909399;
font-size: 24rpx; font-size: 28rpx;
.total-info__num {
margin-left: 4rpx;
color: #2979ff;
font-size: 34rpx;
font-weight: bold;
}
} }

View File

@ -10,8 +10,16 @@
<!-- 搜索框 --> <!-- 搜索框 -->
<view class="search-box" v-if="showSearch"> <view class="search-box" v-if="showSearch">
<u-search v-model="searchKeyword" placeholder="搜索货位编码、自定义名称" bg-color="#f5f5f5" shape="round" <SearchBar
:show-action="false" @search="handleSearch" @clear="handleSearch"></u-search> v-model="searchKeyword"
placeholder="搜索货位编码、自定义名称"
:show-scan="false"
:show-search="false"
:input-font-size="'34rpx'"
:search-text-font-size="'34rpx'"
@search="handleSearch"
@clear="handleSearch"
></SearchBar>
</view> </view>
<!-- 货位列表 --> <!-- 货位列表 -->

View File

@ -0,0 +1,919 @@
<template>
<u-upload
ref="uUploadRef"
:fileList="fileList"
:maxCount="maxCount"
:multiple="multiple"
:disabled="disabled"
@afterRead="handleAfterRead"
@delete="handleDelete"
>
</u-upload>
</template>
<script>
export default {
name: "UploadImgCos",
props: {
business_type: {
type: String,
required: true
},
business_id: {
type: Number,
required: true
},
value: {
type: Array,
default: () => []
},
maxCount: {
type: Number,
default: 6
},
multiple: {
type: Boolean,
default: true
},
disabled: {
type: Boolean,
default: false
}
},
data() {
return {
internalFileList: [],
knownFileIds: [],
// 记录正在上传的文件,用于避免重复上传
uploadingFiles: new Set()
};
},
computed: {
fileList: {
get() {
return this.internalFileList;
},
set(value) {
this.internalFileList = value;
}
}
},
watch: {
business_id: {
immediate: true,
handler() {
this.knownFileIds = [];
}
},
value: {
immediate: true,
handler(newVal) {
this.formatFileList(newVal);
}
}
},
methods: {
resolveDeleteIndex(payload) {
const normalizeIndex = (value) => {
const numeric = Number(value);
if (!Number.isFinite(numeric)) {
return -1;
}
const index = Math.trunc(numeric);
return index >= 0 ? index : -1;
};
if (typeof payload === 'number' || typeof payload === 'string') {
return normalizeIndex(payload);
}
if (!payload || typeof payload !== 'object') {
return -1;
}
const directIndex = normalizeIndex(payload.index);
if (directIndex >= 0) {
return directIndex;
}
const detailIndex = normalizeIndex(payload.detail && payload.detail.index);
if (detailIndex >= 0) {
return detailIndex;
}
const file = payload.file || (payload.detail && payload.detail.file) || null;
if (!file || typeof file !== 'object') {
return -1;
}
const fileId = this.getFileId(file);
if (fileId) {
const byIdIndex = this.fileList.findIndex(item => this.getFileId(item) === fileId);
if (byIdIndex >= 0) {
return byIdIndex;
}
}
const fileUrl = file.url || file.path || file.successUrl || '';
if (fileUrl) {
return this.fileList.findIndex(item => (item.url || item.path || item.successUrl || '') === fileUrl);
}
return -1;
},
getFileId(file) {
if (!file || typeof file !== 'object') {
return '';
}
return file.id || file.fileId || file.file_id || (file.file && (file.file.id || file.file.fileId || file.file.file_id)) || '';
},
normalizeNumericFileIds(fileIds = []) {
return Array.from(new Set((Array.isArray(fileIds) ? fileIds : [fileIds])
.map(fileId => Number(fileId))
.filter(fileId => Number.isFinite(fileId) && fileId > 0)));
},
collectFileIdsFromList(fileList = []) {
if (!Array.isArray(fileList)) {
return [];
}
return this.normalizeNumericFileIds(fileList.map(item => this.getFileId(item)));
},
mergeKnownFileIds(fileIds = []) {
this.knownFileIds = this.normalizeNumericFileIds([...(this.knownFileIds || []), ...fileIds]);
},
replaceKnownFileIds(fileIds = []) {
this.knownFileIds = this.normalizeNumericFileIds(fileIds);
},
extractImageListFromGetImagesResponse(response) {
if (!response || typeof response !== 'object') {
return [];
}
const candidates = [
response.data,
response.data && response.data.data,
response.data && response.data.images,
response.data && response.data.list,
response.data && response.data.rows,
response.data && response.data.records,
response.data && response.data.result,
response.data && response.data.result && response.data.result.images,
response.data && response.data.result && response.data.result.list,
response.images,
response.list,
response.rows,
response.records
];
for (let i = 0; i < candidates.length; i++) {
const current = candidates[i];
if (!current) {
continue;
}
if (Array.isArray(current)) {
return current;
}
if (typeof current === 'object') {
const objectCandidates = [current.images, current.list, current.rows, current.records, current.data];
for (let j = 0; j < objectCandidates.length; j++) {
if (Array.isArray(objectCandidates[j])) {
return objectCandidates[j];
}
}
}
}
return [];
},
getRemoteFileId(file) {
if (!file || typeof file !== 'object') {
return '';
}
return file.file_id
|| file.fileId
|| file.id
|| file.image_id
|| (file.file && (file.file.file_id || file.file.fileId || file.file.id))
|| '';
},
normalizeFileUrl(url) {
if (!url || typeof url !== 'string') {
return '';
}
const trimmed = url.trim();
if (!trimmed) {
return '';
}
return trimmed.split('?')[0].split('#')[0];
},
getFileUrlSignature(url) {
const normalizedUrl = this.normalizeFileUrl(url);
if (!normalizedUrl) {
return '';
}
const withoutProtocol = normalizedUrl.replace(/^https?:\/\//i, '');
const pathWithHost = withoutProtocol.split('/');
if (pathWithHost.length <= 1) {
return withoutProtocol.toLowerCase();
}
const pathOnly = '/' + pathWithHost.slice(1).join('/');
const pathParts = pathOnly.split('/').filter(Boolean);
if (!pathParts.length) {
return pathOnly.toLowerCase();
}
const tail = pathParts.slice(-2).join('/').toLowerCase();
return tail || pathOnly.toLowerCase();
},
getRemoteFileUrl(file) {
if (!file || typeof file !== 'object') {
return '';
}
return this.normalizeFileUrl(
file.url
|| file.path
|| file.fileUrl
|| file.file_url
|| file.image_url
|| file.img_url
|| file.src
|| (file.file && (file.file.file_url || file.file.url || file.file.path || file.file.fileUrl))
|| ''
);
},
async getRemoteImageEntries() {
if (!this.business_id) {
return [];
}
const response = await this.$http('common.getImages', {
type: this.business_type,
id: Number(this.business_id)
});
const entries = this.extractImageListFromGetImagesResponse(response)
.map(item => ({
fileId: this.getRemoteFileId(item),
url: this.getRemoteFileUrl(item)
}))
.filter(item => item.fileId || item.url);
this.mergeKnownFileIds(entries.map(item => item.fileId));
return entries;
},
async getRemoteFileIds() {
if (!this.business_id) {
return [];
}
try {
return (await this.getRemoteImageEntries())
.map(item => item.fileId)
.filter(Boolean);
} catch (error) {
if (process.env.NODE_ENV !== 'production') {
console.warn('[UploadImgCos] getRemoteFileIds failed', error);
}
return [];
}
},
async resolveDeletedFileIds(deletedFile, options = {}) {
const deletedIndex = Number(options.deletedIndex);
const hasValidDeletedIndex = Number.isFinite(deletedIndex) && deletedIndex >= 0;
const deletedIds = [];
const directId = this.getFileId(deletedFile);
if (directId) {
deletedIds.push(directId);
}
if (deletedIds.length > 0) {
return Array.from(new Set(deletedIds));
}
const deletedUrl = this.normalizeFileUrl(
(deletedFile && (deletedFile.url || deletedFile.path || deletedFile.successUrl)) || ''
);
const deletedUrlSignature = this.getFileUrlSignature(deletedUrl);
if (!deletedUrl) {
if (!hasValidDeletedIndex) {
return [];
}
}
try {
const remoteEntries = await this.getRemoteImageEntries();
let matched = remoteEntries
.filter(item => item.fileId && item.url && item.url === deletedUrl)
.map(item => item.fileId);
if (!matched.length && deletedUrlSignature) {
matched = remoteEntries
.filter(item => item.fileId && this.getFileUrlSignature(item.url) === deletedUrlSignature)
.map(item => item.fileId);
}
if (!matched.length && hasValidDeletedIndex && remoteEntries[deletedIndex] && remoteEntries[deletedIndex].fileId) {
matched = [remoteEntries[deletedIndex].fileId];
}
return Array.from(new Set(matched));
} catch (error) {
if (process.env.NODE_ENV !== 'production') {
console.warn('[UploadImgCos] resolveDeletedFileIds failed', error);
}
return [];
}
},
/**
* 格式化文件列表
*/
formatFileList(externalList) {
if (!externalList || !Array.isArray(externalList)) {
this.internalFileList = [];
return;
}
this.internalFileList = externalList.map(item => {
if (item.status) {
return {
...item,
id: this.getFileId(item)
};
}
return {
url: item.url || item.path || '',
name: item.name || this.extractFileName(item.url) || '',
status: 'success',
message: '',
id: this.getFileId(item)
};
});
const listFileIds = this.collectFileIdsFromList(this.internalFileList);
if (listFileIds.length > 0) {
this.mergeKnownFileIds(listFileIds);
}
},
/**
* 提取文件名
*/
extractFileName(filePath) {
if (!filePath || typeof filePath !== 'string') return null;
return filePath.split(/[\\/]/).pop();
},
/**
* 获取文件MD5
*/
async getFileMd5(filePath) {
return new Promise((resolve, reject) => {
uni.getFileInfo({
filePath,
digestAlgorithm: "md5",
success: resolve,
fail: reject
});
});
},
/**
* 处理文件选择
*/
async handleAfterRead(event) {
if (this.disabled) return;
const { file, name } = event;
const files = Array.isArray(file) ? file : [file];
// 检查数量限制
const remainingSlots = this.maxCount - this.fileList.length;
if (remainingSlots <= 0) {
uni.showToast({
title: `最多只能上传${this.maxCount}个文件`,
icon: 'none'
});
return;
}
const filesToUpload = files.slice(0, remainingSlots);
// 添加文件到列表(初始状态为pending)
const startIndex = this.fileList.length;
filesToUpload.forEach((file) => {
this.fileList.push({
...file,
status: "pending",
message: "等待上传"
});
});
// 串行上传
for (let i = 0; i < filesToUpload.length; i++) {
const fileIndex = startIndex + i;
await this.processFileUpload(filesToUpload[i], fileIndex);
}
},
/**
* 处理单个文件上传流程
*/
async processFileUpload(file, fileIndex) {
try {
// 检查是否已经在上传
const fileKey = `${file.url}_${file.size}`;
if (this.uploadingFiles.has(fileKey)) {
return;
}
this.uploadingFiles.add(fileKey);
// 1. 获取文件MD5
const fileInfo = await this.getFileMd5(file.url);
const fileName = this.extractFileName(file.url) || file.name;
// 2. 更新状态为上传中
this.fileList[fileIndex] = {
...file,
status: "uploading",
message: "上传中",
md5: fileInfo.digest
};
// 3. 获取COS上传配置
const uploadConfig = await this.$http('common.getCOSUploadConfig', {
data: {
fileName,
fileSize: fileInfo.size,
fileType: file.type,
id: this.business_id,
md5: fileInfo.digest,
type: this.business_type,
}
});
const configData = uploadConfig.data;
if (!configData) {
throw new Error("获取上传配置失败");
}
console.log(configData);
if(configData.fileId){
// 如果后端已经返回了fileId,说明文件已存在,无需上传,直接通知后端关联即可
this.fileList[fileIndex] = {
...this.fileList[fileIndex],
status: "success",
message: "",
url: configData.fileUrl,
id: configData.fileId,
successUrl: configData.fileUrl // 保存成功后的URL
};
await this.referenceFiles({
source: 'upload'
});
return ;
}
// 4. 执行COS上传(这里不会返回响应数据)
await this.uploadToCOS(file.url, configData, fileIndex);
// 5. 通知后端上传完成
const notifyResult = await this.notifyUploadComplete(configData.fileInfo, fileIndex);
console.log("后端上传成功返回",JSON.stringify(notifyResult));
// 6. 更新状态为成功
if (notifyResult.data?.data) {
const { fileUrl, fileId } = notifyResult.data.data;
this.fileList[fileIndex] = {
...this.fileList[fileIndex],
status: "success",
message: "",
url: fileUrl,
id: fileId,
successUrl: fileUrl // 保存成功后的URL
};
// 7. 关联文件
await this.referenceFiles({
source: 'upload'
});
// 触发成功事件
this.$emit('upload-success', {
file: this.fileList[fileIndex],
index: fileIndex
});
}
} catch (error) {
console.error("上传流程失败:", error);
this.fileList[fileIndex] = {
...this.fileList[fileIndex],
status: "error",
message: error.message || "上传失败"
};
} finally {
// 清理上传记录
const fileKey = `${file.url}_${file.size}`;
this.uploadingFiles.delete(fileKey);
}
},
/**
* 上传文件到COS(关键修改:不需要处理响应)
*/
uploadToCOS(filePath, config, fileIndex) {
return new Promise((resolve, reject) => {
// COS上传不会返回数据,所以这里只是发起请求
const uploadTask = uni.uploadFile({
url: config.uploadUrl, // 应该从config中获取
filePath: filePath,
name: 'file',
formData: config.data,
// COS上传成功不会有响应体,只会有状态码
success: (res) => {
// 注意:COS返回的HTTP状态码成功通常是204或200,但没有响应体
if (res.statusCode === 200 || res.statusCode === 204) {
resolve();
} else {
reject(new Error(`COS上传失败,状态码: ${res.statusCode}`));
}
},
fail: (error) => {
reject(new Error("COS上传请求失败"));
}
});
// 可以监听上传进度
uploadTask.onProgressUpdate = (res) => {
this.fileList[fileIndex] = {
...this.fileList[fileIndex],
progress: res.progress,
message: `上传中 ${res.progress}%`
};
// 触发进度事件
this.$emit('upload-progress', {
index: fileIndex,
progress: res.progress,
totalBytesSent: res.totalBytesSent,
totalBytesExpectedToSend: res.totalBytesExpectedToSend
});
};
});
},
/**
* 通知后端上传完成
*/
async notifyUploadComplete(config, fileIndex) {
try {
// 调用后端接口,通知COS上传已完成
const response = await this.$http('common.uploadSuccessNotify', {
...config,
fileInfo: {
fileName: config.fileName,
fileSize: config.fileSize,
fileType: config.fileType,
md5: config.md5
}
});
return response;
} catch (error) {
console.error("上传完成通知失败:", error);
throw error;
}
},
/**
* 关联文件
*/
async referenceFiles(options = {}) {
const { mergeRemote = true, excludedFileIds = [], excludedFileUrls = [], source = '', explicitFileIds = null } = options;
console.log("this.fileList",this.fileList);
try {
const explicitIds = Array.isArray(explicitFileIds)
? explicitFileIds
.map(fileId => Number(fileId))
.filter(fileId => Number.isFinite(fileId) && fileId > 0)
: null;
if (explicitIds) {
const validFiles = Array.from(new Set(explicitIds)).map(fileId => ({ file_id: fileId }));
if (process.env.NODE_ENV !== 'production') {
console.log('[UploadImgCos] ReferenceFile payload debug', {
source,
business_id: this.business_id,
type: this.business_type,
explicit_file_ids: validFiles.map(item => item.file_id)
});
}
const requestPayload = {
id: this.business_id,
type: this.business_type,
images: validFiles
};
console.log('[UploadImgCos] ReferenceFile request', {
source,
payload: requestPayload
});
const response = await this.$http('common.ReferenceFile', requestPayload);
console.log('[UploadImgCos] ReferenceFile response', {
source,
response
});
this.replaceKnownFileIds(validFiles.map(item => item.file_id));
this.$emit('change', this.fileList);
this.$emit('input', this.fileList);
return response;
}
// 获取当前本地成功文件(以本地列表为准)
const localEntries = this.fileList
.filter(item => {
const status = String((item && item.status) || '').toLowerCase();
if (!status) {
return true;
}
return status !== 'uploading' && status !== 'pending' && status !== 'error';
})
.map(item => ({
fileId: this.getFileId(item),
url: this.normalizeFileUrl(item.url || item.path || item.successUrl || '')
}));
const remoteEntries = mergeRemote ? await this.getRemoteImageEntries() : [];
const remoteFileIds = (remoteEntries || []).map(item => item.fileId).filter(Boolean);
const localFileIds = (localEntries || []).map(item => item.fileId).filter(Boolean);
const knownFileIds = this.normalizeNumericFileIds(this.knownFileIds || []);
const excludedSet = new Set(
(Array.isArray(excludedFileIds) ? excludedFileIds : [excludedFileIds])
.filter(Boolean)
.map(fileId => String(fileId))
);
const excludedUrlSet = new Set(
(Array.isArray(excludedFileUrls) ? excludedFileUrls : [excludedFileUrls])
.map(url => this.normalizeFileUrl(url))
.filter(Boolean)
);
// 优先使用本地已有file_id;若本地项缺失file_id,则按URL从远端补全
const localUrlSet = new Set(
localEntries
.map(item => this.normalizeFileUrl(item.url || ''))
.filter(Boolean)
);
const recoveredFileIds = mergeRemote
? (remoteEntries || [])
.filter(item => {
const normalizedUrl = this.normalizeFileUrl(item && item.url ? item.url : '');
return normalizedUrl && localUrlSet.has(normalizedUrl);
})
.map(item => item.fileId)
.filter(Boolean)
: [];
const shouldKeepAllRemoteIds = mergeRemote && source !== 'delete';
const candidateFileIds = shouldKeepAllRemoteIds
? [...knownFileIds, ...(remoteFileIds || []), ...(localFileIds || [])]
: [...knownFileIds, ...(localFileIds || []), ...(recoveredFileIds || [])];
const mergedFileIds = Array.from(new Set(candidateFileIds
.map(fileId => String(fileId))
.filter(Boolean)))
.filter(fileId => !excludedSet.has(fileId))
.map(fileId => Number(fileId))
.filter(fileId => Number.isFinite(fileId) && fileId > 0);
const validFiles = mergedFileIds.map(fileId => ({ file_id: fileId }));
if (process.env.NODE_ENV !== 'production') {
console.log('[UploadImgCos] ReferenceFile payload debug', {
source,
business_id: this.business_id,
type: this.business_type,
merge_remote: mergeRemote,
excluded_file_ids: Array.from(excludedSet),
excluded_file_urls: Array.from(excludedUrlSet),
remote_file_ids: remoteFileIds,
local_file_ids: localFileIds,
file_ids: validFiles.map(item => item.file_id),
file_list: this.fileList.map(item => ({
url: item.url || item.path || item.successUrl || '',
status: item.status,
id: this.getFileId(item)
}))
});
}
if (validFiles.length === 0) {
// 如果没有成功文件,也要通知后端清空关联
const requestPayload = {
id: this.business_id,
type: this.business_type,
images: []
};
console.log('[UploadImgCos] ReferenceFile request', {
source,
payload: requestPayload
});
const response = await this.$http('common.ReferenceFile', requestPayload);
console.log('[UploadImgCos] ReferenceFile response', {
source,
response
});
this.replaceKnownFileIds([]);
// 更新外部绑定
this.$emit('change', this.fileList);
this.$emit('input', this.fileList);
return response;
}
const requestPayload = {
id: this.business_id,
type: this.business_type,
images: validFiles
};
console.log('[UploadImgCos] ReferenceFile request', {
source,
payload: requestPayload
});
const response = await this.$http('common.ReferenceFile', requestPayload);
console.log('[UploadImgCos] ReferenceFile response', {
source,
response
});
this.replaceKnownFileIds(validFiles.map(item => item.file_id));
// 更新外部绑定
this.$emit('change', this.fileList);
this.$emit('input', this.fileList);
return response;
} catch (error) {
console.error("关联文件失败:", error);
throw error;
}
},
/**
* 处理删除 - 修正版本
*/
async handleDelete(payload) {
const index = this.resolveDeleteIndex(payload);
if (index < 0 || index >= this.fileList.length) {
console.warn('[UploadImgCos] 删除图片失败:无法定位删除项', payload);
return;
}
const deletedFile = this.fileList[index];
const deletedFileUrl = this.normalizeFileUrl(
(deletedFile && (deletedFile.url || deletedFile.path || deletedFile.successUrl)) || ''
);
// 从列表中移除
this.fileList.splice(index, 1);
// 立即更新UI
this.$emit('delete', {
file: deletedFile,
index
});
// 更新外部绑定(立即更新,不等待)
this.$emit('change', this.fileList);
this.$emit('input', this.fileList);
// 异步更新文件关联:删除场景显式提交“剩余file_id”,避免误清空
try {
const remoteEntries = await this.getRemoteImageEntries();
const deletedFileIds = await this.resolveDeletedFileIds(deletedFile, {
deletedIndex: index
});
const deletedIdSet = new Set((deletedFileIds || []).map(fileId => String(fileId)).filter(Boolean));
const deletedDirectId = String(this.getFileId(deletedFile) || '').trim();
if (deletedDirectId) {
deletedIdSet.add(deletedDirectId);
}
const remoteAllIds = this.normalizeNumericFileIds((remoteEntries || []).map(item => item && item.fileId));
const knownAllIds = this.normalizeNumericFileIds(this.knownFileIds || []);
let finalFileIds = remoteAllIds.length > 0
? remoteAllIds.filter(fileId => !deletedIdSet.has(String(fileId)))
: knownAllIds.filter(fileId => !deletedIdSet.has(String(fileId)));
if (this.fileList.length > 0 && finalFileIds.length === 0) {
console.warn('[UploadImgCos] 删除后未能可靠计算剩余file_id,已阻止空关联提交', {
deleted_file_ids: deletedFileIds,
deleted_file_url: deletedFileUrl,
remote_entries_count: Array.isArray(remoteEntries) ? remoteEntries.length : 0,
remote_all_ids: remoteAllIds,
known_all_ids: knownAllIds,
known_file_ids_count: Array.isArray(this.knownFileIds) ? this.knownFileIds.length : 0
});
// 回滚UI,避免前端显示与后端实际不一致
this.fileList.splice(index, 0, deletedFile);
this.$emit('change', this.fileList);
this.$emit('input', this.fileList);
uni.showToast({
title: '删除失败,请重试',
icon: 'none'
});
return;
}
this.replaceKnownFileIds(finalFileIds);
await this.referenceFiles({
explicitFileIds: finalFileIds,
source: 'delete'
});
} catch (error) {
console.error("删除后重新关联失败:", error);
this.fileList.splice(index, 0, deletedFile);
this.$emit('change', this.fileList);
this.$emit('input', this.fileList);
uni.showToast({
title: '删除失败,请重试',
icon: 'none'
});
}
},
/**
* 手动上传
*/
upload() {
if (this.$refs.uUploadRef && !this.disabled) {
this.$refs.uUploadRef.chooseFile();
}
},
/**
* 获取上传成功的文件
*/
getSuccessFiles() {
return this.fileList.filter(item => item.status === "success");
},
/**
* 清空文件
*/
clearFiles() {
this.fileList = [];
this.replaceKnownFileIds([]);
this.$emit('input', []);
this.$emit('change', []);
}
}
};
</script>
<style scoped>
::v-deep .u-upload__deletable {
width: 56rpx !important;
height: 56rpx !important;
top: -16rpx !important;
right: -16rpx !important;
background-color: transparent !important;
border-bottom-left-radius: 0 !important;
}
::v-deep .u-upload__deletable__icon {
position: absolute !important;
top: 10rpx !important;
right: 10rpx !important;
width: 24rpx;
height: 24rpx;
display: flex;
align-items: center;
justify-content: center;
background-color: rgb(55, 55, 55);
border-radius: 100rpx;
transform: none !important;
}
</style>

864
src/core/request/apis.js Normal file
View File

@ -0,0 +1,864 @@
/**
* 接口列表文件
*/
export default {
/** 系统(免登录) ↓ **/
index: {
// 工作台登录码登录:wms_workbench.login_code 命中返回工作台 token(免登录、免鉴权)
LoginWorkbenchByCode: {
path: "index.LoginWorkbenchByCode",
auth: false,
method: "POST",
isSystemApi: true
},
// 按 token(ye4s 登录临时码)查询用户信息:ye4s_user.tmp_code 命中返回 real_name / wms_account_id(免登录、免鉴权)
queryUserByToken: {
path: "index.queryUserByToken",
auth: false,
method: "POST",
isSystemApi: true
}
},
/** 公共 ↓ **/
common: {
ping: {
path: "index.ping",
auth: false,
method: "POST",
isSystemApi: true
},
store: {
path: "index.loadStores",
auth: false,
method: "POST",
isSystemApi: true
},
getCOSUploadConfig: {
path: "index.getCOSUploadConfig",
auth: true,
method: "POST",
isSystemApi: true
},
uploadSuccessNotify: {
path: "index.uploadSuccessNotify",
auth: true,
method: "POST",
isSystemApi: true
},
getImages: {
path: "index.getImages",
auth: true,
method: "POST",
isSystemApi: true
},
ReferenceFile: {
path: "index.ReferenceFile",
auth: true,
method: "POST",
isSystemApi: true
},
searchSpace: {
path: "index.searchSpace",
auth: true,
method: "POST",
isSystemApi: true
},
recognizeLicensePlate: {
path: "index.recognizeLicensePlate",
auth: true,
method: "POST",
isSystemApi: true
},
listTemplatesByType: {
path: "setting.printTemplate.listTemplatesByType",
auth: true,
method: "POST",
isSystemApi: true
},
toOrder: {
path: "index.toOrder",
auth: true,
method: "POST",
isSystemApi: true
}
},
/** 用户 ↓ **/
user: {
info: {
path: "user.info",
auth: false,
method: "POST",
isSystemApi: true
},
login: {
path: "user.login",
auth: false,
method: "POST",
isSystemApi: true
},
loginByCode: {
path: "user.loginByCode",
auth: false,
method: "POST",
isSystemApi: true
},
changeRole: {
path: "user.changeRole",
auth: true,
method: "POST",
isSystemApi: true
}
},
/** 看板 ↓ **/
dashboard: {
storeStats: {
path: "dashboard.storeStats",
auth: true,
method: "POST",
isSystemApi: true
}
},
/** 仓库 ↓ **/
warehouse: {
getSpaceInfo: {
path: "warehouse.getSpaceInfo",
auth: true,
method: "POST",
isSystemApi: true
}
},
/** 工作台 ↓ **/
workbench: {
list: {
path: "workbench.list",
auth: true,
method: "POST",
isSystemApi: true
},
// 工作台绑定(需登录、需权限):绑定码 code + 工作台ID id,成功返回工作台 token
bind: {
path: "workbench.bind",
auth: true,
method: "POST",
isSystemApi: true
},
// 用工作台 token 获取工作台信息(免登录、免鉴权):token 无效/不存在返回 403
getWorkbenchInfo: {
path: "workbench.getWorkbenchInfo",
auth: false,
method: "POST",
isSystemApi: true
},
bindMember: {
path: "workbench.bindMember",
auth: false,
method: "POST",
isSystemApi: true
},
// 移除工作台成员(免登录、免鉴权,以工作台 token 鉴权):ids 为成员行 id(wms_workbench_member.id)
removeMember: {
path: "workbench.removeMember",
auth: false,
method: "POST",
isSystemApi: true
},
// 工作台条码查询订单(免登录、免鉴权,以工作台 token 鉴权):token + barcode(运单号)
queryOrder: {
path: "workbench.queryOrder",
auth: false,
method: "POST",
isSystemApi: true
},
// 工作台打包上报(免登录、免鉴权,以工作台 token 鉴权):发货单号定位订单创建打包任务
packOrder: {
path: "workbench.packOrder",
auth: false,
method: "POST",
isSystemApi: true
},
// 工作台打包完成(免登录、免鉴权,以工作台 token 鉴权):结束该工作台最后一个未结束打包任务
finishPack: {
path: "workbench.finishPack",
auth: false,
method: "POST",
isSystemApi: true
},
// 工作台班次打包统计(免登录、免鉴权,以工作台 token 鉴权):统计窗口为本地时间当日 08:00 至次日 08:00
getWorkbenchCount: {
path: "workbench.getWorkbenchCount",
auth: false,
method: "POST",
isSystemApi: true
}
},
storage: {
receiving: {
getReceivingList: {
path: "storage.receiving.getReceivingList",
auth: true,
method: "POST",
isSystemApi: true
},
create: {
path: "storage.receiving.create",
auth: true,
method: "POST",
isSystemApi: true
},
get: {
path: "storage.receiving.get",
auth: true,
method: "POST",
isSystemApi: true
},
bindStore: {
path: "storage.receiving.bindStore",
auth: true,
method: "POST",
isSystemApi: true
},
addDetail: {
path: "storage.receiving.addDetail",
auth: true,
method: "POST",
isSystemApi: true
},
deleteDetail: {
path: "storage.receiving.deleteDetail",
auth: true,
method: "POST",
isSystemApi: true
},
detailChange: {
path: "storage.receiving.detailChange",
auth: true,
method: "POST",
isSystemApi: true
},
scanDetail: {
path: "storage.receiving.scanDetail",
auth: true,
method: "POST",
isSystemApi: true
},
cancel: {
path: "storage.receiving.cancel",
auth: true,
method: "POST",
isSystemApi: true
},
completeReceiving: {
path: "storage.receiving.completeReceiving",
auth: true,
method: "POST",
isSystemApi: true
}
},
entry: {
list: {
path: "storage.entry.list",
auth: true,
method: "POST",
isSystemApi: true
},
get: {
path: "storage.entry.get",
auth: true,
method: "POST",
isSystemApi: true
},
containerList: {
path: "storage.entry.containerList",
auth: true,
method: "POST",
isSystemApi: true
},
addItem: {
path: "storage.entry.addItem",
auth: true,
method: "POST",
isSystemApi: true
},
commit: {
path: "storage.entry.commit",
auth: true,
method: "POST",
isSystemApi: true
}
},
inventory: {
list: {
path: "storage.inventory.list",
auth: true,
method: "POST",
isSystemApi: true
},
listBySpaceId: {
path: "storage.inventory.listBySpaceId",
auth: true,
method: "POST",
isSystemApi: true
},
listByStockId: {
path: "storage.inventory.listByStockId",
auth: true,
method: "POST",
isSystemApi: true
},
updateExpiry: {
path: "storage.inventory.updateExpiry",
auth: true,
method: "POST",
isSystemApi: true
},
transferByProduct: {
path: "storage.inventory.transferByProduct",
auth: true,
method: "POST",
isSystemApi: true
},
transferLocation: {
path: "storage.inventory.transferLocation",
auth: true,
method: "POST",
isSystemApi: true
}
},
transaction: {
list: {
path: "storage.transaction.list",
auth: true,
method: "POST",
isSystemApi: true
}
},
directInbound: {
inbound: {
path: "storage.directInbound.inbound",
auth: true,
method: "POST",
isSystemApi: true
},
complete: {
path: "storage.directInbound.complete",
auth: true,
method: "POST",
isSystemApi: true
},
addItem: {
path: "storage.directInbound.addItem",
auth: true,
method: "POST",
isSystemApi: true
},
commit: {
path: "storage.directInbound.commit",
auth: true,
method: "POST",
isSystemApi: true
}
},
/** 库存管理 ↓ **/
management: {
replenishmentDemand: {
path: "storage.management.replenishmentDemand",
auth: true,
method: "POST",
isSystemApi: true
}
}
},
stock: {
search: {
path: "stock.search",
auth: true,
method: "POST",
isSystemApi: true
},
warehouse: {
list: {
path: "stock.warehouse.list",
auth: true,
method: "POST",
isSystemApi: true
},
search: {
path: "stock.warehouse.search",
auth: true,
method: "POST",
isSystemApi: true
},
getProhibitedType: {
path: "stock.warehouse.getProhibitedType",
auth: true,
method: "POST",
isSystemApi: true
},
getStockUnits: {
path: "stock.warehouse.getStockUnits",
auth: true,
method: "POST",
isSystemApi: true
},
checkItemCodeUnique: {
path: "stock.warehouse.checkItemCodeUnique",
auth: true,
method: "POST",
isSystemApi: true
},
getBarcodes: {
path: "stock.warehouse.getBarcodes",
auth: true,
method: "POST",
isSystemApi: true
},
saveWarehouseStockBarcode: {
path: "stock.warehouse.saveWarehouseStockBarcode",
auth: true,
method: "POST",
isSystemApi: true
},
saveWarehouseStock: {
path: "stock.warehouse.saveWarehouseStock",
auth: true,
method: "POST",
isSystemApi: true
}
}
},
/** 库存盘点 ↓ */
check: {
// 盘点任务列表:按当前用户仓库限定范围,支持 status/store_id/keyword 筛选与分页
list: {
path: "stock.check.list",
auth: true,
method: "POST",
isSystemApi: true
},
// 盘点任务详情(只返回主表 check:check_no/type/mode/store_id/status/detail_status/进度/时间等):
// 入参仅 id;不再返回明细范围行(rows),明细结果请调 result,作业记录请调 recordList
detail: {
path: "stock.check.detail",
auth: true,
method: "POST",
isSystemApi: true
},
// 盘点明细结果(按范围行聚合作业记录):返回 { check, rows, total },
// rows 含已盘/差异聚合 + 作业记录/库位/未知商品;无状态限制(已完成任务也能拉)
result: {
path: "stock.check.result",
auth: true,
method: "POST",
isSystemApi: true
},
// 盘点作业数据:入参 id + is_goods + keyword + pagination;视图由任务范围与 is_goods 驱动
// (库位任务一律 location 视图;商品任务默认 space 聚合库位视图,is_goods=true 为 goods 商品视图)
// keyword 仅 location 视图生效(按 location_code/location_name 模糊匹配后分页)
// 仅任务状态 approved/checking 可拉取,其他状态返回 400
workData: {
path: "stock.check.workData",
auth: true,
method: "POST",
isSystemApi: true
},
// 盘点作业明细:入参二选一——① detail_id(盘点明细ID,兼容 detailId,库位明细必传);
// ② id(任务ID)+ stock_id(商品库存ID,兼容 stockId;goods 汇总视图行不再返回明细ID,商品钻取用)
// 库位明细返回 location 单行结构(detail_id/location_code/location_name/status/has_unknown/is_empty/checked_at/checkers/goods);
// 商品钻取返回 { stock_id/item_code/item_name/spec/store_name/barcode/images,
// summary(明盘:system_quantity/checked_quantity/diff_quantity/is_diff), rows(按库位分行) };
// warehouse_id 由服务端注入;仅 approved/checking 可拉取
workDataDetail: {
path: "stock.check.workDataDetail",
auth: true,
method: "POST",
isSystemApi: true
},
// 单库位的 space 作业数据(workData space 视图分页版):
// 入参 id(任务ID)+ location_id(库位ID,兼容 locationId,可选)+ pagination;
// 传 location_id 时只返回该库位行(total=1),行结构与 workData space 视图一致
workDataSpaceDetails: {
path: "stock.check.workDataSpaceDetails",
auth: true,
method: "POST",
isSystemApi: true
},
// 盘点作业上报:单条明细实盘数量(quantity>=0 整数)
// detail_id 可选:库位明细行必传;商品模式只传 id + stock_id + space_id,明细由服务端反查
report: {
path: "stock.check.report",
auth: true,
method: "POST",
isSystemApi: true
},
// 删除盘点作业记录(批量:record_ids 数组,单次≤200,兼容单值 recordId/record_id)
// 仅 approved/checking 允许;查不到的 ID 计入 skipped_ids 不报错;删除后重算进度、主表状态不回退
recordDelete: {
path: "stock.check.recordDelete",
auth: true,
method: "POST",
isSystemApi: true
},
// 盘点作业记录列表(id 与 detail_id 至少传一个,传了 detail_id 只查该明细的记录):
// 每条含 location_code/quantity/checker_name/checked_at/is_empty/images + 商品信息列,按记录 id 倒序分页
recordList: {
path: "stock.check.recordList",
auth: true,
method: "POST",
isSystemApi: true
},
// 完成盘点作业:主表置 completed
finish: {
path: "stock.check.finish",
auth: true,
method: "POST",
isSystemApi: true
},
// 提交审核:created/rejected → submitted
submit: {
path: "stock.check.submit",
auth: true,
method: "POST",
isSystemApi: true
},
// 取消盘点任务:created/submitted/rejected → cancelled
cancel: {
path: "stock.check.cancel",
auth: true,
method: "POST",
isSystemApi: true
},
// 添加盘点明细(按任务盘点类型决定维度):商品任务传 stock_ids;
// 库位任务传 locations/location_ids(location_ids 优先),type=location 两者都不传则自动拉全仓启用库位
// 仅 created/rejected 允许;已存在的盘点项自动跳过(幂等);完成后重算主表 total_items
addDetail: {
path: "stock.check.addDetail",
auth: true,
method: "POST",
isSystemApi: true
},
// 批量添加库位明细(兼容入口,转调 addDetail 的库位ID直查路径)
addLocationDetail: {
path: "stock.check.addLocationDetail",
auth: true,
method: "POST",
isSystemApi: true
}
},
pick: {
query: {
path: "pick.query",
auth: true,
method: "POST",
isSystemApi: true
},
wavePickTaskCurrent: {
path: "pick.wavePickTaskCurrent",
auth: true,
method: "POST",
isSystemApi: true
},
wavePickTaskDetail: {
path: "pick.wavePickTaskDetail",
auth: true,
method: "POST",
isSystemApi: true
},
wavePickTaskSubmit: {
path: "pick.wavePickTaskSubmit",
auth: true,
method: "POST",
isSystemApi: true
},
wavePickTaskComplete: {
path: "pick.wavePickTaskComplete",
auth: true,
method: "POST",
isSystemApi: true
},
waveClaimScan: {
path: "pick.waveClaimScan",
auth: true,
method: "POST",
isSystemApi: true
},
items: {
path: "pick.items",
auth: true,
method: "POST",
isSystemApi: true
},
complete: {
path: "pick.complete",
auth: true,
method: "POST",
isSystemApi: true
}
},
pickCart: {
scan: {
path: "pickCart.scan",
auth: true,
method: "POST",
isSystemApi: true
},
list: {
path: "pickCart.list",
auth: true,
method: "POST",
isSystemApi: true
},
bindTaskCart: {
path: "pickCart.bindTaskCart",
auth: true,
method: "POST",
isSystemApi: true
}
},
order: {
print: {
getWavePlatformPrintData: {
path: "order.print.getWavePlatformPrintData",
auth: true,
method: "POST",
isSystemApi: true
},
getPrintDataByWaybillCodes: {
path: "order.print.getPrintDataByWaybillCodes",
auth: true,
method: "POST",
isSystemApi: true
},
getOrderPrintData: {
path: "order.print.getOrderPrintData",
auth: true,
method: "POST",
isSystemApi: true
},
unlockWavePlatformPrintDataByGroup: {
path: "order.print.unlockWavePlatformPrintDataByGroup",
auth: true,
method: "POST",
isSystemApi: true
}
},
wave: {
batchList: {
path: "order.wave.batchList",
auth: true,
method: "POST",
isSystemApi: true
},
confirmPrintUnclaimedWaveCount: {
path: "order.wave.confirmPrintUnclaimedWaveCount",
auth: true,
method: "POST",
isSystemApi: true
},
wavePickTaskList: {
path: "order.wave.wavePickTaskList",
auth: true,
method: "POST",
isSystemApi: true
},
waveStrategyList: {
path: "order.wave.waveStrategyList",
auth: true,
method: "POST",
isSystemApi: true
},
waveStrategyFetchPda: {
path: "order.wave.waveStrategyFetchPda",
auth: true,
method: "POST",
isSystemApi: true
},
wavePickTaskCancelSelf: {
path: "order.wave.wavePickTaskCancelSelf",
auth: true,
method: "POST",
isSystemApi: true
}
},
pendingOrder: {
list: {
path: "index.toOrder",
auth: true,
method: "POST",
isSystemApi: true
},
detail: {
path: "order.detail",
auth: true,
method: "POST",
isSystemApi: true
},
allocateSubOrderNumber: {
path: "order.pendingOrder.allocateSubOrderNumber",
auth: true,
method: "POST",
isSystemApi: true
}
},
recheckOrder: {
recheckOrderList: {
path: "order.recheckOrder.recheckOrderList",
auth: true,
method: "POST",
isSystemApi: true
},
queryRecheckOrderSingleList: {
path: "order.recheckOrder.queryRecheckOrderSingleList",
auth: true,
method: "POST",
isSystemApi: true
},
scanTask: {
path: "order.recheckOrder.scanTask",
auth: true,
method: "POST",
isSystemApi: true
},
scanOrder: {
path: "order.recheckOrder.scanOrder",
auth: true,
method: "POST",
isSystemApi: true
},
confirmRecheck: {
path: "order.recheckOrder.confirmRecheck",
auth: true,
method: "POST",
isSystemApi: true
},
updateExpressWeighingWeight: {
path: "order.updateExpressWeighingWeight",
auth: true,
method: "POST",
isSystemApi: true
},
interceptScan: {
path: "order.recheckOrder.interceptScan",
auth: true,
method: "POST",
isSystemApi: true
},
confirmIntercept: {
path: "order.recheckOrder.confirmIntercept",
auth: true,
method: "POST",
isSystemApi: true
}
},
deliveryOrder: {
list: {
path: "order.deliveryOrder.list",
auth: true,
method: "POST",
isSystemApi: true
},
detail: {
path: "order.deliveryOrder.detail",
auth: true,
method: "POST",
isSystemApi: true
}
},
detail: {
path: "order.detail",
auth: true,
method: "POST",
isSystemApi: true
},
bindExpressPackageMaterialByWaybill: {
path: "order.bindExpressPackageMaterialByWaybill",
auth: true,
method: "POST",
isSystemApi: true
}
},
print: {
getList: {
path: "print.getList",
auth: true,
method: "POST",
isSystemApi: true
},
getComputerPrinter: {
path: "print.getComputerPrinter",
auth: true,
method: "POST",
isSystemApi: true
},
send:{
path: "print.send",
auth: true,
method: "POST",
isSystemApi: true
}
},
setting: {
packageMaterial: {
search: {
path: "setting.packageMaterial.search",
auth: true,
method: "POST",
isSystemApi: true
}
}
},
/** 退件登记 ↓ **/
returnReceived: {
create: {
path: "returnReceived.create",
auth: true,
method: "POST",
isSystemApi: true
},
list: {
path: "returnReceived.list",
auth: true,
method: "POST",
isSystemApi: true
},
export: {
path: "returnReceived.export",
auth: true,
method: "POST",
isSystemApi: true
},
exportTaskProgress: {
path: "returnReceived.exportTaskProgress",
auth: true,
method: "POST",
isSystemApi: true
}
},
/** 收件任务(退件收件任务列表,warehouse_id 由服务端注入)↓ **/
returnReceivedTask: {
create: {
path: "returnReceivedTask.create",
auth: true,
method: "POST",
isSystemApi: true
},
list: {
path: "returnReceivedTask.list",
auth: true,
method: "POST",
isSystemApi: true
},
delete: {
path: "returnReceivedTask.delete",
auth: true,
method: "POST",
isSystemApi: true
},
batchDelete: {
path: "returnReceivedTask.batchDelete",
auth: true,
method: "POST",
isSystemApi: true
}
}
};

119
src/core/request/index.js Normal file
View File

@ -0,0 +1,119 @@
import coreRequest from './request'
import apiList from './apis.js'
import store from '@/core/store/index.js'
import { setToken,removeToken } from '../utils/auth';
import router from '@/core/router'
import { handleTokenExpired } from '@/core/utils/auth-guard'
const Request = new coreRequest();
export default function http(
url,
data = {},
toastBefore = '', // 请求前加载提示
toastAfter = true, // 请求后错误提示
responseType = 'text',
timeout = 0 // 自定义请求超时(ms),0 表示使用默认 20s;长轮询接口需传入大于服务端等待时长的值
) {
let api = getApiPath(url);
console.log(api);
const token = uni.getStorageSync('token');
console.log('[Request] token:', token);
if (api.auth && !token) {
store.dispatch('logout');
uni.hideLoading();
return Promise.reject({
msg: `暂未登录,已阻止此次API请求: '${api.url}'`
});
}
/* 请求之前拦截器 */
Request.interceptor.request((config, cancel) => {
token && Request.setConfig(config => {
config.header.authorization = `Bearer ${token}`
console.log('[Request] Authorization:', config.header.authorization);
})
if (toastBefore !== '') {
uni.showLoading({
title: toastBefore,
mask: true
});
}
return config
});
/* 请求之后拦截器 */
Request.interceptor.response((res) => {
const headers = res.header;
console.log(res);
const response = res.data;
const getHeaderValue = (headerMap, key) => {
if (!headerMap) {
return '';
}
const targetKey = Object.keys(headerMap).find(item => String(item).toLowerCase() === String(key).toLowerCase());
return targetKey ? headerMap[targetKey] : '';
};
const normalizeToken = (rawToken) => {
if (!rawToken) {
return '';
}
const text = String(rawToken).trim();
if (!text) {
return '';
}
return text.startsWith('Bearer ') ? text.substring(7).trim() : text;
};
const token =
getHeaderValue(headers, 'authorization') ||
getHeaderValue(headers, 'token') ||
getHeaderValue(headers, 'x-access-token') ||
getHeaderValue(headers, 'access-token');
const normalizedToken = normalizeToken(token);
if (normalizedToken) {
setToken(normalizedToken)
}
uni.hideLoading();
if (response?.flag === "failure") {
if (toastAfter) {
uni.showToast({
title: response.message || '请求出错,稍后重试',
icon: 'none',
duration: 1000,
mask: true
});
}
}
// token过期注销
if (res.statusCode === 401) {
handleTokenExpired(store)
return Promise.reject({
msg: '登录已过期,请重新登录'
})
}
return response
})
return Request.request({
url: api.url,
path: api.path,
data,
method: api.method,
responseType,
...(timeout ? { timeout } : {})
})
}
// 组装接口路径
function getApiPath(url) {
let apiArray = url.split(".");
let api = apiList;
apiArray.forEach(v => {
api = api[v];
});
// 未登记时报错信息要可读,避免出现 "Cannot read properties of undefined (reading 'auth')"
if (!api || typeof api !== 'object' || !api.path) {
throw new Error(`接口未注册: ${url}(请在 core/request/apis.js 中登记)`);
}
return api;
}

View File

@ -24,6 +24,8 @@ export default class Request {
params: {}, params: {},
method: 'GET', method: 'GET',
dataType: 'json', dataType: 'json',
// 默认请求超时 20s,避免弱网下请求长时间挂起(真机 PDA 网络环境差异明显)
timeout: 20000,
// #ifndef MP-ALIPAY || APP-PLUS // #ifndef MP-ALIPAY || APP-PLUS
responseType: 'text', responseType: 'text',
// #endif // #endif
@ -111,13 +113,45 @@ export default class Request {
mergeUrl += mergeUrl.indexOf('?') === -1 ? `?${query}` : `&${query}` mergeUrl += mergeUrl.indexOf('?') === -1 ? `?${query}` : `&${query}`
} }
options.url = mergeUrl options.url = mergeUrl
// 硬超时兜底:uni.request 的 timeout 在弱网/部分安卓 WebView 下可能不触发,
// 用独立定时器保证请求 Promise 必定 settle,超时主动 abort 并走拦截器,避免界面无限卡住
const timeoutMs = Number(options.timeout) > 0 ? Number(options.timeout) : 20000;
let settled = false;
let task = null;
const timer = setTimeout(() => {
if (settled) return;
settled = true;
if (task && typeof task.abort === 'function') {
try { task.abort(); } catch (e) {}
}
// 构造符合响应拦截器预期的结构,使 toastAfter/隐藏 loading/错误提示链路完整生效
const timeoutRes = {
errMsg: `request:fail timeout(${timeoutMs}ms)`,
statusCode: 0,
header: {},
data: { flag: 'failure', message: '网络超时,请检查网络后重试' }
};
let handled = timeoutRes;
try {
handled = this.requestAfter(timeoutRes);
} catch (e) {}
reject(handled);
}, timeoutMs + 2000);
const settle = (fn, value) => {
if (settled) return;
settled = true;
clearTimeout(timer);
fn(value);
};
options.success = res => { options.success = res => {
resolve(this.requestAfter(res)) settle(resolve, this.requestAfter(res))
} }
options.fail = err => { options.fail = err => {
reject(this.requestAfter(err)) const handled = this.requestAfter(err);
// 原生失败(超时/断网/abort)时透传原始 errMsg,便于调用方识别失败原因
settle(reject, handled === undefined || handled === null ? err : handled)
} }
uni.request(options) task = uni.request(options)
}) })
} }

View File

@ -6,7 +6,8 @@ import {
import store from '@/core/store' import store from '@/core/store'
import { import {
getToken, getToken,
removeToken removeToken,
isWorkbenchSession
} from '@/core/utils/auth' } from '@/core/utils/auth'
const router = createRouter({ const router = createRouter({
platform: process.env.VUE_APP_PLATFORM, platform: process.env.VUE_APP_PLATFORM,
@ -19,21 +20,14 @@ const router = createRouter({
}) => { }) => {
switch (type) { switch (type) {
case 3: // APP退出应用 case 3: // APP退出应用
case 2:
// #ifdef APP-PLUS // #ifdef APP-PLUS
router.$lockStatus = false; router.$lockStatus = false;
uni.showModal({ store.commit('app/showExitConfirm');
title: '提示',
content: '您确定要退出应用吗?',
success: function(res) {
if (res.confirm) {
plus.runtime.quit();
}
}
});
// #endif // #endif
break; break;
case 2:
router.$lockStatus = false;
break;
case 0: case 0:
router.$lockStatus = false; router.$lockStatus = false;
break; break;
@ -58,6 +52,13 @@ const router = createRouter({
//全局路由前置守卫 //全局路由前置守卫
router.beforeEach(async (to, from, next) => { router.beforeEach(async (to, from, next) => {
const hasToken = getToken(); const hasToken = getToken();
// 工作台会话(token = workbenchToken):不做用户态校验,不调用 user.info
if (hasToken && isWorkbenchSession()) {
console.log('工作台会话放行:', to.path);
next();
return;
}
if (hasToken) { if (hasToken) {
console.log("去哪里",to); console.log("去哪里",to);
@ -71,31 +72,45 @@ router.beforeEach(async (to, from, next) => {
const hasGetUserInfo = store.getters.user.employees_name; const hasGetUserInfo = store.getters.user.employees_name;
console.log("有没有用户信息",hasGetUserInfo); console.log("有没有用户信息",hasGetUserInfo);
if (hasGetUserInfo) { if (hasGetUserInfo) {
const isVisible =await store.dispatch('floatWindowManager/is_visible'); try {
if(to.meta && to.meta.auth){ store.dispatch('floatWindowManager/is_visible').catch(error => {
console.log(to.path); console.log('浮窗显示检查失败:', error);
const hasPermiss =await store.dispatch('checkPath',to.path); });
if(!hasPermiss){ if(to.meta && to.meta.auth){
next({path:"/pages/403"}) console.log(to.path);
return; const hasPermiss =await store.dispatch('checkPath',to.path);
if(!hasPermiss){
next({path:"/pages/403"})
return;
}
} }
} const hasFromPath = !!from.path;
if(to.path==from.path){ const isSameRoute = hasFromPath && to.path === from.path && to.fullPath === from.fullPath;
next(false); if(isSameRoute){
}else{ console.log('路由重复,取消跳转:', to.path);
next(false);
}else{
console.log('路由放行:', from.path, '->', to.path);
next();
}
} catch (error) {
console.log('已登录分支路由守卫异常:', error);
next(); next();
} }
} else { } else {
console.log("没有用户信息"); console.log("没有用户信息");
await store.dispatch('getUserInfo');
console.log("获取完成,去哪里",to)
try { try {
await store.dispatch('floatWindowManager/is_visible'); await store.dispatch('getUserInfo');
// 关键修改:等待获取用户信息 console.log("获取完成,去哪里",to)
if (to.path === '/pages/index/index'){ store.dispatch('floatWindowManager/is_visible').catch(error => {
console.log('浮窗显示检查失败:', error);
});
if (to.path === '/pages/index/index') {
console.log('路由放行:', from.path, '->', to.path);
next(); next();
}else{ } else {
console.log('路由重定向:', from.path, '->', to.fullPath);
next({ next({
path: to.fullPath, path: to.fullPath,
NAVTYPE: 'SwitchTab' NAVTYPE: 'SwitchTab'
@ -103,6 +118,10 @@ router.beforeEach(async (to, from, next) => {
} }
} catch (error) { } catch (error) {
await store.dispatch('logout'); await store.dispatch('logout');
next({
path: '/pages/login/index',
replace: true
});
} }
} }
} }

View File

@ -7,7 +7,10 @@ import setting from './modules/setting.js'
import broadcast from './modules/broadcast.js' import broadcast from './modules/broadcast.js'
import floatWindowManager from './modules/floatWindowManager.js' import floatWindowManager from './modules/floatWindowManager.js'
import bluetoothPrint from './modules/bluetoothPrint.js' import bluetoothPrint from './modules/bluetoothPrint.js'
import bluetoothScale from './modules/bluetoothScale.js'
import print from './modules/print.js' import print from './modules/print.js'
import deviceInfo from './modules/deviceInfo.js'
import app from './modules/app.js'
const store = new Vuex.Store({ const store = new Vuex.Store({
modules: { modules: {
@ -16,7 +19,10 @@ const store = new Vuex.Store({
broadcast, broadcast,
floatWindowManager, floatWindowManager,
bluetoothPrint, bluetoothPrint,
print bluetoothScale,
print,
deviceInfo,
app
} }
}) })

Some files were not shown because too many files have changed in this diff Show More