add_goods_detail.vue 4.9 KB

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