appointments.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. <template>
  2. <view class="container" :style="{ '--font-scale': fontScale }">
  3. <view class="header">
  4. <text class="title">我的预约</text>
  5. <text class="subtitle">查看测评预约状态</text>
  6. </view>
  7. <!-- 预约列表 -->
  8. <view class="appointment-list" v-if="appointments.length > 0">
  9. <view class="appointment-card" v-for="item in appointments" :key="item.id">
  10. <view class="card-header">
  11. <text class="appointment-id">#{{ item.id }}</text>
  12. <view class="status-badge" :class="'status-' + item.status">
  13. <text>{{ item.statusText || getStatusText(item.status) }}</text>
  14. </view>
  15. </view>
  16. <view class="card-body">
  17. <view class="info-row">
  18. <text class="label">预约日期</text>
  19. <text class="value">{{ item.appointmentDate || '待确认' }}</text>
  20. </view>
  21. <view class="info-row">
  22. <text class="label">预约时间</text>
  23. <text class="value">{{ item.appointmentTime || '待确认' }}</text>
  24. </view>
  25. <view class="info-row" v-if="item.notes">
  26. <text class="label">备注</text>
  27. <text class="value">{{ item.notes }}</text>
  28. </view>
  29. <view class="info-row" v-if="item.guideName">
  30. <text class="label">规划师</text>
  31. <text class="value guide-name">{{ item.guideName }}</text>
  32. </view>
  33. <view class="info-row" v-if="item.status === 1 && !item.guideName">
  34. <text class="label">规划师</text>
  35. <text class="value">待分配</text>
  36. </view>
  37. <view class="info-row">
  38. <text class="label">创建时间</text>
  39. <text class="value">{{ formatTime(item.createdAt) }}</text>
  40. </view>
  41. </view>
  42. <view class="card-footer" v-if="item.status === 0">
  43. <button class="btn-cancel" size="mini" @click="handleCancel(item.id)">取消预约</button>
  44. </view>
  45. <view class="card-footer" v-if="item.status === 2">
  46. <button class="btn-view-report" size="mini" @click="viewReport(item.id)">查看报告</button>
  47. </view>
  48. </view>
  49. </view>
  50. <view class="empty-state" v-else>
  51. <text class="empty-icon">📋</text>
  52. <text class="empty-text">暂无预约记录</text>
  53. <text class="empty-hint">申请测评后此处会显示预约状态</text>
  54. </view>
  55. </view>
  56. </template>
  57. <script>
  58. import { getMyAppointments, cancelAppointment } from '../../utils/api.js'
  59. import { parseDate } from '../../utils/format.js'
  60. import fontScaleMixin from '@/mixins/font-scale.js'
  61. export default {
  62. mixins: [fontScaleMixin],
  63. data() {
  64. return {
  65. appointments: []
  66. }
  67. },
  68. onShow() {
  69. this.loadAppointments()
  70. },
  71. methods: {
  72. async loadAppointments() {
  73. try {
  74. const res = await getMyAppointments()
  75. if (res.code === 200) {
  76. this.appointments = res.data || []
  77. }
  78. } catch (e) {
  79. console.error('加载预约列表失败', e)
  80. }
  81. },
  82. getStatusText(status) {
  83. const map = { 0: '待确认', 1: '已确认', 2: '已完成', 3: '已取消', 4: '未到' }
  84. return map[status] || '未知'
  85. },
  86. formatTime(ts) {
  87. if (!ts) return ''
  88. const d = parseDate(ts)
  89. if (!d) return ''
  90. return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, '0')}-${String(d.getDate()).padStart(2, '0')} ${String(d.getHours()).padStart(2, '0')}:${String(d.getMinutes()).padStart(2, '0')}`
  91. },
  92. handleCancel(id) {
  93. uni.showModal({
  94. title: '取消预约',
  95. content: '确定取消此预约?',
  96. success: async (res) => {
  97. if (res.confirm) {
  98. try {
  99. const result = await cancelAppointment(id)
  100. if (result.code === 200) {
  101. uni.showToast({ title: '已取消', icon: 'success' })
  102. this.loadAppointments()
  103. }
  104. } catch (e) {
  105. uni.showToast({ title: '操作失败', icon: 'none' })
  106. }
  107. }
  108. }
  109. })
  110. },
  111. viewReport(appointmentId) {
  112. uni.navigateTo({ url: '/pages/assessment/results' })
  113. }
  114. }
  115. }
  116. </script>
  117. <style scoped lang="scss">
  118. .container {
  119. padding: $uni-space-page;
  120. background: $facade-fill-page;
  121. min-height: 100vh;
  122. }
  123. .header {
  124. text-align: center;
  125. padding: 40rpx 0 $uni-space-lg;
  126. }
  127. .title {
  128. font-size: calc(48rpx * var(--font-scale, 1));
  129. font-weight: bold;
  130. color: $facade-text-strong;
  131. display: block;
  132. margin-bottom: 16rpx;
  133. }
  134. .subtitle {
  135. font-size: calc(26rpx * var(--font-scale, 1));
  136. color: $facade-text-body;
  137. }
  138. .appointment-list {
  139. display: flex;
  140. flex-direction: column;
  141. gap: 24rpx;
  142. }
  143. .appointment-card {
  144. background: $app-surface;
  145. border-radius: 24rpx;
  146. padding: $uni-space-lg;
  147. }
  148. .card-header {
  149. display: flex;
  150. justify-content: space-between;
  151. align-items: center;
  152. margin-bottom: 20rpx;
  153. padding-bottom: 16rpx;
  154. border-bottom: 1rpx solid $facade-hairline-2;
  155. }
  156. .appointment-id {
  157. font-size: calc(24rpx * var(--font-scale, 1));
  158. color: $facade-text-muted;
  159. }
  160. .status-badge {
  161. padding: 6rpx 16rpx;
  162. border-radius: 8rpx;
  163. font-size: calc(22rpx * var(--font-scale, 1));
  164. }
  165. .status-0 { background: $fortune-1-tint; color: $mat-orange-base; }
  166. .status-1 { background: $mat-blue-tint; color: $mat-blue-base; }
  167. .status-2 { background: $mat-green-tint; color: $mat-green; }
  168. .status-3 { background: $facade-fill-2; color: #9E9E9E; }
  169. .status-4 { background: $fortune-0-tint; color: $mat-red; }
  170. .card-body {
  171. margin-bottom: 20rpx;
  172. }
  173. .info-row {
  174. display: flex;
  175. justify-content: space-between;
  176. padding: 10rpx 0;
  177. font-size: calc(26rpx * var(--font-scale, 1));
  178. }
  179. .label { color: $facade-text-muted; }
  180. .value { color: $facade-text-strong; }
  181. .guide-name { color: $brand-primary; font-weight: bold; }
  182. .card-footer {
  183. padding-top: 16rpx;
  184. border-top: 1rpx dashed $facade-hairline-2;
  185. display: flex;
  186. justify-content: flex-end;
  187. }
  188. .btn-cancel {
  189. background: $facade-fill-2;
  190. color: $facade-text-muted;
  191. font-size: calc(26rpx * var(--font-scale, 1));
  192. border-radius: 8rpx;
  193. width: 200rpx;
  194. }
  195. .btn-view-report {
  196. background: $accent-indigo;
  197. color: $app-surface;
  198. font-size: calc(26rpx * var(--font-scale, 1));
  199. border-radius: 8rpx;
  200. width: 200rpx;
  201. }
  202. .empty-state {
  203. text-align: center;
  204. padding: 120rpx 0;
  205. }
  206. .empty-icon {
  207. font-size: calc($uni-font-size-5xl * var(--font-scale, 1));
  208. display: block;
  209. margin-bottom: 20rpx;
  210. }
  211. .empty-text {
  212. font-size: calc(28rpx * var(--font-scale, 1));
  213. color: $facade-text-muted;
  214. display: block;
  215. margin-bottom: 10rpx;
  216. }
  217. .empty-hint {
  218. font-size: calc(24rpx * var(--font-scale, 1));
  219. color: $facade-text-ghost;
  220. display: block;
  221. }
  222. </style>