498 lines
13 KiB
Vue
498 lines
13 KiB
Vue
<template>
|
||
<view class="container">
|
||
<!-- 分销员信息头部 -->
|
||
<view class="distributor-header">
|
||
<view class="distributor-avatar">
|
||
<text class="avatar-emoji">💼</text>
|
||
</view>
|
||
<view class="distributor-info">
|
||
<text class="distributor-name">{{ distributorInfo.name || '分销员' }}</text>
|
||
<text class="distributor-phone" v-if="distributorInfo.phone">{{ distributorInfo.phone }}</text>
|
||
<view class="distributor-level">
|
||
<text class="level-tag">{{ distributorInfo.level || 'LV1' }} 分销员</text>
|
||
</view>
|
||
</view>
|
||
<view class="setting-btn" @click="goSetting">
|
||
<text>设置</text>
|
||
</view>
|
||
</view>
|
||
|
||
<!-- 收益统计 -->
|
||
<view class="earnings-section">
|
||
<view class="earnings-item" @click="goPage('/pages/distributor/commission')">
|
||
<text class="earnings-value">¥{{ stats.totalCommission }}</text>
|
||
<text class="earnings-label">累计佣金</text>
|
||
</view>
|
||
<view class="earnings-item" @click="goPage('/pages/distributor/commission?status=pending')">
|
||
<text class="earnings-value">¥{{ stats.pendingCommission }}</text>
|
||
<text class="earnings-label">待结算</text>
|
||
</view>
|
||
<view class="earnings-item" @click="goPage('/pages/distributor/withdraw')">
|
||
<text class="earnings-value">¥{{ stats.availableBalance }}</text>
|
||
<text class="earnings-label">可提现</text>
|
||
</view>
|
||
</view>
|
||
|
||
<!-- 快捷功能 -->
|
||
<view class="quick-actions">
|
||
<view class="action-item" @click="goPage('/distributor-package/pages/distributor/promotion-code')">
|
||
<text class="action-icon">🔗</text>
|
||
<text class="action-text">推广码</text>
|
||
</view>
|
||
<view class="action-item" @click="goPage('/distributor-package/pages/distributor/poster')">
|
||
<text class="action-icon">📱</text>
|
||
<text class="action-text">推广海报</text>
|
||
</view>
|
||
<view class="action-item" @click="goPage('/pages/distributor/course-list')">
|
||
<text class="action-icon">📚</text>
|
||
<text class="action-text">分销课程</text>
|
||
</view>
|
||
<view class="action-item" @click="goPage('/pages/distributor/withdraw')">
|
||
<text class="action-icon">💰</text>
|
||
<text class="action-text">提现</text>
|
||
</view>
|
||
</view>
|
||
|
||
<!-- 业绩数据 -->
|
||
<view class="performance-section">
|
||
<view class="section-title">本月业绩</view>
|
||
<view class="performance-grid">
|
||
<view class="performance-item">
|
||
<text class="performance-value">{{ stats.monthOrders }}</text>
|
||
<text class="performance-label">成交订单</text>
|
||
</view>
|
||
<view class="performance-item">
|
||
<text class="performance-value">¥{{ stats.monthCommission }}</text>
|
||
<text class="performance-label">本月佣金</text>
|
||
</view>
|
||
<view class="performance-item">
|
||
<text class="performance-value">{{ stats.newCustomers }}</text>
|
||
<text class="performance-label">新增客户</text>
|
||
</view>
|
||
<view class="performance-item">
|
||
<text class="performance-value">{{ stats.teamMembers }}</text>
|
||
<text class="performance-label">团队人数</text>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
|
||
<!-- 功能菜单 -->
|
||
<view class="menu-section">
|
||
<view class="menu-item" @click="goPage('/pages/distributor/order-list')">
|
||
<text class="menu-icon">📊</text>
|
||
<text class="menu-text">成交记录</text>
|
||
<text class="arrow">›</text>
|
||
</view>
|
||
<view class="menu-item" @click="goPage('/pages/distributor/commission')">
|
||
<text class="menu-icon">💰</text>
|
||
<text class="menu-text">佣金管理</text>
|
||
<text class="arrow">›</text>
|
||
</view>
|
||
<view class="menu-item" @click="goPage('/pages/distributor/team')">
|
||
<text class="menu-icon">👥</text>
|
||
<text class="menu-text">我的团队</text>
|
||
<text class="arrow">›</text>
|
||
</view>
|
||
<view class="menu-item" @click="goPage('/pages/distributor/customers')">
|
||
<text class="menu-icon">👨👩👧</text>
|
||
<text class="menu-text">客户管理</text>
|
||
<text class="arrow">›</text>
|
||
</view>
|
||
</view>
|
||
|
||
<!-- 推广工具 -->
|
||
<view class="menu-section">
|
||
<view class="section-title">推广工具</view>
|
||
<view class="menu-item" @click="goPage('/distributor-package/pages/distributor/promotion-code')">
|
||
<text class="menu-icon">🔗</text>
|
||
<text class="menu-text">推广码管理</text>
|
||
<text class="arrow">›</text>
|
||
</view>
|
||
<view class="menu-item" @click="goPage('/distributor-package/pages/distributor/poster')">
|
||
<text class="menu-icon">📱</text>
|
||
<text class="menu-text">推广海报</text>
|
||
<text class="arrow">›</text>
|
||
</view>
|
||
<view class="menu-item" @click="goPage('/pages/distributor/course-list')">
|
||
<text class="menu-icon">📚</text>
|
||
<text class="menu-text">可分销课程</text>
|
||
<text class="arrow">›</text>
|
||
</view>
|
||
</view>
|
||
|
||
<!-- 培训与成长 -->
|
||
<view class="menu-section">
|
||
<view class="section-title">培训与成长</view>
|
||
<view class="menu-item" @click="goPage('/pages/training/course-list')">
|
||
<text class="menu-icon">📖</text>
|
||
<text class="menu-text">分销培训</text>
|
||
<text class="arrow">›</text>
|
||
</view>
|
||
<view class="menu-item" @click="goPage('/pages/distributor/rank')">
|
||
<text class="menu-icon">🏆</text>
|
||
<text class="menu-text">排行榜</text>
|
||
<text class="arrow">›</text>
|
||
</view>
|
||
</view>
|
||
|
||
<!-- 其他功能 -->
|
||
<view class="menu-section">
|
||
<view class="menu-item" @click="contactService">
|
||
<text class="menu-icon">💬</text>
|
||
<text class="menu-text">联系客服</text>
|
||
<text class="arrow">›</text>
|
||
</view>
|
||
<view class="menu-item" @click="goPage('/pages/feedback/create')">
|
||
<text class="menu-icon">📝</text>
|
||
<text class="menu-text">意见反馈</text>
|
||
<text class="arrow">›</text>
|
||
</view>
|
||
</view>
|
||
|
||
<!-- 退出登录 -->
|
||
<view class="logout-section">
|
||
<button class="btn-logout" @click="handleLogout">退出登录</button>
|
||
</view>
|
||
</view>
|
||
</template>
|
||
|
||
<script>
|
||
import { distributorApi } from '@/api/index.js'
|
||
|
||
export default {
|
||
data() {
|
||
return {
|
||
distributorInfo: {},
|
||
stats: {
|
||
totalCommission: 0,
|
||
pendingCommission: 0,
|
||
availableBalance: 0,
|
||
monthOrders: 0,
|
||
monthCommission: 0,
|
||
newCustomers: 0,
|
||
teamMembers: 0
|
||
}
|
||
}
|
||
},
|
||
|
||
onShow() {
|
||
this.loadDistributorInfo()
|
||
this.loadStats()
|
||
},
|
||
|
||
methods: {
|
||
loadDistributorInfo() {
|
||
const userInfo = uni.getStorageSync('userInfo')
|
||
if (userInfo) {
|
||
this.distributorInfo = {
|
||
name: userInfo.name || '分销员',
|
||
phone: userInfo.phone,
|
||
level: userInfo.level || 'LV1'
|
||
}
|
||
}
|
||
},
|
||
|
||
async loadStats() {
|
||
try {
|
||
// 并行加载佣金统计和团队信息,使用catch捕获单个API失败
|
||
const [commissionStats, teamInfo] = await Promise.all([
|
||
distributorApi.getCommissionStats().catch(err => {
|
||
console.log('佣金统计加载失败(忽略):', err)
|
||
return { code: 200, data: {} } // 返回空数据,不影响登录状态
|
||
}),
|
||
distributorApi.getTeamInfo().catch(err => {
|
||
console.log('团队信息加载失败(忽略):', err)
|
||
return { code: 200, data: {} } // 返回空数据,不影响登录状态
|
||
})
|
||
])
|
||
|
||
if (commissionStats.code === 200 && commissionStats.data) {
|
||
const commData = commissionStats.data
|
||
this.stats.totalCommission = commData.totalCommission || 0
|
||
this.stats.pendingCommission = commData.pendingCommission || 0
|
||
this.stats.availableBalance = commData.availableBalance || 0
|
||
this.stats.monthOrders = commData.monthOrders || 0
|
||
this.stats.monthCommission = commData.monthCommission || 0
|
||
this.stats.newCustomers = commData.newCustomers || 0
|
||
}
|
||
|
||
if (teamInfo.code === 200 && teamInfo.data) {
|
||
this.stats.teamMembers = teamInfo.data.memberCount || 0
|
||
}
|
||
} catch (err) {
|
||
console.error('加载统计数据失败', err)
|
||
// 失败时使用默认值
|
||
this.stats = {
|
||
totalCommission: 0,
|
||
pendingCommission: 0,
|
||
availableBalance: 0,
|
||
monthOrders: 0,
|
||
monthCommission: 0,
|
||
newCustomers: 0,
|
||
teamMembers: 0
|
||
}
|
||
}
|
||
},
|
||
|
||
goSetting() {
|
||
uni.navigateTo({
|
||
url: '/pages/user/profile'
|
||
})
|
||
},
|
||
|
||
goPage(url) {
|
||
uni.navigateTo({ url })
|
||
},
|
||
|
||
contactService() {
|
||
uni.showToast({
|
||
title: '客服功能开发中',
|
||
icon: 'none'
|
||
})
|
||
},
|
||
|
||
handleLogout() {
|
||
uni.showModal({
|
||
title: '提示',
|
||
content: '确定要退出登录吗?',
|
||
success: (res) => {
|
||
if (res.confirm) {
|
||
uni.removeStorageSync('token')
|
||
uni.removeStorageSync('userInfo')
|
||
uni.reLaunch({
|
||
url: '/pages/index/index'
|
||
})
|
||
}
|
||
}
|
||
})
|
||
}
|
||
}
|
||
}
|
||
</script>
|
||
|
||
<style lang="scss" scoped>
|
||
@import '@/static/css/common.scss';
|
||
|
||
.container {
|
||
min-height: 100vh;
|
||
background: #f8f8f8;
|
||
padding-bottom: 40rpx;
|
||
}
|
||
|
||
.distributor-header {
|
||
background: linear-gradient(135deg, $primary-color 0%, $primary-light 100%);
|
||
padding: 60rpx 30rpx 40rpx;
|
||
display: flex;
|
||
align-items: center;
|
||
|
||
.distributor-avatar {
|
||
width: 120rpx;
|
||
height: 120rpx;
|
||
border-radius: 60rpx;
|
||
border: 4rpx solid rgba(255, 255, 255, 0.3);
|
||
margin-right: 24rpx;
|
||
background: rgba(255, 255, 255, 0.2);
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
|
||
.avatar-emoji {
|
||
font-size: 60rpx;
|
||
}
|
||
}
|
||
|
||
.distributor-info {
|
||
flex: 1;
|
||
|
||
.distributor-name {
|
||
display: block;
|
||
font-size: 36rpx;
|
||
font-weight: bold;
|
||
color: #fff;
|
||
margin-bottom: 12rpx;
|
||
}
|
||
|
||
.distributor-phone {
|
||
display: block;
|
||
font-size: 26rpx;
|
||
color: rgba(255, 255, 255, 0.8);
|
||
margin-bottom: 12rpx;
|
||
}
|
||
|
||
.distributor-level {
|
||
.level-tag {
|
||
display: inline-block;
|
||
padding: 4rpx 16rpx;
|
||
background: rgba(255, 215, 0, 0.3);
|
||
border-radius: 20rpx;
|
||
font-size: 22rpx;
|
||
color: #fff;
|
||
border: 1rpx solid rgba(255, 215, 0, 0.5);
|
||
}
|
||
}
|
||
}
|
||
|
||
.setting-btn {
|
||
color: #fff;
|
||
font-size: 28rpx;
|
||
padding: 12rpx 24rpx;
|
||
background: rgba(255, 255, 255, 0.2);
|
||
border-radius: 30rpx;
|
||
}
|
||
}
|
||
|
||
.earnings-section {
|
||
background: #fff;
|
||
margin: 20rpx 30rpx;
|
||
border-radius: 16rpx;
|
||
padding: 30rpx;
|
||
display: flex;
|
||
justify-content: space-around;
|
||
|
||
.earnings-item {
|
||
display: flex;
|
||
flex-direction: column;
|
||
align-items: center;
|
||
|
||
.earnings-value {
|
||
font-size: 36rpx;
|
||
font-weight: bold;
|
||
color: $primary-color;
|
||
margin-bottom: 8rpx;
|
||
}
|
||
|
||
.earnings-label {
|
||
font-size: 24rpx;
|
||
color: #999;
|
||
}
|
||
}
|
||
}
|
||
|
||
.quick-actions {
|
||
background: #fff;
|
||
margin: 20rpx 30rpx;
|
||
border-radius: 16rpx;
|
||
padding: 30rpx;
|
||
display: flex;
|
||
justify-content: space-around;
|
||
|
||
.action-item {
|
||
display: flex;
|
||
flex-direction: column;
|
||
align-items: center;
|
||
|
||
.action-icon {
|
||
font-size: 48rpx;
|
||
margin-bottom: 12rpx;
|
||
}
|
||
|
||
.action-text {
|
||
font-size: 24rpx;
|
||
color: #666;
|
||
}
|
||
}
|
||
}
|
||
|
||
.performance-section {
|
||
background: #fff;
|
||
margin: 20rpx 30rpx;
|
||
border-radius: 16rpx;
|
||
padding: 30rpx;
|
||
|
||
.section-title {
|
||
font-size: 28rpx;
|
||
color: #999;
|
||
margin-bottom: 24rpx;
|
||
}
|
||
|
||
.performance-grid {
|
||
display: grid;
|
||
grid-template-columns: repeat(2, 1fr);
|
||
gap: 24rpx;
|
||
|
||
.performance-item {
|
||
display: flex;
|
||
flex-direction: column;
|
||
align-items: center;
|
||
padding: 24rpx;
|
||
background: #f8f8f8;
|
||
border-radius: 12rpx;
|
||
|
||
.performance-value {
|
||
font-size: 32rpx;
|
||
font-weight: bold;
|
||
color: $primary-color;
|
||
margin-bottom: 8rpx;
|
||
}
|
||
|
||
.performance-label {
|
||
font-size: 24rpx;
|
||
color: #999;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
.menu-section {
|
||
background: #fff;
|
||
margin: 20rpx 30rpx;
|
||
border-radius: 16rpx;
|
||
overflow: hidden;
|
||
|
||
.section-title {
|
||
padding: 24rpx 30rpx 12rpx;
|
||
font-size: 28rpx;
|
||
color: #999;
|
||
font-weight: 500;
|
||
}
|
||
|
||
.menu-item {
|
||
display: flex;
|
||
align-items: center;
|
||
padding: 32rpx 30rpx;
|
||
border-bottom: 1rpx solid #f0f0f0;
|
||
|
||
&:last-child {
|
||
border-bottom: none;
|
||
}
|
||
|
||
.menu-icon {
|
||
font-size: 40rpx;
|
||
margin-right: 20rpx;
|
||
}
|
||
|
||
.menu-text {
|
||
flex: 1;
|
||
font-size: 30rpx;
|
||
color: #333;
|
||
}
|
||
|
||
.arrow {
|
||
font-size: 32rpx;
|
||
color: #999;
|
||
}
|
||
}
|
||
}
|
||
|
||
.logout-section {
|
||
margin: 40rpx 30rpx;
|
||
|
||
.btn-logout {
|
||
width: 100%;
|
||
height: 88rpx;
|
||
background: #fff;
|
||
color: #ff4d4f;
|
||
border: 1rpx solid #ff4d4f;
|
||
border-radius: 44rpx;
|
||
font-size: 32rpx;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
|
||
&::after {
|
||
border: none;
|
||
}
|
||
}
|
||
}
|
||
</style>
|