commission-log.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. <!-- 分销明细 -->
  2. <template>
  3. <view class="distribution-log-wrap">
  4. <view class="header-box">
  5. <image class="header-bg" :src="sheep.$url.static('/static/img/shop/commission/title2.png')" />
  6. <view class="ss-flex header-title">
  7. <view class="title">实时动态</view>
  8. <text class="cicon-forward"></text>
  9. </view>
  10. </view>
  11. <scroll-view
  12. scroll-y="true"
  13. @scrolltolower="loadmore"
  14. class="scroll-box log-scroll"
  15. scroll-with-animation="true"
  16. >
  17. <view v-if="state.pagination.data">
  18. <view
  19. class="log-item-box ss-flex ss-row-between"
  20. v-for="item in state.pagination.data"
  21. :key="item.id"
  22. >
  23. <view class="log-item-wrap">
  24. <view class="log-item ss-flex ss-ellipsis-1 ss-col-center">
  25. <view class="ss-flex ss-col-center">
  26. <image
  27. v-if="item.oper_type === 'user'"
  28. class="log-img"
  29. :src="sheep.$url.cdn(item.oper?.avatar)"
  30. mode="aspectFill"
  31. ></image>
  32. <image
  33. v-else-if="item.oper_type === 'admin'"
  34. class="log-img"
  35. :src="sheep.$url.static('/static/img/shop/avatar/default_user.png')"
  36. mode="aspectFill"
  37. ></image>
  38. <image
  39. v-else
  40. class="log-img"
  41. :src="sheep.$url.static('/static/img/shop/avatar/notice.png')"
  42. mode="aspectFill"
  43. ></image>
  44. </view>
  45. <view class="log-text ss-ellipsis-1">{{ item.remark }}</view>
  46. </view>
  47. </view>
  48. <text class="log-time">{{ dayjs(item.create_time).fromNow() }}</text>
  49. </view>
  50. </view>
  51. <!-- 加载更多 -->
  52. <uni-load-more
  53. v-if="state.pagination.total > 0"
  54. :status="state.loadStatus"
  55. color="#333333"
  56. @tap="loadmore"
  57. />
  58. </scroll-view>
  59. </view>
  60. </template>
  61. <script setup>
  62. import sheep from '@/sheep';
  63. import { computed, reactive } from 'vue';
  64. import _ from 'lodash';
  65. import dayjs from 'dayjs';
  66. const state = reactive({
  67. loadStatus: '',
  68. pagination: {
  69. data: [],
  70. current_page: 1,
  71. total: 1,
  72. last_page: 1,
  73. },
  74. });
  75. async function getLog(page = 1) {
  76. const res = await sheep.$api.commission.log({
  77. page,
  78. });
  79. if (res.error === 0) {
  80. let list = _.concat(state.pagination.data, res.data.data);
  81. state.pagination = {
  82. ...res.data,
  83. data: list,
  84. };
  85. if (state.pagination.current_page < state.pagination.last_page) {
  86. state.loadStatus = 'more';
  87. } else {
  88. state.loadStatus = 'noMore';
  89. }
  90. }
  91. }
  92. getLog();
  93. // 加载更多
  94. function loadmore() {
  95. if (state.loadStatus !== 'noMore') {
  96. getLog(state.pagination.current_page + 1);
  97. }
  98. }
  99. </script>
  100. <style lang="scss" scoped>
  101. .distribution-log-wrap {
  102. width: 690rpx;
  103. margin: 0 auto;
  104. margin-bottom: 20rpx;
  105. border-radius: 12rpx;
  106. z-index: 3;
  107. position: relative;
  108. .header-box {
  109. width: 690rpx;
  110. height: 76rpx;
  111. position: relative;
  112. .header-bg {
  113. width: 690rpx;
  114. height: 76rpx;
  115. }
  116. .header-title {
  117. position: absolute;
  118. left: 20rpx;
  119. top: 24rpx;
  120. }
  121. .title {
  122. font-size: 28rpx;
  123. font-weight: 500;
  124. color: #ffffff;
  125. line-height: 30rpx;
  126. }
  127. .cicon-forward {
  128. font-size: 30rpx;
  129. font-weight: 400;
  130. color: #ffffff;
  131. line-height: 30rpx;
  132. }
  133. }
  134. .log-scroll {
  135. height: 600rpx;
  136. background: #fdfae9;
  137. padding: 10rpx 20rpx 0;
  138. box-sizing: border-box;
  139. border-radius: 0 0 12rpx 12rpx;
  140. .log-item-box {
  141. margin-bottom: 20rpx;
  142. .log-time {
  143. // margin-left: 30rpx;
  144. text-align: right;
  145. font-size: 24rpx;
  146. font-family: OPPOSANS;
  147. font-weight: 400;
  148. color: #c4c4c4;
  149. }
  150. }
  151. .loadmore-wrap {
  152. // line-height: 80rpx;
  153. }
  154. .log-item {
  155. // background: rgba(#ffffff, 0.2);
  156. border-radius: 24rpx;
  157. padding: 6rpx 20rpx 6rpx 12rpx;
  158. .log-img {
  159. width: 40rpx;
  160. height: 40rpx;
  161. border-radius: 50%;
  162. margin-right: 10rpx;
  163. }
  164. .log-text {
  165. max-width: 480rpx;
  166. font-size: 24rpx;
  167. font-weight: 500;
  168. color: #333333;
  169. }
  170. }
  171. }
  172. }
  173. </style>