|
|
vor 2 Tagen | |
|---|---|---|
| src | vor 2 Tagen | |
| .gitignore | vor 1 Woche | |
| README.md | vor 1 Woche | |
| index.html | vor 1 Woche | |
| package-lock.json | vor 1 Woche | |
| package.json | vor 1 Woche | |
| tsconfig.json | vor 1 Woche | |
| vite.config.ts | vor 1 Woche |
本仓库是 风控品控管理系统 的移动端(uniapp)项目,基于 DCloud 官方 Vue3 + Vite 模板深度定制。
| 模块 | 路由 | 状态 |
|---|---|---|
| 工作台首页 | /pages/index/index |
✅ |
| 巡检任务列表 | /pages/inspection/list/index |
✅ |
| 巡检打卡 | /pages/inspection/check/index |
✅ |
| 扫码打卡 | /pages/inspection/scan/index |
✅ |
仅 H5 端已验证可运行;APP / 微信小程序端需要真机调试。
| 技术 | 版本 | 用途 |
|---|---|---|
| uniapp | 3.x | 跨端框架(iOS / Android / H5 / 微信小程序 / 抖音小程序) |
| Vue | 3.4 | Composition API |
| TypeScript | 5.x | 类型系统 |
| Vite | 5.x | 构建工具 |
| Sass | 1.69 | SCSS 预处理器 |
不使用 uView 等第三方组件库,所有 UI 元素手写 + SCSS 实现,便于定制和体积优化。
uniapp/
├── src/
│ ├── api/ # API 接口层
│ │ └── inspection.ts # 巡检相关接口(列表、详情、提交、扫码校验)
│ │
│ ├── types/ # 全局类型声明
│ │ └── inspection.ts # InspectionTask / InspectionItem / Payload 等
│ │
│ ├── utils/ # 工具类
│ │ └── location.ts # 位置工具(Haversine 距离 / 授权)
│ │
│ ├── static/
│ │ └── styles/
│ │ ├── variables.scss # 颜色/间距/字号/圆角变量
│ │ └── common.scss # 通用工具类(flex / tag / btn / 间距)
│ │
│ ├── components/ # 业务组件(easycom 自动注册)
│ │
│ ├── pages/ # 页面
│ │ ├── index/index.vue # 首页(入口)
│ │ └── inspection/
│ │ ├── list/index.vue # 巡检任务列表
│ │ ├── check/index.vue # 巡检打卡
│ │ └── scan/index.vue # 扫码中间页
│ │
│ ├── App.vue # 根组件
│ ├── main.ts # 入口
│ ├── pages.json # 路由与 tabBar 配置(uniapp 必需)
│ └── manifest.json # 应用配置(uniapp 必需)
│
├── index.html # H5 入口
├── vite.config.ts
├── tsconfig.json
├── package.json
└── README.md
功能:
跳转逻辑:
if (punchType === 'NORMAL') {
// 常规打卡:直接跳到打卡页
navigateTo('/pages/inspection/check/index?taskId=' + id)
} else if (punchType === 'SCAN') {
// 扫码打卡:先跳到扫码页
navigateTo('/pages/inspection/scan/index?taskId=' + id)
}
功能:
uni.scanCode 识别二维码/risk/inspectionTask/verifyQr)scan_limit_meter,默认 100 米)距离计算:utils/location.ts 中 calculateDistance() 使用 Haversine 公式。
功能:
校验逻辑(提交前):
成功弹窗:
点击「查看详情」进入打卡页时携带 ?readonly=1:
| 平台 | 支持情况 | 备注 |
|---|---|---|
| H5 | ✅ 完整 | 浏览器 + 移动端 H5 |
| Android | ✅ | 需自定义基座 / 真机调试 |
| iOS | ✅ | 需 Apple 证书 |
| 微信小程序 | ✅ | 需在 manifest.json 填入 appid |
| 抖音/支付宝小程序 | ⚠️ | 可能需调整 API |
扫码 API 限制:
uni.scanCode 在 H5 端无法直接拉起摄像头# 1. 安装依赖
npm install --registry=https://registry.npmmirror.com
# 2. 启动 H5 开发服务器(默认 :9000)
npm run dev:h5
# 3. 启动微信小程序(需在 manifest.json 填入 appid)
npm run dev:mp-weixin
# 4. 生产构建
npm run build:h5 # H5 静态资源输出到 dist/
npm run build:mp-weixin # 微信小程序输出到 dist/dev/mp-weixin
启动后访问 http://127.0.0.1:9000/,按 F12 切到移动端模拟器(iPhone 14 Pro 390×844)体验。
vite.config.ts 中已配置代理:
proxy: {
'/dev-api': {
target: 'http://127.0.0.1:8080', // RuoYi-Vue-Plus 后端
changeOrigin: true
}
}
确保后端 http://127.0.0.1:8080 已启动且:
GET /risk/inspectionTask/mobileListGET /risk/inspectionTask/{id}POST /risk/inspectionRecord/punchPOST /risk/inspectionTask/verifyQr演示模式:未连接后端时,
loadDetail()与listInspectionTasks()会自动 fallback 到 mock 数据(消防设备、电气安全、通道畅通 3 个示例项目)。
所有接口统一走 RuoYi-Vue-Plus 后端,基础路径 /dev-api(开发)/ /prod-api(生产):
// 列表
GET /risk/inspectionTask/mobileList?status=ALL&pageNo=1&pageSize=10
Response: {
code: 200,
msg: 'ok',
data: {
total: 3,
rows: InspectionTask[],
pageNum: 1,
pageSize: 10
}
}
// 详情
GET /risk/inspectionTask/{id}
Response: { code: 200, data: InspectionTask }
// 校验二维码
POST /risk/inspectionTask/verifyQr
Body: { taskId: number, qrContent: string }
Response: { code: 200, data: { valid: boolean } }
// 提交打卡
POST /risk/inspectionRecord/punch
Body: {
taskId: number,
longitude: number,
latitude: number,
punchType: 'NORMAL' | 'SCAN',
items: Array<{ itemId, result, reason?, photos? }>
}
Response: { code: 200, data: { punchId: number } }
npm run build:h5
# 输出至 dist/ 目录
Nginx 配置示例:
server {
listen 80;
server_name m.example.com;
root /var/www/risk-mobile/dist/build/h5;
index index.html;
location / { try_files $uri $uri/ /index.html; }
location /prod-api/ {
proxy_pass http://127.0.0.1:8080/;
proxy_set_header Host $host;
}
}
使用 HBuilderX 打开项目 → 发行 → 原生 APP-云打包,上传证书后生成 apk / ipa。
npm run build:mp-weixin
# 用微信开发者工具导入 dist/dev/mp-weixin
| 版本 | 日期 | 说明 |
|---|---|---|
| v1.0.0 | 2026-06 | 巡检模块首版上线(列表 + 打卡 + 扫码) |