appointments.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. <template>
  2. <view class="container">
  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. export default {
  60. data() {
  61. return {
  62. appointments: []
  63. }
  64. },
  65. onShow() {
  66. this.loadAppointments()
  67. },
  68. methods: {
  69. async loadAppointments() {
  70. try {
  71. const res = await getMyAppointments()
  72. if (res.code === 200) {
  73. this.appointments = res.data || []
  74. }
  75. } catch (e) {
  76. console.error('加载预约列表失败', e)
  77. }
  78. },
  79. getStatusText(status) {
  80. const map = { 0: '待确认', 1: '已确认', 2: '已完成', 3: '已取消', 4: '未到' }
  81. return map[status] || '未知'
  82. },
  83. formatTime(ts) {
  84. if (!ts) return ''
  85. const d = new Date(ts)
  86. 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')}`
  87. },
  88. handleCancel(id) {
  89. uni.showModal({
  90. title: '取消预约',
  91. content: '确定取消此预约?',
  92. success: async (res) => {
  93. if (res.confirm) {
  94. try {
  95. const result = await cancelAppointment(id)
  96. if (result.code === 200) {
  97. uni.showToast({ title: '已取消', icon: 'success' })
  98. this.loadAppointments()
  99. }
  100. } catch (e) {
  101. uni.showToast({ title: '操作失败', icon: 'none' })
  102. }
  103. }
  104. }
  105. })
  106. },
  107. viewReport(appointmentId) {
  108. uni.navigateTo({ url: '/pages/assessment/results' })
  109. }
  110. }
  111. }
  112. </script>
  113. <style scoped>
  114. .container {
  115. padding: 30rpx;
  116. background: #F8F8F8;
  117. min-height: 100vh;
  118. }
  119. .header {
  120. text-align: center;
  121. padding: 40rpx 0 30rpx;
  122. }
  123. .title {
  124. font-size: 48rpx;
  125. font-weight: bold;
  126. color: #333;
  127. display: block;
  128. margin-bottom: 16rpx;
  129. }
  130. .subtitle {
  131. font-size: 26rpx;
  132. color: #666;
  133. }
  134. .appointment-list {
  135. display: flex;
  136. flex-direction: column;
  137. gap: 24rpx;
  138. }
  139. .appointment-card {
  140. background: #fff;
  141. border-radius: 20rpx;
  142. padding: 30rpx;
  143. }
  144. .card-header {
  145. display: flex;
  146. justify-content: space-between;
  147. align-items: center;
  148. margin-bottom: 20rpx;
  149. padding-bottom: 16rpx;
  150. border-bottom: 1rpx solid #eee;
  151. }
  152. .appointment-id {
  153. font-size: 24rpx;
  154. color: #999;
  155. }
  156. .status-badge {
  157. padding: 6rpx 16rpx;
  158. border-radius: 8rpx;
  159. font-size: 22rpx;
  160. }
  161. .status-0 { background: #FFF3E0; color: #FF9800; }
  162. .status-1 { background: #E3F2FD; color: #2196F3; }
  163. .status-2 { background: #E8F5E9; color: #4CAF50; }
  164. .status-3 { background: #F5F5F5; color: #9E9E9E; }
  165. .status-4 { background: #FFEBEE; color: #F44336; }
  166. .card-body {
  167. margin-bottom: 20rpx;
  168. }
  169. .info-row {
  170. display: flex;
  171. justify-content: space-between;
  172. padding: 10rpx 0;
  173. font-size: 26rpx;
  174. }
  175. .label { color: #999; }
  176. .value { color: #333; }
  177. .guide-name { color: #F97316; font-weight: bold; }
  178. .card-footer {
  179. padding-top: 16rpx;
  180. border-top: 1rpx dashed #eee;
  181. display: flex;
  182. justify-content: flex-end;
  183. }
  184. .btn-cancel {
  185. background: #F5F5F5;
  186. color: #999;
  187. font-size: 26rpx;
  188. border-radius: 10rpx;
  189. width: 200rpx;
  190. }
  191. .btn-view-report {
  192. background: #667eea;
  193. color: #fff;
  194. font-size: 26rpx;
  195. border-radius: 10rpx;
  196. width: 200rpx;
  197. }
  198. .empty-state {
  199. text-align: center;
  200. padding: 120rpx 0;
  201. }
  202. .empty-icon {
  203. font-size: 80rpx;
  204. display: block;
  205. margin-bottom: 20rpx;
  206. }
  207. .empty-text {
  208. font-size: 28rpx;
  209. color: #999;
  210. display: block;
  211. margin-bottom: 10rpx;
  212. }
  213. .empty-hint {
  214. font-size: 24rpx;
  215. color: #CCC;
  216. display: block;
  217. }
  218. </style>