index.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  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. <order-list
  35. :orders="filteredOrders"
  36. :order-info-fields="orderInfoFields"
  37. @delete="handleDelete"
  38. @message="handleMessage"
  39. ></order-list>
  40. <!-- 底部导航栏 -->
  41. <bar-navigasi-handap></bar-navigasi-handap>
  42. </view>
  43. </template>
  44. <script>
  45. import BarNavigasiHandap from "@/components/barNavigasiHandap.vue"
  46. import OrderList from "./components/order.vue"
  47. export default {
  48. name: 'Index',
  49. components: {
  50. BarNavigasiHandap,
  51. OrderList
  52. },
  53. data() {
  54. return {
  55. activeTab: 'all', // 当前选中的标签页
  56. searchKeyword: '', // 搜索关键词
  57. // 标签页配置
  58. tabList: [
  59. { key: 'all', label: '全部订单', count: 2 },
  60. { key: 'progress', label: '进行中', count: 0 },
  61. { key: 'completed', label: '已完成', count: 0 }
  62. ],
  63. // 订单信息字段配置
  64. orderInfoFields: [
  65. { key: 'orderNo', label: '订单编号' },
  66. { key: 'phone', label: '联系电话' },
  67. { key: 'serviceFee', label: '服务费用' },
  68. { key: 'orderTime', label: '下单时间' },
  69. { key: 'payTime', label: '支付时间' },
  70. { key: 'commissionRate', label: '佣金比例' }
  71. ],
  72. // 订单列表数据
  73. orders: [
  74. {
  75. id: 1,
  76. customerName: '张明明',
  77. avatar: '/static/images/profile.jpg',
  78. validDate: '2025-11-07',
  79. status: 'progress',
  80. orderNo: 'LAW2023071500123',
  81. phone: '13877092066',
  82. serviceFee: '¥200/次',
  83. orderTime: '2025-11-11 11:11:11',
  84. payTime: '2025-11-11 11:11:11',
  85. commissionRate: '3%',
  86. revenue: 280
  87. },
  88. {
  89. id: 2,
  90. customerName: '张明明',
  91. avatar: '/static/images/profile.jpg',
  92. validDate: '2025-11-07',
  93. status: 'completed',
  94. orderNo: 'LAW2023071500123',
  95. phone: '13877092066',
  96. serviceFee: '¥200/次',
  97. orderTime: '2025-11-11 11:11:11',
  98. payTime: '2025-11-11 11:11:11',
  99. commissionRate: '3%',
  100. revenue: 280
  101. },
  102. {
  103. id: 3,
  104. customerName: '张明明',
  105. avatar: '/static/images/profile.jpg',
  106. validDate: '2025-11-07',
  107. status: 'completed',
  108. orderNo: 'LAW2023071500123',
  109. phone: '13877092066',
  110. serviceFee: '¥200/次',
  111. orderTime: '2025-11-11 11:11:11',
  112. payTime: '2025-11-11 11:11:11',
  113. commissionRate: '3%',
  114. revenue: 280
  115. }
  116. ]
  117. }
  118. },
  119. computed: {
  120. /**
  121. * 过滤后的订单列表
  122. */
  123. filteredOrders() {
  124. let result = this.orders
  125. // 根据标签页筛选
  126. if (this.activeTab !== 'all') {
  127. result = result.filter(order => order.status === this.activeTab)
  128. }
  129. // 根据搜索关键词筛选
  130. if (this.searchKeyword.trim()) {
  131. const keyword = this.searchKeyword.trim().toLowerCase()
  132. result = result.filter(order =>
  133. order.customerName.toLowerCase().includes(keyword) ||
  134. order.orderNo.toLowerCase().includes(keyword) ||
  135. order.phone.includes(keyword)
  136. )
  137. }
  138. return result
  139. }
  140. },
  141. methods: {
  142. /**
  143. * 切换标签页
  144. */
  145. switchTab(tab) {
  146. if (this.activeTab === tab) return
  147. this.activeTab = tab
  148. this.updateTabCount()
  149. },
  150. /**
  151. * 更新标签页数量
  152. */
  153. updateTabCount() {
  154. this.tabList.forEach(tab => {
  155. if (tab.key === 'all') {
  156. tab.count = this.orders.length
  157. } else {
  158. tab.count = this.orders.filter(order => order.status === tab.key).length
  159. }
  160. })
  161. },
  162. /**
  163. * 处理搜索
  164. */
  165. handleSearch() {
  166. // 搜索逻辑已在 computed 中处理
  167. },
  168. /**
  169. * 处理筛选
  170. */
  171. handleFilter() {
  172. uni.showToast({
  173. title: '筛选功能开发中',
  174. icon: 'none'
  175. })
  176. },
  177. /**
  178. * 处理发消息(从子组件触发)
  179. */
  180. handleMessage(order) {
  181. // TODO: 实现跳转到消息页面
  182. },
  183. /**
  184. * 处理删除(从子组件触发)
  185. */
  186. handleDelete(order) {
  187. const index = this.orders.findIndex(item => item.id === order.id)
  188. if (index > -1) {
  189. this.orders.splice(index, 1)
  190. this.updateTabCount()
  191. uni.showToast({
  192. title: '删除成功',
  193. icon: 'success'
  194. })
  195. }
  196. }
  197. },
  198. onLoad() {
  199. // 页面加载时更新标签页数量
  200. this.updateTabCount()
  201. }
  202. }
  203. </script>
  204. <style scoped>
  205. .page {
  206. padding-top: calc(var(--status-bar-height) + 20rpx);
  207. padding-bottom: calc(16rpx + env(safe-area-inset-bottom));
  208. background: linear-gradient(180deg, rgba(40, 86, 199, 0.3) 0%, rgba(255, 255, 255, 0) 100%);
  209. min-height: 100vh;
  210. box-sizing: border-box;
  211. }
  212. /* 搜索区域 */
  213. .search-section {
  214. display: flex;
  215. align-items: center;
  216. padding: 0 30rpx 24rpx;
  217. gap: 20rpx;
  218. }
  219. .search-box {
  220. flex: 1;
  221. display: flex;
  222. align-items: center;
  223. background-color: #F5F5F5;
  224. border-radius: 38rpx;
  225. padding: 20rpx 24rpx;
  226. gap: 12rpx;
  227. }
  228. .search-input {
  229. flex: 1;
  230. font-size: 28rpx;
  231. color: #323232;
  232. }
  233. .search-box-text {
  234. font-weight: 400;
  235. font-size: 27rpx;
  236. color: #151515;
  237. }
  238. .filter-btn {
  239. display: flex;
  240. align-items: center;
  241. gap: 8rpx;
  242. padding: 20rpx 24rpx;
  243. }
  244. .filter-text {
  245. font-size: 28rpx;
  246. color: #323232;
  247. }
  248. /* 订单标签页 */
  249. .order-tabs {
  250. display: flex;
  251. justify-content: space-around;
  252. width: 100%;
  253. }
  254. .tab-item {
  255. padding: 24rpx 0;
  256. position: relative;
  257. cursor: pointer;
  258. }
  259. .tab-item.active {
  260. font-weight: 600;
  261. }
  262. .tab-text {
  263. font-size: 28rpx;
  264. color: #8D8D8D;
  265. transition: color 0.3s;
  266. }
  267. .tab-item.active .tab-text {
  268. color: #323232;
  269. }
  270. </style>