Files
shanxia2.0/miniprogram/README.md
T
2026-09-12 19:42:20 +08:00

75 lines
3.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 山峡化工 · 微信小程序(miniprogram)
基于 [uni-app](https://uniapp.dcloud.net.cn/) 的微信小程序工程。地磅业务 UI 使用自研 `components/db-ui/*`(视觉对齐 mobile-h5 Vant4 主色 `#52B788`)。
> 说明:`@vant/weapp` 依赖微信原生 `Behavior`,在 uni-app H5/Vite 下会报 `Behavior is not defined`,故地磅页不直接引用 Weapp 组件。
## 技术栈
- uni-app(Vue 3 + Composition API)
- Pinia + Vuex(遗留壳)
- 地磅 UI:`components/db-ui`(对齐 Vant 视觉)
- RSA 登录加密 + `utils/request.js` / 地磅 `utils/dbRequest.js`
## 已接通业务:地磅管理
工作台「地磅管理」四菜单(自 `mobile-h5` 迁移):
| 菜单 | 路径 |
|------|------|
| 仪表盘 | `pages/db/dashboard/index` |
| 计划管理 | `pages/db/plans/*` |
| 出入库管理 | `pages/db/inventory/*` |
| 地磅单管理 | `pages/db/weighing/*` |
- API:`pages/db/api/db.js`(分包内,避免占用主包)→ `/dashboard` `/plans` `/inventory` `/weighing`(裸 JSON)
- 表单选择:`api/dbOptions.js`(CRM 客户/产品 + 运输车辆;主包组件共用)
- 日期工具:`pages/db/utils/dbDate.js`
- 样式:`styles/db-theme.scss`(局部主题,不改全局三墙壳色)
- 仪表盘图表:数字卡片 + 简易条形列表(非 ECharts)
未迁:基础资料/用户管理菜单、免登录第三方填写页。
## 壳页面
登录 / 首页 / 待办 / 工作台 / 我的;CRM / 报销 / 运输菜单仍为灰卡。
## 本地开发
1. HBuilderX 打开 `miniprogram/`(`manifest.json` → `mp-weixin.appid` 已填生产 AppID)
2. 环境开关:改 `config/env.js` 的 `APP_ENV`
- `local`:本机 `http://127.0.0.1:8000/api`(默认)
- `test`:测试门户 `http://121.43.228.102:9911/api`
- `production`:生产 `https://w.shanxiachem.com/api`
3. 启动 `backend/`(local 时)→ 运行到微信开发者工具
### 正式发版上传(微信)
不要用「运行到微信开发者工具」产物去上传(未压缩、主包偏大)。请用:
1. `APP_ENV=production` 且 `npm run release:check-api` 通过
2. HBuilderX:**发行 → 小程序-微信**(会压缩 JS)
3. 用发行产物在微信开发者工具中上传
已配置:`pages/db`、`pages/bx` 分包;`lazyCodeLoading=requiredComponents`;`mp-weixin.setting.minified=true`。
```bash
cd miniprogram
npm install
npm run release:check-api # 发版前:要求 APP_ENV=production
```
### 生产信息(来自 https://w.shanxiachem.com/)
| 项 | 地址 |
|----|------|
| Web | https://w.shanxiachem.com/ |
| API | https://w.shanxiachem.com/api |
| 静态资源 | https://w.shanxiachem.com/shanxia-static/ |
| MinIO 反代 | https://w.shanxiachem.com/ruoyi |
| 微信 AppID | `wx7db1ddb2a90c9425` |
微信公众平台合法域名请配置:`w.shanxiachem.com`(request / uploadFile / downloadFile)。
设计与计划:`docs/superpowers/specs/2026-09-11-miniprogram-db-from-h5-design.md`、`docs/superpowers/plans/2026-09-11-miniprogram-db-from-h5.md`