share-log.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. <!-- 分销记录 -->
  2. <template>
  3. <s-layout title="分享记录">
  4. <view class="distraction-share-wrap">
  5. <view class="share-log-box">
  6. <!-- 分享记录列表 -->
  7. <view class="log-list ss-flex" v-for="item in state.pagination.data" :key="item.id">
  8. <view class="log-avatar-wrap">
  9. <image
  10. class="log-avatar"
  11. :src="sheep.$url.cdn(item.user?.avatar)"
  12. mode="aspectFill"
  13. ></image>
  14. </view>
  15. <view class="item-right">
  16. <view class="name">{{ item.user?.nickname }}</view>
  17. <view class="content ss-flex">
  18. <view v-if="item.ext?.image" class="content-img-wrap">
  19. <image class="content-img" :src="sheep.$url.cdn(item.ext?.image)" mode="aspectFill">
  20. </image>
  21. </view>
  22. <view v-if="item.ext?.memo" class="content-text">
  23. {{ item.ext?.memo }}
  24. </view>
  25. </view>
  26. <view class="item-bottom ss-flex ss-row-between">
  27. <view class="from-text"></view>
  28. <view class="time">{{ dayjs(item.create_time).fromNow() }}</view>
  29. </view>
  30. </view>
  31. </view>
  32. <s-empty
  33. v-if="state.pagination.total === 0"
  34. icon="/static/data-empty.png"
  35. text="暂无分享记录"
  36. >
  37. </s-empty>
  38. <!-- 加载更多 -->
  39. <uni-load-more
  40. v-if="state.pagination.total > 0"
  41. :status="state.loadStatus"
  42. :content-text="{
  43. contentdown: '上拉加载更多',
  44. }"
  45. @tap="loadmore"
  46. />
  47. </view>
  48. </view>
  49. </s-layout>
  50. </template>
  51. <script setup>
  52. import sheep from '@/sheep';
  53. import { onLoad } from '@dcloudio/uni-app';
  54. import { computed, reactive } from 'vue';
  55. import _ from 'lodash';
  56. import dayjs from 'dayjs';
  57. const state = reactive({
  58. pagination: {
  59. data: [],
  60. current_page: 1,
  61. total: 1,
  62. last_page: 1,
  63. },
  64. loadStatus: '',
  65. });
  66. async function getShareLog(page = 1, list_rows = 8) {
  67. state.loadStatus = 'loading';
  68. let res = await sheep.$api.user.share.list({
  69. list_rows,
  70. page,
  71. });
  72. if (res.error === 0) {
  73. let orderList = _.concat(state.pagination.data, res.data.data);
  74. state.pagination = {
  75. ...res.data,
  76. data: orderList,
  77. };
  78. if (state.pagination.current_page < state.pagination.last_page) {
  79. state.loadStatus = 'more';
  80. } else {
  81. state.loadStatus = 'noMore';
  82. }
  83. }
  84. }
  85. // 加载更多
  86. function loadmore() {
  87. if (state.loadStatus !== 'noMore') {
  88. getShareLog(state.pagination.current_page + 1);
  89. }
  90. }
  91. onLoad(async () => {
  92. getShareLog();
  93. });
  94. </script>
  95. <style lang="scss" scoped>
  96. .share-log-box {
  97. // 分享记录列表
  98. .log-list {
  99. background-color: #fff;
  100. padding: 30rpx;
  101. margin: 10rpx 0;
  102. align-items: flex-start;
  103. .log-avatar-wrap {
  104. margin-right: 14rpx;
  105. .log-avatar {
  106. width: 40rpx;
  107. height: 40rpx;
  108. border-radius: 50%;
  109. }
  110. }
  111. .item-right {
  112. flex: 1;
  113. .name {
  114. font-size: 26rpx;
  115. font-weight: 500;
  116. color: #7f7aa5;
  117. margin-bottom: 30rpx;
  118. }
  119. .content {
  120. background: rgba(241, 241, 241, 0.46);
  121. border-radius: 2rpx;
  122. padding: 10rpx;
  123. margin-bottom: 20rpx;
  124. .content-img-wrap {
  125. margin-right: 16rpx;
  126. width: 80rpx;
  127. height: 80rpx;
  128. .content-img {
  129. width: 80rpx;
  130. height: 80rpx;
  131. border-radius: 6rpx;
  132. }
  133. }
  134. .content-text {
  135. font-size: 24rpx;
  136. font-weight: 500;
  137. color: #333333;
  138. }
  139. }
  140. .item-bottom {
  141. width: 100%;
  142. .time {
  143. font-size: 22rpx;
  144. font-weight: 500;
  145. color: #c8c8c8;
  146. }
  147. .from-text {
  148. font-size: 22rpx;
  149. font-weight: 500;
  150. color: #c8c8c8;
  151. }
  152. }
  153. }
  154. }
  155. }
  156. </style>