order.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353
  1. <template>
  2. <scroll-view class="order-list" scroll-y>
  3. <view
  4. v-for="(order, index) in orders"
  5. :key="order.id || index"
  6. class="order-card"
  7. >
  8. <view class="order-header">
  9. <view class="user-info">
  10. <image
  11. class="avatar"
  12. :src="order.avatar || '/static/images/profile.jpg'"
  13. mode="aspectFill"
  14. ></image>
  15. <view class="user-details">
  16. <text class="user-name">{{ order.customerName }}</text>
  17. <text class="valid-date">有效期至: {{ order.validDate }}</text>
  18. </view>
  19. </view>
  20. <view
  21. class="status-tag"
  22. :class="`status-tag--${order.status}`"
  23. >
  24. {{ getStatusText(order.status) }}
  25. </view>
  26. </view>
  27. <view class="order-content">
  28. <view
  29. v-for="(item, idx) in orderInfoFields"
  30. :key="idx"
  31. class="order-row"
  32. >
  33. <text class="order-label">{{ item.label }}</text>
  34. <text class="order-value">{{ order[item.key] || '-' }}</text>
  35. </view>
  36. </view>
  37. <view class="order-footer">
  38. <text class="revenue">
  39. <text class="revenue-syText">收益:</text>
  40. <text>¥{{ order.revenue }}</text>
  41. </text>
  42. <view class="action-buttons">
  43. <view
  44. v-for="(action, idx) in getOrderActions(order.status)"
  45. :key="idx"
  46. class="action-btn"
  47. :class="`action-btn--${action.type}`"
  48. @click="handleAction(action.type, order)"
  49. >
  50. <uni-icons :type="action.icon" size="16" :color="action.color"></uni-icons>
  51. <text class="btn-text">{{ action.text }}</text>
  52. </view>
  53. </view>
  54. </view>
  55. </view>
  56. <!-- 空状态 -->
  57. <view v-if="orders.length === 0" class="empty-state">
  58. <text class="empty-text">暂无订单数据</text>
  59. </view>
  60. </scroll-view>
  61. </template>
  62. <script>
  63. export default {
  64. name: 'OrderList',
  65. props: {
  66. // 订单列表
  67. orders: {
  68. type: Array,
  69. default: () => []
  70. },
  71. // 订单信息字段配置
  72. orderInfoFields: {
  73. type: Array,
  74. default: () => [
  75. { key: 'orderNo', label: '订单编号' },
  76. { key: 'phone', label: '联系电话' },
  77. { key: 'serviceFee', label: '服务费用' },
  78. { key: 'orderTime', label: '下单时间' },
  79. { key: 'payTime', label: '支付时间' },
  80. { key: 'commissionRate', label: '佣金比例' }
  81. ]
  82. }
  83. },
  84. methods: {
  85. /**
  86. * 获取状态文本
  87. */
  88. getStatusText(status) {
  89. const statusMap = {
  90. progress: '进行中',
  91. completed: '已完成'
  92. }
  93. return statusMap[status] || '未知'
  94. },
  95. /**
  96. * 获取订单操作按钮
  97. */
  98. getOrderActions(status) {
  99. if (status === 'progress') {
  100. return [
  101. { type: 'message', icon: 'chat', color: '#1976D2', text: '发消息' },
  102. { type: 'call', icon: 'phone', color: '#4CAF50', text: '联系客户' }
  103. ]
  104. } else if (status === 'completed') {
  105. return [
  106. { type: 'delete', icon: 'trash', color: '#F44336', text: '删除' },
  107. { type: 'message', icon: 'chat', color: '#1976D2', text: '查看消息' }
  108. ]
  109. }
  110. return []
  111. },
  112. /**
  113. * 处理操作按钮点击
  114. */
  115. handleAction(actionType, order) {
  116. switch (actionType) {
  117. case 'message':
  118. this.handleMessage(order)
  119. break
  120. case 'call':
  121. this.handleCall(order)
  122. break
  123. case 'delete':
  124. this.handleDelete(order)
  125. break
  126. default:
  127. console.warn('未知操作类型:', actionType)
  128. }
  129. },
  130. /**
  131. * 处理发消息
  132. */
  133. handleMessage(order) {
  134. this.$emit('message', order)
  135. uni.navigateTo({
  136. url:'/pages/indexOrder/message'
  137. })
  138. },
  139. /**
  140. * 处理打电话
  141. */
  142. handleCall(order) {
  143. uni.makePhoneCall({
  144. phoneNumber: order.phone,
  145. fail: (err) => {
  146. console.error('拨打电话失败:', err)
  147. uni.showToast({
  148. title: '拨打电话失败',
  149. icon: 'none'
  150. })
  151. }
  152. })
  153. },
  154. /**
  155. * 处理删除
  156. */
  157. handleDelete(order) {
  158. uni.showModal({
  159. title: '提示',
  160. content: '确定要删除该订单吗?',
  161. success: (res) => {
  162. if (res.confirm) {
  163. this.$emit('delete', order)
  164. }
  165. }
  166. })
  167. }
  168. }
  169. }
  170. </script>
  171. <style scoped>
  172. /* 订单列表 */
  173. .order-list {
  174. height: 77vh;
  175. padding: 24rpx 30rpx;
  176. box-sizing: border-box;
  177. }
  178. /* 订单卡片 */
  179. .order-card {
  180. background-color: #FFFFFF;
  181. border-radius: 16rpx;
  182. padding: 32rpx;
  183. margin-bottom: 24rpx;
  184. box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.04);
  185. }
  186. .order-header {
  187. display: flex;
  188. justify-content: space-between;
  189. align-items: flex-start;
  190. margin-bottom: 32rpx;
  191. padding-bottom: 24rpx;
  192. border-bottom: 1px solid #EEEEEE;
  193. }
  194. .user-info {
  195. display: flex;
  196. align-items: center;
  197. gap: 24rpx;
  198. flex: 1;
  199. }
  200. .avatar {
  201. width: 96rpx;
  202. height: 96rpx;
  203. border-radius: 50%;
  204. background-color: #F5F5F5;
  205. flex-shrink: 0;
  206. }
  207. .user-details {
  208. display: flex;
  209. flex-direction: column;
  210. gap: 12rpx;
  211. }
  212. .user-name {
  213. font-size: 32rpx;
  214. font-weight: 500;
  215. color: #323232;
  216. }
  217. .valid-date {
  218. font-size: 24rpx;
  219. color: #999999;
  220. }
  221. .status-tag {
  222. padding: 8rpx 20rpx;
  223. border-radius: 20rpx;
  224. font-size: 24rpx;
  225. white-space: nowrap;
  226. }
  227. .status-tag--progress {
  228. background-color: #E8F5E9;
  229. color: #4CAF50;
  230. }
  231. .status-tag--completed {
  232. background-color: #FFF3E0;
  233. color: #FF9800;
  234. }
  235. /* 订单内容 */
  236. .order-content {
  237. margin-bottom: 32rpx;
  238. }
  239. .order-row {
  240. display: flex;
  241. justify-content: space-between;
  242. margin-bottom: 20rpx;
  243. }
  244. .order-row:last-child {
  245. margin-bottom: 0;
  246. }
  247. .order-label {
  248. font-weight: 500;
  249. font-size: 27rpx;
  250. color: #666666;
  251. }
  252. .order-value {
  253. font-weight: 500;
  254. font-size: 27rpx;
  255. color: #323232;
  256. }
  257. /* 订单底部 */
  258. .order-footer {
  259. display: flex;
  260. justify-content: space-between;
  261. align-items: center;
  262. padding-top: 24rpx;
  263. border-top: 1px solid #EEEEEE;
  264. }
  265. .revenue {
  266. font-size: 34rpx;
  267. color: #FF9800;
  268. font-weight: 600;
  269. }
  270. .revenue-syText {
  271. font-weight: 500;
  272. font-size: 27rpx;
  273. color: #666666;
  274. }
  275. .action-buttons {
  276. display: flex;
  277. gap: 16rpx;
  278. }
  279. .action-btn {
  280. display: flex;
  281. align-items: center;
  282. gap: 8rpx;
  283. padding: 12rpx 24rpx;
  284. border-radius: 8rpx;
  285. font-size: 27rpx;
  286. cursor: pointer;
  287. height: 69rpx;
  288. border-radius: 191rpx 191rpx 191rpx 191rpx;
  289. }
  290. .action-btn--message {
  291. background: rgba(52,117,231,0.1);
  292. border-radius: 191rpx 191rpx 191rpx 191rpx;
  293. }
  294. .action-btn--call {
  295. background-color: #E8F5E9;
  296. color: #4CAF50;
  297. }
  298. .action-btn--delete {
  299. background-color: #FFEBEE;
  300. color: #F44336;
  301. }
  302. .btn-text {
  303. font-size: 24rpx;
  304. margin-left: 4rpx;
  305. }
  306. /* 空状态 */
  307. .empty-state {
  308. display: flex;
  309. justify-content: center;
  310. align-items: center;
  311. padding: 100rpx 0;
  312. }
  313. .empty-text {
  314. font-size: 28rpx;
  315. color: #999999;
  316. }
  317. </style>