index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595
  1. <template>
  2. <view class="page">
  3. <!-- 搜索和筛选区域 -->
  4. <view class="search-section">
  5. <view class="search-box">
  6. <uni-icons type="search" size="18" color="#999999"></uni-icons>
  7. <input
  8. class="search-input"
  9. placeholder="搜客户姓名"
  10. placeholder-style="color: #999999"
  11. v-model="searchKeyword"
  12. @input="handleSearch"
  13. />
  14. <text class="search-box-text">搜索</text>
  15. </view>
  16. <view class="filter-btn" @click="handleFilter">
  17. <uni-icons type="settings" size="18" color="#323232"></uni-icons>
  18. <text class="filter-text">筛选</text>
  19. </view>
  20. </view>
  21. <!-- 订单标签页 -->
  22. <view class="order-tabs">
  23. <view
  24. v-for="tab in tabList"
  25. :key="tab.key"
  26. class="tab-item"
  27. :class="{ 'active': activeTab === tab.key }"
  28. @click="switchTab(tab.key)"
  29. >
  30. <text class="tab-text">{{ tab.label }}({{ tab.count }})</text>
  31. </view>
  32. </view>
  33. <!-- 订单列表 -->
  34. <scroll-view class="order-list" scroll-y>
  35. <view
  36. v-for="(order, index) in filteredOrders"
  37. :key="order.id || index"
  38. class="order-card"
  39. >
  40. <view class="order-header">
  41. <view class="user-info">
  42. <image
  43. class="avatar"
  44. :src="order.avatar || '/static/images/profile.jpg'"
  45. mode="aspectFill"
  46. ></image>
  47. <view class="user-details">
  48. <text class="user-name">{{ order.customerName }}</text>
  49. <text class="valid-date">有效期至: {{ order.validDate }}</text>
  50. </view>
  51. </view>
  52. <view
  53. class="status-tag"
  54. :class="`status-tag--${order.status}`"
  55. >
  56. {{ getStatusText(order.status) }}
  57. </view>
  58. </view>
  59. <view class="order-content">
  60. <view
  61. v-for="(item, idx) in orderInfoFields"
  62. :key="idx"
  63. class="order-row"
  64. >
  65. <text class="order-label">{{ item.label }}</text>
  66. <text class="order-value">{{ order[item.key] || '-' }}</text>
  67. </view>
  68. </view>
  69. <view class="order-footer">
  70. <text class="revenue">
  71. <text class="revenue-syText">收益:</text>
  72. <text>¥{{ order.revenue }}</text>
  73. </text>
  74. <view class="action-buttons">
  75. <view
  76. v-for="(action, idx) in getOrderActions(order.status)"
  77. :key="idx"
  78. class="action-btn"
  79. :class="`action-btn--${action.type}`"
  80. @click="handleAction(action.type, order)"
  81. >
  82. <uni-icons :type="action.icon" size="16" :color="action.color"></uni-icons>
  83. <text class="btn-text">{{ action.text }}</text>
  84. </view>
  85. </view>
  86. </view>
  87. </view>
  88. <!-- 空状态 -->
  89. <view v-if="filteredOrders.length === 0" class="empty-state">
  90. <text class="empty-text">暂无订单数据</text>
  91. </view>
  92. </scroll-view>
  93. <!-- 底部导航栏 -->
  94. <bar-navigasi-handap></bar-navigasi-handap>
  95. </view>
  96. </template>
  97. <script>
  98. import BarNavigasiHandap from "@/components/barNavigasiHandap.vue"
  99. export default {
  100. name: 'Index',
  101. components: {
  102. BarNavigasiHandap
  103. },
  104. data() {
  105. return {
  106. activeTab: 'all', // 当前选中的标签页
  107. searchKeyword: '', // 搜索关键词
  108. // 标签页配置
  109. tabList: [
  110. { key: 'all', label: '全部订单', count: 2 },
  111. { key: 'progress', label: '进行中', count: 0 },
  112. { key: 'completed', label: '已完成', count: 0 }
  113. ],
  114. // 订单信息字段配置
  115. orderInfoFields: [
  116. { key: 'orderNo', label: '订单编号' },
  117. { key: 'phone', label: '联系电话' },
  118. { key: 'serviceFee', label: '服务费用' },
  119. { key: 'orderTime', label: '下单时间' },
  120. { key: 'payTime', label: '支付时间' },
  121. { key: 'commissionRate', label: '佣金比例' }
  122. ],
  123. // 订单列表数据
  124. orders: [
  125. {
  126. id: 1,
  127. customerName: '张明明',
  128. avatar: '/static/images/profile.jpg',
  129. validDate: '2025-11-07',
  130. status: 'progress',
  131. orderNo: 'LAW2023071500123',
  132. phone: '13877092066',
  133. serviceFee: '¥200/次',
  134. orderTime: '2025-11-11 11:11:11',
  135. payTime: '2025-11-11 11:11:11',
  136. commissionRate: '3%',
  137. revenue: 280
  138. },
  139. {
  140. id: 2,
  141. customerName: '张明明',
  142. avatar: '/static/images/profile.jpg',
  143. validDate: '2025-11-07',
  144. status: 'completed',
  145. orderNo: 'LAW2023071500123',
  146. phone: '13877092066',
  147. serviceFee: '¥200/次',
  148. orderTime: '2025-11-11 11:11:11',
  149. payTime: '2025-11-11 11:11:11',
  150. commissionRate: '3%',
  151. revenue: 280
  152. },
  153. {
  154. id: 3,
  155. customerName: '张明明',
  156. avatar: '/static/images/profile.jpg',
  157. validDate: '2025-11-07',
  158. status: 'completed',
  159. orderNo: 'LAW2023071500123',
  160. phone: '13877092066',
  161. serviceFee: '¥200/次',
  162. orderTime: '2025-11-11 11:11:11',
  163. payTime: '2025-11-11 11:11:11',
  164. commissionRate: '3%',
  165. revenue: 280
  166. }
  167. ]
  168. }
  169. },
  170. computed: {
  171. /**
  172. * 过滤后的订单列表
  173. */
  174. filteredOrders() {
  175. let result = this.orders
  176. // 根据标签页筛选
  177. if (this.activeTab !== 'all') {
  178. result = result.filter(order => order.status === this.activeTab)
  179. }
  180. // 根据搜索关键词筛选
  181. if (this.searchKeyword.trim()) {
  182. const keyword = this.searchKeyword.trim().toLowerCase()
  183. result = result.filter(order =>
  184. order.customerName.toLowerCase().includes(keyword) ||
  185. order.orderNo.toLowerCase().includes(keyword) ||
  186. order.phone.includes(keyword)
  187. )
  188. }
  189. return result
  190. }
  191. },
  192. methods: {
  193. /**
  194. * 切换标签页
  195. */
  196. switchTab(tab) {
  197. if (this.activeTab === tab) return
  198. this.activeTab = tab
  199. this.updateTabCount()
  200. },
  201. /**
  202. * 更新标签页数量
  203. */
  204. updateTabCount() {
  205. this.tabList.forEach(tab => {
  206. if (tab.key === 'all') {
  207. tab.count = this.orders.length
  208. } else {
  209. tab.count = this.orders.filter(order => order.status === tab.key).length
  210. }
  211. })
  212. },
  213. /**
  214. * 处理搜索
  215. */
  216. handleSearch() {
  217. // 搜索逻辑已在 computed 中处理
  218. },
  219. /**
  220. * 处理筛选
  221. */
  222. handleFilter() {
  223. uni.showToast({
  224. title: '筛选功能开发中',
  225. icon: 'none'
  226. })
  227. },
  228. /**
  229. * 获取状态文本
  230. */
  231. getStatusText(status) {
  232. const statusMap = {
  233. progress: '进行中',
  234. completed: '已完成'
  235. }
  236. return statusMap[status] || '未知'
  237. },
  238. /**
  239. * 获取订单操作按钮
  240. */
  241. getOrderActions(status) {
  242. if (status === 'progress') {
  243. return [
  244. { type: 'message', icon: 'chat', color: '#1976D2', text: '发消息' },
  245. { type: 'call', icon: 'phone', color: '#4CAF50', text: '联系客户' }
  246. ]
  247. } else if (status === 'completed') {
  248. return [
  249. { type: 'delete', icon: 'trash', color: '#F44336', text: '删除' },
  250. { type: 'message', icon: 'chat', color: '#1976D2', text: '查看消息' }
  251. ]
  252. }
  253. return []
  254. },
  255. /**
  256. * 处理操作按钮点击
  257. */
  258. handleAction(actionType, order) {
  259. switch (actionType) {
  260. case 'message':
  261. this.handleMessage(order)
  262. break
  263. case 'call':
  264. this.handleCall(order)
  265. break
  266. case 'delete':
  267. this.handleDelete(order)
  268. break
  269. default:
  270. console.warn('未知操作类型:', actionType)
  271. }
  272. },
  273. /**
  274. * 处理发消息
  275. */
  276. handleMessage(order) {
  277. uni.showToast({
  278. title: '跳转到消息页面',
  279. icon: 'none'
  280. })
  281. // TODO: 实现跳转到消息页面
  282. },
  283. /**
  284. * 处理打电话
  285. */
  286. handleCall(order) {
  287. uni.makePhoneCall({
  288. phoneNumber: order.phone,
  289. fail: (err) => {
  290. console.error('拨打电话失败:', err)
  291. uni.showToast({
  292. title: '拨打电话失败',
  293. icon: 'none'
  294. })
  295. }
  296. })
  297. },
  298. /**
  299. * 处理删除
  300. */
  301. handleDelete(order) {
  302. uni.showModal({
  303. title: '提示',
  304. content: '确定要删除该订单吗?',
  305. success: (res) => {
  306. if (res.confirm) {
  307. const index = this.orders.findIndex(item => item.id === order.id)
  308. if (index > -1) {
  309. this.orders.splice(index, 1)
  310. this.updateTabCount()
  311. uni.showToast({
  312. title: '删除成功',
  313. icon: 'success'
  314. })
  315. }
  316. }
  317. }
  318. })
  319. }
  320. },
  321. onLoad() {
  322. // 页面加载时更新标签页数量
  323. this.updateTabCount()
  324. }
  325. }
  326. </script>
  327. <style scoped>
  328. .page {
  329. padding-top: calc(var(--status-bar-height) + 20rpx);
  330. padding-bottom: calc(16rpx + env(safe-area-inset-bottom));
  331. background: linear-gradient(180deg, rgba(40, 86, 199, 0.3) 0%, rgba(255, 255, 255, 0) 100%);
  332. min-height: 100vh;
  333. box-sizing: border-box;
  334. }
  335. /* 搜索区域 */
  336. .search-section {
  337. display: flex;
  338. align-items: center;
  339. padding: 0 30rpx 24rpx;
  340. gap: 20rpx;
  341. }
  342. .search-box {
  343. flex: 1;
  344. display: flex;
  345. align-items: center;
  346. background-color: #F5F5F5;
  347. border-radius: 38rpx;
  348. padding: 20rpx 24rpx;
  349. gap: 12rpx;
  350. }
  351. .search-input {
  352. flex: 1;
  353. font-size: 28rpx;
  354. color: #323232;
  355. }
  356. .search-box-text {
  357. font-weight: 400;
  358. font-size: 27rpx;
  359. color: #151515;
  360. }
  361. .filter-btn {
  362. display: flex;
  363. align-items: center;
  364. gap: 8rpx;
  365. padding: 20rpx 24rpx;
  366. }
  367. .filter-text {
  368. font-size: 28rpx;
  369. color: #323232;
  370. }
  371. /* 订单标签页 */
  372. .order-tabs {
  373. display: flex;
  374. justify-content: space-around;
  375. width: 100%;
  376. }
  377. .tab-item {
  378. padding: 24rpx 0;
  379. position: relative;
  380. cursor: pointer;
  381. }
  382. .tab-item.active {
  383. font-weight: 600;
  384. }
  385. .tab-text {
  386. font-size: 28rpx;
  387. color: #8D8D8D;
  388. transition: color 0.3s;
  389. }
  390. .tab-item.active .tab-text {
  391. color: #323232;
  392. }
  393. /* 订单列表 */
  394. .order-list {
  395. /* flex: 1; */
  396. height:77vh;
  397. padding: 24rpx 30rpx;
  398. box-sizing: border-box;
  399. }
  400. /* 订单卡片 */
  401. .order-card {
  402. background-color: #FFFFFF;
  403. border-radius: 16rpx;
  404. padding: 32rpx;
  405. margin-bottom: 24rpx;
  406. box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.04);
  407. }
  408. .order-header {
  409. display: flex;
  410. justify-content: space-between;
  411. align-items: flex-start;
  412. margin-bottom: 32rpx;
  413. padding-bottom: 24rpx;
  414. border-bottom: 1px solid #EEEEEE;
  415. }
  416. .user-info {
  417. display: flex;
  418. align-items: center;
  419. gap: 24rpx;
  420. flex: 1;
  421. }
  422. .avatar {
  423. width: 96rpx;
  424. height: 96rpx;
  425. border-radius: 50%;
  426. background-color: #F5F5F5;
  427. flex-shrink: 0;
  428. }
  429. .user-details {
  430. display: flex;
  431. flex-direction: column;
  432. gap: 12rpx;
  433. }
  434. .user-name {
  435. font-size: 32rpx;
  436. font-weight: 500;
  437. color: #323232;
  438. }
  439. .valid-date {
  440. font-size: 24rpx;
  441. color: #999999;
  442. }
  443. .status-tag {
  444. padding: 8rpx 20rpx;
  445. border-radius: 20rpx;
  446. font-size: 24rpx;
  447. white-space: nowrap;
  448. }
  449. .status-tag--progress {
  450. background-color: #E8F5E9;
  451. color: #4CAF50;
  452. }
  453. .status-tag--completed {
  454. background-color: #FFF3E0;
  455. color: #FF9800;
  456. }
  457. /* 订单内容 */
  458. .order-content {
  459. margin-bottom: 32rpx;
  460. }
  461. .order-row {
  462. display: flex;
  463. justify-content: space-between;
  464. margin-bottom: 20rpx;
  465. }
  466. .order-row:last-child {
  467. margin-bottom: 0;
  468. }
  469. .order-label {
  470. font-weight: 500;
  471. font-size: 27rpx;
  472. color: #666666;
  473. }
  474. .order-value {
  475. font-weight: 500;
  476. font-size: 27rpx;
  477. color: #323232;
  478. }
  479. /* 订单底部 */
  480. .order-footer {
  481. display: flex;
  482. justify-content: space-between;
  483. align-items: center;
  484. padding-top: 24rpx;
  485. border-top: 1px solid #EEEEEE;
  486. }
  487. .revenue {
  488. font-size: 34rpx;
  489. color: #FF9800;
  490. font-weight: 600;
  491. }
  492. .revenue-syText{
  493. font-weight: 500;
  494. font-size: 27rpx;
  495. color: #666666;
  496. }
  497. .action-buttons {
  498. display: flex;
  499. gap: 16rpx;
  500. }
  501. .action-btn {
  502. display: flex;
  503. align-items: center;
  504. gap: 8rpx;
  505. padding: 12rpx 24rpx;
  506. border-radius: 8rpx;
  507. font-size: 24rpx;
  508. cursor: pointer;
  509. }
  510. .action-btn--message {
  511. background-color: #E3F2FD;
  512. color: #1976D2;
  513. }
  514. .action-btn--call {
  515. background-color: #E8F5E9;
  516. color: #4CAF50;
  517. }
  518. .action-btn--delete {
  519. background-color: #FFEBEE;
  520. color: #F44336;
  521. }
  522. .btn-text {
  523. font-size: 24rpx;
  524. margin-left: 4rpx;
  525. }
  526. /* 空状态 */
  527. .empty-state {
  528. display: flex;
  529. justify-content: center;
  530. align-items: center;
  531. padding: 100rpx 0;
  532. }
  533. .empty-text {
  534. font-size: 28rpx;
  535. color: #999999;
  536. }
  537. </style>