index.vue 3.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <template>
  2. <view class="gorder-page">
  3. <view class="section-card">
  4. <text class="section-title">团报</text>
  5. <text class="card-desc">多人拼单同报一个班次,可填写企业开票信息</text>
  6. <button class="create-btn" @click="goCreate">发起团报</button>
  7. </view>
  8. <view class="section-card">
  9. <text class="section-title">我的团报单</text>
  10. <view v-if="loading" class="empty-tip">加载中…</view>
  11. <view v-else-if="list.length === 0" class="empty-tip">暂无团报单</view>
  12. <view v-else>
  13. <view class="order-item" v-for="item in list" :key="item.id" @click="goDetail(item.id)">
  14. <view class="order-head">
  15. <text class="order-no">{{ item.groupNo }}</text>
  16. <text class="order-status" :class="item.status">{{ statusLabel(item.status) }}</text>
  17. </view>
  18. <text class="order-class">{{ item.className || ('班次' + item.classId) }}</text>
  19. <text class="order-meta">{{ item.memberCount }} 人 · 合计 ¥{{ fenToYuan(item.totalAmount) }}</text>
  20. <text class="order-time" v-if="item.createdAt">创建时间:{{ formatDateTime(item.createdAt) }}</text>
  21. </view>
  22. </view>
  23. </view>
  24. </view>
  25. </template>
  26. <script>
  27. import { getMyGroupOrders } from '@/utils/api.js'
  28. import { fenToYuan, formatDateTime } from '@/utils/format.js'
  29. import { guardPage } from '@/utils/guard.js'
  30. export default {
  31. data() {
  32. return {
  33. list: [],
  34. loading: false
  35. }
  36. },
  37. onShow() {
  38. if (!guardPage()) return
  39. this.loadMine()
  40. },
  41. methods: {
  42. fenToYuan: fenToYuan,
  43. formatDateTime: formatDateTime,
  44. loadMine() {
  45. var self = this
  46. self.loading = true
  47. getMyGroupOrders().then(function(resp) {
  48. self.list = resp.data || []
  49. }).catch(function() {
  50. uni.showToast({ title: '加载团报单失败', icon: 'none' })
  51. }).finally(function() {
  52. self.loading = false
  53. })
  54. },
  55. statusLabel(status) {
  56. var map = { pending: '待支付', paid: '已支付', closed: '已关闭' }
  57. return map[status] || status || '未知'
  58. },
  59. goCreate() {
  60. uni.navigateTo({ url: '/pages/group-order/create' })
  61. },
  62. goDetail(id) {
  63. uni.navigateTo({ url: '/pages/group-order/detail?id=' + id })
  64. }
  65. }
  66. }
  67. </script>
  68. <style scoped>
  69. .gorder-page { min-height: 100vh; background: #F5F5F5; padding: 32rpx; }
  70. .section-card { background: #FFF; border-radius: 16rpx; padding: 32rpx; margin-bottom: 24rpx; }
  71. .section-title { display: block; font-size: 32rpx; font-weight: 700; color: #1E293B; margin-bottom: 8rpx; border-left: 8rpx solid #F97316; padding-left: 16rpx; }
  72. .card-desc { display: block; font-size: 26rpx; color: #64748B; margin-bottom: 24rpx; }
  73. .empty-tip { font-size: 26rpx; color: #94A3B8; padding: 32rpx 0; text-align: center; }
  74. .create-btn { width: 100%; height: 88rpx; line-height: 88rpx; background: #F97316; color: #FFF; font-size: 30rpx; font-weight: 600; border-radius: 44rpx; border: none; }
  75. .create-btn:active { opacity: 0.85; }
  76. .order-item { padding: 24rpx 0; border-bottom: 1rpx solid #F1F5F9; }
  77. .order-item:last-child { border-bottom: none; }
  78. .order-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8rpx; }
  79. .order-no { font-size: 26rpx; color: #475569; font-weight: 500; }
  80. .order-status { font-size: 24rpx; font-weight: 600; }
  81. .order-status.pending { color: #F97316; }
  82. .order-status.paid { color: #22C55E; }
  83. .order-status.closed { color: #94A3B8; }
  84. .order-class { display: block; font-size: 28rpx; color: #1E293B; font-weight: 600; margin-bottom: 6rpx; }
  85. .order-meta { display: block; font-size: 26rpx; color: #64748B; margin-bottom: 6rpx; }
  86. .order-time { display: block; font-size: 24rpx; color: #94A3B8; }
  87. </style>