index.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  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" @click="toMerchant(record)">商城主页</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. const toMerchant = (obj) => {
  72. uni.navigateTo({ url:"/pages/merchant/index?merchantId="+obj.merchantId });
  73. }
  74. </script>
  75. <style lang="scss" scoped>
  76. .container {
  77. padding: 20rpx;
  78. box-sizing: border-box;
  79. }
  80. .record-list {
  81. display: flex;
  82. flex-direction: column;
  83. gap: 15px;
  84. }
  85. .record-item {
  86. background-color: #fff;
  87. border-radius: 24rpx;
  88. padding: 20rpx;
  89. display: flex;
  90. align-items: center;
  91. }
  92. .icon-container {
  93. width: 100rpx;
  94. height: 100rpx;
  95. border-radius: 16rpx;
  96. margin-right: 20rpx;
  97. display: flex;
  98. align-items: center;
  99. justify-content: center;
  100. overflow: hidden;
  101. }
  102. .info-container {
  103. flex: 1;
  104. }
  105. .shop-name {
  106. font-size: 32rpx;
  107. font-weight: 500;
  108. margin-bottom: 10rpx;
  109. color: #333;
  110. }
  111. .browse-time {
  112. font-size: 24rpx;
  113. color: #666666;
  114. }
  115. .action-btn {
  116. background-color: rgba(248, 192, 8, 0.10);
  117. color: #F8C008;
  118. border: none;
  119. border-radius: 16rpx;
  120. padding: 12rpx 24rpx;
  121. font-size: 24rpx;
  122. cursor: pointer;
  123. transition: background-color 0.2s;
  124. }
  125. .footer {
  126. text-align: center;
  127. margin-top: 20px;
  128. color: #999;
  129. font-size: 13px;
  130. }
  131. .no-data {
  132. margin: 150rpx auto 0;
  133. text-align: center;
  134. img {
  135. width: 65%;
  136. height: auto;
  137. }
  138. }
  139. .mores-txt {
  140. width: 100%;
  141. align-items: center;
  142. justify-content: center;
  143. height: 70rpx;
  144. color: #999;
  145. font-size: 24rpx;
  146. }
  147. </style>