index.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  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>
  10. <image class="icon-container" :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 class="img"
  26. :src="HTTP_REQUEST_URL_IMG+'noData.png'"
  27. mode="widthFix"
  28. />
  29. </view>
  30. <view class="mores-txt flex" v-if="!goodScroll && !isNoDataState">
  31. <text>我是有底线的</text>
  32. </view>
  33. </view>
  34. </view>
  35. </template>
  36. <script setup>
  37. import {computed, ref} from 'vue';
  38. import { onLoad, onShow, onReachBottom } from "@dcloudio/uni-app";
  39. import { footprintList } from "@/api/merchant.js";
  40. import { HTTP_REQUEST_URL_IMG } from "@/config/app";
  41. const records = ref([]);
  42. const loading = ref(false);
  43. const goodScroll = ref(true);
  44. // Pagination
  45. const params = ref({
  46. page: 1,
  47. limit: 10,
  48. });
  49. onLoad(() => {
  50. getList();
  51. });
  52. onReachBottom(() => {
  53. getList();
  54. });
  55. const isNoDataState = computed(() => {
  56. return records.value.length === 0 && !loading.value;
  57. });
  58. const getList = async () => {
  59. if (!goodScroll.value) return;
  60. try {
  61. loading.value = true;
  62. const { data } = await footprintList(params.value);
  63. console.log(data);
  64. records.value = [...records.value, ...data.records] || [];
  65. goodScroll.value = data.records.length >= params.value.limit;
  66. params.value.page++;
  67. } catch (err) {
  68. console.error(err);
  69. } finally {
  70. loading.value = false;
  71. }
  72. };
  73. const toMerchant = (obj) => {
  74. uni.navigateTo({ url:"/pages/merchantCenters/merchant?merchantId="+obj.merchantId });
  75. }
  76. </script>
  77. <style lang="scss" scoped>
  78. .container {
  79. padding: 20rpx;
  80. box-sizing: border-box;
  81. }
  82. .record-list {
  83. display: flex;
  84. flex-direction: column;
  85. gap: 15px;
  86. }
  87. .record-item {
  88. background-color: #fff;
  89. border-radius: 24rpx;
  90. padding: 20rpx;
  91. display: flex;
  92. align-items: center;
  93. }
  94. .icon-container {
  95. width: 100rpx;
  96. height: 100rpx;
  97. border-radius: 16rpx;
  98. margin-right: 20rpx;
  99. display: flex;
  100. align-items: center;
  101. justify-content: center;
  102. overflow: hidden;
  103. }
  104. .info-container {
  105. flex: 1;
  106. }
  107. .shop-name {
  108. font-size: 32rpx;
  109. font-weight: 500;
  110. margin-bottom: 10rpx;
  111. color: #333;
  112. }
  113. .browse-time {
  114. font-size: 24rpx;
  115. color: #666666;
  116. }
  117. .action-btn {
  118. background-color: rgba(248, 192, 8, 0.10);
  119. color: #F8C008;
  120. border: none;
  121. border-radius: 16rpx;
  122. padding: 12rpx 24rpx;
  123. font-size: 24rpx;
  124. cursor: pointer;
  125. transition: background-color 0.2s;
  126. }
  127. .footer {
  128. text-align: center;
  129. margin-top: 20px;
  130. color: #999;
  131. font-size: 13px;
  132. }
  133. .no-data {
  134. margin: 150rpx auto 0;
  135. text-align: center;
  136. width: 100%;
  137. height: 100%;
  138. min-height: 300rpx;
  139. .img {
  140. width: 65%;
  141. height: auto;
  142. }
  143. }
  144. .mores-txt {
  145. width: 100%;
  146. align-items: center;
  147. justify-content: center;
  148. height: 70rpx;
  149. color: #999;
  150. font-size: 24rpx;
  151. }
  152. </style>