Просмотр исходного кода

feat(train-frontend): M2 培训主线前端落地(批次/签到/学时页 + 组件库)

新增 cohort/attendance/credit 三个域页面(含二维码扫码 qr.vue、scan.vue)、通用组件(empty/error/loading-skeleton/progress-bar/status-tag)、uqrcode 工具与 api 封装;页面注册与工具库(creditHours 分钟→小时仅展示层)同步。

build:h5 → DONE Build complete(exit 0)
liaoxg 1 неделя назад
Родитель
Сommit
cca946b6c1

+ 32 - 0
train-frontend/api/attendance.js

@@ -0,0 +1,32 @@
+/**
+ * api/attendance.js — 现场签到域接口
+ * 契约见《健康服务人员助手_后端服务设计_v1.0》§7.1 培训线 / §6.2 签到码模型
+ * 复用 utils/api.js 的统一 request 封装。
+ */
+import { request } from '@/utils/api.js'
+
+/**
+ * 反向扫码签到 ★幂等 + 同事务
+ * 入参:{sessionId: Long 必填, code: String 必填}(cohortId 由 session 推导,可不传)
+ * 出参:{attended: boolean, name: String, time: String}
+ * 错误:401「请先登录」/ 500「签到码已过期,请重新扫码」/ 500「签到码无效」
+ */
+export function attendanceScan(sessionId, code) {
+  return request('/api/attendance/scan', 'POST', {
+    sessionId: sessionId,
+    code: code
+  }, { silent: true })
+}
+
+/**
+ * 场次签到码下发(讲师/组织端出码用)
+ * ⚠【待确认】后端 §7.1 未单列出码接口;默认由 session 相关接口下发 code 串,
+ *  前端本地生成二维码(禁外链图片服务,离线可用)。此接口为 add 预留。
+ * 入参:{sessionId}
+ * 出参:{sessionId, code, sessionName?, cohortName?, startAt?, endAt?}
+ */
+export function getAttendanceSessionCode(sessionId) {
+  return request('/api/attendance/session/code', 'POST', {
+    sessionId: sessionId
+  }, { silent: true })
+}

+ 43 - 0
train-frontend/api/cohort.js

@@ -0,0 +1,43 @@
+/**
+ * api/cohort.js — 培训批次域接口(学员端)
+ * 契约见《健康服务人员助手_后端服务设计_v1.0》§7.1 培训线
+ * 复用 utils/api.js 的统一 request 封装。
+ */
+import { request } from '@/utils/api.js'
+
+/**
+ * 批次列表
+ * 入参:{courseId?: Long, page?: int=1, size?: int=10}(均可空,未登录可浏览)
+ * 出参:{list:[{id,cohortNo,courseId,name,startAt,endAt,capacity,signedCount,
+ *               creditTheory,creditPractice,status}], total}
+ * 错误:500「查询失败」
+ */
+export function getCohortList(params) {
+  var data = { page: 1, size: 10 }
+  if (params) {
+    if (params.courseId) data.courseId = params.courseId
+    if (params.page) data.page = params.page
+    if (params.size) data.size = params.size
+  }
+  // 列表查询失败由页面展示错误态 + 重试,不弹全局 toast
+  return request('/api/cohort/list', 'POST', data, { silent: true })
+}
+
+/**
+ * 批次详情
+ * 入参:{cohortId}
+ * ⚠ 后端 §7.1 暂未单列 detail,优先走 list 冗余;此接口作为 add 预留,失败时由页面回退 list 数据。
+ */
+export function getCohortDetail(cohortId) {
+  return request('/api/cohort/detail', 'POST', { cohortId: cohortId }, { silent: true })
+}
+
+/**
+ * 批次报名 ★幂等
+ * 入参:{cohortId}
+ * 出参:Boolean(已报名也返回 true)
+ * 错误:404「批次不存在或已截止」/ 500「容量已满」/ 401「请先登录」
+ */
+export function cohortSignup(cohortId) {
+  return request('/api/cohort/signup', 'POST', { cohortId: cohortId }, { silent: true })
+}

+ 48 - 0
train-frontend/api/credit.js

@@ -0,0 +1,48 @@
+/**
+ * api/credit.js — 学时账户域接口
+ * 契约见《健康服务人员助手_后端服务设计_v1.0》§7.1 培训线
+ * ⚠ 单位红线:total/theory/practice/gap/hours 一律为【分钟整数】,
+ *   展示层统一走 utils/format.js 的 creditHours() 做 /60 换算,后端不做小时转换。
+ * 复用 utils/api.js 的统一 request 封装。
+ */
+import { request } from '@/utils/api.js'
+
+/**
+ * 我的学时账户
+ * 入参:{year?: int = 当前年}
+ * 出参:{year, total, theory, practice, gap,
+ *        detail:[{id,sourceType,sourceId,hours,theory,practice,status,effectiveAt}]}
+ * status: pending | effective | objected | rejected(明细单位同为分钟)
+ * 错误:401
+ */
+export function getCreditMine(year) {
+  var data = {}
+  if (year) data.year = year
+  return request('/api/credit/mine', 'POST', data, { silent: true })
+}
+
+/**
+ * 待生效明细(T+3 待入账)
+ * 入参:{page, size}
+ * 出参:{list:[pending 明细], total}
+ * 错误:401
+ */
+export function getCreditPending(page, size) {
+  return request('/api/credit/pending', 'POST', {
+    page: page || 1,
+    size: size || 20
+  }, { silent: true })
+}
+
+/**
+ * 学时异议 ★幂等
+ * 入参:{creditId: Long 必填, reason: String 必填}
+ * 出参:Boolean
+ * 错误:404「学时记录不存在或不属于您」/ 500「该学时状态不允许异议」
+ */
+export function creditObject(creditId, reason) {
+  return request('/api/credit/object', 'POST', {
+    creditId: creditId,
+    reason: reason
+  }, { silent: true })
+}

Разница между файлами не показана из-за своего большого размера
+ 33 - 0
train-frontend/common/uqrcode.js


+ 56 - 0
train-frontend/components/empty-state.vue

