爱简收旧衣按件回收前端代码仓库
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.

230 lines
4.9 KiB

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