index.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. <template>
  2. <view class="container">
  3. <view class="record-list">
  4. <view
  5. v-for="(record, index) in records"
  6. :key="index"
  7. class="record-item"
  8. >
  9. <view class="icon-container">
  10. <image :src="record.merchantLogo" mode="aspectFit"></image>
  11. </view>
  12. <view class="info-container">
  13. <view class="shop-name">{{ record.merchantName }}</view>
  14. <view class="browse-time">浏览时间:{{ record.createTime }}</view>
  15. </view>
  16. <button class="action-btn">商城主页</button>
  17. </view>
  18. <view class="loadingicon acea-row row-center-wrapper" v-if="goodScroll">
  19. <text
  20. class="loading iconfont icon-jiazai"
  21. :hidden="loading == false"
  22. ></text>
  23. </view>
  24. <view class="no-data" v-if="isNoDataState">
  25. <image
  26. src="https://my-go-easy-im.oss-cn-shenzhen.aliyuncs.com/goeasy-im-%E6%B0%B4%E8%B4%9D%E5%95%86%E5%9F%8E/zhanwu_20250827104005_1720_6.png"
  27. />
  28. </view>
  29. <view class="mores-txt flex" v-if="!goodScroll && !isNoDataState">
  30. <text>我是有底线的</text>
  31. </view>
  32. </view>
  33. </view>
  34. </template>
  35. <script setup>
  36. import {computed, ref} from 'vue';
  37. import { onLoad, onShow, onReachBottom } from "@dcloudio/uni-app";
  38. import { footprintList } from "@/api/merchant.js";
  39. const records = ref([]);
  40. const loading = ref(false);
  41. const goodScroll = ref(true);
  42. // Pagination
  43. const params = ref({
  44. page: 1,
  45. limit: 10,
  46. });
  47. onLoad(() => {
  48. getList();
  49. });
  50. onReachBottom(() => {
  51. getList();
  52. });
  53. const isNoDataState = computed(() => {
  54. return records.value.length === 0 && !loading.value;
  55. });
  56. const getList = async () => {
  57. if (!goodScroll.value) return;
  58. try {
  59. loading.value = true;
  60. const { data } = await footprintList(params.value);
  61. console.log(data);
  62. records.value = [...records.value, ...data.records] || [];
  63. goodScroll.value = data.records.length >= params.value.limit;
  64. params.value.page++;
  65. } catch (err) {
  66. console.error(err);
  67. } finally {
  68. loading.value = false;
  69. }
  70. };
  71. </script>
  72. <style lang="scss" scoped>
  73. .container {
  74. padding: 20rpx;
  75. box-sizing: border-box;
  76. }
  77. .record-list {
  78. display: flex;
  79. flex-direction: column;
  80. gap: 15px;
  81. }
  82. .record-item {
  83. background-color: #fff;
  84. border-radius: 24rpx;
  85. padding: 20rpx;
  86. display: flex;
  87. align-items: center;
  88. }
  89. .icon-container {
  90. width: 100rpx;
  91. height: 100rpx;
  92. border-radius: 16rpx;
  93. margin-right: 20rpx;
  94. display: flex;
  95. align-items: center;
  96. justify-content: center;
  97. overflow: hidden;
  98. }
  99. .info-container {
  100. flex: 1;
  101. }
  102. .shop-name {
  103. font-size: 32rpx;
  104. font-weight: 500;
  105. margin-bottom: 10rpx;
  106. color: #333;
  107. }
  108. .browse-time {
  109. font-size: 24rpx;
  110. color: #666666;
  111. }
  112. .action-btn {
  113. background-color: rgba(248, 192, 8, 0.10);
  114. color: #F8C008;
  115. border: none;
  116. border-radius: 16rpx;
  117. padding: 12rpx 24rpx;
  118. font-size: 24rpx;
  119. cursor: pointer;
  120. transition: background-color 0.2s;
  121. }
  122. .footer {
  123. text-align: center;
  124. margin-top: 20px;
  125. color: #999;
  126. font-size: 13px;
  127. }
  128. .no-data {
  129. margin: 150rpx auto 0;
  130. text-align: center;
  131. img {
  132. width: 65%;
  133. height: auto;
  134. }
  135. }
  136. .mores-txt {
  137. width: 100%;
  138. align-items: center;
  139. justify-content: center;
  140. height: 70rpx;
  141. color: #999;
  142. font-size: 24rpx;
  143. }
  144. </style>