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

262 lines
6.2 KiB

6 days ago
  1. <template>
  2. <view class="team-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. <!-- tab栏 -->
  12. <view class="team-tabs">
  13. <view :class="['tab', tabActive===0 ? 'active' : '']" @tap="tabActive=0">一级团队</view>
  14. <view :class="['tab', tabActive===1 ? 'active' : '']" @tap="tabActive=1">二级团队</view>
  15. </view>
  16. <!-- 统计 -->
  17. <view class="team-summary">
  18. 共邀请 <text class="highlight">{{ teamList.length }}</text>
  19. <text class="highlight">{{ orderedCount }}</text>人已下单
  20. <text class="highlight">{{ notOrderedCount }}</text>人未下单
  21. </view>
  22. <!-- 团队列表 -->
  23. <view class="team-list-card">
  24. <view class="team-item" v-for="(item, idx) in teamList" :key="idx">
  25. <image class="avatar" :src="item.avatar" mode="aspectFill" />
  26. <view class="team-info">
  27. <view class="team-name">{{ item.name }}</view>
  28. <view class="team-join">已加入平台{{ item.days }}</view>
  29. </view>
  30. <view class="team-order">
  31. <view class="order-count">{{ item.orders }}</view>
  32. <view class="order-label">下单量</view>
  33. </view>
  34. <view class="team-amount">
  35. <view class="amount">¥{{ item.amount }}</view>
  36. <view class="amount-label">佣金</view>
  37. </view>
  38. </view>
  39. </view>
  40. </view>
  41. </view>
  42. </template>
  43. <script>
  44. export default {
  45. data() {
  46. return {
  47. tabActive: 0,
  48. teamList: [],
  49. teamList1: [], // 一级团队
  50. teamList2: [] // 二级团队
  51. }
  52. },
  53. computed: {
  54. orderedCount() {
  55. return this.teamList.filter(item => item.orders > 0).length;
  56. },
  57. notOrderedCount() {
  58. return this.teamList.filter(item => item.orders == 0).length;
  59. }
  60. },
  61. watch: {
  62. tabActive(val) {
  63. this.teamList = val === 0 ? this.teamList1 : this.teamList2;
  64. }
  65. },
  66. mounted() {
  67. this.fetchTeamList(0); // 一级
  68. this.fetchTeamList(1); // 二级
  69. },
  70. methods: {
  71. goBack() {
  72. uni.navigateBack();
  73. },
  74. fetchTeamList(state) {
  75. this.$api('getHanHaiMemberUser', { state }, res => {
  76. if (res && res.code === 200 && res.result && Array.isArray(res.result.records)) {
  77. const list = res.result.records.map(item => {
  78. // 计算加入天数
  79. let days = 0;
  80. if (item.createTime) {
  81. const joinDate = new Date(item.createTime.replace(/-/g, '/'));
  82. const now = new Date();
  83. days = Math.floor((now - joinDate) / (1000 * 60 * 60 * 24));
  84. }
  85. return {
  86. avatar: item.headImage,
  87. name: item.nickName,
  88. days,
  89. orders: item.orderNum,
  90. amount: item.commission
  91. }
  92. });
  93. if (state === 0) {
  94. this.teamList1 = list;
  95. if (this.tabActive === 0) this.teamList = list;
  96. } else {
  97. this.teamList2 = list;
  98. if (this.tabActive === 1) this.teamList = list;
  99. }
  100. }
  101. })
  102. }
  103. }
  104. }
  105. </script>
  106. <style lang="scss" scoped>
  107. .team-container {
  108. min-height: 100vh;
  109. background: #f7f7f7;
  110. }
  111. .nav-bar {
  112. display: flex;
  113. align-items: center;
  114. height: calc(150rpx + var(--status-bar-height));
  115. padding: 0 32rpx;
  116. padding-top: var(--status-bar-height);
  117. background: #fff;
  118. position: fixed;
  119. top: 0;
  120. left: 0;
  121. right: 0;
  122. z-index: 999;
  123. box-sizing: border-box;
  124. box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.03);
  125. .back {
  126. padding: 20rpx;
  127. margin-left: -20rpx;
  128. }
  129. .title {
  130. flex: 1;
  131. text-align: center;
  132. font-size: 34rpx;
  133. font-weight: 500;
  134. color: #222;
  135. }
  136. }
  137. .main-content {
  138. margin-top: calc(150rpx + var(--status-bar-height));
  139. margin-bottom: 40rpx;
  140. }
  141. .team-tabs {
  142. display: flex;
  143. justify-content: center;
  144. align-items: center;
  145. background: #fff;
  146. border-radius: 40rpx 40rpx 0 0;
  147. margin: 0 32rpx;
  148. padding: 0 0 0 0;
  149. box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.03);
  150. .tab {
  151. flex: 1;
  152. text-align: center;
  153. font-size: 30rpx;
  154. color: #b3b3b3;
  155. font-weight: 500;
  156. padding: 32rpx 0 24rpx 0;
  157. border-bottom: 4rpx solid transparent;
  158. transition: color 0.2s, border-color 0.2s;
  159. &.active {
  160. color: #ff8917;
  161. border-bottom: 4rpx solid #ff8917;
  162. font-weight: 600;
  163. }
  164. }
  165. }
  166. .team-summary {
  167. background: #eeffe9;
  168. color: #4cbb4c;
  169. font-size: 26rpx;
  170. text-align: center;
  171. padding: 18rpx 0;
  172. margin: 0 32rpx 0 32rpx;
  173. border-radius: 0 0 20rpx 20rpx;
  174. font-family: PingFang SC;
  175. font-weight: 400;
  176. .highlight {
  177. color: #f79400;
  178. font-weight: 600;
  179. }
  180. }
  181. .team-list-card {
  182. background: #fff;
  183. border-radius: 40rpx;
  184. margin: 24rpx 32rpx 32rpx 32rpx;
  185. padding: 0 0 0 0;
  186. box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.03);
  187. }
  188. .team-item {
  189. display: flex;
  190. align-items: center;
  191. justify-content: flex-start;
  192. padding: 28rpx 36rpx 28rpx 36rpx;
  193. border-bottom: 2rpx solid #f3f3f3;
  194. &:last-child {
  195. border-bottom: none;
  196. }
  197. }
  198. .avatar {
  199. width: 60rpx;
  200. height: 60rpx;
  201. border-radius: 50%;
  202. margin-right: 24rpx;
  203. object-fit: cover;
  204. background: #f5f5f5;
  205. }
  206. .team-info {
  207. display: flex;
  208. flex-direction: column;
  209. justify-content: center;
  210. min-width: 120rpx;
  211. }
  212. .team-name {
  213. font-size: 28rpx;
  214. color: #222;
  215. font-weight: 500;
  216. }
  217. .team-join {
  218. font-size: 22rpx;
  219. color: #b3b3b3;
  220. font-weight: 400;
  221. margin-top: 2rpx;
  222. }
  223. .team-order {
  224. flex: 1;
  225. display: flex;
  226. flex-direction: column;
  227. align-items: center;
  228. min-width: 90rpx;
  229. margin-left: 12rpx;
  230. margin-right: 12rpx;
  231. .order-count {
  232. font-size: 26rpx;
  233. color: #222;
  234. font-weight: 500;
  235. }
  236. .order-label {
  237. font-size: 22rpx;
  238. color: #b3b3b3;
  239. font-weight: 400;
  240. margin-top: 2rpx;
  241. }
  242. }
  243. .team-amount {
  244. min-width: 80rpx;
  245. display: flex;
  246. flex-direction: column;
  247. align-items: flex-end;
  248. margin-left: 12rpx;
  249. .amount {
  250. font-size: 26rpx;
  251. color: #f79400;
  252. font-weight: 500;
  253. }
  254. .amount-label {
  255. font-size: 22rpx;
  256. color: #b3b3b3;
  257. font-weight: 400;
  258. margin-top: 2rpx;
  259. }
  260. }
  261. </style>