379 行
8.8 KiB
Vue
379 行
8.8 KiB
Vue
<!-- 区域公司中心 -->
|
|
<template>
|
|
<view class="regional-agent-page brand-page">
|
|
<view class="page-wrap">
|
|
<shopro-navbar variant="gradient" backText="区域公司"></shopro-navbar>
|
|
<scroll-view scroll-y class="page-scroll">
|
|
<view class="stats-card brand-card" v-if="normalAgents.length">
|
|
<view class="section-title u-flex u-row-between">
|
|
<text>我的公司区域</text>
|
|
<view class="period-tabs u-flex">
|
|
<text :class="['period-tab', period === 'all' ? 'active' : '']" @tap="switchPeriod('all')">全部</text>
|
|
<text :class="['period-tab', period === 'month' ? 'active' : '']" @tap="switchPeriod('month')">本月</text>
|
|
</view>
|
|
</view>
|
|
|
|
<view class="summary-row u-flex" v-if="summary.order_count !== undefined">
|
|
<view class="summary-item">
|
|
<view class="summary-num">{{ summary.order_count || 0 }}</view>
|
|
<view class="summary-label">订单</view>
|
|
</view>
|
|
<view class="summary-item">
|
|
<view class="summary-num">¥{{ summary.order_money || '0.00' }}</view>
|
|
<view class="summary-label">销售额</view>
|
|
</view>
|
|
<view class="summary-item">
|
|
<view class="summary-num highlight">¥{{ summary.total_income || '0.00' }}</view>
|
|
<view class="summary-label">收益</view>
|
|
</view>
|
|
</view>
|
|
|
|
<view class="delay-money-row" v-if="delayMoney > 0">
|
|
<text class="delay-label">待结算差价</text>
|
|
<text class="delay-value">¥{{ delayMoney }}</text>
|
|
</view>
|
|
|
|
<view class="agent-item" v-for="item in displayStats" :key="item.agent.id">
|
|
<view class="agent-area">{{ item.agent.area_name }} ({{ levelName(item.agent.area_level) }})</view>
|
|
<view class="agent-stats u-flex">
|
|
<view class="stat-col">
|
|
<view class="stat-num">{{ item.order_count || 0 }}</view>
|
|
<view class="stat-label">区域订单</view>
|
|
</view>
|
|
<view class="stat-col">
|
|
<view class="stat-num">{{ item.order_money || '0.00' }}</view>
|
|
<view class="stat-label">销售额</view>
|
|
</view>
|
|
<view class="stat-col">
|
|
<view class="stat-num highlight">{{ item.total_income || '0.00' }}</view>
|
|
<view class="stat-label">总收益</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
|
|
<view class="pending-card brand-card" v-if="pendingAgents.length">
|
|
<view class="section-title">审核中</view>
|
|
<view class="pending-item" v-for="item in pendingAgents" :key="item.id">
|
|
<view>{{ item.area_name || '待分配区域' }} ({{ levelName(item.area_level) }})</view>
|
|
<view class="pending-tag">审核中,请耐心等待</view>
|
|
</view>
|
|
</view>
|
|
|
|
<view class="empty-card brand-card" v-if="!normalAgents.length && !pendingAgents.length && !loading">
|
|
<view class="empty-text">您还不是区域公司</view>
|
|
<button class="apply-btn" @tap="jump('/pages/app/regional-agent/apply')">申请成为区域公司</button>
|
|
</view>
|
|
|
|
<view class="menu-box brand-card" v-if="normalAgents.length">
|
|
<view class="menu-item u-flex u-row-between u-col-center" @tap="jump('/pages/app/regional-agent/orders')">
|
|
<view class="menu-left u-flex u-col-center">
|
|
<text class="menu-icon u-iconfont uicon-order"></text>
|
|
<text>区域订单</text>
|
|
</view>
|
|
<text class="u-iconfont uicon-arrow-right menu-arrow"></text>
|
|
</view>
|
|
<view class="menu-item u-flex u-row-between u-col-center" @tap="jump('/pages/app/regional-agent/rewards')">
|
|
<view class="menu-left u-flex u-col-center">
|
|
<text class="menu-icon u-iconfont uicon-red-packet"></text>
|
|
<text>差价明细</text>
|
|
</view>
|
|
<text class="u-iconfont uicon-arrow-right menu-arrow"></text>
|
|
</view>
|
|
<view class="menu-item highlight u-flex u-row-between u-col-center" @tap="jump('/pages/user/wallet/withdraw')">
|
|
<view class="menu-left u-flex u-col-center">
|
|
<text class="menu-icon u-iconfont uicon-rmb"></text>
|
|
<text>去提现</text>
|
|
</view>
|
|
<text class="u-iconfont uicon-arrow-right menu-arrow"></text>
|
|
</view>
|
|
</view>
|
|
|
|
<view class="menu-box brand-card" v-if="!normalAgents.length && !pendingAgents.length && !loading">
|
|
<view class="menu-item" @tap="jump('/pages/app/regional-agent/apply')">立即申请区域公司</view>
|
|
</view>
|
|
</scroll-view>
|
|
</view>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
export default {
|
|
data() {
|
|
return {
|
|
loading: true,
|
|
agentList: [],
|
|
statsList: [],
|
|
summary: {},
|
|
delayMoney: '0.00',
|
|
period: 'all',
|
|
featureClosed: false
|
|
};
|
|
},
|
|
computed: {
|
|
normalAgents() {
|
|
return this.agentList.filter(item => item.status === 'normal');
|
|
},
|
|
pendingAgents() {
|
|
return this.agentList.filter(item => item.status === 'pending');
|
|
},
|
|
displayStats() {
|
|
if (this.statsList.length) {
|
|
return this.statsList;
|
|
}
|
|
return this.normalAgents.map(agent => ({
|
|
agent,
|
|
order_count: agent.order_count,
|
|
order_money: agent.order_money,
|
|
total_income: agent.total_income
|
|
}));
|
|
}
|
|
},
|
|
onShow() {
|
|
this.loadInfo();
|
|
},
|
|
methods: {
|
|
loadInfo() {
|
|
this.loading = true;
|
|
this.$http('regionalAgent.info').then(res => {
|
|
if (res.code === 1) {
|
|
if (res.data && res.data.status === 'close') {
|
|
this.featureClosed = true;
|
|
this.$u.toast('区域公司功能暂未开放');
|
|
this.loading = false;
|
|
return;
|
|
}
|
|
this.agentList = (res.data && res.data.agents) || [];
|
|
if (!Array.isArray(this.agentList)) {
|
|
this.agentList = [];
|
|
}
|
|
this.delayMoney = (res.data && res.data.delay_money) || '0.00';
|
|
this.loadStats();
|
|
} else {
|
|
this.loading = false;
|
|
}
|
|
}).catch(() => {
|
|
this.loading = false;
|
|
});
|
|
},
|
|
loadStats() {
|
|
const params = {};
|
|
if (this.period === 'month') {
|
|
const now = new Date();
|
|
const start = new Date(now.getFullYear(), now.getMonth(), 1);
|
|
params.start_time = Math.floor(start.getTime() / 1000);
|
|
params.end_time = Math.floor(now.getTime() / 1000);
|
|
}
|
|
this.$http('regionalAgent.stats', params).then(res => {
|
|
this.loading = false;
|
|
if (res.code === 1) {
|
|
this.statsList = (res.data && res.data.list) || res.data || [];
|
|
this.summary = (res.data && res.data.summary) || {};
|
|
if (!Array.isArray(this.statsList)) {
|
|
this.statsList = [];
|
|
}
|
|
}
|
|
}).catch(() => {
|
|
this.loading = false;
|
|
});
|
|
},
|
|
switchPeriod(period) {
|
|
this.period = period;
|
|
this.loadStats();
|
|
},
|
|
levelName(level) {
|
|
const map = { 1: '省级', 2: '市级', 3: '区县' };
|
|
return map[level] || '公司';
|
|
},
|
|
jump(path) {
|
|
this.$Router.push({ path });
|
|
}
|
|
}
|
|
};
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
.regional-agent-page {
|
|
height: 100vh;
|
|
}
|
|
|
|
.page-wrap {
|
|
background: $brand-header-gradient;
|
|
min-height: 100vh;
|
|
display: flex;
|
|
flex-direction: column;
|
|
}
|
|
|
|
.page-scroll {
|
|
flex: 1;
|
|
height: 0;
|
|
padding: 0 $brand-page-gutter 24rpx;
|
|
box-sizing: border-box;
|
|
}
|
|
|
|
.stats-card, .empty-card, .menu-box, .pending-card {
|
|
padding: 28rpx;
|
|
margin-bottom: 24rpx;
|
|
}
|
|
|
|
.section-title {
|
|
font-size: 30rpx;
|
|
font-weight: 600;
|
|
margin-bottom: 20rpx;
|
|
}
|
|
|
|
.period-tabs {
|
|
gap: 16rpx;
|
|
}
|
|
|
|
.period-tab {
|
|
font-size: 24rpx;
|
|
color: #999;
|
|
padding: 6rpx 16rpx;
|
|
border-radius: 20rpx;
|
|
|
|
&.active {
|
|
color: #1677FF;
|
|
background: #f0f7ff;
|
|
}
|
|
}
|
|
|
|
.summary-row {
|
|
margin-bottom: 20rpx;
|
|
padding: 16rpx 0;
|
|
border-bottom: 1rpx solid #f0f0f0;
|
|
|
|
.summary-item {
|
|
flex: 1;
|
|
text-align: center;
|
|
|
|
.summary-num {
|
|
font-size: 28rpx;
|
|
font-weight: 600;
|
|
|
|
&.highlight {
|
|
color: #1677FF;
|
|
}
|
|
}
|
|
|
|
.summary-label {
|
|
font-size: 22rpx;
|
|
color: #999;
|
|
margin-top: 8rpx;
|
|
}
|
|
}
|
|
}
|
|
|
|
.delay-money-row {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
padding: 16rpx 20rpx;
|
|
margin-bottom: 20rpx;
|
|
background: #f0f7ff;
|
|
border-radius: 12rpx;
|
|
|
|
.delay-label {
|
|
font-size: 26rpx;
|
|
color: #666;
|
|
}
|
|
|
|
.delay-value {
|
|
font-size: 32rpx;
|
|
font-weight: 600;
|
|
color: #1677FF;
|
|
}
|
|
}
|
|
|
|
.agent-item {
|
|
padding: 20rpx 0;
|
|
border-bottom: 1rpx solid #f0f0f0;
|
|
|
|
&:last-child {
|
|
border-bottom: none;
|
|
}
|
|
|
|
.agent-area {
|
|
font-size: 30rpx;
|
|
font-weight: 600;
|
|
margin-bottom: 16rpx;
|
|
}
|
|
|
|
.stat-col {
|
|
flex: 1;
|
|
text-align: center;
|
|
|
|
.stat-num {
|
|
font-size: 28rpx;
|
|
font-weight: 600;
|
|
|
|
&.highlight {
|
|
color: #1677FF;
|
|
}
|
|
}
|
|
|
|
.stat-label {
|
|
font-size: 22rpx;
|
|
color: #999;
|
|
margin-top: 8rpx;
|
|
}
|
|
}
|
|
}
|
|
|
|
.pending-item {
|
|
padding: 16rpx 0;
|
|
font-size: 28rpx;
|
|
|
|
.pending-tag {
|
|
margin-top: 8rpx;
|
|
font-size: 24rpx;
|
|
color: #1677FF;
|
|
}
|
|
}
|
|
|
|
.empty-text {
|
|
text-align: center;
|
|
color: #999;
|
|
margin-bottom: 24rpx;
|
|
}
|
|
|
|
.apply-btn {
|
|
background: #1677FF;
|
|
color: #fff;
|
|
border-radius: 40rpx;
|
|
height: 80rpx;
|
|
line-height: 80rpx;
|
|
}
|
|
|
|
.menu-item {
|
|
padding: 28rpx 0;
|
|
border-bottom: 1rpx solid #f0f0f0;
|
|
font-size: 28rpx;
|
|
min-height: 88rpx;
|
|
box-sizing: border-box;
|
|
|
|
&.highlight {
|
|
color: #1677FF;
|
|
font-weight: 600;
|
|
}
|
|
|
|
&:last-child {
|
|
border-bottom: none;
|
|
}
|
|
|
|
.menu-left {
|
|
gap: 16rpx;
|
|
}
|
|
|
|
.menu-icon {
|
|
font-size: 36rpx;
|
|
color: #1677FF;
|
|
}
|
|
|
|
.menu-arrow {
|
|
font-size: 24rpx;
|
|
color: #C4C4C4;
|
|
}
|
|
}
|
|
</style>
|