@@ -0,0 +1,56 @@
+<template>
+  <view class="empty-box">
+    <text v-if="icon" class="empty-icon">{{ icon }}</text>
+    <text class="empty-title">{{ title }}</text>
+    <text v-if="desc" class="empty-desc">{{ desc }}</text>
+    <button v-if="actionText" class="empty-btn" @click="handleAction">{{ actionText }}</button>
+  </view>
+</template>
+
+<script>
+/**
+ * 空态占位(分子组件):统一文案/图标/CTA
+ */
+export default {
+  name: 'EmptyState',
+  props: {
+    icon: { type: String, default: '📭' },
+    title: { type: String, default: '暂无数据' },
+    desc: { type: String, default: '' },
+    actionText: { type: String, default: '' }
+  },
+  methods: {
+    handleAction() {
+      this.$emit('action')
+    }
+  }
+}
+</script>
+
+<style scoped>
+.empty-box {
+  background: #FFFFFF;
+  border: 1px solid #E3EEF7;
+  border-radius: 20rpx;
+  padding: 56rpx 36rpx;
+  display: flex;
+  flex-direction: column;
+  align-items: center;
+}
+.empty-icon { font-size: 72rpx; margin-bottom: 20rpx; }
+.empty-title { font-size: 30rpx; font-weight: 600; color: #12395F; margin-bottom: 12rpx; }
+.empty-desc { font-size: 24rpx; color: #5B7A99; text-align: center; line-height: 1.7; margin-bottom: 28rpx; }
+.empty-btn {
+  width: 60%;
+  height: 80rpx;
+  line-height: 80rpx;
+  background: #2E6FA8;
+  color: #FFFFFF;
+  font-size: 28rpx;
+  font-weight: 600;
+  border-radius: 40rpx;
+  border: none;
+  padding: 0;
+}
+.empty-btn:active { opacity: 0.9; }
+</style>

+ 54 - 0
train-frontend/components/error-state.vue

@@ -0,0 +1,54 @@
+<template>
+  <view class="error-box">
+    <text class="error-icon">⚠️</text>
+    <text class="error-title">{{ message }}</text>
+    <text class="error-sub">请检查网络后重试</text>
+    <button class="error-btn" @click="handleRetry">重新加载</button>
+  </view>
+</template>
+
+<script>
+/**
+ * 错误态 + 重试(分子组件)
+ */
+export default {
+  name: 'ErrorState',
+  props: {
+    message: { type: String, default: '加载失败' }
+  },
+  methods: {
+    handleRetry() {
+      this.$emit('retry')
+    }
+  }
+}
+</script>
+
+<style scoped>
+.error-box {
+  background: #FFFFFF;
+  border: 1px solid #E3EEF7;
+  border-radius: 20rpx;
+  padding: 60rpx 40rpx;
+  margin-top: 60rpx;
+  display: flex;
+  flex-direction: column;
+  align-items: center;
+}
+.error-icon { font-size: 64rpx; margin-bottom: 20rpx; }
+.error-title { font-size: 30rpx; font-weight: 600; color: #12395F; margin-bottom: 10rpx; }
+.error-sub { font-size: 24rpx; color: #7A97B5; margin-bottom: 32rpx; }
+.error-btn {
+  width: 60%;
+  height: 80rpx;
+  line-height: 80rpx;
+  background: #2E6FA8;
+  color: #FFFFFF;
+  font-size: 28rpx;
+  font-weight: 600;
+  border-radius: 40rpx;
+  border: none;
+  padding: 0;
+}
+.error-btn:active { opacity: 0.9; }
+</style>

+ 56 - 0
train-frontend/components/loading-skeleton.vue

@@ -0,0 +1,56 @@
+<template>
+  <view class="skeleton-box">
+    <view v-for="(b, idx) in blocks" :key="idx" class="skeleton-row">
+      <view class="skeleton-block" :class="b.cls"></view>
+    </view>
+  </view>
+</template>
+
+<script>
+/**
+ * 骨架屏(分子组件):卡片占位
+ * cls 在 computed 预生成(class 仅绑计算/数据属性,不在模板做表达式)
+ */
+export default {
+  name: 'LoadingSkeleton',
+  props: {
+    rows: { type: Number, default: 3 }
+  },
+  computed: {
+    blocks() {
+      var arr = []
+      var n = this.rows || 3
+      for (var i = 0; i < n; i++) {
+        arr.push({
+          cls: (i + 1) % 3 === 0 ? 'skeleton-short' : ''
+        })
+      }
+      return arr
+    }
+  }
+}
+</script>
+
+<style scoped>
+.skeleton-box {
+  padding: 8rpx 0;
+}
+.skeleton-row {
+  background: #E9F2F9;
+  border-radius: 16rpx;
+  height: 120rpx;
+  margin-bottom: 20rpx;
+  padding: 24rpx;
+  display: flex;
+  align-items: center;
+}
+.skeleton-block {
+  width: 100%;
+  height: 36rpx;
+  background: #DCE9F3;
+  border-radius: 8rpx;
+}
+.skeleton-short {
+  width: 60%;
+}
+</style>

+ 61 - 0
train-frontend/components/progress-bar.vue

@@ -0,0 +1,61 @@
+<template>
+  <view class="progress-wrap">
+    <view class="progress-track" :style="{ background: trackBg }">
+      <view class="progress-fill" :style="{ width: safePercent + '%', background: fillColor }"></view>
+    </view>
+  </view>
+</template>
+
+<script>
+/**
+ * 线性进度条(原子组件,纯 flexbox,不用 CSS Grid)
+ * 用法:<ProgressBar :percent="68" />
+ */
+export default {
+  name: 'ProgressBar',
+  props: {
+    // 0-100
+    percent: {
+      type: Number,
+      default: 0
+    },
+    color: {
+      type: String,
+      default: '#2E6FA8'
+    },
+    trackBg: {
+      type: String,
+      default: '#E9F2F9'
+    }
+  },
+  computed: {
+    safePercent() {
+      var p = Number(this.percent) || 0
+      if (p < 0) return 0
+      if (p > 100) return 100
+      return p
+    },
+    fillColor() {
+      return this.color || '#2E6FA8'
+    }
+  }
+}
+</script>
+
+<style scoped>
+.progress-wrap {
+  width: 100%;
+}
+.progress-track {
+  width: 100%;
+  height: 18rpx;
+  border-radius: 10rpx;
+  overflow: hidden;
+  display: flex;
+  align-items: stretch;
+}
+.progress-fill {
+  height: 18rpx;
+  border-radius: 10rpx;
+}
+</style>

+ 107 - 0
train-frontend/components/status-tag.vue

@@ -0,0 +1,107 @@
+<template>
+  <text class="status-tag" :class="tagClass">{{ tagText }}</text>
+</template>
+
+<script>
+/**
+ * 状态徽标(原子组件)
+ * 目的:把 status → 文案/颜色的映射收敛到一处,避免各页面各写一份导致口径漂移。
+ * 用法:<StatusTag status="published" type="cohort" />
+ */
+export default {
+  name: 'StatusTag',
+  props: {
+    // 状态值
+    status: {
+      type: String,
+      default: ''
+    },
+    // 业务域:cohort / credit / attendance / promo
+    type: {
+      type: String,
+      default: ''
+    },
+    // 自定义文案(优先于映射)
+    text: {
+      type: String,
+      default: ''
+    }
+  },
+  computed: {
+    tagText() {
+      if (this.text) return this.text
+      var map = this.textMap()
+      return map[this.status] || this.status || '未知'
+    },
+    tagClass() {
+      return 'tag-' + this.colorKey()
+    },
+    colorKey() {
+      var map = this.colorMap()
+      return map[this.status] || 'grey'
+    }
+  },
+  methods: {
+    textMap() {
+      var map = {
+        // 批次
+        draft: '未发布',
+        published: '可报名',
+        ongoing: '进行中',
+        full: '已满',
+        closed: '已截止',
+        signed: '已报名',
+        // 学时
+        effective: '生效中',
+        pending: '待生效',
+        objected: '异议中',
+        rejected: '已驳回',
+        // 签到
+        success: '签到成功',
+        dupe: '已签到',
+        invalid: '码无效',
+        // 通用
+        accepted: '已通过',
+        rejected2: '未通过'
+      }
+      if (this.type === 'credit') {
+        return map
+      }
+      return map
+    },
+    colorMap() {
+      var map = {
+        draft: 'grey',
+        published: 'blue',
+        ongoing: 'green',
+        full: 'orange',
+        closed: 'grey',
+        signed: 'blue',
+        effective: 'green',
+        pending: 'orange',
+        objected: 'blue',
+        rejected: 'red',
+        success: 'green',
+        dupe: 'blue',
+        invalid: 'red',
+        accepted: 'green'
+      }
+      return map
+    }
+  }
+}
+</script>
+
+<style scoped>
+.status-tag {
+  font-size: 22rpx;
+  padding: 4rpx 16rpx;
+  border-radius: 8rpx;
+  line-height: 1.5;
+}
+.tag-blue { background: #EAF3FB; color: #2E6FA8; }
+.tag-green { background: #E4F3EA; color: #0E8A4F; }
+.tag-orange { background: #FFF3E0; color: #B9770E; }
+.tag-red { background: #FDECEA; color: #C0392B; }
+.tag-grey { background: #F0F3F7; color: #7A97B5; }
+</style>

+ 30 - 0
train-frontend/pages.json

@@ -233,6 +233,36 @@
       "style": {
         "navigationBarTitleText": "档案详情"
       }
+    },
+    {
+      "path": "pages/cohort/index",
+      "style": {
+        "navigationBarTitleText": "培训批次"
+      }
+    },
+    {
+      "path": "pages/cohort/detail",
+      "style": {
+        "navigationBarTitleText": "批次详情"
+      }
+    },
+    {
+      "path": "pages/attendance/scan",
+      "style": {
+        "navigationBarTitleText": "现场签到"
+      }
+    },
+    {
+      "path": "pages/attendance/qr",
+      "style": {
+        "navigationBarTitleText": "签到码"
+      }
+    },
+    {
+      "path": "pages/credit/index",
+      "style": {
+        "navigationBarTitleText": "学时账户"
+      }
     }
   ],
   "globalStyle": {

+ 239 - 0
train-frontend/pages/attendance/qr.vue

@@ -0,0 +1,239 @@
+<template>
+  <view class="qr-page">
+    <view class="qr-card">
+      <!-- 场次信息 -->
+      <text class="qr-title">{{ sessionName || '现场签到码' }}</text>
+      <text v-if="cohortName" class="qr-sub">{{ cohortName }}</text>
+      <text v-if="sessionTime" class="qr-time">{{ sessionTime }}</text>
+
+      <!-- 二维码 -->
+      <view class="qr-box">
+        <!-- #ifdef MP-WEIXIN || H5 -->
+        <canvas canvas-id="qrcode" class="qr-canvas" :style="{ width: canvasSize + 'px', height: canvasSize + 'px' }"></canvas>
+        <!-- #endif -->
+        <view v-if="drawing" class="qr-loading">生成中...</view>
+      </view>
+
+      <!-- 倒计时 + 刷新 -->
+      <view class="countdown-row">
+        <text class="countdown-label">二维码 {{ countdown }}s 后自动刷新</text>
+      </view>
+      <button class="big-btn refresh-btn" :disabled="drawing" @click="refreshCode">刷新换码</button>
+      <text class="qr-tip">· 每次刷新旧码立即失效,防照片回放</text>
+      <text class="qr-tip">· 让学员扫码,或让其手动输入下方签到码</text>
+
+      <!-- 签到码文字兜底(供手动输入) -->
+      <view v-if="code" class="code-box">
+        <text class="code-label">签到码</text>
+        <text class="code-value">{{ code }}</text>
+      </view>
+    </view>
+
+    <!-- 错误态 -->
+    <ErrorState v-if="error" message="签到码生成失败" @retry="loadCode" />
+    <!-- 空态:未传场次编号 -->
+    <EmptyState
+      v-if="!error && !code && !drawing && !sessionId"
+      icon="🔑"
+      title="缺少场次信息"
+      desc="请从批次/场次管理进入本页,以指定场次生成签到码"
+    />
+  </view>
+</template>
+
+<script>
+import UQRCode from '@/common/uqrcode.js'
+import { getAttendanceSessionCode } from '@/api/attendance.js'
+import { formatDateTime } from '@/utils/format.js'
+import ErrorState from '@/components/error-state.vue'
+import EmptyState from '@/components/empty-state.vue'
+
+var AUTO_SECONDS = 60
+
+export default {
+  components: { ErrorState, EmptyState },
+  data() {
+    return {
+      sessionId: '',
+      code: '',
+      sessionName: '',
+      cohortName: '',
+      sessionTime: '',
+      drawing: false,
+      error: false,
+      countdown: AUTO_SECONDS,
+      timer: null,
+      canvasSize: 220
+    }
+  },
+  onLoad(options) {
+    if (options && options.sessionId) {
+      this.sessionId = String(options.sessionId)
+    }
+    // 自适应画布尺寸(不小于 200px,不超过屏宽 - 80)
+    var info = uni.getSystemInfoSync()
+    var winW = info.windowWidth || 375
+    this.canvasSize = winW - 80 > 260 ? 260 : (winW - 80 < 200 ? 200 : winW - 80)
+  },
+  onReady() {
+    if (this.sessionId) {
+      this.loadCode()
+    }
+  },
+  onUnload() {
+    this.clearTimer()
+  },
+  methods: {
+    loadCode() {
+      var self = this
+      self.error = false
+      self.drawing = true
+      getAttendanceSessionCode(this.sessionId).then(function(res) {
+        var data = (res && res.data) ? res.data : {}
+        self.code = data.code || ''
+        self.sessionName = data.sessionName || data.name || '现场签到码'
+        self.cohortName = data.cohortName || ''
+        if (data.startAt || data.endAt) {
+          var s = formatDateTime(data.startAt)
+          var e = formatDateTime(data.endAt)
+          self.sessionTime = s + ' ~ ' + e
+        } else {
+          self.sessionTime = ''
+        }
+        self.drawing = false
+        if (self.code) {
+          self.drawQr()
+          self.startCountdown()
+        }
+      }).catch(function() {
+        self.drawing = false
+        self.error = true
+        self.clearTimer()
+      })
+    },
+    refreshCode() {
+      if (this.drawing || !this.sessionId) return
+      this.loadCode()
+    },
+    drawQr() {
+      var self = this
+      var content = this.sessionId + '|' + this.code
+      try {
+        var qr = new UQRCode()
+        qr.data = content
+        qr.size = this.canvasSize
+        qr.margin = 16
+        qr.make()
+        var ctx = uni.createCanvasContext('qrcode', this)
+        qr.canvasContext = ctx
+        qr.drawCanvas()
+        setTimeout(function() {
+          ctx.draw(true)
+        }, 30)
+      } catch (e) {
+        console.error('[qr] 二维码绘制失败', e)
+      }
+    },
+    startCountdown() {
+      var self = this
+      this.clearTimer()
+      this.countdown = AUTO_SECONDS
+      this.timer = setInterval(function() {
+        self.countdown = self.countdown - 1
+        if (self.countdown <= 0) {
+          self.loadCode()
+        }
+      }, 1000)
+    },
+    clearTimer() {
+      if (this.timer) {
+        clearInterval(this.timer)
+        this.timer = null
+      }
+    }
+  }
+}
+</script>
+
+<style scoped>
+.qr-page {
+  min-height: 100vh;
+  background: #F4F8FC;
+  padding: 32rpx 24rpx;
+}
+.qr-card {
+  background: #FFFFFF;
+  border: 1px solid #E3EEF7;
+  border-radius: 20rpx;
+  padding: 40rpx 28rpx;
+  display: flex;
+  flex-direction: column;
+  align-items: center;
+}
+.qr-title { font-size: 34rpx; font-weight: 700; color: #12395F; margin-bottom: 8rpx; text-align: center; }
+.qr-sub { font-size: 26rpx; color: #5B7A99; margin-bottom: 8rpx; }
+.qr-time { font-size: 24rpx; color: #7A97B5; margin-bottom: 24rpx; }
+/* 二维码 */
+.qr-box {
+  position: relative;
+  background: #F8FAFC;
+  border: 1rpx solid #E3EEF7;
+  border-radius: 20rpx;
+  padding: 32rpx;
+  margin-bottom: 24rpx;
+  display: flex;
+  align-items: center;
+  justify-content: center;
+}
+.qr-canvas {
+  background: #FFFFFF;
+}
+.qr-loading {
+  position: absolute;
+  font-size: 26rpx;
+  color: #7A97B5;
+}
+/* 倒计时 */
+.countdown-row { margin-bottom: 20rpx; }
+.countdown-label { font-size: 26rpx; color: #5B7A99; }
+.big-btn {
+  width: 100%;
+  height: 88rpx;
+  line-height: 88rpx;
+  background: #2E6FA8;
+  color: #FFFFFF;
+  font-size: 32rpx;
+  font-weight: 600;
+  border-radius: 44rpx;
+  border: none;
+  padding: 0;
+  text-align: center;
+}
+.big-btn:active { opacity: 0.9; }
+.big-btn[disabled] { background: #9DB3C9; }
+.refresh-btn { margin-bottom: 20rpx; }
+.qr-tip {
+  display: block;
+  font-size: 24rpx;
+  color: #9DB3C9;
+  margin-top: 12rpx;
+}
+/* 签到码文字兜底 */
+.code-box {
+  margin-top: 32rpx;
+  padding-top: 28rpx;
+  width: 100%;
+  border-top: 1rpx solid #F0F5FA;
+  display: flex;
+  flex-direction: column;
+  align-items: center;
+}
+.code-label { font-size: 24rpx; color: #7A97B5; margin-bottom: 8rpx; }
+.code-value {
+  font-size: 52rpx;
+  font-weight: 700;
+  color: #2E6FA8;
+  letter-spacing: 8rpx;
+  font-family: monospace;
+}
+</style>

+ 285 - 0
train-frontend/pages/attendance/scan.vue

@@ -0,0 +1,285 @@
+<template>
+  <view class="scan-page">
+    <view class="scan-card">
+      <text class="scan-title">现场签到</text>
+      <text class="scan-sub">请对准讲师/带教展示的签到二维码</text>
+
+      <!-- MP 端:原生扫码 -->
+      <!-- #ifdef MP-WEIXIN -->
+      <view class="scan-icon">📷</view>
+      <button class="big-btn scan-btn" :disabled="busy" @click="openScanner">
+        {{ busy ? '处理中...' : '扫码签到' }}
+      </button>
+      <text class="scan-alt" @click="toggleManual">手动输入签到码</text>
+      <!-- #endif -->
+
+      <!-- 手动输入(H5 降级 + MP 备用) -->
+      <view v-if="manual" class="manual-box">
+        <view v-if="!hasSessionId" class="field-row">
+          <text class="field-label">场次编号</text>
+          <input class="field-input" v-model="inputSessionId" placeholder="请输入场次编号" type="number" />
+        </view>
+        <view class="field-row">
+          <text class="field-label">签到码</text>
+          <input class="field-input" v-model="inputCode" placeholder="请输入签到码" maxlength="16" />
+        </view>
+        <button class="big-btn submit-btn" :disabled="busy" @click="submitManual">
+          {{ busy ? '处理中...' : '提交签到' }}
+        </button>
+      </view>
+
+      <text class="scan-tip">· 扫码即完成签到,学时将在 T+3 自动生效</text>
+      <text class="scan-tip">· 同一场次重复扫码不会重复计学时</text>
+    </view>
+
+    <!-- 结果覆盖层 -->
+    <view v-if="result" class="result-mask">
+      <view class="result-card">
+        <text class="result-icon">{{ resultIcon }}</text>
+        <text class="result-title">{{ result.title }}</text>
+        <text class="result-desc">{{ result.desc }}</text>
+        <button class="big-btn result-btn" @click="closeResult">{{ result.closeText }}</button>
+      </view>
+    </view>
+  </view>
+</template>
+
+<script>
+import { attendanceScan } from '@/api/attendance.js'
+
+export default {
+  data() {
+    return {
+      busy: false,
+      manual: false,
+      hasSessionId: false,
+      sessionId: '',
+      inputSessionId: '',
+      inputCode: '',
+      result: null,
+      lastCode: '',
+      lastTime: 0
+    }
+  },
+  computed: {
+    resultIcon() {
+      if (!this.result) return ''
+      var map = { success: '✅', dupe: 'ℹ️', invalid: '⚠️', error: '❌' }
+      return map[this.result.type] || ''
+    }
+  },
+  onLoad(options) {
+    // 反扫入口:?sessionId=xxx(场次由讲师/带教页面带出)
+    if (options && options.sessionId) {
+      this.sessionId = String(options.sessionId)
+      this.hasSessionId = true
+    }
+    // H5 端 uni.scanCode 不可用:默认展示手动输入表单(降级)
+    // #ifndef MP-WEIXIN
+    this.manual = true
+    // #endif
+  },
+  onShow() {
+    // MP 端进入页面自动唤起扫码
+    // #ifdef MP-WEIXIN
+    this.openScanner()
+    // #endif
+  },
+  methods: {
+    openScanner() {
+      var self = this
+      uni.scanCode({
+        scanType: ['qrCode'],
+        success: function(res) {
+          var content = (res && res.result) ? String(res.result).trim() : ''
+          if (!content) return
+          self.parseAndSubmit(content)
+        },
+        fail: function() {
+          // 用户取消或相机不可用:回落到手动输入
+          self.manual = true
+        }
+      })
+    },
+    toggleManual() {
+      this.manual = !this.manual
+    },
+    submitManual() {
+      var code = (this.inputCode || '').trim()
+      if (!code) {
+        uni.showToast({ title: '请输入签到码', icon: 'none' })
+        return
+      }
+      var sessionId = this.hasSessionId
+        ? this.sessionId
+        : (this.inputSessionId || '').trim()
+      if (!sessionId) {
+        uni.showToast({ title: '请输入场次编号', icon: 'none' })
+        return
+      }
+      this.submit(String(sessionId), code)
+    },
+    // 解析扫码内容:约定 sessionId|code;无分隔符时视作纯 code
+    parseAndSubmit(content) {
+      var sessionId
+      var code
+      if (content.indexOf('|') >= 0) {
+        var parts = content.split('|')
+        sessionId = (parts[0] || '').trim()
+        code = (parts[1] || '').trim()
+      } else {
+        sessionId = this.hasSessionId ? this.sessionId : ''
+        code = content
+      }
+      if (!code) return
+      if (!sessionId) {
+        // 无场次编号:让用户手动补场次
+        this.manual = true
+        this.inputCode = code
+        uni.showToast({ title: '请补充场次编号', icon: 'none' })
+        return
+      }
+      this.submit(sessionId, code)
+    },
+    submit(sessionId, code) {
+      var self = this
+      // 30s 防抖:同场次同码 30s 内不重复提交(服务端幂等兜底为「已签到」)
+      var now = Date.now()
+      if (self.lastCode === code + '#' + sessionId && now - self.lastTime < 30000) {
+        self.showResult('dupe', '已提交,请勿重复操作', '稍后可在学时账户查看入账情况', '知道了')
+        return
+      }
+      self.busy = true
+      self.lastCode = code + '#' + sessionId
+      self.lastTime = now
+      attendanceScan(sessionId, code).then(function(res) {
+        self.busy = false
+        var data = (res && res.data) ? res.data : {}
+        var attended = data.attended !== false
+        var time = data.time || ''
+        self.showResult('success', '签到成功', '✓ 学时待 T+3 生效' + (time ? '(' + time + ')' : ''), '完成')
+      }).catch(function(err) {
+        self.busy = false
+        var msg = (err && err.message) || ''
+        if (msg.indexOf('已签到') >= 0) {
+          self.showResult('dupe', '已签到', '本场次已签到,无需重复操作', '知道了')
+        } else if (msg.indexOf('过期') >= 0 || msg.indexOf('无效') >= 0) {
+          self.showResult('invalid', '签到码无效或已过期', '请找带教刷新签到码后重试', '重新扫码')
+        } else {
+          self.showResult('error', '签到失败', msg || '网络异常,请稍后重试', '重新扫码')
+        }
+      })
+    },
+    showResult(type, title, desc, closeText) {
+      this.result = { type: type, title: title, desc: desc, closeText: closeText }
+    },
+    closeResult() {
+      var type = this.result ? this.result.type : ''
+      this.result = null
+      if (type === 'invalid' || type === 'error') {
+        // 失效/失败:清空输入,便于重扫
+        this.inputCode = ''
+        // #ifdef MP-WEIXIN
+        this.openScanner()
+        // #endif
+      }
+    }
+  }
+}
+</script>
+
+<style scoped>
+.scan-page {
+  min-height: 100vh;
+  background: #F4F8FC;
+  padding: 40rpx 32rpx;
+}
+.scan-card {
+  background: #FFFFFF;
+  border: 1px solid #E3EEF7;
+  border-radius: 20rpx;
+  padding: 56rpx 32rpx;
+  display: flex;
+  flex-direction: column;
+  align-items: center;
+}
+.scan-title { font-size: 36rpx; font-weight: 700; color: #12395F; margin-bottom: 12rpx; }
+.scan-sub { font-size: 26rpx; color: #5B7A99; margin-bottom: 40rpx; }
+.scan-icon { font-size: 96rpx; margin-bottom: 24rpx; }
+.big-btn {
+  width: 100%;
+  height: 88rpx;
+  line-height: 88rpx;
+  background: #2E6FA8;
+  color: #FFFFFF;
+  font-size: 32rpx;
+  font-weight: 600;
+  border-radius: 44rpx;
+  border: none;
+  padding: 0;
+  text-align: center;
+}
+.big-btn:active { opacity: 0.9; }
+.big-btn[disabled] { background: #9DB3C9; }
+.scan-btn { margin-bottom: 24rpx; }
+.scan-alt { font-size: 26rpx; color: #2E6FA8; }
+.manual-box {
+  width: 100%;
+  margin-top: 32rpx;
+  padding-top: 32rpx;
+  border-top: 1rpx solid #F0F5FA;
+}
+.field-row {
+  display: flex;
+  align-items: center;
+  margin-bottom: 20rpx;
+}
+.field-label {
+  width: 150rpx;
+  font-size: 26rpx;
+  color: #5B7A99;
+}
+.field-input {
+  flex: 1;
+  height: 72rpx;
+  background: #F8FAFC;
+  border: 1rpx solid #E3EEF7;
+  border-radius: 12rpx;
+  padding: 0 20rpx;
+  font-size: 28rpx;
+  color: #12395F;
+}
+.submit-btn { margin-top: 12rpx; }
+.scan-tip {
+  display: block;
+  font-size: 24rpx;
+  color: #9DB3C9;
+  margin-top: 16rpx;
+}
+/* 结果覆盖层 */
+.result-mask {
+  position: fixed;
+  left: 0;
+  top: 0;
+  right: 0;
+  bottom: 0;
+  background: rgba(18, 57, 95, 0.55);
+  display: flex;
+  align-items: center;
+  justify-content: center;
+  z-index: 999;
+}
+.result-card {
+  width: 78%;
+  background: #FFFFFF;
+  border-radius: 20rpx;
+  padding: 56rpx 40rpx 40rpx;
+  display: flex;
+  flex-direction: column;
+  align-items: center;
+}
+.result-icon { font-size: 96rpx; margin-bottom: 24rpx; }
+.result-title { font-size: 34rpx; font-weight: 700; color: #12395F; margin-bottom: 16rpx; }
+.result-desc { font-size: 26rpx; color: #5B7A99; text-align: center; line-height: 1.7; margin-bottom: 36rpx; }
+.result-btn { width: 100%; }
+</style>

+ 345 - 0
train-frontend/pages/cohort/detail.vue

@@ -0,0 +1,345 @@
+<template>
+  <view class="cd-page">
+    <!-- 加载骨架 -->
+    <LoadingSkeleton v-if="loading" :rows="4" />
+
+    <!-- 错误态 -->
+    <ErrorState v-else-if="error" message="批次详情加载失败" @retry="loadDetail" />
+
+    <!-- 空态:详情与本地缓存均无数据 -->
+    <EmptyState
+      v-else-if="!cohort"
+      icon="🔍"
+      title="未找到该批次"
+      desc="批次可能已下线或已截止,可返回批次列表查看其他场次"
+      action-text="返回列表"
+      @action="goBackList"
+    />
+
+    <!-- 正常态 -->
+    <view v-else class="cd-content">
+      <!-- 信息卡 -->
+      <view class="info-card">
+        <view class="card-top">
+          <text class="card-name">{{ cohort.name }}</text>
+          <StatusTag :status="statusKey" />
+        </view>
+
+        <view class="info-row">
+          <text class="info-label">时间</text>
+          <text class="info-value">{{ timeText }}</text>
+        </view>
+        <view v-if="cohort.teacherName" class="info-row">
+          <text class="info-label">讲师</text>
+          <text class="info-value">{{ cohort.teacherName }}</text>
+        </view>
+        <view v-if="cohort.place" class="info-row">
+          <text class="info-label">地点</text>
+          <text class="info-value">{{ cohort.place }}</text>
+        </view>
+        <view class="info-row">
+          <text class="info-label">学时构成</text>
+          <text class="info-value">{{ creditText }}</text>
+        </view>
+        <view v-if="deadlineText" class="info-row">
+          <text class="info-label">报名截止</text>
+          <text class="info-value">{{ deadlineText }}</text>
+        </view>
+        <view class="info-row">
+          <text class="info-label">批次编号</text>
+          <text class="info-value">{{ cohort.cohortNo || cohort.id }}</text>
+        </view>
+      </view>
+
+      <!-- 报名进度卡 -->
+      <view class="progress-card">
+        <view class="progress-head">
+          <text class="progress-title">报名进度</text>
+          <text class="progress-num">{{ signedCount }}/{{ capacity }} 人</text>
+        </view>
+        <ProgressBar :percent="signPercent" :color="progressColor" />
+        <text class="progress-tip">{{ progressTip }}</text>
+      </view>
+
+      <!-- 报名须知 -->
+      <view class="notice-card">
+        <text class="notice-title">报名须知</text>
+        <text class="notice-line">· 报名成功后需等待机构审核,审核通过即可进入班级</text>
+        <text class="notice-line">· 现场签到后学时待 T+3 生效,可在「学时账户」查看</text>
+        <text class="notice-line">· 重复报名不会重复占用名额</text>
+      </view>
+    </view>
+
+    <!-- 底部操作栏 -->
+    <view v-if="cohort" class="action-bar">
+      <view v-if="isFull" class="action-btn action-disabled">已满</view>
+      <view v-else-if="isSigned" class="action-btn action-disabled">已报名(待审核)</view>
+      <view v-else class="action-btn action-primary" @click="doSignup">
+        {{ submitting ? '报名中...' : '立即报名' }}
+      </view>
+    </view>
+  </view>
+</template>
+
+<script>
+import { getCohortDetail, cohortSignup } from '@/api/cohort.js'
+import { creditHours, formatDateTime, parseDate } from '@/utils/format.js'
+import StatusTag from '@/components/status-tag.vue'
+import EmptyState from '@/components/empty-state.vue'
+import ErrorState from '@/components/error-state.vue'
+import LoadingSkeleton from '@/components/loading-skeleton.vue'
+import ProgressBar from '@/components/progress-bar.vue'
+
+var CACHE_KEY = 'cohortDetailCache'
+var SIGNED_KEY = 'cohortSignedIds'
+
+export default {
+  components: { StatusTag, EmptyState, ErrorState, LoadingSkeleton, ProgressBar },
+  data() {
+    return {
+      loading: true,
+      error: false,
+      cohortId: null,
+      cohort: null,
+      submitting: false
+    }
+  },
+  computed: {
+    statusKey() {
+      if (!this.cohort) return ''
+      return this.resolveStatus(this.cohort)
+    },
+    isFull() {
+      return this.statusKey === 'full' || this.statusKey === 'closed'
+    },
+    isSigned() {
+      if (!this.cohortId) return false
+      if (this.cohort.enrolled === true || this.cohort.signedUp === true) return true
+      var ids = this.localSignedIds()
+      for (var i = 0; i < ids.length; i++) {
+        if (String(ids[i]) === String(this.cohortId)) return true
+      }
+      return false
+    },
+    capacity() {
+      return this.cohort ? this.cohort.capacity || 0 : 0
+    },
+    signedCount() {
+      return this.cohort ? this.cohort.signedCount || 0 : 0
+    },
+    signPercent() {
+      if (this.capacity <= 0) return 0
+      var p = (this.signedCount / this.capacity) * 100
+      if (p < 0) return 0
+      if (p > 100) return 100
+      return Math.round(p)
+    },
+    progressColor() {
+      if (this.isFull) return '#C0392B'
+      return '#2E6FA8'
+    },
+    progressTip() {
+      if (this.capacity <= 0) return '名额信息待更新'
+      if (this.isFull) return '名额已满,可关注下一批次'
+      return '还可报名 ' + (this.capacity - this.signedCount) + ' 人'
+    },
+    timeText() {
+      if (!this.cohort) return ''
+      var start = formatDateTime(this.cohort.startAt)
+      var end = formatDateTime(this.cohort.endAt)
+      var t = start ? start.slice(0, 16) : '时间待定'
+      if (end) t = t + ' ~ ' + end.slice(0, 16)
+      return t
+    },
+    creditText() {
+      if (!this.cohort) return ''
+      var theory = creditHours(this.cohort.creditTheory || 0)
+      var practice = creditHours(this.cohort.creditPractice || 0)
+      return '理论 ' + theory + ' + 实践 ' + practice + ' 学时'
+    },
+    deadlineText() {
+      if (!this.cohort) return ''
+      var d = this.cohort.signupDeadline || this.cohort.deadline || this.cohort.enrollDeadline
+      return d ? formatDateTime(d).slice(0, 16) : ''
+    }
+  },
+  onLoad(options) {
+    this.cohortId = options && options.cohortId ? options.cohortId : null
+    this.loadDetail()
+  },
+  methods: {
+    loadDetail() {
+      var self = this
+      if (!this.cohortId) {
+        // 无 id:尝试回退到列表页缓存
+        this.cohort = this.cacheData()
+        this.loading = false
+        if (!this.cohort) this.error = false
+        return
+      }
+      self.loading = true
+      self.error = false
+      getCohortDetail(this.cohortId).then(function(res) {
+        self.loading = false
+        var data = (res && res.data) ? res.data : null
+        self.cohort = data || self.cacheData()
+        if (!self.cohort) {
+          self.cohort = { id: self.cohortId }
+        }
+      }).catch(function() {
+        // detail 接口未上线/失败:回退列表页传入的缓存数据,保证报名可用
+        self.loading = false
+        var cache = self.cacheData()
+        if (cache) {
+          self.cohort = cache
+        } else {
+          self.error = true
+        }
+      })
+    },
+    cacheData() {
+      var c = uni.getStorageSync(CACHE_KEY)
+      if (!c) return null
+      if (this.cohortId && String(c.id) !== String(this.cohortId)) return null
+      return c
+    },
+    localSignedIds() {
+      var arr = uni.getStorageSync(SIGNED_KEY)
+      return Array.isArray(arr) ? arr : []
+    },
+    resolveStatus(c) {
+      var status = c.status || ''
+      if (status === 'closed') return 'closed'
+      if (status === 'draft') return 'draft'
+      var capacity = c.capacity || 0
+      var signed = c.signedCount || 0
+      if (capacity > 0 && signed >= capacity) return 'full'
+      var start = parseDate(c.startAt)
+      var end = parseDate(c.endAt)
+      if (start && end) {
+        var now = new Date()
+        if (now.getTime() >= start.getTime() && now.getTime() <= end.getTime()) {
+          return 'ongoing'
+        }
+      }
+      return 'published'
+    },
+    doSignup() {
+      var self = this
+      if (self.submitting || self.isSigned || self.isFull) return
+      if (!self.cohortId) return
+      uni.showModal({
+        title: '确认报名',
+        content: '报名后请等待机构审核,审核通过即可进入班级。',
+        success: function(res) {
+          if (!res.confirm) return
+          self.submitSignup()
+        }
+      })
+    },
+    submitSignup() {
+      var self = this
+      self.submitting = true
+      cohortSignup(this.cohortId).then(function() {
+        self.submitting = false
+        var ids = self.localSignedIds()
+        var found = false
+        for (var i = 0; i < ids.length; i++) {
+          if (String(ids[i]) === String(self.cohortId)) { found = true; break }
+        }
+        if (!found) {
+          ids.push(self.cohortId)
+          uni.setStorageSync(SIGNED_KEY, ids)
+        }
+        uni.showToast({ title: '报名成功,审核通过后进入班级', icon: 'none' })
+        // 刷新名额展示
+        self.cohort = Object.assign({}, self.cohort, {
+          signedCount: (self.signedCount || 0) + 1
+        })
+      }).catch(function(err) {
+        self.submitting = false
+        var msg = (err && err.message) || '报名失败'
+        uni.showToast({ title: msg, icon: 'none' })
+      })
+    },
+    goBackList() {
+      uni.redirectTo({ url: '/pages/cohort/index' })
+    }
+  }
+}
+</script>
+
+<style scoped>
+.cd-page {
+  min-height: 100vh;
+  background: #F4F8FC;
+  padding: 20rpx 24rpx 160rpx;
+}
+.info-card,
+.progress-card,
+.notice-card {
+  background: #FFFFFF;
+  border: 1px solid #E3EEF7;
+  border-radius: 20rpx;
+  padding: 28rpx 26rpx;
+  margin-bottom: 20rpx;
+}
+.card-top {
+  display: flex;
+  justify-content: space-between;
+  align-items: center;
+  margin-bottom: 20rpx;
+}
+.card-name { font-size: 34rpx; font-weight: 700; color: #12395F; }
+.info-row {
+  display: flex;
+  justify-content: space-between;
+  align-items: flex-start;
+  padding: 14rpx 0;
+  border-bottom: 1rpx solid #F0F5FA;
+}
+.info-row:last-child { border-bottom: none; }
+.info-label { font-size: 26rpx; color: #7A97B5; }
+.info-value {
+  font-size: 26rpx;
+  color: #1E3A5F;
+  font-weight: 500;
+  max-width: 62%;
+  text-align: right;
+  line-height: 1.5;
+}
+.progress-head {
+  display: flex;
+  justify-content: space-between;
+  align-items: center;
+  margin-bottom: 20rpx;
+}
+.progress-title { font-size: 30rpx; font-weight: 700; color: #12395F; }
+.progress-num { font-size: 28rpx; color: #2E6FA8; font-weight: 600; }
+.progress-tip { display: block; font-size: 24rpx; color: #7A97B5; margin-top: 16rpx; }
+.notice-title { display: block; font-size: 30rpx; font-weight: 700; color: #12395F; margin-bottom: 16rpx; }
+.notice-line { display: block; font-size: 24rpx; color: #5B7A99; line-height: 1.9; }
+/* 底部操作栏 */
+.action-bar {
+  position: fixed;
+  left: 0;
+  right: 0;
+  bottom: 0;
+  background: #FFFFFF;
+  border-top: 1rpx solid #E3EEF7;
+  padding: 20rpx 24rpx;
+  padding-bottom: calc(20rpx + constant(safe-area-inset-bottom));
+  padding-bottom: calc(20rpx + env(safe-area-inset-bottom));
+}
+.action-btn {
+  height: 88rpx;
+  line-height: 88rpx;
+  border-radius: 44rpx;
+  text-align: center;
+  font-size: 32rpx;
+  font-weight: 600;
+}
+.action-primary { background: #2E6FA8; color: #FFFFFF; }
+.action-primary:active { opacity: 0.9; }
+.action-disabled { background: #C9D6E2; color: #FFFFFF; }
+</style>

+ 311 - 0
train-frontend/pages/cohort/index.vue

@@ -0,0 +1,311 @@
+<template>
+  <view class="cohort-page">
+    <!-- 课程筛选 -->
+    <view class="filter-bar">
+      <scroll-view class="filter-scroll" scroll-x="true" :show-scrollbar="false">
+        <view class="filter-row">
+          <view
+            v-for="(c, idx) in filterItems"
+            :key="idx"
+            class="filter-item"
+            :class="c.cls"
+            @click="selectCourse(c)"
+          >{{ c.name }}</view>
+        </view>
+      </scroll-view>
+    </view>
+
+    <!-- 加载骨架 -->
+    <LoadingSkeleton v-if="loading" :rows="3" />
+
+    <!-- 错误态 -->
+    <ErrorState v-else-if="error" message="批次列表加载失败" @retry="loadCohorts" />
+
+    <!-- 空态 -->
+    <EmptyState
+      v-else-if="list.length === 0"
+      icon="📅"
+      title="暂无可报名批次"
+      desc="新批次发布后会出现在这里,可先关注培训通知"
+      :action-text="filterCourseId ? '查看全部批次' : ''"
+      @action="resetFilter"
+    />
+
+    <!-- 正常态:批次卡片 -->
+    <view v-else class="cohort-list">
+      <view v-for="(item, idx) in list" :key="item.id || idx" class="cohort-card" @click="goDetail(item)">
+        <view class="card-top">
+          <text class="card-name">{{ item.name }}</text>
+          <StatusTag :status="item.statusKey" />
+        </view>
+
+        <view class="card-meta">
+          <text class="meta-line">📅 {{ item.timeText }}</text>
+          <text v-if="item.teacherText" class="meta-line">👤 {{ item.teacherText }}</text>
+          <text v-if="item.placeText" class="meta-line">📍 {{ item.placeText }}</text>
+          <text class="meta-line">⏱ 学时 {{ item.creditText }}</text>
+          <text v-if="item.deadlineText" class="meta-line">⏳ 报名截止 {{ item.deadlineText }}</text>
+        </view>
+
+        <view class="card-bottom">
+          <view class="capacity">
+            <text class="capacity-text">已报 {{ item.signedCount }}/{{ item.capacity }} 人</text>
+          </view>
+          <text class="card-arrow">›</text>
+        </view>
+      </view>
+
+      <view v-if="hasMore" class="more-btn" @click="loadMore">加载更多</view>
+      <view v-else class="no-more">没有更多批次了</view>
+    </view>
+  </view>
+</template>
+
+<script>
+import { getCohortList } from '@/api/cohort.js'
+import { getCourseList } from '@/utils/api.js'
+import { creditHours, formatDateTime, parseDate } from '@/utils/format.js'
+import StatusTag from '@/components/status-tag.vue'
+import EmptyState from '@/components/empty-state.vue'
+import ErrorState from '@/components/error-state.vue'
+import LoadingSkeleton from '@/components/loading-skeleton.vue'
+
+export default {
+  components: { StatusTag, EmptyState, ErrorState, LoadingSkeleton },
+  data() {
+    return {
+      loading: true,
+      error: false,
+      rawList: [],
+      total: 0,
+      page: 1,
+      size: 10,
+      courses: [],
+      courseIndex: -1,
+      filterCourseId: null
+    }
+  },
+  computed: {
+    hasMore() {
+      return this.rawList.length < this.total
+    },
+    // 课程筛选项视图模型:cls 在高德、无模板方法/表达式(class 仅绑计算属性)
+    filterItems() {
+      var arr = []
+      arr.push({
+        name: '全部',
+        courseId: null,
+        index: -1,
+        cls: this.courseIndex === -1 ? 'filter-active' : 'filter-normal'
+      })
+      for (var i = 0; i < this.courses.length; i++) {
+        var c = this.courses[i]
+        arr.push({
+          name: c.name || c.courseName || c.title || '',
+          courseId: c.id || c.courseId,
+          index: i,
+          cls: this.courseIndex === i ? 'filter-active' : 'filter-normal'
+        })
+      }
+      return arr
+    },
+    // 列表视图模型:状态归一 + 排序(可报名 → 进行中 → 已满/已截止)
+    list() {
+      var arr = []
+      for (var i = 0; i < this.rawList.length; i++) {
+        arr.push(this.toView(this.rawList[i]))
+      }
+      arr.sort(function(a, b) {
+        return a.rank - b.rank
+      })
+      return arr
+    }
+  },
+  onLoad() {
+    this.loadCourses()
+    this.loadCohorts()
+  },
+  methods: {
+    loadCourses() {
+      var self = this
+      getCourseList().then(function(res) {
+        var data = (res && res.data) ? res.data : []
+        self.courses = Array.isArray(data) ? data : (data.list || [])
+      }).catch(function() {
+        self.courses = []
+      })
+    },
+    loadCohorts() {
+      var self = this
+      self.loading = true
+      self.error = false
+      getCohortList({
+        courseId: this.filterCourseId,
+        page: this.page,
+        size: this.size
+      }).then(function(res) {
+        self.loading = false
+        var data = (res && res.data) ? res.data : {}
+        var list = data.list || []
+        if (self.page === 1) {
+          self.rawList = list
+        } else {
+          self.rawList = self.rawList.concat(list)
+        }
+        self.total = data.total || self.rawList.length
+      }).catch(function() {
+        self.loading = false
+        self.error = true
+      })
+    },
+    loadMore() {
+      if (this.loading) return
+      this.page = this.page + 1
+      this.loadCohorts()
+    },
+    selectCourse(item) {
+      if (!item) return
+      this.courseIndex = item.index === undefined ? -1 : item.index
+      this.filterCourseId = item.courseId || null
+      this.page = 1
+      this.rawList = []
+      this.loadCohorts()
+    },
+    resetFilter() {
+      this.courseIndex = -1
+      this.filterCourseId = null
+      this.page = 1
+      this.rawList = []
+      this.loadCohorts()
+    },
+    // 批次 → 视图模型:状态归一(可报名/进行中/已满/已截止/未发布)+ 字段兜底
+    toView(c) {
+      var statusKey = this.resolveStatus(c)
+      var theory = creditHours(c.creditTheory || 0)
+      var practice = creditHours(c.creditPractice || 0)
+      var start = formatDateTime(c.startAt)
+      var end = formatDateTime(c.endAt)
+      var timeText = start ? start.slice(0, 16) : '时间待定'
+      if (end) timeText = timeText + ' ~ ' + end.slice(0, 16)
+      var deadline = c.signupDeadline || c.deadline || c.enrollDeadline
+      var deadlineText = deadline ? formatDateTime(deadline).slice(0, 16) : ''
+      return {
+        id: c.id,
+        name: c.name || '培训批次',
+        statusKey: statusKey,
+        rank: this.rankOf(statusKey),
+        timeText: timeText,
+        teacherText: c.teacherName || c.teacher || '',
+        placeText: c.place || c.address || '',
+        creditText: theory + '+' + practice + ' 学时',
+        deadlineText: deadlineText,
+        capacity: c.capacity || 0,
+        signedCount: c.signedCount || 0
+      }
+    },
+    // 状态归一:后端 status(draft/published/closed) + 容量 + 时间窗
+    resolveStatus(c) {
+      var status = c.status || ''
+      if (status === 'closed') return 'closed'
+      if (status === 'draft') return 'draft'
+      var capacity = c.capacity || 0
+      var signed = c.signedCount || 0
+      if (capacity > 0 && signed >= capacity) return 'full'
+      var start = parseDate(c.startAt)
+      var end = parseDate(c.endAt)
+      if (start && end) {
+        var now = new Date()
+        if (now.getTime() >= start.getTime() && now.getTime() <= end.getTime()) {
+          return 'ongoing'
+        }
+      }
+      return 'published'
+    },
+    // 排序权重:可报名(0) → 进行中(1) → 已满(2) → 已截止(3) → 未发布(4)
+    rankOf(statusKey) {
+      var map = { published: 0, ongoing: 1, full: 2, closed: 3, draft: 4 }
+      var v = map[statusKey]
+      return (v === undefined) ? 5 : v
+    },
+    goDetail(item) {
+      // 缓存批次信息:detail 接口未上线时,详情页用缓存兜底展示并支持报名
+      uni.setStorageSync('cohortDetailCache', item)
+      uni.navigateTo({ url: '/pages/cohort/detail?cohortId=' + item.id })
+    }
+  }
+}
+</script>
+
+<style scoped>
+.cohort-page {
+  min-height: 100vh;
+  background: #F4F8FC;
+  padding: 20rpx 24rpx 40rpx;
+}
+/* 课程筛选 */
+.filter-bar {
+  background: #FFFFFF;
+  border: 1px solid #E3EEF7;
+  border-radius: 16rpx;
+  padding: 16rpx 12rpx;
+  margin-bottom: 20rpx;
+}
+.filter-scroll { white-space: nowrap; width: 100%; }
+.filter-row { display: flex; flex-direction: row; align-items: center; }
+.filter-item {
+  display: inline-flex;
+  align-items: center;
+  height: 60rpx;
+  line-height: 60rpx;
+  padding: 0 28rpx;
+  margin-right: 16rpx;
+  border-radius: 30rpx;
+  font-size: 26rpx;
+  white-space: nowrap;
+}
+.filter-normal { background: #F0F5FA; color: #5B7A99; }
+.filter-active { background: #2E6FA8; color: #FFFFFF; font-weight: 600; }
+/* 批次卡片 */
+.cohort-card {
+  background: #FFFFFF;
+  border: 1px solid #E3EEF7;
+  border-radius: 20rpx;
+  padding: 26rpx 24rpx;
+  margin-bottom: 20rpx;
+}
+.cohort-card:active { background: #F7FBFE; }
+.card-top {
+  display: flex;
+  justify-content: space-between;
+  align-items: center;
+  margin-bottom: 16rpx;
+}
+.card-name { font-size: 32rpx; font-weight: 700; color: #12395F; }
+.card-meta { margin-bottom: 16rpx; }
+.meta-line {
+  display: block;
+  font-size: 25rpx;
+  color: #5B7A99;
+  line-height: 1.9;
+}
+.card-bottom {
+  display: flex;
+  justify-content: space-between;
+  align-items: center;
+  padding-top: 16rpx;
+  border-top: 1rpx solid #F0F5FA;
+}
+.capacity-text { font-size: 25rpx; color: #7A97B5; }
+.card-arrow { font-size: 34rpx; color: #C4D6E4; }
+.more-btn {
+  height: 84rpx;
+  line-height: 84rpx;
+  text-align: center;
+  background: #FFFFFF;
+  border: 1px solid #E3EEF7;
+  border-radius: 44rpx;
+  font-size: 28rpx;
+  color: #2E6FA8;
+}
+.no-more { text-align: center; padding: 24rpx 0; }
+</style>

+ 464 - 0
train-frontend/pages/credit/index.vue

@@ -0,0 +1,464 @@
+<template>
+  <view class="credit-page">
+    <!-- 加载骨架 -->
+    <LoadingSkeleton v-if="loading" :rows="4" />
+
+    <!-- 错误态 -->
+    <ErrorState v-else-if="error" message="学时账户加载失败" @retry="loadAll" />
+
+    <!-- 空态 -->
+    <EmptyState
+      v-else-if="isEmpty"
+      icon="⏳"
+      title="暂无学时"
+      desc="完成培训签到后学时将自动入账,T+3 后正式生效"
+    />
+
+    <!-- 正常态 -->
+    <view v-else>
+      <!-- 顶部大数字 -->
+      <view class="hero-card">
+        <text class="hero-label">{{ year }}年已学</text>
+        <view class="hero-num-row">
+          <text class="hero-num">{{ totalText }}</text>
+          <text class="hero-unit">/ 90.0 学时</text>
+        </view>
+        <text class="hero-gap" :class="gapClass">{{ gapText }}</text>
+      </view>
+
+      <!-- 理论/实践分列 -->
+      <view class="split-card">
+        <view class="split-row">
+          <view class="split-head">
+            <text class="split-name">理论学时</text>
+            <text class="split-num">已 {{ theoryText }} / 40.0 h</text>
+          </view>
+          <ProgressBar :percent="theoryPercent" :color="blueColor" />
+        </view>
+        <view class="split-row">
+          <view class="split-head">
+            <text class="split-name">实践学时</text>
+            <text class="split-num">已 {{ practiceText }} / 20.0 h</text>
+          </view>
+          <ProgressBar :percent="practicePercent" :color="greenColor" />
+        </view>
+      </view>
+
+      <!-- 双 Tab -->
+      <view class="tab-card">
+        <view class="tab-head">
+          <view class="tab-item" :class="effectiveTabClass" @click="switchTab('effective')">
+            生效中({{ effectiveList.length }})
+          </view>
+          <view class="tab-item" :class="pendingTabClass" @click="switchTab('pending')">
+            待生效({{ pendingList.length }})
+          </view>
+        </view>
+
+        <!-- 明细列表 -->
+        <view v-if="activeList.length === 0" class="list-empty">
+          <text class="list-empty-text">暂无{{ activeTab === 'effective' ? '生效' : '待生效' }}明细</text>
+        </view>
+        <view v-else>
+          <view v-for="(item, idx) in activeList" :key="item.id || idx" class="credit-item">
+            <view class="item-top">
+              <text class="item-name">{{ item.sourceText }}</text>
+              <text class="item-hours">+{{ item.hoursText }}h</text>
+            </view>
+            <view class="item-mid">
+              <StatusTag :status="item.status" type="credit" />
+              <text v-if="item.effectiveText" class="item-time">{{ item.effectiveText }}</text>
+              <text v-else-if="item.status === 'pending'" class="item-time">待 T+3 生效</text>
+            </view>
+            <view v-if="item.canObject && activeTab === 'pending'" class="item-bottom">
+              <text class="object-btn" @click="openObject(item)">提异议</text>
+            </view>
+          </view>
+        </view>
+      </view>
+    </view>
+
+    <!-- 提异议弹窗 -->
+    <view v-if="objectModal" class="modal-mask">
+      <view class="modal-card">
+        <text class="modal-title">学时异议</text>
+        <text class="modal-desc">异议提交后由机构复核,请说明原因</text>
+        <textarea
+          class="modal-textarea"
+          v-model="objectReason"
+          placeholder="请输入异议原因(必填)"
+          maxlength="200"
+        ></textarea>
+        <view class="modal-btns">
+          <view class="modal-btn modal-btn-cancel" @click="closeObject">取消</view>
+          <view class="modal-btn modal-btn-ok" @click="submitObject">提交</view>
+        </view>
+      </view>
+    </view>
+  </view>
+</template>
+
+<script>
+import { getCreditMine, getCreditPending, creditObject } from '@/api/credit.js'
+import { creditHours, formatDateTime } from '@/utils/format.js'
+import StatusTag from '@/components/status-tag.vue'
+import EmptyState from '@/components/empty-state.vue'
+import ErrorState from '@/components/error-state.vue'
+import LoadingSkeleton from '@/components/loading-skeleton.vue'
+import ProgressBar from '@/components/progress-bar.vue'
+
+// 目标阈值(分钟):理论 2400=40h / 实践 1200=20h / 总 5400=90h(合同红线:一律分钟)
+var TARGET_THEORY = 2400
+var TARGET_PRACTICE = 1200
+var TARGET_TOTAL = 5400
+
+export default {
+  components: { StatusTag, EmptyState, ErrorState, LoadingSkeleton, ProgressBar },
+  data() {
+    return {
+      loading: true,
+      error: false,
+      year: 0,
+      total: 0,
+      theory: 0,
+      practice: 0,
+      gap: 0,
+      detail: [],
+      pendingRows: [],
+      activeTab: 'effective',
+      objectModal: false,
+      objectReason: '',
+      objectTarget: null,
+      submittingObject: false
+    }
+  },
+  computed: {
+    isEmpty() {
+      if (this.loading || this.error) return false
+      return this.total === 0 && this.theory === 0 && this.practice === 0 && (this.detail.length === 0 || !this.hasAnyDetail())
+    },
+    totalText() {
+      return creditHours(this.total)
+    },
+    theoryText() {
+      return creditHours(this.theory)
+    },
+    practiceText() {
+      return creditHours(this.practice)
+    },
+    gapText() {
+      if (this.gap > 0) return '还差 ' + creditHours(this.gap) + ' 学时满足年度目标'
+      return '已达成年度目标 🎉'
+    },
+    gapClass() {
+      return this.gap > 0 ? 'gap-warn' : 'gap-ok'
+    },
+    theoryPercent() {
+      return this.percentOf(this.theory, TARGET_THEORY)
+    },
+    practicePercent() {
+      return this.percentOf(this.practice, TARGET_PRACTICE)
+    },
+    blueColor() {
+      return '#2E6FA8'
+    },
+    greenColor() {
+      return '#0E8A4F'
+    },
+    // 生效侧(effective/objected/rejected)视图模型
+    effectiveList() {
+      return this.buildList('effective')
+    },
+    // 待生效侧(pending)视图模型
+    pendingList() {
+      var arr = []
+      var self = this
+      var source = this.pendingRows.length > 0 ? this.pendingRows : this.filterDetail('pending')
+      for (var i = 0; i < source.length; i++) {
+        arr.push(this.toItem(source[i]))
+      }
+      return arr
+    },
+    activeList() {
+      return this.activeTab === 'effective' ? this.effectiveList : this.pendingList
+    },
+    effectiveTabClass() {
+      return this.activeTab === 'effective' ? 'tab-active' : 'tab-normal'
+    },
+    pendingTabClass() {
+      return this.activeTab === 'pending' ? 'tab-active' : 'tab-normal'
+    }
+  },
+  onShow() {
+    this.loadAll()
+  },
+  methods: {
+    loadAll() {
+      var self = this
+      self.loading = true
+      self.error = false
+      getCreditMine().then(function(res) {
+        var data = (res && res.data) ? res.data : {}
+        self.year = data.year || new Date().getFullYear()
+        self.total = data.total || 0
+        self.theory = data.theory || 0
+        self.practice = data.practice || 0
+        self.gap = data.gap || 0
+        self.detail = data.detail || []
+        // 待生效明细为分页接口,先加载第一页(不足时兜底用 mine.detail 过滤)
+        return getCreditPending(1, 50).then(function(resp) {
+          var pdata = (resp && resp.data) ? resp.data : {}
+          self.pendingRows = Array.isArray(pdata.list) ? pdata.list : []
+          return null
+        })
+      }).catch(function() {
+        self.error = true
+      }).finally(function() {
+        self.loading = false
+      })
+    },
+    hasAnyDetail() {
+      var arr = this.detail || []
+      return arr.length > 0
+    },
+    filterDetail(status) {
+      var arr = []
+      var raw = this.detail || []
+      for (var i = 0; i < raw.length; i++) {
+        if (raw[i].status === status) arr.push(raw[i])
+      }
+      return arr
+    },
+    buildList(tab) {
+      var arr = []
+      var raw = this.detail || []
+      for (var i = 0; i < raw.length; i++) {
+        var s = raw[i].status || ''
+        var hit = tab === 'effective'
+          ? (s === 'effective' || s === 'objected' || s === 'rejected')
+          : (s === 'pending')
+        if (hit) arr.push(this.toItem(raw[i]))
+      }
+      return arr
+    },
+    toItem(raw) {
+      var item = raw || {}
+      return {
+        id: item.id,
+        sourceText: this.sourceText(item.sourceType),
+        hoursText: creditHours(item.hours || item.theory || 0),
+        status: item.status || 'pending',
+        effectiveText: item.effectiveAt ? formatDateTime(item.effectiveAt).slice(0, 16) : '',
+        canObject: this.canObject(item)
+      }
+    },
+    sourceText(type) {
+      var map = {
+        training: '培训',
+        attendance: '现场签到',
+        internship: '实习',
+        community: '社区服务',
+        family_service: '家庭服务',
+        exam: '考核',
+        other: '其他'
+      }
+      return map[type] || type || '学时'
+    },
+    canObject(item) {
+      var s = item.status || ''
+      return s === 'pending' || s === 'effective'
+    },
+    percentOf(part, totalTarget) {
+      if (!totalTarget || totalTarget <= 0) return 0
+      var p = (part / totalTarget) * 100
+      if (p < 0) return 0
+      if (p > 100) return 100
+      return Math.round(p)
+    },
+    switchTab(tab) {
+      this.activeTab = tab
+    },
+    openObject(item) {
+      this.objectTarget = item
+      this.objectReason = ''
+      this.objectModal = true
+    },
+    closeObject() {
+      this.objectModal = false
+      this.objectTarget = null
+      this.objectReason = ''
+    },
+    submitObject() {
+      var self = this
+      var reason = (this.objectReason || '').trim()
+      if (!this.objectTarget) return
+      if (!reason) {
+        uni.showToast({ title: '请输入异议原因', icon: 'none' })
+        return
+      }
+      if (self.submittingObject) return
+      self.submittingObject = true
+      creditObject(this.objectTarget.id, reason).then(function() {
+        self.submittingObject = false
+        self.closeObject()
+        uni.showToast({ title: '异议已提交,待机构复核', icon: 'none' })
+        self.loadAll()
+      }).catch(function(err) {
+        self.submittingObject = false
+        uni.showToast({ title: (err && err.message) || '提交失败', icon: 'none' })
+      })
+    }
+  }
+}
+</script>
+
+<style scoped>
+.credit-page {
+  min-height: 100vh;
+  background: #F4F8FC;
+  padding: 20rpx 24rpx 48rpx;
+}
+/* 顶部大数字 */
+.hero-card {
+  background: linear-gradient(135deg, #12395F, #2E6FA8);
+  border-radius: 20rpx;
+  padding: 36rpx 32rpx;
+  margin-bottom: 20rpx;
+  display: flex;
+  flex-direction: column;
+  align-items: center;
+}
+.hero-label { font-size: 26rpx; color: rgba(255, 255, 255, 0.85); margin-bottom: 12rpx; }
+.hero-num-row { display: flex; align-items: baseline; margin-bottom: 14rpx; }
+.hero-num { font-size: 88rpx; font-weight: 700; color: #FFFFFF; line-height: 1.1; }
+.hero-unit { font-size: 28rpx; color: rgba(255, 255, 255, 0.85); margin-left: 10rpx; }
+.hero-gap { font-size: 26rpx; padding: 6rpx 24rpx; border-radius: 24rpx; }
+.gap-warn { background: rgba(255, 255, 255, 0.2); color: #FFE0B2; }
+.gap-ok { background: rgba(34, 197, 94, 0.3); color: #B8F5CE; }
+/* 分列 */
+.split-card {
+  background: #FFFFFF;
+  border: 1px solid #E3EEF7;
+  border-radius: 20rpx;
+  padding: 28rpx 26rpx;
+  margin-bottom: 20rpx;
+}
+.split-row { margin-bottom: 28rpx; }
+.split-row:last-child { margin-bottom: 0; }
+.split-head {
+  display: flex;
+  justify-content: space-between;
+  align-items: center;
+  margin-bottom: 16rpx;
+}
+.split-name { font-size: 28rpx; font-weight: 600; color: #12395F; }
+.split-num { font-size: 24rpx; color: #7A97B5; }
+/* 双 Tab */
+.tab-card {
+  background: #FFFFFF;
+  border: 1px solid #E3EEF7;
+  border-radius: 20rpx;
+  overflow: hidden;
+}
+.tab-head {
+  display: flex;
+  border-bottom: 1rpx solid #F0F5FA;
+}
+.tab-item {
+  flex: 1;
+  text-align: center;
+  height: 88rpx;
+  line-height: 88rpx;
+  font-size: 28rpx;
+  color: #7A97B5;
+}
+.tab-active {
+  color: #2E6FA8;
+  font-weight: 700;
+}
+.tab-normal { color: #7A97B5; }
+/* 明细 */
+.credit-item {
+  padding: 26rpx 26rpx 22rpx;
+  border-bottom: 1rpx solid #F0F5FA;
+}
+.item-top {
+  display: flex;
+  justify-content: space-between;
+  align-items: center;
+  margin-bottom: 12rpx;
+}
+.item-name { font-size: 28rpx; font-weight: 600; color: #1E3A5F; }
+.item-hours { font-size: 34rpx; font-weight: 700; color: #0E8A4F; }
+.item-mid {
+  display: flex;
+  justify-content: space-between;
+  align-items: center;
+}
+.item-time { font-size: 24rpx; color: #9DB3C9; }
+.item-bottom {
+  display: flex;
+  justify-content: flex-end;
+  margin-top: 12rpx;
+}
+.object-btn {
+  font-size: 24rpx;
+  color: #2E6FA8;
+  border: 1rpx solid #BFDCF1;
+  border-radius: 28rpx;
+  padding: 8rpx 28rpx;
+}
+.object-btn:active { background: #EAF3FB; }
+.list-empty { padding: 56rpx 0; }
+.list-empty-text { display: block; text-align: center; font-size: 26rpx; color: #9DB3C9; }
+/* 弹窗 */
+.modal-mask {
+  position: fixed;
+  left: 0;
+  top: 0;
+  right: 0;
+  bottom: 0;
+  background: rgba(18, 57, 95, 0.55);
+  display: flex;
+  align-items: center;
+  justify-content: center;
+  z-index: 999;
+}
+.modal-card {
+  width: 80%;
+  background: #FFFFFF;
+  border-radius: 20rpx;
+  padding: 40rpx 32rpx 32rpx;
+  display: flex;
+  flex-direction: column;
+}
+.modal-title { font-size: 34rpx; font-weight: 700; color: #12395F; margin-bottom: 12rpx; }
+.modal-desc { font-size: 24rpx; color: #7A97B5; margin-bottom: 24rpx; }
+.modal-textarea {
+  width: 100%;
+  height: 180rpx;
+  background: #F8FAFC;
+  border: 1rpx solid #E3EEF7;
+  border-radius: 12rpx;
+  padding: 20rpx;
+  font-size: 26rpx;
+  color: #12395F;
+  box-sizing: border-box;
+}
+.modal-btns { display: flex; margin-top: 28rpx; }
+.modal-btn {
+  flex: 1;
+  height: 80rpx;
+  line-height: 80rpx;
+  text-align: center;
+  border-radius: 40rpx;
+  font-size: 30rpx;
+  font-weight: 600;
+}
+.modal-btn-cancel {
+  background: #F0F5FA;
+  color: #5B7A99;
+  margin-right: 20rpx;
+}
+.modal-btn-ok { background: #2E6FA8; color: #FFFFFF; }
+</style>

+ 46 - 3
train-frontend/pages/practitioner/index.vue

@@ -99,13 +99,14 @@
       <view class="entry-grid">
         <view class="entry-item active" @click="goWork">
           <text class="entry-icon">🗂️</text>
+          <text v-if="pendingOrderCount > 0" class="badge-dot">{{ pendingOrderCount }}</text>
           <text class="entry-name">工作台</text>
           <text class="entry-sub">接单/履约</text>
         </view>
-        <view class="entry-item disabled">
+        <view class="entry-item active" @click="goCredit">
           <text class="entry-icon">⏳</text>
           <text class="entry-name">学时账户</text>
-          <text class="entry-sub">二期开通</text>
+          <text class="entry-sub">年度达标</text>
         </view>
         <view class="entry-item disabled">
           <text class="entry-icon">⭐</text>
@@ -134,6 +135,7 @@
 
 <script>
 import { getMyPractitioner } from '@/api/practitioner.js'
+import { getMyServiceOrderCounts } from '@/utils/api.js'
 import { maskName } from '@/utils/mask.js'
 import { creditHours } from '@/utils/format.js'
 
@@ -144,7 +146,8 @@ export default {
       error: false,
       errorMsg: '档案加载失败',
       creating: false,
-      profile: null
+      profile: null,
+      pendingOrderCount: 0
     }
   },
   computed: {
@@ -215,8 +218,29 @@ export default {
   },
   onLoad() {
     this.loadProfile()
+    this.loadOrderBadge()
   },
   methods: {
+    // P1 工作台角标:只取 /api/order/mine 的 pending 组 count
+    // ⚠ 合规:该接口 VO 内 familyName/contactPhone/address 未脱敏(mustOwn 本人可见),
+    // 档案页是跨角色共享页面,只允许取 count 角标,禁止渲染 VO 明文字段。
+    loadOrderBadge() {
+      var self = this
+      getMyServiceOrderCounts().then(function(res) {
+        var groups = (res && res.data) ? res.data : []
+        var count = 0
+        for (var i = 0; i < groups.length; i++) {
+          if (groups[i] && groups[i].key === 'pending') {
+            count = groups[i].count || 0
+            break
+          }
+        }
+        self.pendingOrderCount = count
+      }).catch(function() {
+        // 角标失败静默降级,不影响档案主流程
+        self.pendingOrderCount = 0
+      })
+    },
     loadProfile() {
       var self = this
       self.loading = true
@@ -265,6 +289,9 @@ export default {
     goWork() {
       uni.navigateTo({ url: '/pages/work/index' })
     },
+    goCredit() {
+      uni.navigateTo({ url: '/pages/credit/index' })
+    },
     goDetail() {
       uni.navigateTo({ url: '/pages/practitioner/detail' })
     }
@@ -476,6 +503,22 @@ export default {
   display: flex;
   flex-direction: column;
   align-items: center;
+  position: relative;
+}
+/* 待接单角标(只放 count,不放订单明文字段,合规) */
+.badge-dot {
+  position: absolute;
+  top: 18rpx;
+  right: 22rpx;
+  min-width: 36rpx;
+  height: 36rpx;
+  padding: 0 8rpx;
+  background: #C0392B;
+  color: #FFFFFF;
+  font-size: 22rpx;
+  line-height: 36rpx;
+  text-align: center;
+  border-radius: 18rpx;
 }
 .entry-item.active:active { background: #F0F5FA; }
 .entry-item.disabled { background: #FAFCFE; }

+ 8 - 0
train-frontend/utils/api.js

@@ -400,3 +400,11 @@ export const confirmServiceOrder = (data) =>
 /** 收入台账 */
 export const getServiceEarnings = () =>
   request('/api/order/earnings', 'POST', {})
+
+/** 我的工单(角标用):静默失败,不打扰用户。
+ *  ⚠ 合规:/api/order/mine 的 VO 内 familyName / contactPhone / address **未脱敏**
+ *  (家政域工人上门必须看到客户地址电话,属 mustOwn 本人可见)。
+ *  跨角色共享页面(如健康服务档案页)**只允许取 count 角标**,禁止渲染该 VO 明文字段。
+ *  admin/org 视角的订单列表由 M2 DispatchService 另出(会脱敏)。 */
+export const getMyServiceOrderCounts = () =>
+  request('/api/order/mine', 'POST', {}, { silent: true })

+ 2 - 0
train-frontend/utils/format.js

@@ -66,6 +66,8 @@ export function fenToYuan(fen) {
  * 学时分钟数 → 小时文本(保留 1 位小数)
  * 红线:系统内学时一律以「分钟」整数存储(90 分钟 = 1.5 学时),
  * 只有展示层才做 分钟 / 60 换算,不要在前端其他地方按小时存取。
+ * ⚠ 防呆:本函数入参单位固定为「分钟」。若某接口直接返回小时(如 /api/credit/mine),
+ * 直接展示原值,切勿再调用本函数,否则会二次 ÷60(口径漂移事故)。
  * @param {Number} minutes 分钟
  * @returns {String} 如 5400 → '90.0',540 → '9.0',0 → '0.0'
  */

Некоторые файлы не были показаны из-за большого количества измененных файлов