爱简收旧衣按件回收前端代码仓库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

193 lines
4.6 KiB

1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
  1. <template>
  2. <view class="profit-detail-container">
  3. <!-- 顶部导航栏 -->
  4. <view class="nav-bar">
  5. <view class="back" @tap="goBack">
  6. <uni-icons type="left" size="20"></uni-icons>
  7. </view>
  8. <text class="title">收益明细</text>
  9. </view>
  10. <view class="main-content">
  11. <view class="profit-list-card">
  12. <view class="profit-item" v-for="(item, idx) in profits" :key="idx">
  13. <image class="avatar" :src="item.avatar" mode="aspectFill" />
  14. <view class="profit-info">
  15. <view class="profit-name-date">
  16. <view class="profit-name">{{ item.name }}</view>
  17. <view class="profit-date">{{ item.date }}</view>
  18. </view>
  19. </view>
  20. <view class="profit-type">{{ item.type }}</view>
  21. <text class="profit-amount">+¥{{ item.amount }}</text>
  22. </view>
  23. <view v-if="isLoading" style="text-align:center;color:#bbb;padding:20rpx;">加载中...</view>
  24. <view v-else-if="!hasMore && profits.length > 0" style="text-align:center;color:#bbb;padding:20rpx;">没有更多了</view>
  25. </view>
  26. </view>
  27. </view>
  28. </template>
  29. <script>
  30. export default {
  31. data() {
  32. return {
  33. profits: [],
  34. pageNo: 1,
  35. pageSize: 10,
  36. hasMore: true,
  37. isLoading: false
  38. }
  39. },
  40. onLoad() {
  41. this.pageNo = 1;
  42. this.hasMore = true;
  43. this.fetchProfits();
  44. },
  45. onReachBottom() {
  46. if (this.hasMore && !this.isLoading) {
  47. this.fetchProfits(true);
  48. }
  49. },
  50. methods: {
  51. goBack() {
  52. uni.navigateBack();
  53. },
  54. fetchProfits(isLoadMore = false) {
  55. if (this.isLoading || (!this.hasMore && isLoadMore)) return;
  56. this.isLoading = true;
  57. const token = uni.getStorageSync('token') || '';
  58. this.$api && this.$api('income', {
  59. key: token,
  60. pageNo: this.pageNo,
  61. pageSize: this.pageSize
  62. }, res => {
  63. this.isLoading = false;
  64. if (res.code === 200 && res.result && res.result.records) {
  65. const newList = res.result.records.map(item => ({
  66. avatar: item.formUser?.headImage || '',
  67. name: item.formUser?.name || '',
  68. date: (item.createTime || '').slice(5, 10),
  69. type: item.title,
  70. amount: item.formUser.price
  71. }));
  72. if (isLoadMore) {
  73. this.profits = this.profits.concat(newList);
  74. } else {
  75. this.profits = newList;
  76. }
  77. // 分页判断
  78. this.hasMore = (res.result.current * res.result.size) < res.result.total;
  79. if (this.hasMore) {
  80. this.pageNo = res.result.current + 1;
  81. }
  82. }
  83. });
  84. }
  85. }
  86. }
  87. </script>
  88. <style lang="scss" scoped>
  89. .profit-detail-container {
  90. min-height: 100vh;
  91. background: #f7f7f7;
  92. }
  93. .nav-bar {
  94. display: flex;
  95. align-items: center;
  96. height: calc(150rpx + var(--status-bar-height));
  97. padding: 0 32rpx;
  98. padding-top: var(--status-bar-height);
  99. background: #fff;
  100. position: fixed;
  101. top: 0;
  102. left: 0;
  103. right: 0;
  104. z-index: 999;
  105. box-sizing: border-box;
  106. box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.03);
  107. .back {
  108. padding: 20rpx;
  109. margin-left: -20rpx;
  110. }
  111. .title {
  112. flex: 1;
  113. text-align: center;
  114. font-size: 34rpx;
  115. font-weight: 500;
  116. color: #222;
  117. }
  118. }
  119. .main-content {
  120. margin-top: calc(150rpx + var(--status-bar-height));
  121. margin-bottom: 40rpx;
  122. min-height: 100vh;
  123. overflow-y: auto;
  124. width: 100vw;
  125. box-sizing: border-box;
  126. }
  127. .profit-list-card {
  128. background: #fff;
  129. border-radius: 40rpx;
  130. margin: 0 32rpx 32rpx 32rpx;
  131. padding: 0 0 0 0;
  132. box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.03);
  133. }
  134. .profit-item {
  135. display: flex;
  136. align-items: center;
  137. justify-content: flex-start;
  138. padding: 28rpx 36rpx 28rpx 36rpx;
  139. border-bottom: 2rpx solid #f3f3f3;
  140. &:last-child {
  141. border-bottom: none;
  142. }
  143. }
  144. .avatar {
  145. width: 60rpx;
  146. height: 60rpx;
  147. border-radius: 50%;
  148. margin-right: 24rpx;
  149. object-fit: cover;
  150. background: #f5f5f5;
  151. }
  152. .profit-info {
  153. display: flex;
  154. flex-direction: column;
  155. justify-content: center;
  156. min-width: 120rpx;
  157. }
  158. .profit-name-date {
  159. display: flex;
  160. flex-direction: column;
  161. }
  162. .profit-name {
  163. font-size: 28rpx;
  164. color: #222;
  165. font-weight: 500;
  166. }
  167. .profit-date {
  168. font-size: 22rpx;
  169. color: #b3b3b3;
  170. font-weight: 400;
  171. margin-top: 2rpx;
  172. }
  173. .profit-type {
  174. flex: 1;
  175. text-align: center;
  176. font-family: PingFang SC;
  177. font-weight: 400;
  178. font-size: 14px;
  179. line-height: 100%;
  180. letter-spacing: 0%;
  181. color: #4c4c4c;
  182. font-weight: 400;
  183. }
  184. .profit-amount {
  185. font-size: 28rpx;
  186. color: #ff8917;
  187. font-weight: 500;
  188. margin-left: 12rpx;
  189. min-width: 80rpx;
  190. text-align: right;
  191. }
  192. </style>