index.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404
  1. <template>
  2. <view class="order-detail-page">
  3. <!-- 订单号与状态 -->
  4. <view class="order-header">
  5. <view class="order-id-row">
  6. <text class="order-id">{{ order.id }}</text>
  7. <text :class="['status-badge', `badge-${order.statusKey}`]">{{ order.statusText }}</text>
  8. <text class="service-badge">{{ currentServiceName }}</text>
  9. </view>
  10. </view>
  11. <!-- 状态进度条 -->
  12. <view class="progress-card">
  13. <view class="progress-steps">
  14. <view v-for="(step, i) in progressSteps" :key="i"
  15. :class="['step-item', { done: step.done, active: step.active }]">
  16. <view class="step-circle">
  17. <uni-icons v-if="step.done" type="checkmarkempty" size="12" color="#fff"></uni-icons>
  18. <text v-else class="step-num">{{ i + 1 }}</text>
  19. </view>
  20. <view class="step-line" v-if="i < progressSteps.length - 1" :class="{ done: step.done }"></view>
  21. <text class="step-label">{{ step.label }}</text>
  22. <text class="step-time">{{ step.time }}</text>
  23. </view>
  24. </view>
  25. </view>
  26. <!-- 宠物档案 + 用户信息 -->
  27. <view class="info-row-cards">
  28. <view class="info-card pet-card">
  29. <text class="card-label">宠物档案</text>
  30. <view class="pet-header">
  31. <view class="pet-avatar"><text>{{ order.petName[0] }}</text></view>
  32. <view class="pet-basic">
  33. <text class="pet-name">{{ order.petName }} ♂</text>
  34. <view class="pet-tags">
  35. <text class="mini-tag">{{ order.petAge }}岁</text>
  36. <text class="mini-tag">{{ order.petWeight }}kg</text>
  37. </view>
  38. </view>
  39. <text class="breed-badge">{{ order.petBreed }}</text>
  40. </view>
  41. <view class="pet-attrs">
  42. <view class="attr-item">
  43. <text class="attr-label">绝育状态</text>
  44. <text class="attr-val">已绝育</text>
  45. </view>
  46. <view class="attr-item">
  47. <text class="attr-label">疫苗状态</text>
  48. <text class="attr-val highlight">已接种</text>
  49. </view>
  50. <view class="attr-item full">
  51. <text class="attr-label">性格特点</text>
  52. <text class="attr-val">活泼好动,喜欢球类玩具</text>
  53. </view>
  54. </view>
  55. </view>
  56. <view class="info-card user-card">
  57. <text class="card-label">用户信息</text>
  58. <view class="user-header">
  59. <view class="user-avatar">
  60. <uni-icons type="person" size="26" color="#aaa"></uni-icons>
  61. </view>
  62. <view class="user-basic">
  63. <text class="user-name-text">{{ order.userName }}</text>
  64. <text class="user-phone">{{ order.userPhone }}</text>
  65. </view>
  66. </view>
  67. <view class="service-address-box">
  68. <text class="addr-label">服务地址</text>
  69. <text class="addr-text">{{ order.address }}</text>
  70. </view>
  71. </view>
  72. </view>
  73. <!-- 标签页 -->
  74. <view class="detail-tabs-wrap">
  75. <view class="tab-nav">
  76. <view v-for="tab in tabList" :key="tab.name"
  77. :class="['tab-nav-item', { active: activeTab === tab.name }]"
  78. @click="activeTab = tab.name">
  79. <text>{{ tab.title }}</text>
  80. </view>
  81. </view>
  82. <!-- 订单基础信息 -->
  83. <view class="tab-content" v-if="activeTab === 'base'">
  84. <view class="base-info-grid">
  85. <view class="bi-item" v-for="item in baseInfoList" :key="item.label">
  86. <text class="bi-label">{{ item.label }}</text>
  87. <text :class="['bi-val', item.highlight ? 'highlight' : '']">{{ item.value }}</text>
  88. </view>
  89. </view>
  90. <template v-if="activeService === 'transport'">
  91. <text class="sub-title">接送任务详情</text>
  92. <view class="route-block">
  93. <view class="route-header">
  94. <text class="route-tag pick">宠物接送</text>
  95. <text class="route-tag arrow">接</text>
  96. <text class="route-time">{{ order.pickTime }}</text>
  97. </view>
  98. <view class="route-addr">
  99. <uni-icons type="location" size="14" color="#999"></uni-icons>
  100. <text>{{ order.pickAddress }}</text>
  101. </view>
  102. </view>
  103. <view class="route-block">
  104. <view class="route-header">
  105. <text class="route-tag send">宠物接送</text>
  106. <text class="route-tag arrow send-arrow">送</text>
  107. <text class="route-time">{{ order.sendTime }}</text>
  108. </view>
  109. <view class="route-addr">
  110. <uni-icons type="location" size="14" color="#999"></uni-icons>
  111. <text>{{ order.sendAddress }}</text>
  112. </view>
  113. </view>
  114. </template>
  115. <template v-else>
  116. <text class="sub-title">上门服务地址</text>
  117. <view class="route-block">
  118. <view class="route-addr">
  119. <uni-icons type="location" size="14" color="#999"></uni-icons>
  120. <text>{{ order.address }}</text>
  121. </view>
  122. </view>
  123. </template>
  124. </view>
  125. <!-- 指派履约者 -->
  126. <view class="tab-content" v-if="activeTab === 'assignee'">
  127. <view class="empty-state" v-if="order.statusKey === 'wait_dispatch'">
  128. <uni-icons type="clock" size="40" color="#ccc"></uni-icons>
  129. <text class="empty-text">等待派单中...</text>
  130. </view>
  131. <view class="assignee-card" v-else>
  132. <view class="assignee-header">
  133. <view class="assignee-avatar">
  134. <uni-icons type="person" size="30" color="#aaa"></uni-icons>
  135. </view>
  136. <view class="assignee-info">
  137. <text class="assignee-name">{{ order.assigneeName }}</text>
  138. <text class="assignee-phone">联系电话:13812345678</text>
  139. <text class="assignee-zone">归属区域:朝阳服务站</text>
  140. </view>
  141. </view>
  142. </view>
  143. </view>
  144. <!-- 服务进度 -->
  145. <view class="tab-content" v-if="activeTab === 'progress'">
  146. <view class="empty-state" v-if="['wait_dispatch', 'wait_accept'].includes(order.statusKey)">
  147. <uni-icons type="info" size="40" color="#ccc"></uni-icons>
  148. <text class="empty-text">服务尚未开始</text>
  149. </view>
  150. <view class="timeline" v-else>
  151. <view class="tl-item" v-for="(tl, i) in serviceTimeline" :key="i">
  152. <view class="tl-dot"></view>
  153. <view class="tl-body">
  154. <text class="tl-time">{{ tl.time }}</text>
  155. <text class="tl-title">{{ tl.title }}</text>
  156. <text class="tl-desc">{{ tl.desc }}</text>
  157. </view>
  158. </view>
  159. </view>
  160. </view>
  161. <!-- 订单日志 -->
  162. <view class="tab-content" v-if="activeTab === 'log'">
  163. <view class="timeline">
  164. <view class="tl-item" v-for="(log, i) in orderLogs" :key="i">
  165. <view class="tl-dot log-dot"></view>
  166. <view class="tl-body">
  167. <text class="tl-time">{{ log.time }}</text>
  168. <text class="tl-title">{{ log.title }}</text>
  169. <text class="tl-desc">{{ log.desc }}</text>
  170. </view>
  171. </view>
  172. </view>
  173. </view>
  174. </view>
  175. <!-- 底部取消按钮 -->
  176. <view class="cancel-bar safe-bottom" v-if="['wait_dispatch', 'wait_accept'].includes(order.statusKey)">
  177. <button class="cancel-order-btn" @click="onCancelOrder">取消订单</button>
  178. </view>
  179. </view>
  180. </template>
  181. <script setup>
  182. import { ref, reactive, computed } from 'vue'
  183. import { onLoad } from '@dcloudio/uni-app'
  184. const activeTab = ref('base')
  185. const activeService = ref('transport')
  186. const tabList = [
  187. { title: '基础信息', name: 'base' },
  188. { title: '履约者', name: 'assignee' },
  189. { title: '服务进度', name: 'progress' },
  190. { title: '订单日志', name: 'log' }
  191. ]
  192. const currentServiceName = computed(() => {
  193. const map = { transport: '宠物接送', feed: '上门喂遛', wash: '上门洗护' }
  194. return map[activeService.value]
  195. })
  196. onLoad((options) => {
  197. if (options.service) activeService.value = options.service
  198. if (options.status) {
  199. const statusTextMap = { wait_dispatch: '待派单', wait_accept: '待接单', serving: '服务中', done: '已完成', cancel: '已取消' }
  200. order.statusKey = options.status
  201. order.statusText = statusTextMap[options.status] || '服务中'
  202. }
  203. if (options.cancelTime) order.cancelTime = decodeURIComponent(options.cancelTime)
  204. })
  205. const order = reactive({
  206. id: 'ORD202402048803',
  207. statusKey: 'serving',
  208. statusText: '服务中',
  209. petName: 'Cookie',
  210. petBreed: '柯基',
  211. petAge: 2,
  212. petWeight: 15,
  213. userName: '王先生',
  214. userPhone: '13612345678',
  215. address: '北京市朝阳区 某小区5号楼2单元101',
  216. shopName: '爱宠生活馆 (中关村店)',
  217. createTime: '2024-02-04 12:00',
  218. bookTime: '2024-02-04 18:00',
  219. packageName: '新春特惠接送套餐',
  220. remark: '暂无备注',
  221. assigneeName: '张小美',
  222. cancelTime: '',
  223. pickAddress: '北京市朝阳区三里屯SOHO 6号楼',
  224. pickTime: '2024-02-04 09:30',
  225. sendAddress: '北京市朝阳区某小区5号楼2单元101',
  226. sendTime: '2024-02-04 18:00'
  227. })
  228. const progressSteps = computed(() => {
  229. const statusOrder = ['wait_dispatch', 'wait_accept', 'serving', 'done']
  230. const currentIdx = statusOrder.indexOf(order.statusKey)
  231. const allSteps = [
  232. { label: '商户下单', time: '02-04' },
  233. { label: '运营派单', time: '02-04' },
  234. { label: '履约接单', time: '02-05' },
  235. { label: '服务中', time: '02-04' },
  236. { label: '已完成', time: '' }
  237. ]
  238. if (order.statusKey === 'cancel') return allSteps.map((s, i) => ({ ...s, done: i === 0, active: false }))
  239. return allSteps.map((s, i) => ({ ...s, done: i <= currentIdx, active: i === currentIdx + 1 }))
  240. })
  241. const baseInfoList = computed(() => {
  242. const list = [
  243. { label: '系统单号', value: order.id },
  244. { label: '服务类型', value: currentServiceName.value },
  245. { label: '归属门店', value: order.shopName },
  246. { label: '宠主信息', value: `${order.userName} / ${order.userPhone}` },
  247. { label: '预约时间', value: order.bookTime },
  248. { label: '团购套餐', value: order.packageName },
  249. { label: '创建时间', value: order.createTime },
  250. { label: '订单备注', value: order.remark }
  251. ]
  252. if (order.statusKey === 'cancel') list.push({ label: '取消时间', value: order.cancelTime || '2024-02-02 11:30', highlight: true })
  253. return list
  254. })
  255. const serviceTimeline = [
  256. { time: '2024-02-04 09:30', title: '已接单', desc: '履约者 张小美 已确认接单' },
  257. { time: '2024-02-04 09:50', title: '到达打卡', desc: '已到达指定位置' },
  258. { time: '2024-02-04 10:10', title: '确认出发', desc: '接到宠物,状态良好' }
  259. ]
  260. const orderLogs = [
  261. { time: '2024-02-04 09:30', title: '订单创建', desc: '商户提交订单' },
  262. { time: '2024-02-04 10:00', title: '系统派单', desc: '指派给 张小美' },
  263. { time: '2024-02-04 10:05', title: '接单成功', desc: '履约者已确认接单' },
  264. { time: '2024-02-04 13:55', title: '到达服务点', desc: '履约者到达服务地址' }
  265. ]
  266. const onCancelOrder = () => {
  267. uni.showModal({
  268. title: '取消订单',
  269. content: `确定要取消订单 [${order.id}] 吗?`,
  270. confirmText: '确认取消',
  271. confirmColor: '#f44336',
  272. success: (res) => {
  273. if (res.confirm) {
  274. order.statusKey = 'cancel'
  275. order.statusText = '已取消'
  276. uni.showToast({ title: '订单已取消', icon: 'success' })
  277. setTimeout(() => uni.navigateBack(), 1000)
  278. }
  279. }
  280. })
  281. }
  282. </script>
  283. <style lang="scss" scoped>
  284. .order-detail-page {
  285. background: #f2f3f7;
  286. min-height: 100vh;
  287. padding-bottom: 160rpx;
  288. }
  289. .order-header { padding: 24rpx 32rpx 16rpx; }
  290. .order-id-row { display: flex; align-items: center; gap: 16rpx; flex-wrap: wrap; }
  291. .order-id { font-size: 26rpx; color: #666; font-family: monospace; }
  292. .status-badge { font-size: 22rpx; padding: 4rpx 16rpx; border-radius: 20rpx; font-weight: 600; }
  293. .badge-wait_dispatch { background: #fff0f0; color: #f44336; }
  294. .badge-wait_accept { background: #fff8e1; color: #ff9800; }
  295. .badge-serving { background: #e3f2fd; color: #2196f3; }
  296. .badge-done { background: #e8f5e9; color: #4caf50; }
  297. .badge-cancel { background: #f5f5f5; color: #9e9e9e; }
  298. .service-badge { font-size: 22rpx; padding: 4rpx 16rpx; border-radius: 20rpx; background: #fff3e0; color: #ff9500; }
  299. .progress-card { background: #fff; margin: 0 24rpx 24rpx; border-radius: 28rpx; padding: 32rpx 16rpx 24rpx; }
  300. .progress-steps { display: flex; align-items: flex-start; }
  301. .step-item { display: flex; flex-direction: column; align-items: center; flex: 1; position: relative; z-index: 1; }
  302. .step-circle { width: 44rpx; height: 44rpx; border-radius: 50%; background: #e0e0e0; display: flex; align-items: center; justify-content: center; margin-bottom: 8rpx; }
  303. .step-num { font-size: 20rpx; color: #fff; }
  304. .step-item.done .step-circle, .step-item.active .step-circle { background: #ff9500; }
  305. .step-line { position: absolute; top: 22rpx; left: 50%; width: 100%; height: 4rpx; background: #e0e0e0; z-index: 0; }
  306. .step-line.done { background: #ff9500; }
  307. .step-label { font-size: 20rpx; color: #999; text-align: center; }
  308. .step-item.done .step-label, .step-item.active .step-label { color: #ff9500; font-weight: 600; }
  309. .step-time { font-size: 18rpx; color: #bbb; margin-top: 4rpx; }
  310. .info-row-cards { display: flex; gap: 20rpx; margin: 0 24rpx 24rpx; }
  311. .info-card { flex: 1; background: #fff; border-radius: 28rpx; padding: 24rpx; min-width: 0; }
  312. .card-label { display: block; font-size: 24rpx; font-weight: 700; color: #333; margin-bottom: 20rpx; border-left: 6rpx solid #ff9500; padding-left: 12rpx; }
  313. .pet-header { display: flex; align-items: center; gap: 16rpx; margin-bottom: 20rpx; }
  314. .pet-avatar { width: 72rpx; height: 72rpx; border-radius: 20rpx; background: #e3f2fd; color: #2196f3; font-size: 36rpx; font-weight: bold; display: flex; align-items: center; justify-content: center; }
  315. .pet-basic { flex: 1; min-width: 0; }
  316. .pet-name { display: block; font-size: 28rpx; font-weight: bold; color: #222; }
  317. .pet-tags { display: flex; gap: 8rpx; margin-top: 6rpx; }
  318. .mini-tag { font-size: 20rpx; background: #f5f5f5; border-radius: 8rpx; padding: 2rpx 10rpx; color: #666; }
  319. .breed-badge { font-size: 20rpx; background: #ffe0b2; color: #e65100; border-radius: 8rpx; padding: 4rpx 12rpx; }
  320. .pet-attrs { display: flex; flex-wrap: wrap; gap: 12rpx 0; }
  321. .attr-item { width: 50%; }
  322. .attr-item.full { width: 100%; }
  323. .attr-label { display: block; font-size: 20rpx; color: #aaa; }
  324. .attr-val { display: block; font-size: 22rpx; color: #333; }
  325. .attr-val.highlight { color: #4caf50; }
  326. .user-header { display: flex; align-items: center; gap: 16rpx; margin-bottom: 20rpx; }
  327. .user-avatar { width: 80rpx; height: 80rpx; border-radius: 50%; background: #f5f5f5; display: flex; align-items: center; justify-content: center; }
  328. .user-name-text { display: block; font-size: 28rpx; font-weight: bold; color: #222; }
  329. .user-phone { display: block; font-size: 24rpx; color: #666; }
  330. .service-address-box { background: #fff8f0; border-radius: 16rpx; padding: 16rpx; }
  331. .addr-label { display: block; font-size: 20rpx; color: #ff9500; margin-bottom: 6rpx; }
  332. .addr-text { display: block; font-size: 22rpx; color: #333; line-height: 1.5; }
  333. .detail-tabs-wrap { margin: 0 24rpx; background: #fff; border-radius: 28rpx; overflow: hidden; }
  334. .tab-nav { display: flex; border-bottom: 1rpx solid #f0f0f0; }
  335. .tab-nav-item { flex: 1; text-align: center; padding: 24rpx 0; font-size: 24rpx; color: #666; position: relative; }
  336. .tab-nav-item.active { color: #ff9500; font-weight: bold; }
  337. .tab-nav-item.active::after { content: ''; position: absolute; bottom: 0; left: 50%; transform: translateX(-50%); width: 48rpx; height: 6rpx; background: #ff9500; border-radius: 6rpx; }
  338. .tab-content { padding: 28rpx; min-height: 280rpx; }
  339. .base-info-grid { display: flex; flex-wrap: wrap; gap: 20rpx; margin-bottom: 32rpx; }
  340. .bi-item { width: calc(50% - 10rpx); background: #f8f8f8; border-radius: 16rpx; padding: 16rpx 20rpx; }
  341. .bi-label { display: block; font-size: 20rpx; color: #aaa; margin-bottom: 6rpx; }
  342. .bi-val { display: block; font-size: 24rpx; color: #333; font-weight: 500; }
  343. .bi-val.highlight { color: #f44336; }
  344. .sub-title { display: block; font-size: 26rpx; font-weight: 700; color: #333; margin-bottom: 20rpx; padding-left: 12rpx; border-left: 6rpx solid #ff9500; }
  345. .route-block { background: #f9f9f9; border-radius: 20rpx; padding: 20rpx 24rpx; margin-bottom: 20rpx; }
  346. .route-header { display: flex; align-items: center; gap: 12rpx; margin-bottom: 16rpx; }
  347. .route-tag { font-size: 22rpx; padding: 4rpx 12rpx; border-radius: 8rpx; }
  348. .route-tag.pick { background: #e3f2fd; color: #2196f3; }
  349. .route-tag.send { background: #e8f5e9; color: #4caf50; }
  350. .route-tag.arrow { background: #2196f3; color: #fff; }
  351. .route-tag.send-arrow { background: #4caf50; }
  352. .route-time { font-size: 22rpx; color: #ff9500; margin-left: auto; }
  353. .route-addr { display: flex; align-items: center; gap: 8rpx; font-size: 24rpx; color: #555; }
  354. .assignee-card { background: #f9f9f9; border-radius: 24rpx; padding: 28rpx; }
  355. .assignee-header { display: flex; gap: 24rpx; }
  356. .assignee-avatar { width: 100rpx; height: 100rpx; border-radius: 50%; background: #e0e0e0; display: flex; align-items: center; justify-content: center; }
  357. .assignee-name { display: block; font-size: 30rpx; font-weight: bold; color: #222; margin-bottom: 8rpx; }
  358. .assignee-phone, .assignee-zone { display: block; font-size: 24rpx; color: #666; margin-bottom: 4rpx; }
  359. .timeline { position: relative; padding-left: 40rpx; }
  360. .tl-item { position: relative; margin-bottom: 40rpx; padding-left: 32rpx; }
  361. .tl-dot { position: absolute; left: -12rpx; top: 8rpx; width: 24rpx; height: 24rpx; border-radius: 50%; background: #ff9500; border: 4rpx solid #fff; box-shadow: 0 0 0 4rpx #ff9500; }
  362. .tl-item::before { content: ''; position: absolute; left: -2rpx; top: 32rpx; bottom: -40rpx; width: 4rpx; background: #f0f0f0; }
  363. .tl-item:last-child::before { display: none; }
  364. .tl-time { display: block; font-size: 22rpx; color: #aaa; margin-bottom: 6rpx; }
  365. .tl-title { display: block; font-size: 28rpx; font-weight: 600; color: #222; margin-bottom: 6rpx; }
  366. .tl-desc { display: block; font-size: 24rpx; color: #666; }
  367. .log-dot { background: #e0e0e0; box-shadow: 0 0 0 4rpx #e0e0e0; }
  368. .empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 80rpx 0; gap: 24rpx; }
  369. .empty-text { font-size: 26rpx; color: #bbb; }
  370. .cancel-bar { position: fixed; bottom: 0; left: 0; right: 0; padding: 24rpx 32rpx; background: rgba(255,255,255,0.95); box-shadow: 0 -8rpx 28rpx rgba(0,0,0,0.08); z-index: 100; }
  371. .cancel-order-btn { width: 100%; height: 96rpx; font-size: 32rpx; font-weight: 600; border: 2rpx solid #f44336; color: #f44336; background: transparent; border-radius: 48rpx; line-height: 96rpx; }
  372. </style>