文件
Henglianshutong/uniapp/pages/commission/team.vue

314 行
8.7 KiB
Vue

此文件含有模棱两可的 Unicode 字符

此文件含有可能会与其他字符混淆的 Unicode 字符。 如果您是想特意这样的,可以安全地忽略该警告。 使用 Escape 按钮显示他们。

<!-- 页面 -->
<template>
<s-layout title="我的团队" :class="state.scrollTop ? 'team-wrap' : ''" navbar="inner">
<view
class="header-box"
:style="[
{
marginTop: '-' + Number(statusBarHeight + 88) + 'rpx',
paddingTop: Number(statusBarHeight + 108) + 'rpx',
},
]"
>
<!-- 推荐人 -->
<view v-if="userInfo.parent_user" class="referrer-box ss-flex ss-col-center">
推荐人:
<image
class="referrer-avatar ss-m-r-10"
:src="sheep.$url.cdn(userInfo.parent_user.avatar)"
mode="aspectFill"
>
</image>
{{ userInfo.parent_user.nickname }}
</view>
<!-- 团队数据总览 -->
<view class="team-data-box ss-flex ss-col-center ss-row-between">
<view class="data-card">
<view class="total-item">
<view class="item-title">团队总人数(人)</view>
<view class="total-num">{{ headerNum('child_user_count_all') }}</view>
</view>
<view class="category-item ss-flex">
<view class="ss-flex-1">
<view class="item-title">一级成员</view>
<view class="category-num">{{ headerNum('child_user_count_1') }}</view>
</view>
<view class="ss-flex-1">
<view class="item-title">二级成员</view>
<view class="category-num">{{ headerNum('child_user_count_2') }}</view>
</view>
</view>
</view>
<view class="data-card">
<view class="total-item">
<view class="item-title">团队合伙股东人数(人)</view>
<view class="total-num">{{ headerNum('child_agent_count_all') }}</view>
</view>
<view class="category-item ss-flex">
<view class="ss-flex-1">
<view class="item-title">一级成员</view>
<view class="category-num">{{ headerNum('child_agent_count_1') }}</view>
</view>
<view class="ss-flex-1">
<view class="item-title">二级成员</view>
<view class="category-num">{{ headerNum('child_agent_count_2') }}</view>
</view>
</view>
</view>
</view>
</view>
<view class="list-box">
<uni-list :border="false">
<uni-list-chat
v-for="item in state.pagination.data"
:key="item.id"
:avatar-circle="true"
:title="item.nickname"
:avatar="sheep.$url.cdn(item.avatar)"
:note="filterUserNum(item.agent?.child_user_count_1)"
>
<view class="chat-custom-right">
<view class="ss-flex ss-col-center ss-row-right tag-row">
<view v-if="memberLevelName(item)" class="tag-box ss-flex ss-col-center">
<image
v-if="item.agent?.level_info?.image"
class="tag-img"
:src="sheep.$url.cdn(item.agent.level_info.image)"
mode="aspectFill"
>
</image>
<text class="tag-title">{{ memberLevelName(item) }}</text>
</view>
<view v-if="item.agent?.is_venue || item.agent?.identities?.includes('venue')" class="mini-tag">馆</view>
<view v-if="item.agent?.is_county || item.agent?.identities?.includes('county')" class="mini-tag">县</view>
</view>
<text class="time-text">{{ item.createtime }}</text>
</view>
</uni-list-chat>
</uni-list>
</view>
<s-empty v-if="state.pagination.total === 0" icon="/static/data-empty.png" text="暂无团队信息">
</s-empty>
</s-layout>
</template>
<script setup>
import sheep from '@/sheep';
import { onLoad, onShow, onReachBottom, onPullDownRefresh, onPageScroll } from '@dcloudio/uni-app';
import { computed, reactive } from 'vue';
import _ from 'lodash';
const statusBarHeight = sheep.$platform.device.statusBarHeight * 2;
const agentInfo = computed(() => sheep.$store('user').agentInfo);
const userInfo = computed(() => sheep.$store('user').userInfo);
const headerBg = sheep.$url.css('/assets/addons/shopro/uniapp/user/withdraw_bg.png');
onPageScroll((e) => {
if (e.scrollTop > 100) {
state.scrollTop = false;
} else {
state.scrollTop = true;
}
});
const state = reactive({
pagination: {
data: [],
current_page: 1,
total: 0,
last_page: 1,
},
loadStatus: '',
});
function headerNum(field) {
const stored = Number(agentInfo.value?.[field] || 0);
if (stored > 0) {
return stored;
}
const listTotal = Number(state.pagination.total || 0);
if (
listTotal > 0 &&
['child_user_count_1', 'child_user_count_all', 'child_agent_count_1', 'child_agent_count_all'].includes(field)
) {
return listTotal;
}
return 0;
}
function memberLevelName(item) {
return (
item?.agent?.level_info?.name ||
item?.agent?.maker_level_name ||
item?.agent?.identity_text ||
''
);
}
function filterUserNum(num) {
if (_.isNil(num)) {
return '直推 0 人';
}
return `直推 ${num} 人`;
}
async function getTeamList(page = 1, list_rows = 16) {
state.loadStatus = 'loading';
let res = await sheep.$api.commission.team({
list_rows,
page,
});
if (res.code === 1) {
const rows = res.data?.data || [];
state.pagination = {
...res.data,
data: page === 1 ? rows : _.concat(state.pagination.data, rows),
};
if (state.pagination.current_page < state.pagination.last_page) {
state.loadStatus = 'more';
} else {
state.loadStatus = 'noMore';
}
}
}
async function refreshHeader() {
await Promise.all([sheep.$store('user').getAgentInfo(), sheep.$store('user').getInfo()]);
}
async function refreshPage() {
await Promise.all([refreshHeader(), getTeamList(1)]);
}
onLoad(() => {
refreshPage();
});
onShow(() => {
refreshHeader();
});
onPullDownRefresh(async () => {
await refreshPage();
uni.stopPullDownRefresh();
});
onReachBottom(() => {
if (state.loadStatus !== 'noMore') {
getTeamList(state.pagination.current_page + 1);
}
});
</script>
<style lang="scss" scoped>
.header-box {
box-sizing: border-box;
padding: 0 20rpx 20rpx 20rpx;
width: 750rpx;
z-index: 3;
position: relative;
background: v-bind(headerBg) no-repeat,
linear-gradient(90deg, var(--ui-BG-Main), var(--ui-BG-Main-gradient));
background-size: 750rpx 100%;
// 团队信息总览
.team-data-box {
.data-card {
width: 305rpx;
background: #ffffff;
border-radius: 20rpx;
padding: 20rpx;
.item-title {
font-size: 22rpx;
font-weight: 500;
color: #999999;
line-height: 30rpx;
margin-bottom: 10rpx;
}
.total-item {
margin-bottom: 30rpx;
}
.total-num {
font-size: 38rpx;
font-weight: 500;
color: #333333;
font-family: OPPOSANS;
}
.category-num {
font-size: 26rpx;
font-weight: 500;
color: #333333;
font-family: OPPOSANS;
}
}
}
}
.list-box {
z-index: 3;
position: relative;
}
.chat-custom-right {
.time-text {
font-size: 22rpx;
font-weight: 400;
color: #999999;
}
.tag-row {
justify-content: flex-end;
margin-bottom: 6rpx;
}
.mini-tag {
margin-left: 8rpx;
padding: 0 10rpx;
height: 32rpx;
line-height: 32rpx;
border-radius: 16rpx;
background: #c48a3a;
font-size: 18rpx;
color: #ffffff;
}
.tag-box {
background: rgba(0, 0, 0, 0.2);
border-radius: 21rpx;
line-height: 30rpx;
padding: 5rpx 10rpx;
min-width: 120rpx;
width: auto;
.tag-img {
width: 34rpx;
height: 34rpx;
margin-right: 6rpx;
border-radius: 50%;
}
.tag-title {
font-size: 18rpx;
font-weight: 500;
color: rgba(255, 255, 255, 1);
line-height: 20rpx;
}
}
}
// 推荐人
.referrer-box {
font-size: 28rpx;
font-weight: 500;
color: #ffffff;
padding: 20rpx;
.referrer-avatar {
width: 34rpx;
height: 34rpx;
border-radius: 50%;
}
}
</style>