order.uvue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503
  1. <template>
  2. <view class="page-container">
  3. <!-- 1. 顶部标签栏 (Scroll View) -->
  4. <scroll-view scroll-x class="tab-scroll" show-scrollbar="false" :enable-flex="true">
  5. <view class="tab-wrapper">
  6. <view v-for="(tab, index) in tabs" :key="index"
  7. :class="['tab-item', currentTab === index ? 'active' : '']" @click="currentTab = index">
  8. <text>
  9. {{ tab }}
  10. </text>
  11. <!-- 激活下的黄色短线 -->
  12. <view v-if="currentTab === index" class="tab-indicator">
  13. </view>
  14. </view>
  15. </view>
  16. </scroll-view>
  17. <!-- 2. 订单列表 -->
  18. <view class="order-list">
  19. <view v-for="(order, idx) in orders" :key="order['id']" class="order-card">
  20. <!-- Card Header: 时间 & 状态 -->
  21. <view class="card-header">
  22. <text class="time-text">
  23. 预约时间:{{ order['time'] }}
  24. </text>
  25. <text class="status-badge paid">
  26. 已支付
  27. </text>
  28. </view>
  29. <!-- Card Body: 服务信息 (左图右文) -->
  30. <view class="service-section">
  31. <image :src="order['image']" class="service-image" mode="aspectFill" />
  32. <view class="service-details">
  33. <view class="service-title-row">
  34. <text class="service-name">
  35. {{ order['serviceName'] }}
  36. </text>
  37. <text v-for="(tag, tIdx) in tagList(order)" :key="tIdx" :class="['tag-pill', tag.type]">
  38. {{ tag.text }}
  39. </text>
  40. </view>
  41. <view class="contact-info-row">
  42. <text class="contact-info">
  43. 联系人:{{ order['contact'] }}
  44. </text>
  45. <text class="tag-pill green ">
  46. 新客
  47. </text>
  48. </view>
  49. </view>
  50. <text class="service-price">
  51. ¥{{ order.price }}
  52. </text>
  53. </view>
  54. <!-- Card Address: 地址 & 距离 -->
  55. <view class="address-section">
  56. <u-icon type="location" size="16" color="#999999">
  57. </u-icon>
  58. <text class="address-content">
  59. {{ order.address }}
  60. </text>
  61. <text class="distance-text">
  62. {{ order.distance }}km
  63. </text>
  64. </view>
  65. <!-- Card Income: 预估收入 -->
  66. <view class="income-section">
  67. <text class="income-label">
  68. 预估收入
  69. </text>
  70. <view class="income-value-group">
  71. <text class="income-main">
  72. ¥{{ order.income }}
  73. </text>
  74. <text class="income-sub">
  75. (含路费)
  76. </text>
  77. </view>
  78. </view>
  79. <!-- Card Actions: 按钮组 -->
  80. <view class="action-section">
  81. <view class="btn btn-nav" @click="onNavigate(order.address)">
  82. <u-icon type="navigation" size="14" color="#333333">
  83. </u-icon>
  84. <text>
  85. 地址导航
  86. </text>
  87. </view>
  88. <text class="btn btn-transfer" @click="onTransfer(order.id)">
  89. 我要转单
  90. </text>
  91. <text class="btn btn-confirm" @click="onConfirm(order.id)">
  92. 确认接单
  93. </text>
  94. </view>
  95. </view>
  96. </view>
  97. </view>
  98. </template>
  99. <script setup lang="ts">
  100. import { ref } from 'vue';
  101. // --- 数据 ---
  102. const tabs = ['新订单',
  103. '进行中',
  104. '取消/售后',
  105. '已完成',
  106. '全部'];
  107. const currentTab = ref(0);
  108. type OrderTag = {
  109. text : string;
  110. type : 'orange' | 'green' | 'red';
  111. }
  112. type OrderItem = {
  113. id : number;
  114. time : string;
  115. serviceName : string;
  116. tags : OrderTag[];
  117. contact : string;
  118. price : string;
  119. address : string;
  120. distance : string;
  121. income : string;
  122. image : string;
  123. };
  124. // orders data – no need for reactivity, use a plain typed array
  125. const orders : OrderItem[] = [
  126. {
  127. id: 1,
  128. time: '2025-06-18 4:00',
  129. serviceName: '润养SPA',
  130. tags: [
  131. { text: '上门', type: 'orange' } as OrderTag,
  132. { text: '首单', type: 'orange' } as OrderTag,
  133. ],
  134. contact: '刘',
  135. price: '286.6',
  136. address: '烟台 芝罘区楚风一街楚凤花园(烟台吾悦)广场附近',
  137. distance: '2.24',
  138. income: '186.6',
  139. image: '/static/testInfo/demo.png'
  140. },
  141. {
  142. id: 2,
  143. time: '2025-06-18 8:00',
  144. serviceName: '润养SPA',
  145. tags: [
  146. { text: '加钟', type: 'red' } as OrderTag
  147. ],
  148. contact: '刘',
  149. price: '286.6',
  150. address: '烟台 芝罘区楚风一街楚凤花园(烟台吾悦)广场附近',
  151. distance: '2.24',
  152. income: '186.6',
  153. image: '/static/testInfo/demo.png'
  154. }
  155. ] as OrderItem[];
  156. // --- 方法 ---
  157. const onNavigate = (addr : string) => {
  158. uni.showToast({ title: '启动导航', icon: 'none' });
  159. };
  160. // helper used in template to give v-for a typed array source
  161. function tagList(order: OrderItem): OrderTag[] {
  162. return order.tags;
  163. }
  164. const onTransfer = (id : number) => {
  165. uni.showModal({
  166. title: '转单确认',
  167. content: '确定将此订单转给其他技师吗?',
  168. success: (res) => {
  169. if (res.confirm) uni.showToast({ title: '转单成功', icon: 'success' });
  170. }
  171. });
  172. };
  173. const onConfirm = (id : number) => {
  174. uni.showLoading({ title: '处理中...' });
  175. setTimeout(() => {
  176. uni.hideLoading();
  177. uni.showToast({ title: '接单成功', icon: 'success' });
  178. }, 600);
  179. };
  180. </script>
  181. <style scoped>
  182. .page-container {
  183. background-color: #f5f6f8;
  184. /* min-height: 100vh; unsupported by uvue, replace with fixed value or remove */
  185. min-height: 1000rpx;
  186. /* width: 100%; */ /* 默认块级元素已撑满父容器 */
  187. /* 确保内部元素不溢出 */
  188. box-sizing: border-box;
  189. }
  190. /* --- Tab 区域 --- */
  191. .tab-scroll {
  192. /* width: 100%; */ /* 不使用百分比 */
  193. background-color: #ffffff;
  194. /* 固定高度或自适应 */
  195. height: 88rpx;
  196. }
  197. .tab-wrapper {
  198. display: flex;
  199. /* 内部横向排列 */
  200. flex-direction: row;
  201. align-items: center;
  202. /* 直接使用固定高度匹配 .tab-scroll */
  203. height: 88rpx;
  204. padding: 0 20rpx;
  205. white-space: nowrap;
  206. }
  207. .tab-item {
  208. position: relative;
  209. padding: 0 30rpx;
  210. /* 高度与容器一致,避免百分比 */
  211. height: 88rpx;
  212. display: flex;
  213. align-items: center;
  214. justify-content: center;
  215. font-size: 30rpx;
  216. color: #666666;
  217. }
  218. .tab-item.active {
  219. color: #333333;
  220. font-weight: bold;
  221. }
  222. .tab-indicator {
  223. position: absolute;
  224. bottom: 16rpx;
  225. left: 0;
  226. right: 0;
  227. margin: 0 auto;
  228. width: 40rpx;
  229. height: 6rpx;
  230. background-color: #ffc107;
  231. border-radius: 3rpx;
  232. }
  233. /* --- 列表区域 --- */
  234. .order-list {
  235. padding: 20rpx;
  236. /* 垂直排列卡片 */
  237. display: flex;
  238. flex-direction: column;
  239. /* gap: 20rpx; */
  240. }
  241. .order-card {
  242. background-color: #ffffff;
  243. border-radius: 16rpx;
  244. padding: 30rpx;
  245. /* 卡片内部也是垂直流 */
  246. display: flex;
  247. flex-direction: column;
  248. /* gap: 20rpx; */
  249. }
  250. /* 1. 头部 */
  251. .card-header {
  252. display: flex;
  253. flex-direction: row;
  254. /* 左右布局 */
  255. justify-content: space-between;
  256. align-items: center;
  257. }
  258. .time-text {
  259. font-size: 28rpx;
  260. color: #333333;
  261. font-weight: 400;
  262. /* use supported weight */
  263. }
  264. .status-badge {
  265. font-size: 24rpx;
  266. padding: 6rpx 16rpx;
  267. border-radius: 20rpx;
  268. }
  269. .status-badge.paid {
  270. background-color: #fff7e6;
  271. color: #ff9900;
  272. }
  273. /* 2. 服务信息 (左图右文) */
  274. .service-section {
  275. display: flex;
  276. flex-direction: row;
  277. /* 关键:横向排列图和文 */
  278. align-items: flex-start;
  279. /* gap: 20rpx; */
  280. }
  281. .service-image {
  282. width: 110rpx;
  283. height: 110rpx;
  284. border-radius: 12rpx;
  285. background-color: #f0f0f0;
  286. flex-shrink: 0;
  287. /* 防止图片被压缩 */
  288. }
  289. .service-details {
  290. flex: 1;
  291. display: flex;
  292. /* flex-direction: column; */
  293. /* 文字内部垂直排列 */
  294. justify-content: space-between;
  295. /* height: 110rpx; */
  296. }
  297. .service-title-row {
  298. display: flex;
  299. flex-direction: row;
  300. /* justify-content: space-between; */
  301. align-items: center;
  302. }
  303. .service-name {
  304. font-size: 32rpx;
  305. font-weight: bold;
  306. color: #333333;
  307. }
  308. .service-price {
  309. font-size: 34rpx;
  310. font-weight: bold;
  311. color: #333333;
  312. }
  313. .tags-container {
  314. display: flex;
  315. flex-direction: row;
  316. /* gap: 12rpx; */
  317. flex-wrap: wrap;
  318. }
  319. .tag-pill {
  320. font-size: 22rpx;
  321. padding: 4rpx 12rpx;
  322. border-radius: 20rpx;
  323. border-width: 1rpx;
  324. border-style: solid;
  325. line-height: 1.2;
  326. }
  327. .tag-pill.orange {
  328. color: #ff9900;
  329. border-color: #ff9900;
  330. background-color: #fffaf0;
  331. }
  332. .tag-pill.green {
  333. color: #52c41a;
  334. border-color: #52c41a;
  335. background-color: #f6ffed;
  336. }
  337. .tag-pill.red {
  338. color: #ff4d4f;
  339. border-color: #ff4d4f;
  340. background-color: #fff1f0;
  341. }
  342. .contact-info-row {
  343. display: flex;
  344. flex-direction: row;
  345. align-items: center;
  346. /* gap: 20rpx; */
  347. }
  348. .contact-info {
  349. font-size: 26rpx;
  350. color: #999999;
  351. }
  352. /* 3. 地址栏 */
  353. .address-section {
  354. display: flex;
  355. flex-direction: row;
  356. align-items: flex-start;
  357. padding-bottom: 20rpx;
  358. border-bottom-width: 1rpx;
  359. border-bottom-color: #f5f5f5;
  360. border-bottom-style: solid;
  361. /* gap: 10rpx; */
  362. }
  363. .address-content {
  364. flex: 1;
  365. font-size: 26rpx;
  366. color: #666666;
  367. line-height: 1.4;
  368. /* multi-line ellipsis removed; not supported by uvue */
  369. /* display: -webkit-box;
  370. -webkit-line-clamp: 2;
  371. -webkit-box-orient: vertical;
  372. overflow: hidden;
  373. */
  374. }
  375. .distance-text {
  376. font-size: 24rpx;
  377. color: #999999;
  378. white-space: nowrap;
  379. margin-left: 10rpx;
  380. }
  381. /* 4. 收入栏 */
  382. .income-section {
  383. display: flex;
  384. flex-direction: row;
  385. justify-content: space-between;
  386. align-items: center;
  387. }
  388. .income-label {
  389. font-size: 28rpx;
  390. color: #666666;
  391. }
  392. .income-value-group {
  393. display: flex;
  394. flex-direction: row;
  395. align-items: center;
  396. /* baseline not supported */
  397. /* */
  398. }
  399. .income-main {
  400. font-size: 36rpx;
  401. font-weight: bold;
  402. color: #ff4d4f;
  403. }
  404. .income-sub {
  405. font-size: 24rpx;
  406. color: #999999;
  407. }
  408. /* 5. 按钮组 */
  409. .action-section {
  410. display: flex;
  411. flex-direction: row;
  412. justify-content: space-between;
  413. /* gap: 20rpx; */
  414. }
  415. .btn {
  416. flex: 1;
  417. height: 72rpx;
  418. border-radius: 36rpx;
  419. font-size: 28rpx;
  420. font-weight: 400;
  421. display: flex;
  422. flex-direction: row;
  423. /* 按钮内图标和文字横向 */
  424. justify-content: center;
  425. align-items: center;
  426. /* */
  427. }
  428. .btn-nav {
  429. background-color: #f5f5f5;
  430. color: #333333;
  431. }
  432. .btn-transfer {
  433. background-color: #ffffff;
  434. color: #ff9900;
  435. border-width: 1rpx;
  436. border-color: #ff9900;
  437. border-style: solid;
  438. }
  439. .btn-confirm {
  440. background-color: #ffc107;
  441. color: #333333;
  442. border-width: 1rpx;
  443. border-color: #ffc107;
  444. border-style: solid;
  445. }
  446. </style>