order.uvue 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453
  1. <template>
  2. <view class="container">
  3. <!-- 状态标签页 (顶部) -->
  4. <scroll-view scroll-x class="tab-bar" show-scrollbar="false">
  5. <view
  6. v-for="(tab, index) in tabs"
  7. :key="index"
  8. :class="['tab-item', { active: currentTab === index }]"
  9. @click="currentTab = index"
  10. >
  11. {{ tab }}
  12. <!-- 仅在新订单下显示黄色下划线 -->
  13. <view v-if="index === 0" class="underline">
  14. </view>
  15. </view>
  16. </scroll-view>
  17. <!-- 订单列表区域 -->
  18. <view class="order-list">
  19. <view v-for="(order, idx) in orders" :key="idx" class="order-card">
  20. <!-- 1. 头部:时间与状态 -->
  21. <view class="card-header">
  22. <text class="time-text">
  23. 预约时间:{{ order.time }}
  24. </text>
  25. <text class="status-tag paid">
  26. 已支付
  27. </text>
  28. </view>
  29. <!-- 2. 服务信息行 -->
  30. <view class="service-row">
  31. <image :src="order.image" class="service-img" mode="aspectFill" />
  32. <view class="service-info">
  33. <view class="title-row">
  34. <text class="service-name">
  35. {{ order.serviceName }}
  36. </text>
  37. <text class="price">
  38. ¥{{ order.price }}
  39. </text>
  40. </view>
  41. <view class="tags-row">
  42. <text v-for="(tag, tIdx) in order.tags" :key="tIdx" :class="['tag', tag.type]">
  43. {{ tag.text }}
  44. </text>
  45. </view>
  46. <text class="contact-text">
  47. 联系人:{{ order.contact }}
  48. </text>
  49. </view>
  50. </view>
  51. <!-- 3. 地址与距离 -->
  52. <view class="address-row">
  53. <uni-icons type="location" size="16" color="#999">
  54. </uni-icons>
  55. <text class="address-text">
  56. {{ order.address }}
  57. </text>
  58. <text class="distance-text">
  59. {{ order.distance }}km
  60. </text>
  61. </view>
  62. <!-- 4. 预估收入 -->
  63. <view class="income-section">
  64. <text class="income-label">
  65. 预估收入
  66. </text>
  67. <view class="income-value-box">
  68. <text class="income-value">
  69. ¥{{ order.income }}
  70. </text>
  71. <text class="income-note">
  72. (含路费)
  73. </text>
  74. </view>
  75. </view>
  76. <!-- 5. 底部操作按钮 -->
  77. <view class="action-buttons">
  78. <view class="btn btn-nav" @click="handleNav(order.address)">
  79. <uni-icons type="navigation" size="14" color="#333">
  80. </uni-icons>
  81. <text>
  82. 地址导航
  83. </text>
  84. </view>
  85. <view class="btn btn-transfer" @click="handleTransfer(order.id)">
  86. 我要转单
  87. </view>
  88. <view class="btn btn-confirm" @click="handleConfirm(order.id)">
  89. 确认接单
  90. </view>
  91. </view>
  92. </view>
  93. <!-- 空状态提示 (可选) -->
  94. <view v-if="orders.length === 0" class="empty-state">
  95. <text>
  96. 暂无相关订单
  97. </text>
  98. </view>
  99. </view>
  100. </view>
  101. </template>
  102. <script setup lang="ts">
  103. import { ref } from 'vue';
  104. // --- 数据定义 ---
  105. const tabs = ['新订单',
  106. '进行中',
  107. '取消/售后',
  108. '已完成',
  109. '全部'];
  110. const currentTab = ref(0);
  111. // 模拟订单数据
  112. const orders = ref([
  113. {
  114. id: 101,
  115. time: '2025-06-18 4:00',
  116. serviceName: '润养SPA',
  117. tags: [
  118. { text: '上门', type: 'orange-outline' },
  119. { text: '首单', type: 'orange-outline' },
  120. { text: '新客', type: 'green-outline' }
  121. ],
  122. contact: '刘',
  123. price: '286.6',
  124. address: '烟台 芝罘区楚风一街楚凤花园(烟台吾悦)广场附近',
  125. distance: '2.24',
  126. income: '186.6',
  127. // 请替换为实际图片路径,或使用占位图
  128. image: 'https://via.placeholder.com/100x100/ffccaa/ffffff?text=SPA'
  129. },
  130. {
  131. id: 102,
  132. time: '2025-06-18 8:00',
  133. serviceName: '润养SPA',
  134. tags: [
  135. { text: '加钟', type: 'green-outline' }
  136. ],
  137. contact: '刘',
  138. price: '286.6',
  139. address: '烟台 芝罘区楚风一街楚凤花园(烟台吾悦)广场附近',
  140. distance: '2.24',
  141. income: '186.6',
  142. image: 'https://via.placeholder.com/100x100/ffccaa/ffffff?text=SPA'
  143. }
  144. ]);
  145. // --- 事件处理 ---
  146. const handleNav = (address: string) => {
  147. uni.showToast({ title: '打开地图导航', icon: 'none' });
  148. // 实际逻辑: uni.openLocation(...)
  149. };
  150. const handleTransfer = (id: number) => {
  151. uni.showModal({
  152. title: '提示',
  153. content: '确定要转单吗?',
  154. success: (res) => {
  155. if (res.confirm) {
  156. uni.showToast({ title: '转单成功', icon: 'success' });
  157. }
  158. }
  159. });
  160. };
  161. const handleConfirm = (id: number) => {
  162. uni.showLoading({ title: '接单中...' });
  163. setTimeout(() => {
  164. uni.hideLoading();
  165. uni.showToast({ title: '接单成功', icon: 'success' });
  166. }, 800);
  167. };
  168. </script>
  169. <style scoped>
  170. /* 容器:去掉上下 padding,让内容贴边或根据父容器决定 */
  171. .container {
  172. background-color: #f5f6f8;
  173. /* 浅灰背景 */
  174. min-height: 100vh;
  175. width: 100%;
  176. }
  177. /* --- 标签栏样式 --- */
  178. .tab-bar {
  179. width: 100%;
  180. white-space: nowrap;
  181. background-color: #ffffff;
  182. padding: 0 20rpx;
  183. box-sizing: border-box;
  184. /* 去掉滚动条 */
  185. scrollbar-width: none;
  186. }
  187. /* 兼容 H5/APP 隐藏滚动条 */
  188. .tab-bar ::v-deep(.uni-scroll-view::-webkit-scrollbar) {
  189. display: none;
  190. width: 0;
  191. height: 0;
  192. }
  193. .tab-item {
  194. display: inline-block;
  195. padding: 24rpx 30rpx;
  196. font-size: 30rpx;
  197. color: #666666;
  198. position: relative;
  199. margin-right: 10rpx;
  200. }
  201. .tab-item.active {
  202. color: #333333;
  203. font-weight: bold;
  204. }
  205. .underline {
  206. position: absolute;
  207. bottom: 10rpx;
  208. left: 50%;
  209. transform: translateX(-50%);
  210. width: 40rpx;
  211. height: 6rpx;
  212. background-color: #ffc107;
  213. /* 黄色下划线 */
  214. border-radius: 3rpx;
  215. }
  216. /* --- 订单列表 --- */
  217. .order-list {
  218. padding: 20rpx;
  219. box-sizing: border-box;
  220. }
  221. .order-card {
  222. background-color: #ffffff;
  223. border-radius: 16rpx;
  224. padding: 30rpx;
  225. margin-bottom: 24rpx;
  226. box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.04);
  227. flex-direction: row;
  228. }
  229. /* 1. 头部 */
  230. .card-header {
  231. display: flex;
  232. justify-content: space-between;
  233. align-items: center;
  234. margin-bottom: 24rpx;
  235. }
  236. .time-text {
  237. font-size: 28rpx;
  238. color: #333;
  239. font-weight: 500;
  240. }
  241. .status-tag {
  242. font-size: 24rpx;
  243. padding: 6rpx 16rpx;
  244. border-radius: 20rpx;
  245. }
  246. .status-tag.paid {
  247. background-color: #fff7e6;
  248. color: #ff9900;
  249. }
  250. /* 2. 服务信息 */
  251. .service-row {
  252. display: flex;
  253. align-items: flex-start;
  254. margin-bottom: 20rpx;
  255. }
  256. .service-img {
  257. width: 110rpx;
  258. height: 110rpx;
  259. border-radius: 12rpx;
  260. margin-right: 20rpx;
  261. background-color: #eee;
  262. }
  263. .service-info {
  264. flex: 1;
  265. display: flex;
  266. flex-direction: column;
  267. justify-content: space-between;
  268. height: 110rpx;
  269. }
  270. .title-row {
  271. display: flex;
  272. justify-content: space-between;
  273. align-items: center;
  274. }
  275. .service-name {
  276. font-size: 32rpx;
  277. font-weight: bold;
  278. color: #333;
  279. }
  280. .price {
  281. font-size: 34rpx;
  282. font-weight: bold;
  283. color: #333;
  284. }
  285. .tags-row {
  286. display: flex;
  287. gap: 12rpx;
  288. flex-wrap: wrap;
  289. }
  290. .tag {
  291. font-size: 22rpx;
  292. padding: 4rpx 12rpx;
  293. border-radius: 20rpx;
  294. border: 1rpx solid;
  295. line-height: 1.2;
  296. }
  297. /* 标签颜色变体 */
  298. .tag.orange-outline {
  299. color: #ff9900;
  300. border-color: #ff9900;
  301. background-color: #fffaf0;
  302. }
  303. .tag.green-outline {
  304. color: #52c41a;
  305. border-color: #52c41a;
  306. background-color: #f6ffed;
  307. }
  308. .contact-text {
  309. font-size: 26rpx;
  310. color: #999;
  311. }
  312. /* 3. 地址行 */
  313. .address-row {
  314. display: flex;
  315. align-items: flex-start;
  316. margin-bottom: 20rpx;
  317. padding-bottom: 20rpx;
  318. border-bottom: 1rpx solid #f5f5f5;
  319. }
  320. .address-text {
  321. flex: 1;
  322. font-size: 26rpx;
  323. color: #666;
  324. margin-left: 10rpx;
  325. line-height: 1.4;
  326. /* 多行省略 */
  327. display: -webkit-box;
  328. -webkit-line-clamp: 2;
  329. -webkit-box-orient: vertical;
  330. overflow: hidden;
  331. }
  332. .distance-text {
  333. font-size: 24rpx;
  334. color: #999;
  335. margin-left: 10rpx;
  336. white-space: nowrap;
  337. }
  338. /* 4. 收入区域 */
  339. .income-section {
  340. display: flex;
  341. justify-content: space-between;
  342. align-items: center;
  343. margin-bottom: 24rpx;
  344. }
  345. .income-label {
  346. font-size: 28rpx;
  347. color: #666;
  348. }
  349. .income-value-box {
  350. display: flex;
  351. align-items: baseline;
  352. }
  353. .income-value {
  354. font-size: 36rpx;
  355. font-weight: bold;
  356. color: #ff4d4f;
  357. /* 红色金额 */
  358. margin-right: 8rpx;
  359. }
  360. .income-note {
  361. font-size: 24rpx;
  362. color: #999;
  363. }
  364. /* 5. 按钮组 */
  365. .action-buttons {
  366. display: flex;
  367. justify-content: space-between;
  368. gap: 20rpx;
  369. }
  370. .btn {
  371. flex: 1;
  372. height: 72rpx;
  373. display: flex;
  374. justify-content: center;
  375. align-items: center;
  376. border-radius: 36rpx;
  377. font-size: 28rpx;
  378. font-weight: 500;
  379. }
  380. .btn-nav {
  381. background-color: #f5f5f5;
  382. color: #333;
  383. gap: 8rpx;
  384. }
  385. .btn-transfer {
  386. background-color: #ffffff;
  387. color: #ff9900;
  388. border: 1rpx solid #ff9900;
  389. }
  390. .btn-confirm {
  391. background-color: #ffc107;
  392. /* 黄色实心 */
  393. color: #333;
  394. border: 1rpx solid #ffc107;
  395. }
  396. .empty-state {
  397. text-align: center;
  398. padding: 100rpx 0;
  399. color: #999;
  400. font-size: 28rpx;
  401. }
  402. </style>