add_goods_detail.vue 5.2 KB

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