hexiao_detail.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. <template>
  2. <view class="page-container">
  3. <view class="info-card">
  4. <view class="info-row">
  5. <text class="info-label">核销门店</text>
  6. <text class="info-value">{{ recordInfo.storeName }}</text>
  7. </view>
  8. <view class="info-row">
  9. <text class="info-label">核销时间</text>
  10. <text class="info-value">{{ recordInfo.verificationTime }}</text>
  11. </view>
  12. </view>
  13. <view class="summary-card">
  14. <view
  15. class="summary-tab"
  16. v-for="item in summaryData"
  17. :key="item.key"
  18. >
  19. <text class="tab-category">{{ item.category }}</text>
  20. <text class="tab-count">{{ item.count }}{{ item.unit }}</text>
  21. </view>
  22. </view>
  23. <scroll-view class="details-list" scroll-y="true" @scrolltolower="loadMore">
  24. <view v-if="detailsList.length === 0 && loadStatus !== 'loading'" class="empty-tip">
  25. 暂无明细记录
  26. </view>
  27. <view v-for="(item, index) in detailsList" :key="index" class="detail-item-card">
  28. <text class="item-name">{{ item.name }}</text>
  29. <text class="item-code">扫码编号:{{ item.code }}</text>
  30. </view>
  31. <uni-load-more :status="loadStatus"></uni-load-more>
  32. </scroll-view>
  33. </view>
  34. </template>
  35. <script>
  36. import {queryAddRecordDetail} from "@/api/hexiao";
  37. export default {
  38. data() {
  39. return {
  40. id:"",
  41. // 总览信息
  42. recordInfo: {
  43. storeName: '湖南长沙超吉炫旗舰店',
  44. verificationTime: '2025-08-11 09:30:00',
  45. },
  46. // 分类汇总数据
  47. summaryData: [
  48. { category: '10元槟榔', count: 20, unit: '袋', key: 'product_10' },
  49. { category: '20元槟榔', count: 20, unit: '袋', key: 'product_20' },
  50. { category: '30元槟榔', count: 20, unit: '袋', key: 'product_30' },
  51. { category: '能量饮料', count: 20, unit: '罐', key: 'product_drink' },
  52. ],
  53. // 所有明细的列表
  54. detailsList: [],
  55. // 分页加载相关
  56. pagination: { page: 1, limit: 15 },
  57. loadStatus: 'more', // 'more', 'loading', 'noMore'
  58. isLoading: false,
  59. };
  60. },
  61. onLoad(opt) {
  62. // 页面加载时,获取第一页数据
  63. // options.id 可以用来从上个页面传递记录ID
  64. this.id = opt.id
  65. this.getDetail(true);
  66. },
  67. onPullDownRefresh() {
  68. this.fetchDetails(true);
  69. },
  70. methods: {
  71. getDetail(){
  72. queryAddRecordDetail(this.id).then(res=>{
  73. debugger;
  74. })
  75. },
  76. // 模拟从API获取明细数据
  77. async fetchDetails(isRefresh = false) {
  78. if (this.isLoading || (this.loadStatus === 'noMore' && !isRefresh)) {
  79. return;
  80. }
  81. if (isRefresh) {
  82. this.pagination.page = 1;
  83. this.detailsList = [];
  84. this.loadStatus = 'more';
  85. }
  86. this.isLoading = true;
  87. this.loadStatus = 'loading';
  88. console.log(`请求第 ${this.pagination.page} 页明细...`);
  89. await new Promise(resolve => setTimeout(resolve, 1000));
  90. const mockData = Array.from({ length: this.pagination.limit }, (_, i) => {
  91. const id = (this.pagination.page - 1) * this.pagination.limit + i + 1;
  92. return {
  93. name: `超吉炫10元精制槟榔 - ${id}`,
  94. code: `BH2025010020${String(id).padStart(3, '0')}`
  95. };
  96. });
  97. const noMoreData = this.pagination.page >= 5; // 模拟加载4页后没有更多
  98. uni.stopPullDownRefresh();
  99. if (mockData.length > 0 && !noMoreData) {
  100. this.detailsList = [...this.detailsList, ...mockData];
  101. this.pagination.page++;
  102. this.loadStatus = 'more';
  103. } else {
  104. this.loadStatus = 'noMore';
  105. }
  106. this.isLoading = false;
  107. },
  108. // 滚动到底部加载更多
  109. loadMore() {
  110. this.fetchDetails();
  111. }
  112. }
  113. }
  114. </script>
  115. <style lang="scss" scoped>
  116. .page-container {
  117. display: flex;
  118. flex-direction: column;
  119. height: 100vh;
  120. background-color: #f5f6fa;
  121. }
  122. .info-card {
  123. background-color: #ffffff;
  124. border-radius: 16rpx;
  125. margin: 20rpx;
  126. padding: 20rpx 30rpx;
  127. box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.05);
  128. }
  129. .info-row {
  130. display: flex;
  131. justify-content: space-between;
  132. align-items: center;
  133. font-size: 28rpx;
  134. padding: 15rpx 0;
  135. .info-label { color: #666; }
  136. .info-value { color: #333; }
  137. }
  138. .summary-card {
  139. display: flex;
  140. justify-content: space-around;
  141. background: linear-gradient(to right, #6ca1ff, #3c82f8);
  142. border-radius: 16rpx;
  143. margin: 0 20rpx 20rpx;
  144. padding: 20rpx 10rpx;
  145. color: #ffffff;
  146. }
  147. .summary-tab {
  148. display: flex;
  149. flex-direction: column;
  150. align-items: center;
  151. padding: 10rpx;
  152. .tab-category {
  153. font-size: 26rpx;
  154. opacity: 0.9;
  155. }
  156. .tab-count {
  157. font-size: 28rpx;
  158. font-weight: bold;
  159. margin-top: 10rpx;
  160. }
  161. }
  162. .details-list {
  163. flex: 1;
  164. height: 100%;
  165. padding: 0 20rpx;
  166. }
  167. .empty-tip {
  168. text-align: center;
  169. color: #999;
  170. padding-top: 100rpx;
  171. }
  172. .detail-item-card {
  173. background-color: #ffffff;
  174. border-radius: 16rpx;
  175. padding: 30rpx;
  176. margin-bottom: 20rpx;
  177. box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.05);
  178. .item-name {
  179. display: block;
  180. font-size: 30rpx;
  181. font-weight: bold;
  182. color: #333;
  183. }
  184. .item-code {
  185. display: block;
  186. font-size: 26rpx;
  187. color: #999;
  188. margin-top: 15rpx;
  189. }
  190. }
  191. </style>