Merge remote-tracking branch 'origin/huangzhenbao-admin'

This commit is contained in:
not-like-juvenile
2026-03-18 17:14:05 +08:00
676 changed files with 25158 additions and 46646 deletions

View File

@@ -0,0 +1,164 @@
<template>
<view class="admin-page">
<view class="filter-card">
<view class="filter-row">
<view class="filter-item">
<text class="label">搜索:</text>
<input class="filter-input" placeholder="请输入姓名、UID" />
</view>
<view class="filter-btns">
<button class="btn primary" @click="onSearch">查询</button>
</view>
</view>
</view>
<view class="content-card">
<view class="tabs-row">
<view v-for="(tab, index) in tabs" :key="index" class="tab-item" :class="{ active: activeTab === index }" @click="activeTab = index">
<text>{{ tab }}</text>
</view>
</view>
<view class="table-container">
<view class="table-header">
<view class="col col-uid"><text>用户UID</text></view>
<view class="col col-name"><text>代理商名称</text></view>
<view class="col col-phone"><text>代理商电话</text></view>
<view class="col col-dept"><text>事业部名称</text></view>
<view class="col col-img"><text>申请图片</text></view>
<view class="col col-time"><text>申请时间</text></view>
<view class="col col-status"><text>申请状态</text></view>
<view class="col col-code"><text>邀请码</text></view>
<view class="col col-ops"><text>操作</text></view>
</view>
<view class="table-body">
<view v-for="item in pagedList" :key="item.uid" class="table-row">
<view class="col col-uid"><text>{{ item.uid }}</text></view>
<view class="col col-name"><text>{{ item.name }}</text></view>
<view class="col col-phone"><text>{{ item.phone }}</text></view>
<view class="col col-dept"><text>{{ item.deptName }}</text></view>
<view class="col col-img">
<image class="table-img" src="/static/logo.png" mode="aspectFill" />
</view>
<view class="col col-time"><text>{{ item.time }}</text></view>
<view class="col col-status">
<view class="status-tag"><text>{{ item.statusText }}</text></view>
</view>
<view class="col col-code"><view class="code-box"><text>{{ item.code }}</text></view></view>
<view class="col col-ops">
<text class="op-link">同意</text>
<text class="op-divider">|</text>
<text class="op-link">拒绝</text>
<text class="op-divider">|</text>
<text class="op-link">删除</text>
</view>
</view>
</view>
</view>
<CommonPagination
v-if="total > 0"
:total="total"
:loading="false"
:currentPage="currentPage"
:pageSize="pageSize"
:pageSizeOptionLabels="pageSizeOptionLabels"
:pageSizeIndex="pageSizeIndex"
:visiblePages="visiblePages"
:totalPage="totalPage"
:jumpPageInput="jumpPageInput"
@page-size-change="handlePageSizeChange"
@page-change="handlePageChange"
@update:jumpPageInput="(val: string) => { jumpPageInput.value = val }"
@jump-page="handleJumpPage"
/>
</view>
</view>
</template>
<script setup lang="uts">
import { ref, computed } from 'vue'
import CommonPagination from '@/components/CommonPagination/CommonPagination.uvue'
const activeTab = ref(0)
const tabs = ['全部', '申请中', '已同意', '已拒绝']
// ========== MOCK DATA START ==========
// TODO: 接真实接口时替换此处 applyList 为 fetchApplyList() 调用
const applyList = ref([
{ uid: '81806', name: '测试测试', phone: '19910205954', deptName: '26991', time: '2026-01-08 15:30:39', statusText: '申请中', code: '70623142' },
{ uid: '81807', name: '张三', phone: '13812345678', deptName: '北京事业部', time: '2026-01-10 09:20:15', statusText: '已同意', code: '80731253' },
{ uid: '81808', name: '李四', phone: '13987654321', deptName: '上海事业部', time: '2026-01-12 14:05:33', statusText: '已拒绝', code: '90842364' },
{ uid: '81809', name: '王五', phone: '15012341234', deptName: '广州事业部', time: '2026-01-15 11:45:20', statusText: '申请中', code: '10953475' },
{ uid: '81810', name: '赵六', phone: '18600001111', deptName: '深圳事业部', time: '2026-01-18 08:30:00', statusText: '已同意', code: '21064586' },
{ uid: '81811', name: '孙七', phone: '17712349876', deptName: '成都事业部', time: '2026-01-20 16:15:44', statusText: '已同意', code: '32175697' },
{ uid: '81812', name: '周八', phone: '13300002222', deptName: '杭州事业部', time: '2026-01-22 10:55:30', statusText: '申请中', code: '43286708' },
{ uid: '81813', name: '吴九', phone: '15566667777', deptName: '武汉事业部', time: '2026-01-25 13:40:18', statusText: '已拒绝', code: '54397819' },
{ uid: '81814', name: '郑十', phone: '18899998888', deptName: '南京事业部', time: '2026-01-28 09:00:05', statusText: '申请中', code: '65408920' },
{ uid: '81815', name: '冯云', phone: '13712348765', deptName: '西安事业部', time: '2026-02-01 15:20:33', statusText: '已同意', code: '76519031' },
{ uid: '81816', name: '陈霞', phone: '15087651234', deptName: '重庆事业部', time: '2026-02-05 11:10:22', statusText: '申请中', code: '87620142' },
{ uid: '81817', name: '蒋峰', phone: '13500004444', deptName: '郑州事业部', time: '2026-02-08 14:35:49', statusText: '已同意', code: '98731253' },
{ uid: '81818', name: '卫林', phone: '17656785678', deptName: '长沙事业部', time: '2026-02-10 08:45:11', statusText: '已拒绝', code: '09842364' },
{ uid: '81819', name: '蒋彪', phone: '18211112222', deptName: '合肥事业部', time: '2026-02-12 17:00:00', statusText: '申请中', code: '10953476' },
{ uid: '81820', name: '沈辉', phone: '13655554444', deptName: '天津事业部', time: '2026-02-15 12:30:40', statusText: '已同意', code: '21064587' },
{ uid: '81821', name: '韩磊', phone: '15999990000', deptName: '苏州事业部', time: '2026-02-18 09:55:28', statusText: '已同意', code: '32175698' },
{ uid: '81822', name: '杨红', phone: '17811122233', deptName: '宁波事业部', time: '2026-02-20 16:40:15', statusText: '申请中', code: '43286709' },
{ uid: '81823', name: '秦波', phone: '13234561234', deptName: '厦门事业部', time: '2026-02-22 11:20:06', statusText: '已拒绝', code: '54397820' },
{ uid: '81824', name: '许丹', phone: '18777776666', deptName: '青岛事业部', time: '2026-02-25 14:05:50', statusText: '已同意', code: '65408921' },
{ uid: '81825', name: '何强', phone: '15344443333', deptName: '福州事业部', time: '2026-02-28 08:15:38', statusText: '申请中', code: '76519032' },
])
// ========== MOCK DATA END ==========
// ========== PAGINATION STATE ==========
const currentPage = ref(1)
const pageSize = ref(15)
const jumpPageInput = ref('')
const pageSizeOptions = [10, 15, 20, 30, 50]
const pageSizeOptionLabels = computed(() => pageSizeOptions.map((n: number) => `${n}条/页`))
const pageSizeIndex = computed(() => { const idx = pageSizeOptions.indexOf(pageSize.value); return idx >= 0 ? idx : 0 })
const total = computed(() => applyList.value.length)
const totalPage = computed(() => Math.max(1, Math.ceil(total.value / pageSize.value)))
const pagedList = computed(() => {
const start = (currentPage.value - 1) * pageSize.value
return applyList.value.slice(start, start + pageSize.value)
})
const visiblePages = computed((): number[] => {
const t = totalPage.value; const cur = currentPage.value
if (t <= 7) return Array.from({ length: t }, (_: any, i: number) => i + 1)
if (cur <= 4) return [1, 2, 3, 4, 5, -1, t]
if (cur >= t - 3) return [1, -1, t - 4, t - 3, t - 2, t - 1, t]
return [1, -1, cur - 1, cur, cur + 1, -1, t]
})
const handlePageChange = (p: number) => { currentPage.value = p }
const handlePageSizeChange = (e: any) => {
const idx = Number(e.detail.value)
pageSize.value = pageSizeOptions[idx] ?? pageSizeOptions[0]
currentPage.value = 1
}
const handleJumpPage = () => {
const p = parseInt(jumpPageInput.value)
if (!isNaN(p) && p >= 1 && p <= totalPage.value) currentPage.value = p
}
// ========== END PAGINATION STATE ==========
function onSearch() { uni.showToast({ title: '查询中...', icon: 'none' }) }
</script>
<style scoped lang="scss">
.admin-page { padding: 0; }
.filter-card { background: #fff; padding: 24px; margin-bottom: 16px; border-radius: 4px; }
.filter-row { display: flex; flex-direction: row; align-items: center; gap: 24px; }
.label { font-size: 14px; color: #333; }
.filter-input { border: 1px solid #d9d9d9; height: 32px; width: 220px; padding: 0 12px; font-size: 14px; }
.btn { height: 32px; padding: 0 16px; font-size: 14px; border: 1px solid #d9d9d9; background: #fff; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.btn.primary { background: #1890ff; border-color: #1890ff; color: #fff; }
.content-card { background: #fff; border-radius: 4px; }
.tabs-row { display: flex; flex-direction: row; padding: 0 24px; border-bottom: 1px solid #f0f0f0; }
.tab-item { padding: 16px 20px; cursor: pointer; position: relative; text { font-size: 15px; color: #666; } &.active { text { color: #1890ff; font-weight: 500; } &::after { content: ''; position: absolute; bottom: 0; left: 0; right: 0; height: 2px; background: #1890ff; } } }
.table-container { padding: 24px; }
.table-header { display: flex; flex-direction: row; background: #f8faff; border-bottom: 1px solid #f0f0f0; padding: 12px 0; }
.table-row { display: flex; flex-direction: row; border-bottom: 1px solid #f0f0f0; padding: 12px 0; align-items: center; &:hover { background: #fafafa; } }
.col { padding: 0 8px; font-size: 14px; color: #333; display: flex; align-items: center; }
.col-uid { width: 80px; } .col-name { width: 120px; } .col-phone { width: 120px; } .col-dept { width: 120px; } .col-img { width: 80px; justify-content: center; } .col-time { width: 160px; justify-content: center; } .col-status { width: 100px; justify-content: center; } .col-code { width: 100px; justify-content: center; }
.col-ops { flex: 1; justify-content: flex-end; display: flex; flex-direction: row; }
.table-img { width: 32px; height: 32px; border-radius: 2px; }
.status-tag { border: 1px solid #1890ff; color: #1890ff; padding: 2px 8px; border-radius: 4px; font-size: 12px; }
.code-box { border: 1px solid #d9d9d9; padding: 2px 8px; border-radius: 4px; font-size: 12px; background: #fafafa; }
.op-link { color: #1890ff; cursor: pointer; }
.op-divider { color: #e8e8e8; margin: 0 8px; }
</style>

View File

@@ -0,0 +1,157 @@
<template>
<view class="admin-page">
<view class="filter-card">
<view class="filter-row">
<view class="filter-item">
<text class="label">代理商查询:</text>
<input class="filter-input" placeholder="请输入姓名、手机号或UID" />
</view>
<view class="filter-btns">
<button class="btn primary" @click="onSearch">查询</button>
</view>
</view>
</view>
<view class="content-card">
<view class="action-bar">
<button class="btn primary small" @click="onAdd">添加代理商</button>
</view>
<view class="table-container">
<view class="table-header">
<view class="col col-uid"><text>用户UID</text></view>
<view class="col col-avatar"><text>头像</text></view>
<view class="col col-name"><text>名称</text></view>
<view class="col col-ratio"><text>分佣比例</text></view>
<view class="col col-count"><text>员工数量</text></view>
<view class="col col-time"><text>过期时间</text></view>
<view class="col col-status"><text>状态</text></view>
<view class="col col-ops"><text>操作</text></view>
</view>
<view class="table-body">
<view v-for="item in pagedList" :key="item.uid" class="table-row">
<view class="col col-uid"><text>{{ item.uid }}</text></view>
<view class="col col-avatar">
<image class="avatar-img" src="/static/logo.png" mode="aspectFill" />
</view>
<view class="col col-name"><text>{{ item.name }}</text></view>
<view class="col col-ratio"><text>{{ item.ratio }}%</text></view>
<view class="col col-count"><text>{{ item.staffCount }}</text></view>
<view class="col col-time"><text>{{ item.endTime }}</text></view>
<view class="col col-status">
<switch :checked="item.status" color="#1890ff" scale="0.8" />
</view>
<view class="col col-ops">
<text class="op-link">编辑</text>
<text class="op-divider">|</text>
<text class="op-link">查看</text>
<text class="op-divider">|</text>
<text class="op-link">员工</text>
<text class="op-divider">|</text>
<text class="op-link">删除</text>
</view>
</view>
</view>
</view>
<CommonPagination
v-if="total > 0"
:total="total"
:loading="false"
:currentPage="currentPage"
:pageSize="pageSize"
:pageSizeOptionLabels="pageSizeOptionLabels"
:pageSizeIndex="pageSizeIndex"
:visiblePages="visiblePages"
:totalPage="totalPage"
:jumpPageInput="jumpPageInput"
@page-size-change="handlePageSizeChange"
@page-change="handlePageChange"
@update:jumpPageInput="(val: string) => { jumpPageInput.value = val }"
@jump-page="handleJumpPage"
/>
</view>
</view>
</template>
<script setup lang="uts">
import { ref, computed } from 'vue'
import CommonPagination from '@/components/CommonPagination/CommonPagination.uvue'
// ========== MOCK DATA START ==========
// TODO: 接真实接口时替换此处 agentList 为 fetchAgentList() 调用
const agentList = ref([
{ uid: '60569', name: 'cs2020', ratio: 50, staffCount: 1, endTime: '2026-01-01', status: true },
{ uid: '60570', name: '张伟', ratio: 45, staffCount: 3, endTime: '2026-06-30', status: true },
{ uid: '60571', name: '李华', ratio: 40, staffCount: 5, endTime: '2026-12-31', status: true },
{ uid: '60572', name: '王芳', ratio: 38, staffCount: 2, endTime: '2027-03-01', status: false },
{ uid: '60573', name: '赵磊', ratio: 42, staffCount: 7, endTime: '2026-09-30', status: true },
{ uid: '60574', name: '陈浩', ratio: 35, staffCount: 0, endTime: '2026-04-15', status: true },
{ uid: '60575', name: '刘娜', ratio: 48, staffCount: 4, endTime: '2026-08-01', status: true },
{ uid: '60576', name: '黄明', ratio: 33, staffCount: 6, endTime: '2027-01-31', status: false },
{ uid: '60577', name: '周静', ratio: 52, staffCount: 1, endTime: '2026-11-30', status: true },
{ uid: '60578', name: '吴强', ratio: 30, staffCount: 9, endTime: '2026-07-15', status: true },
{ uid: '60579', name: '郑丽', ratio: 55, staffCount: 2, endTime: '2026-03-31', status: true },
{ uid: '60580', name: '孙勇', ratio: 28, staffCount: 11, endTime: '2027-06-30', status: true },
{ uid: '60581', name: '朱婷', ratio: 46, staffCount: 3, endTime: '2026-10-31', status: false },
{ uid: '60582', name: '马林', ratio: 37, staffCount: 0, endTime: '2026-05-01', status: true },
{ uid: '60583', name: '胡倩', ratio: 41, staffCount: 8, endTime: '2026-02-28', status: true },
{ uid: '60584', name: '高峰', ratio: 36, staffCount: 4, endTime: '2027-09-30', status: true },
{ uid: '60585', name: '梁雪', ratio: 49, staffCount: 2, endTime: '2026-06-15', status: false },
{ uid: '60586', name: '邓超', ratio: 32, staffCount: 6, endTime: '2027-02-01', status: true },
{ uid: '60587', name: '彭宇', ratio: 44, staffCount: 5, endTime: '2026-08-30', status: true },
{ uid: '60588', name: '曹芸', ratio: 39, staffCount: 1, endTime: '2026-12-01', status: true },
])
// ========== MOCK DATA END ==========
// ========== PAGINATION STATE ==========
const currentPage = ref(1)
const pageSize = ref(15)
const jumpPageInput = ref('')
const pageSizeOptions = [10, 15, 20, 30, 50]
const pageSizeOptionLabels = computed(() => pageSizeOptions.map((n: number) => `${n}条/页`))
const pageSizeIndex = computed(() => { const idx = pageSizeOptions.indexOf(pageSize.value); return idx >= 0 ? idx : 0 })
const total = computed(() => agentList.value.length)
const totalPage = computed(() => Math.max(1, Math.ceil(total.value / pageSize.value)))
const pagedList = computed(() => {
const start = (currentPage.value - 1) * pageSize.value
return agentList.value.slice(start, start + pageSize.value)
})
const visiblePages = computed((): number[] => {
const t = totalPage.value; const cur = currentPage.value
if (t <= 7) return Array.from({ length: t }, (_: any, i: number) => i + 1)
if (cur <= 4) return [1, 2, 3, 4, 5, -1, t]
if (cur >= t - 3) return [1, -1, t - 4, t - 3, t - 2, t - 1, t]
return [1, -1, cur - 1, cur, cur + 1, -1, t]
})
const handlePageChange = (p: number) => { currentPage.value = p }
const handlePageSizeChange = (e: any) => {
const idx = Number(e.detail.value)
pageSize.value = pageSizeOptions[idx] ?? pageSizeOptions[0]
currentPage.value = 1
}
const handleJumpPage = () => {
const p = parseInt(jumpPageInput.value)
if (!isNaN(p) && p >= 1 && p <= totalPage.value) currentPage.value = p
}
// ========== END PAGINATION STATE ==========
function onSearch() { uni.showToast({ title: '查询中...', icon: 'none' }) }
function onAdd() { uni.showToast({ title: '添加中...', icon: 'none' }) }
</script>
<style scoped lang="scss">
.admin-page { padding: 0; }
.filter-card { background: #fff; padding: 24px; margin-bottom: 16px; border-radius: 4px; }
.filter-row { display: flex; flex-direction: row; align-items: center; gap: 24px; }
.label { font-size: 14px; color: #333; }
.filter-input { border: 1px solid #d9d9d9; height: 32px; width: 220px; padding: 0 12px; font-size: 14px; }
.btn { height: 32px; padding: 0 16px; font-size: 14px; border: 1px solid #d9d9d9; background: #fff; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.btn.primary { background: #1890ff; border-color: #1890ff; color: #fff; }
.content-card { background: #fff; border-radius: 4px; }
.action-bar { padding: 16px 24px; }
.table-container { padding: 0 24px 24px; }
.table-header { display: flex; flex-direction: row; background: #f8faff; border-bottom: 1px solid #f0f0f0; padding: 12px 0; }
.table-row { display: flex; flex-direction: row; border-bottom: 1px solid #f0f0f0; padding: 12px 0; align-items: center; &:hover { background: #fafafa; } }
.col { padding: 0 8px; font-size: 14px; color: #333; display: flex; align-items: center; }
.col-uid { width: 80px; } .col-avatar { width: 80px; justify-content: center; } .col-name { width: 120px; } .col-ratio { width: 100px; justify-content: center; } .col-count { width: 100px; justify-content: center; } .col-time { width: 120px; justify-content: center; } .col-status { width: 80px; justify-content: center; }
.col-ops { flex: 1; justify-content: flex-end; display: flex; flex-direction: row; }
.avatar-img { width: 32px; height: 32px; border-radius: 2px; }
.op-link { color: #1890ff; cursor: pointer; }
.op-divider { color: #e8e8e8; margin: 0 8px; }
</style>

View File

@@ -0,0 +1,157 @@
<template>
<view class="admin-page">
<view class="filter-card">
<view class="filter-row">
<view class="filter-item">
<text class="label">搜索:</text>
<input class="filter-input" placeholder="请输入姓名、UID" />
</view>
<view class="filter-btns">
<button class="btn primary" @click="onSearch">查询</button>
</view>
</view>
</view>
<view class="content-card">
<view class="action-bar">
<button class="btn primary small" @click="onAdd">添加事业部</button>
</view>
<view class="table-container">
<view class="table-header">
<view class="col col-uid"><text>用户UID</text></view>
<view class="col col-avatar"><text>头像</text></view>
<view class="col col-name"><text>名称</text></view>
<view class="col col-code"><text>邀请码</text></view>
<view class="col col-ratio"><text>分销比例</text></view>
<view class="col col-count"><text>代理商数量</text></view>
<view class="col col-time"><text>截止时间</text></view>
<view class="col col-status"><text>状态</text></view>
<view class="col col-ops"><text>操作</text></view>
</view>
<view class="table-body">
<view v-for="item in pagedList" :key="item.uid" class="table-row">
<view class="col col-uid"><text>{{ item.uid }}</text></view>
<view class="col col-avatar">
<image class="avatar-img" src="/static/logo.png" mode="aspectFill" />
</view>
<view class="col col-name"><text>{{ item.name }}</text></view>
<view class="col col-code"><text>{{ item.code }}</text></view>
<view class="col col-ratio"><text>{{ item.ratio }}%</text></view>
<view class="col col-count"><text>{{ item.agentCount }}</text></view>
<view class="col col-time"><text>{{ item.endTime }}</text></view>
<view class="col col-status">
<switch :checked="item.status" color="#1890ff" scale="0.8" />
</view>
<view class="col col-ops">
<text class="op-link">查看代理商</text>
<text class="op-divider">|</text>
<text class="op-link">编辑</text>
<text class="op-divider">|</text>
<text class="op-link">删除</text>
</view>
</view>
</view>
</view>
<CommonPagination
v-if="total > 0"
:total="total"
:loading="false"
:currentPage="currentPage"
:pageSize="pageSize"
:pageSizeOptionLabels="pageSizeOptionLabels"
:pageSizeIndex="pageSizeIndex"
:visiblePages="visiblePages"
:totalPage="totalPage"
:jumpPageInput="jumpPageInput"
@page-size-change="handlePageSizeChange"
@page-change="handlePageChange"
@update:jumpPageInput="(val: string) => { jumpPageInput.value = val }"
@jump-page="handleJumpPage"
/>
</view>
</view>
</template>
<script setup lang="uts">
import { ref, computed } from 'vue'
import CommonPagination from '@/components/CommonPagination/CommonPagination.uvue'
// ========== MOCK DATA START ==========
// TODO: 接真实接口时替换此处 divisionList 为 fetchDivisionList() 调用
const divisionList = ref([
{ uid: '26991', name: '北京事业部', code: '70623142', ratio: 40, agentCount: 5, endTime: '2026-12-31', status: true },
{ uid: '26992', name: '上海事业部', code: '80731253', ratio: 35, agentCount: 8, endTime: '2026-06-30', status: true },
{ uid: '26993', name: '广州事业部', code: '90842364', ratio: 38, agentCount: 3, endTime: '2027-03-01', status: true },
{ uid: '26994', name: '深圳事业部', code: '10953475', ratio: 42, agentCount: 12, endTime: '2026-09-30', status: false },
{ uid: '26995', name: '成都事业部', code: '21064586', ratio: 30, agentCount: 2, endTime: '2026-08-15', status: true },
{ uid: '26996', name: '杭州事业部', code: '32175697', ratio: 45, agentCount: 7, endTime: '2026-12-01', status: true },
{ uid: '26997', name: '武汉事业部', code: '43286708', ratio: 33, agentCount: 4, endTime: '2027-01-01', status: true },
{ uid: '26998', name: '南京事业部', code: '54397819', ratio: 36, agentCount: 6, endTime: '2026-11-30', status: false },
{ uid: '26999', name: '西安事业部', code: '65408920', ratio: 40, agentCount: 1, endTime: '2026-07-31', status: true },
{ uid: '27000', name: '重庆事业部', code: '76519031', ratio: 28, agentCount: 9, endTime: '2026-10-01', status: true },
{ uid: '27001', name: '郑州事业部', code: '87620142', ratio: 32, agentCount: 3, endTime: '2026-05-31', status: true },
{ uid: '27002', name: '长沙事业部', code: '98731253', ratio: 37, agentCount: 5, endTime: '2027-02-28', status: false },
{ uid: '27003', name: '合肥事业部', code: '09842364', ratio: 41, agentCount: 2, endTime: '2026-04-30', status: true },
{ uid: '27004', name: '天津事业部', code: '10953476', ratio: 39, agentCount: 10, endTime: '2026-12-31', status: true },
{ uid: '27005', name: '苏州事业部', code: '21064587', ratio: 34, agentCount: 4, endTime: '2026-03-31', status: true },
{ uid: '27006', name: '宁波事业部', code: '32175698', ratio: 43, agentCount: 6, endTime: '2027-06-30', status: true },
{ uid: '27007', name: '厦门事业部', code: '43286709', ratio: 31, agentCount: 1, endTime: '2026-08-31', status: false },
{ uid: '27008', name: '青岛事业部', code: '54397820', ratio: 44, agentCount: 7, endTime: '2026-02-28', status: true },
{ uid: '27009', name: '福州事业部', code: '65408921', ratio: 29, agentCount: 3, endTime: '2027-04-30', status: true },
{ uid: '27010', name: '昆明事业部', code: '76519032', ratio: 46, agentCount: 8, endTime: '2026-01-31', status: true },
])
// ========== MOCK DATA END ==========
// ========== PAGINATION STATE ==========
const currentPage = ref(1)
const pageSize = ref(15)
const jumpPageInput = ref('')
const pageSizeOptions = [10, 15, 20, 30, 50]
const pageSizeOptionLabels = computed(() => pageSizeOptions.map((n: number) => `${n}条/页`))
const pageSizeIndex = computed(() => { const idx = pageSizeOptions.indexOf(pageSize.value); return idx >= 0 ? idx : 0 })
const total = computed(() => divisionList.value.length)
const totalPage = computed(() => Math.max(1, Math.ceil(total.value / pageSize.value)))
const pagedList = computed(() => {
const start = (currentPage.value - 1) * pageSize.value
return divisionList.value.slice(start, start + pageSize.value)
})
const visiblePages = computed((): number[] => {
const t = totalPage.value; const cur = currentPage.value
if (t <= 7) return Array.from({ length: t }, (_: any, i: number) => i + 1)
if (cur <= 4) return [1, 2, 3, 4, 5, -1, t]
if (cur >= t - 3) return [1, -1, t - 4, t - 3, t - 2, t - 1, t]
return [1, -1, cur - 1, cur, cur + 1, -1, t]
})
const handlePageChange = (p: number) => { currentPage.value = p }
const handlePageSizeChange = (e: any) => {
const idx = Number(e.detail.value)
pageSize.value = pageSizeOptions[idx] ?? pageSizeOptions[0]
currentPage.value = 1
}
const handleJumpPage = () => {
const p = parseInt(jumpPageInput.value)
if (!isNaN(p) && p >= 1 && p <= totalPage.value) currentPage.value = p
}
// ========== END PAGINATION STATE ==========
function onSearch() { uni.showToast({ title: '查询中...', icon: 'none' }) }
function onAdd() { uni.showToast({ title: '添加中...', icon: 'none' }) }
</script>
<style scoped lang="scss">
.admin-page { padding: 0; }
.filter-card { background: #fff; padding: 24px; margin-bottom: 16px; border-radius: 4px; }
.filter-row { display: flex; flex-direction: row; align-items: center; gap: 24px; }
.label { font-size: 14px; color: #333; }
.filter-input { border: 1px solid #d9d9d9; height: 32px; width: 220px; padding: 0 12px; font-size: 14px; }
.btn { height: 32px; padding: 0 16px; font-size: 14px; border: 1px solid #d9d9d9; background: #fff; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.btn.primary { background: #1890ff; border-color: #1890ff; color: #fff; }
.content-card { background: #fff; border-radius: 4px; }
.action-bar { padding: 16px 24px; }
.table-container { padding: 0 24px 24px; }
.table-header { display: flex; flex-direction: row; background: #f8faff; border-bottom: 1px solid #f0f0f0; padding: 12px 0; }
.table-row { display: flex; flex-direction: row; border-bottom: 1px solid #f0f0f0; padding: 12px 0; align-items: center; &:hover { background: #fafafa; } }
.col { padding: 0 8px; font-size: 14px; color: #333; display: flex; align-items: center; }
.col-uid { width: 80px; } .col-avatar { width: 80px; justify-content: center; } .col-name { width: 120px; } .col-code { width: 100px; justify-content: center; } .col-ratio { width: 100px; justify-content: center; } .col-count { width: 100px; justify-content: center; } .col-time { width: 120px; justify-content: center; } .col-status { width: 80px; justify-content: center; }
.col-ops { flex: 1; justify-content: flex-end; display: flex; flex-direction: row; }
.avatar-img { width: 32px; height: 32px; border-radius: 2px; }
.op-link { color: #1890ff; cursor: pointer; }
.op-divider { color: #e8e8e8; margin: 0 8px; }
</style>

View File

@@ -0,0 +1,184 @@
<template>
<view class="admin-page">
<view class="filter-card">
<view class="filter-row">
<view class="filter-item">
<text class="label">时间选择:</text>
<view class="date-picker-mock">
<text class="placeholder">开始日期 - 结束日期</text>
<text class="icon-calendar">📅</text>
</view>
</view>
<view class="filter-item">
<text class="label">搜索:</text>
<input class="filter-input" placeholder="请输入姓名、电话、UID" />
</view>
<view class="filter-btns">
<button class="btn primary" @click="onSearch">查询</button>
</view>
</view>
</view>
<view class="content-card">
<view class="action-bar">
<button class="btn ghost small" @click="onExport">导出</button>
</view>
<view class="table-container">
<view class="table-header">
<view class="col col-id"><text>ID</text></view>
<view class="col col-img"><text>头像</text></view>
<view class="col col-info"><text>用户信息</text></view>
<view class="col col-level"><text>分销等级</text></view>
<view class="col col-stat"><text>推广用户数量</text></view>
<view class="col col-stat"><text>推广订单数量</text></view>
<view class="col col-stat"><text>推广订单金额</text></view>
<view class="col col-stat"><text>佣金总金额</text></view>
<view class="col col-stat"><text>已提现金额</text></view>
<view class="col col-stat"><text>提现次数</text></view>
<view class="col col-stat"><text>未提现金额</text></view>
<view class="col col-ops"><text>操作</text></view>
</view>
<view class="table-body">
<view v-for="item in pagedList" :key="item.id" class="table-row">
<view class="col col-id"><text>{{ item.id }}</text></view>
<view class="col col-img">
<image class="table-img" src="/static/logo.png" mode="aspectFill" />
</view>
<view class="col col-info">
<view class="user-info-box">
<text class="info-text">昵称:{{ item.nickname }}</text>
<text class="info-text">姓名:{{ item.name }}</text>
<text class="info-text">电话:{{ item.phone }}</text>
</view>
</view>
<view class="col col-level"><text>{{ item.level }}</text></view>
<view class="col col-stat"><text>{{ item.userCount }}</text></view>
<view class="col col-stat"><text>{{ item.orderCount }}</text></view>
<view class="col col-stat"><text>{{ item.orderAmount }}</text></view>
<view class="col col-stat"><text>{{ item.commissionTotal }}</text></view>
<view class="col col-stat"><text>{{ item.withdrawnAmount }}</text></view>
<view class="col col-stat"><text>{{ item.withdrawCount }}</text></view>
<view class="col col-stat"><text>{{ item.unwithdrawnAmount }}</text></view>
<view class="col col-ops">
<text class="op-link" @click="onPromoter(item)">推广人</text>
<text class="op-divider">|</text>
<text class="op-link" @click="onMore(item)">更多</text>
<text class="arrow-down">▼</text>
</view>
</view>
</view>
</view>
<CommonPagination
v-if="total > 0"
:total="total"
:loading="false"
:currentPage="currentPage"
:pageSize="pageSize"
:pageSizeOptionLabels="pageSizeOptionLabels"
:pageSizeIndex="pageSizeIndex"
:visiblePages="visiblePages"
:totalPage="totalPage"
:jumpPageInput="jumpPageInput"
@page-size-change="handlePageSizeChange"
@page-change="handlePageChange"
@update:jumpPageInput="(val: string) => { jumpPageInput.value = val }"
@jump-page="handleJumpPage"
/>
</view>
</view>
</template>
<script setup lang="uts">
import { ref, computed } from 'vue'
import CommonPagination from '@/components/CommonPagination/CommonPagination.uvue'
// ========== MOCK DATA START ==========
// TODO: 接真实接口时替换此处 promoterList 为 fetchPromoterList() 调用
const promoterList = ref([
{ id: '82764', nickname: '183****5762', name: '-', phone: '183****5762', level: '--', userCount: 0, orderCount: 0, orderAmount: '0.00', commissionTotal: '0.00', withdrawnAmount: 0, withdrawCount: 0, unwithdrawnAmount: 0 },
{ id: '82765', nickname: '张小明', name: '张小明', phone: '138****1234', level: '一级', userCount: 12, orderCount: 8, orderAmount: '2560.00', commissionTotal: '256.00', withdrawnAmount: 200, withdrawCount: 2, unwithdrawnAmount: 56 },
{ id: '82766', nickname: '李美丽', name: '李美丽', phone: '139****5678', level: '二级', userCount: 5, orderCount: 3, orderAmount: '980.00', commissionTotal: '98.00', withdrawnAmount: 50, withdrawCount: 1, unwithdrawnAmount: 48 },
{ id: '82767', nickname: '王大力', name: '王大力', phone: '150****9876', level: '一级', userCount: 28, orderCount: 20, orderAmount: '8800.00', commissionTotal: '880.00', withdrawnAmount: 800, withdrawCount: 5, unwithdrawnAmount: 80 },
{ id: '82768', nickname: '赵小红', name: '赵小红', phone: '186****1111', level: '三级', userCount: 3, orderCount: 2, orderAmount: '450.00', commissionTotal: '22.50', withdrawnAmount: 0, withdrawCount: 0, unwithdrawnAmount: 22.5 },
{ id: '82769', nickname: '陈风', name: '陈风', phone: '177****2222', level: '二级', userCount: 15, orderCount: 10, orderAmount: '3200.00', commissionTotal: '320.00', withdrawnAmount: 300, withdrawCount: 3, unwithdrawnAmount: 20 },
{ id: '82770', nickname: '刘明亮', name: '刘明亮', phone: '133****3333', level: '一级', userCount: 42, orderCount: 35, orderAmount: '15600.00', commissionTotal: '1560.00', withdrawnAmount: 1500, withdrawCount: 8, unwithdrawnAmount: 60 },
{ id: '82771', nickname: '黄小花', name: '黄小花', phone: '155****4444', level: '--', userCount: 1, orderCount: 0, orderAmount: '0.00', commissionTotal: '0.00', withdrawnAmount: 0, withdrawCount: 0, unwithdrawnAmount: 0 },
{ id: '82772', nickname: '周建国', name: '周建国', phone: '188****5555', level: '二级', userCount: 9, orderCount: 6, orderAmount: '2100.00', commissionTotal: '210.00', withdrawnAmount: 200, withdrawCount: 2, unwithdrawnAmount: 10 },
{ id: '82773', nickname: '吴晓燕', name: '吴晓燕', phone: '137****6666', level: '一级', userCount: 20, orderCount: 15, orderAmount: '6300.00', commissionTotal: '630.00', withdrawnAmount: 600, withdrawCount: 4, unwithdrawnAmount: 30 },
{ id: '82774', nickname: '郑强', name: '郑强', phone: '150****7777', level: '三级', userCount: 2, orderCount: 1, orderAmount: '320.00', commissionTotal: '16.00', withdrawnAmount: 0, withdrawCount: 0, unwithdrawnAmount: 16 },
{ id: '82775', nickname: '孙月', name: '孙月', phone: '182****8888', level: '一级', userCount: 35, orderCount: 28, orderAmount: '11200.00', commissionTotal: '1120.00', withdrawnAmount: 1000, withdrawCount: 6, unwithdrawnAmount: 120 },
{ id: '82776', nickname: '冯磊', name: '冯磊', phone: '136****9999', level: '二级', userCount: 8, orderCount: 5, orderAmount: '1800.00', commissionTotal: '180.00', withdrawnAmount: 150, withdrawCount: 2, unwithdrawnAmount: 30 },
{ id: '82777', nickname: '陈小丽', name: '陈小丽', phone: '159****0000', level: '--', userCount: 0, orderCount: 0, orderAmount: '0.00', commissionTotal: '0.00', withdrawnAmount: 0, withdrawCount: 0, unwithdrawnAmount: 0 },
{ id: '82778', nickname: '蒋涛', name: '蒋涛', phone: '178****1234', level: '一级', userCount: 18, orderCount: 12, orderAmount: '4500.00', commissionTotal: '450.00', withdrawnAmount: 400, withdrawCount: 3, unwithdrawnAmount: 50 },
{ id: '82779', nickname: '卫芳', name: '卫芳', phone: '132****5678', level: '三级', userCount: 4, orderCount: 3, orderAmount: '750.00', commissionTotal: '37.50', withdrawnAmount: 30, withdrawCount: 1, unwithdrawnAmount: 7.5 },
{ id: '82780', nickname: '韩超', name: '韩超', phone: '156****9876', level: '二级', userCount: 11, orderCount: 8, orderAmount: '2800.00', commissionTotal: '280.00', withdrawnAmount: 250, withdrawCount: 3, unwithdrawnAmount: 30 },
{ id: '82781', nickname: '杨静', name: '杨静', phone: '199****1111', level: '一级', userCount: 25, orderCount: 18, orderAmount: '7200.00', commissionTotal: '720.00', withdrawnAmount: 700, withdrawCount: 5, unwithdrawnAmount: 20 },
{ id: '82782', nickname: '秦刚', name: '秦刚', phone: '135****2222', level: '--', userCount: 0, orderCount: 0, orderAmount: '0.00', commissionTotal: '0.00', withdrawnAmount: 0, withdrawCount: 0, unwithdrawnAmount: 0 },
{ id: '82783', nickname: '许丽华', name: '许丽华', phone: '180****3333', level: '二级', userCount: 7, orderCount: 4, orderAmount: '1400.00', commissionTotal: '140.00', withdrawnAmount: 100, withdrawCount: 1, unwithdrawnAmount: 40 },
])
// ========== MOCK DATA END ==========
// ========== PAGINATION STATE ==========
const currentPage = ref(1)
const pageSize = ref(15)
const jumpPageInput = ref('')
const pageSizeOptions = [10, 15, 20, 30, 50]
const pageSizeOptionLabels = computed(() => pageSizeOptions.map((n: number) => `${n}条/页`))
const pageSizeIndex = computed(() => { const idx = pageSizeOptions.indexOf(pageSize.value); return idx >= 0 ? idx : 0 })
const total = computed(() => promoterList.value.length)
const totalPage = computed(() => Math.max(1, Math.ceil(total.value / pageSize.value)))
const pagedList = computed(() => {
const start = (currentPage.value - 1) * pageSize.value
return promoterList.value.slice(start, start + pageSize.value)
})
const visiblePages = computed((): number[] => {
const t = totalPage.value; const cur = currentPage.value
if (t <= 7) return Array.from({ length: t }, (_: any, i: number) => i + 1)
if (cur <= 4) return [1, 2, 3, 4, 5, -1, t]
if (cur >= t - 3) return [1, -1, t - 4, t - 3, t - 2, t - 1, t]
return [1, -1, cur - 1, cur, cur + 1, -1, t]
})
const handlePageChange = (p: number) => { currentPage.value = p }
const handlePageSizeChange = (e: any) => {
const idx = Number(e.detail.value)
pageSize.value = pageSizeOptions[idx] ?? pageSizeOptions[0]
currentPage.value = 1
}
const handleJumpPage = () => {
const p = parseInt(jumpPageInput.value)
if (!isNaN(p) && p >= 1 && p <= totalPage.value) currentPage.value = p
}
// ========== END PAGINATION STATE ==========
function onSearch() { uni.showToast({ title: '查询中...', icon: 'none' }) }
function onExport() { uni.showToast({ title: '开始导出', icon: 'none' }) }
function onPromoter(item: any) { uni.showToast({ title: '推广人: ' + item.id, icon: 'none' }) }
function onMore(item: any) { uni.showToast({ title: '更多: ' + item.id, icon: 'none' }) }
</script>
<style scoped lang="scss">
.admin-page { padding: 0; }
.filter-card { background: #fff; padding: 24px; margin-bottom: 16px; border-radius: 4px; }
.filter-row { display: flex; flex-direction: row; align-items: center; gap: 24px; }
.label { font-size: 14px; color: #333; }
.date-picker-mock { display: flex; flex-direction: row; align-items: center; justify-content: space-between; border: 1px solid #d9d9d9; border-radius: 2px; height: 32px; width: 260px; padding: 0 12px; background: #fff; .placeholder { font-size: 14px; color: #bfbfbf; } .icon-calendar { font-size: 14px; color: #bfbfbf; } }
.filter-input { border: 1px solid #d9d9d9; height: 32px; width: 220px; padding: 0 12px; font-size: 14px; }
.btn { height: 32px; padding: 0 16px; font-size: 14px; border-radius: 2px; border: 1px solid #d9d9d9; background: #fff; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.btn.primary { background: #1890ff; border-color: #1890ff; color: #fff; }
.btn.ghost { color: #666; background: #fff; }
.btn.small { height: 28px; padding: 0 12px; font-size: 13px; }
.content-card { background: #fff; border-radius: 4px; }
.action-bar { padding: 16px 24px; }
.table-container { padding: 0 24px 24px; }
.table-header { display: flex; flex-direction: row; background: #f8faff; border-bottom: 1px solid #f0f0f0; padding: 12px 0; }
.table-row { display: flex; flex-direction: row; border-bottom: 1px solid #f0f0f0; padding: 12px 0; align-items: center; &:hover { background: #fafafa; } }
.col { padding: 0 8px; display: flex; align-items: center; font-size: 14px; color: #333; }
.col-id { width: 60px; } .col-img { width: 80px; justify-content: center; } .col-info { width: 180px; } .col-level { width: 100px; justify-content: center; } .col-stat { width: 110px; justify-content: center; } .col-ops { flex: 1; justify-content: flex-end; padding-right: 16px; }
.table-img { width: 40px; height: 40px; border-radius: 4px; }
.user-info-box { display: flex; flex-direction: column; }
.info-text { font-size: 12px; color: #666; margin-bottom: 2px; }
.op-link { color: #1890ff; cursor: pointer; }
.op-divider { color: #e8e8e8; margin: 0 8px; }
.arrow-down { font-size: 10px; color: #1890ff; margin-left: 4px; }
.pagination { padding: 16px 24px; border-top: 1px solid #f0f0f0; }
.page-info { font-size: 14px; color: #999; }
</style>

View File

@@ -1,334 +0,0 @@
<template>
<view class="admin-page">
<view class="filter-card">
<view class="filter-row">
<view class="filter-item">
<text class="label">代理商查询:</text>
<input class="filter-input" placeholder="请输入姓名或UID" v-model="searchQuery" @confirm="onSearch" />
</view>
<view class="filter-btns">
<button class="btn primary" @click="onSearch">查询</button>
<button class="btn" @click="onReset">重置</button>
</view>
</view>
</view>
<view class="content-card">
<view class="action-bar">
<button class="btn primary small" @click="onAdd">添加代理商</button>
</view>
<view class="table-container">
<view v-if="isLoading" class="loading-mask">
<text class="loading-text">数据加载中...</text>
</view>
<view class="table-header">
<view class="col col-uid"><text>用户UID</text></view>
<view class="col col-avatar"><text>头像</text></view>
<view class="col col-name"><text>名称</text></view>
<view class="col col-ratio"><text>分佣比例</text></view>
<view class="col col-dept"><text>所属事业部</text></view>
<view class="col col-count"><text>员工数量</text></view>
<view class="col col-time"><text>过期时间</text></view>
<view class="col col-status"><text>状态</text></view>
<view class="col col-ops"><text>操作</text></view>
</view>
<view class="table-body">
<view v-if="agentList.length === 0 && !isLoading" class="empty-row">
<text>暂无代理商数据</text>
</view>
<view v-for="item in agentList" :key="item.uid" class="table-row">
<view class="col col-uid"><text class="td-txt-small">{{ item.uid }}</text></view>
<view class="col col-avatar">
<image class="avatar-img" src="/static/logo.png" mode="aspectFill" />
</view>
<view class="col col-name"><text>{{ item.name }}</text></view>
<view class="col col-ratio"><text>{{ item.commission_ratio }}%</text></view>
<view class="col col-dept"><text>{{ item.division_name || '-' }}</text></view>
<view class="col col-count"><text>{{ item.staffCount }}</text></view>
<view class="col col-time"><text>{{ item.end_time ? item.end_time.substring(0, 10) : '-' }}</text></view>
<view class="col col-status">
<switch :checked="item.is_enabled" color="#1890ff" scale="0.8" @change="() => onToggleStatus(item)" />
</view>
<view class="col col-ops">
<text class="op-link" @click="onEdit(item)">编辑</text>
<text class="op-divider">|</text>
<text class="op-link danger" @click="onDelete(item.uid)">删除</text>
</view>
</view>
</view>
</view>
<view class="pagination">
<view class="pager-btns">
<button class="btn small" :disabled="page <= 1" @click="onPrevPage">上一页</button>
<text class="page-num">第 {{ page }} 页</text>
<button class="btn small" :disabled="agentList.length < pageSize" @click="onNextPage">下一页</button>
</view>
<text class="page-info">共 {{ agentList.length }} 条记录</text>
</view>
</view>
<!-- 添加/编辑 弹窗 -->
<view v-if="editPopupVisible" class="popup-mask" @click="closeEditModal">
<view class="popup-card" @click.stop>
<view class="popup-header">
<text class="popup-title">{{ isEdit ? '编辑代理商' : '添加代理商' }}</text>
<text class="popup-close" @click="closeEditModal">×</text>
</view>
<view class="popup-body">
<view class="popup-item" v-if="!isEdit">
<text class="popup-label">用户 UID</text>
<input v-model="editForm.uid" class="popup-input" placeholder="请输入代理商 UID" />
</view>
<view class="popup-item">
<text class="popup-label">所属事业部</text>
<picker :value="divisionIndex" :range="divisionOptions" range-key="name" @change="onDivisionChange">
<view class="select-box">
<text>{{ divisionOptions[divisionIndex]?.name || '请选择事业部' }}</text>
<text class="arrow">▼</text>
</view>
</picker>
</view>
<view class="popup-item">
<text class="popup-label">代理商名称</text>
<input v-model="editForm.name" class="popup-input" placeholder="请输入名称" />
</view>
<view class="popup-item">
<text class="popup-label">分佣比例 (%)</text>
<input v-model="editForm.commission_ratio" type="digit" class="popup-input" placeholder="0 - 100" />
</view>
<view class="popup-item">
<text class="popup-label">过期时间</text>
<input v-model="editForm.end_time" class="popup-input" placeholder="YYYY-MM-DD" />
</view>
<view class="popup-item popup-row">
<text class="popup-label">启用状态</text>
<switch :checked="editForm.is_enabled" color="#1890ff" scale="0.8" @change="(e : any) => editForm.is_enabled = e.detail.value" />
</view>
</view>
<view class="popup-footer">
<button class="btn" @click="closeEditModal">取消</button>
<button class="btn primary" @click="handleSave">保存</button>
</view>
</view>
</view>
</view>
</template>
<script setup lang="uts">
import { ref, onMounted, reactive } from 'vue'
import { getAgentList, saveAgent, deleteAgent, getDivisionList, type Agent, type Division } from '@/services/admin/distributionService.uts'
const agentList = ref<Agent[]>([])
const isLoading = ref(false)
const searchQuery = ref('')
const page = ref(1)
const pageSize = 20
// 事业部选项 (供选择器使用)
const divisionOptions = ref<Division[]>([])
const divisionIndex = ref(0)
// 弹窗状态
const editPopupVisible = ref(false)
const isEdit = ref(false)
const editForm = reactive({
uid: '',
division_uid: '',
name: '',
commission_ratio: 0,
is_enabled: true,
end_time: ''
})
onMounted(() => {
loadAgents()
loadDivisions()
})
async function loadAgents() {
isLoading.value = true
try {
const res = await getAgentList(searchQuery.value || null, page.value, pageSize)
agentList.value = res
} catch (e) {
uni.showToast({ title: '加载失败', icon: 'none' })
} finally {
isLoading.value = false
}
}
async function loadDivisions() {
const res = await getDivisionList(null, 1, 100)
divisionOptions.value = res
}
function onSearch() {
page.value = 1
loadAgents()
}
function onReset() {
searchQuery.value = ''
page.value = 1
loadAgents()
}
function onAdd() {
isEdit.value = false
Object.assign(editForm, {
uid: '',
division_uid: '',
name: '',
commission_ratio: 0,
is_enabled: true,
end_time: ''
})
divisionIndex.value = 0
editPopupVisible.value = true
}
function onEdit(item : Agent) {
isEdit.value = true
Object.assign(editForm, {
uid: item.uid,
division_uid: item.division_uid,
name: item.name,
commission_ratio: item.commission_ratio,
is_enabled: item.is_enabled,
end_time: item.end_time || ''
})
const idx = divisionOptions.value.findIndex(d => d.uid === item.division_uid)
divisionIndex.value = idx > -1 ? idx : 0
editPopupVisible.value = true
}
function closeEditModal() {
editPopupVisible.value = false
}
function onDivisionChange(e : any) {
divisionIndex.value = e.detail.value as number
editForm.division_uid = divisionOptions.value[divisionIndex.value].uid
}
async function handleSave() {
if (!editForm.uid || !editForm.division_uid || !editForm.name) {
uni.showToast({ title: '请完善信息', icon: 'none' })
return
}
isLoading.value = true
try {
const success = await saveAgent(editForm)
if (success) {
uni.showToast({ title: '保存成功', icon: 'success' })
editPopupVisible.value = false
loadAgents()
}
} finally {
isLoading.value = false
}
}
async function onDelete(uid : string) {
uni.showModal({
title: '确认删除',
content: '确定要删除该代理商吗?',
success: async (res) => {
if (res.confirm) {
isLoading.value = true
try {
const success = await deleteAgent(uid)
if (success) {
uni.showToast({ title: '删除成功' })
loadAgents()
}
} finally {
isLoading.value = false
}
}
}
})
}
async function onToggleStatus(item : Agent) {
const updated = { ...item, is_enabled: !item.is_enabled }
const success = await saveAgent(updated)
if (success) {
item.is_enabled = !item.is_enabled
uni.showToast({ title: '状态已更新' })
}
}
function onPrevPage() {
if (page.value > 1) {
page.value--
loadAgents()
}
}
function onNextPage() {
if (agentList.value.length < pageSize) return
page.value++
loadAgents()
}
</script>
<style scoped lang="scss">
.admin-page { padding: 0; }
.filter-card { background: #fff; padding: 24px; margin-bottom: 16px; border-radius: 4px; }
.filter-row { display: flex; flex-direction: row; align-items: center; gap: 24px; }
.label { font-size: 14px; color: #333; }
.filter-input { border: 1px solid #d9d9d9; height: 32px; width: 220px; padding: 0 12px; font-size: 14px; border-radius: 4px; }
.btn { height: 32px; padding: 0 16px; font-size: 14px; border: 1px solid #d9d9d9; background: #fff; display: flex; align-items: center; justify-content: center; cursor: pointer; border-radius: 4px; }
.btn.primary { background: #1890ff; border-color: #1890ff; color: #fff; }
.btn.small { height: 28px; padding: 0 12px; font-size: 13px; }
.content-card { background: #fff; border-radius: 4px; position: relative; }
.action-bar { padding: 16px 24px; }
.table-container { padding: 0 24px 24px; min-height: 200px; }
.table-header { display: flex; flex-direction: row; background: #f8faff; border-bottom: 1px solid #f0f0f0; padding: 12px 0; }
.table-row { display: flex; flex-direction: row; border-bottom: 1px solid #f0f0f0; padding: 12px 0; align-items: center; &:hover { background: #fafafa; } }
.col { padding: 0 8px; font-size: 14px; color: #333; display: flex; align-items: center; }
.col-uid { width: 80px; } .col-avatar { width: 80px; justify-content: center; } .col-name { width: 120px; } .col-ratio { width: 100px; justify-content: center; } .col-dept { width: 140px; } .col-count { width: 100px; justify-content: center; } .col-time { width: 120px; justify-content: center; } .col-status { width: 80px; justify-content: center; } .col-ops { flex: 1; justify-content: flex-end; }
.avatar-img { width: 32px; height: 32px; border-radius: 2px; }
.op-link { color: #1890ff; cursor: pointer; &.danger { color: #ff4d4f; } }
.op-divider { color: #e8e8e8; margin: 0 8px; }
.pagination { padding: 16px 24px; border-top: 1px solid #f0f0f0; display: flex; flex-direction: row; align-items: center; justify-content: space-between; }
.pager-btns { display: flex; flex-direction: row; align-items: center; gap: 12px; }
.page-num { font-size: 14px; color: #333; }
.page-info { font-size: 14px; color: #999; }
.loading-mask { position: absolute; top: 0; left: 0; right: 0; bottom: 0; background: rgba(255,255,255,0.7); display: flex; align-items: center; justify-content: center; z-index: 10; }
.loading-text { color: #1890ff; font-size: 14px; }
.empty-row { padding: 40px 0; text-align: center; color: #999; font-size: 14px; }
/* 弹窗样式 */
.popup-mask { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background-color: rgba(0, 0, 0, 0.5); display: flex; align-items: center; justify-content: center; z-index: 999; }
.popup-card { width: 500px; background-color: #fff; border-radius: 8px; display: flex; flex-direction: column; overflow: hidden; }
.popup-header { display: flex; flex-direction: row; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid #f0f0f0; }
.popup-title { font-size: 16px; font-weight: bold; color: #333; }
.popup-close { font-size: 20px; color: #999; cursor: pointer; padding: 4px; }
.popup-body { padding: 24px; display: flex; flex-direction: column; gap: 16px; }
.popup-item { display: flex; flex-direction: column; gap: 8px; }
.popup-row { flex-direction: row; align-items: center; justify-content: space-between; }
.popup-label { font-size: 14px; color: #666; }
.popup-input { border: 1px solid #d9d9d9; border-radius: 4px; height: 36px; padding: 0 12px; font-size: 14px; width: 100%; }
.select-box { border: 1px solid #d9d9d9; border-radius: 4px; height: 36px; padding: 0 12px; display: flex; flex-direction: row; align-items: center; justify-content: space-between; text { font-size: 14px; color: #333; } .arrow { font-size: 10px; color: #bfbfbf; } }
.popup-footer { padding: 16px 24px; border-top: 1px solid #f0f0f0; display: flex; flex-direction: row; justify-content: flex-end; gap: 12px; }
</style>

View File

@@ -17,7 +17,7 @@
</view>
<view class="content-card">
<view class="action-bar">
<button class="btn primary small" @click="openEditModal(null)">添加等级</button>
<button class="btn primary small" @click="onAdd">添加等级</button>
</view>
<view class="table-container">
<view class="table-header">
@@ -33,7 +33,7 @@
<view class="col col-ops"><text>操作</text></view>
</view>
<view class="table-body">
<view v-for="item in levelList" :key="item.id" class="table-row">
<view v-for="item in pagedList" :key="item.id" class="table-row">
<view class="col col-id"><text>{{ item.id }}</text></view>
<view class="col col-img">
<image class="table-img" src="/static/logo.png" mode="aspectFill" />
@@ -42,190 +42,104 @@
<view class="col col-level"><text>{{ item.level }}</text></view>
<view class="col col-percent"><text>{{ item.percent1 }}%</text></view>
<view class="col col-percent"><text>{{ item.percent2 }}%</text></view>
<view class="col col-stat"><text>{{ item.task_total }}</text></view>
<view class="col col-stat"><text>{{ item.task_finish }}</text></view>
<view class="col col-stat"><text>{{ item.taskTotal }}</text></view>
<view class="col col-stat"><text>{{ item.taskFinish }}</text></view>
<view class="col col-status">
<switch :checked="item.is_visible" color="#1890ff" scale="0.8" @change="() => onToggleVisible(item)" />
<switch :checked="item.show" color="#1890ff" scale="0.8" />
</view>
<view class="col col-ops">
<text class="op-link">等级任务</text>
<text class="op-divider">|</text>
<text class="op-link" @click="openEditModal(item)">编辑</text>
<text class="op-link">编辑</text>
<text class="op-divider">|</text>
<text class="op-link" @click="onDelete(item.id)">删除</text>
<text class="op-link">删除</text>
</view>
</view>
</view>
</view>
<view class="pagination">
<text class="page-info">共 {{ levelList.length }} 条</text>
</view>
</view>
<view v-if="editPopupVisible" class="popup-mask" @click="closeEditModal">
<view class="popup-card" @click.stop>
<view class="popup-header">
<text class="popup-title">{{ editForm.id == null ? '添加分销等级' : '编辑分销等级' }}</text>
<text class="popup-close" @click="closeEditModal">×</text>
</view>
<view class="popup-body">
<view class="popup-item">
<text class="popup-label">等级名称</text>
<input v-model="editForm.name" class="popup-input" placeholder="如:一级分销员" />
</view>
<view class="popup-item">
<text class="popup-label">等级权重</text>
<input v-model="editForm.level" type="number" class="popup-input" placeholder="如1" />
</view>
<view class="popup-item">
<text class="popup-label">一级分佣比例 (%)</text>
<input v-model="editForm.percent1" type="digit" class="popup-input" placeholder="0 - 100" />
</view>
<view class="popup-item">
<text class="popup-label">二级分佣比例 (%)</text>
<input v-model="editForm.percent2" type="digit" class="popup-input" placeholder="0 - 100" />
</view>
<view class="popup-item">
<text class="popup-label">任务总数</text>
<input v-model="editForm.task_total" type="number" class="popup-input" placeholder="如0" />
</view>
<view class="popup-item">
<text class="popup-label">需完成数量</text>
<input v-model="editForm.task_finish" type="number" class="popup-input" placeholder="如0" />
</view>
<view class="popup-item popup-row">
<text class="popup-label">是否显示</text>
<switch :checked="!!editForm.is_visible" color="#1890ff" scale="0.8" @change="(e) => editForm.is_visible = e.detail.value" />
</view>
</view>
<view class="popup-footer">
<button class="btn" @click="closeEditModal">取消</button>
<button class="btn primary" @click="handleSave">保存</button>
</view>
</view>
<CommonPagination
v-if="total > 0"
:total="total"
:loading="false"
:currentPage="currentPage"
:pageSize="pageSize"
:pageSizeOptionLabels="pageSizeOptionLabels"
:pageSizeIndex="pageSizeIndex"
:visiblePages="visiblePages"
:totalPage="totalPage"
:jumpPageInput="jumpPageInput"
@page-size-change="handlePageSizeChange"
@page-change="handlePageChange"
@update:jumpPageInput="(val: string) => { jumpPageInput.value = val }"
@jump-page="handleJumpPage"
/>
</view>
</view>
</template>
<script setup lang="uts">
import { ref, onMounted, reactive } from 'vue'
import { getDistributionLevelList, saveDistributionLevel, deleteDistributionLevel, DistributionLevel } from '@/services/admin/distributionService.uts'
import { ref, computed } from 'vue'
import CommonPagination from '@/components/CommonPagination/CommonPagination.uvue'
const levelList = ref<DistributionLevel[]>([])
const isLoading = ref(false)
// ========== MOCK DATA START ==========
// TODO: 接真实接口时替换此处 levelList 为 fetchLevelList() 调用
const levelList = ref([
{ id: '1', name: '一级分销员', level: 1, percent1: 20.00, percent2: 10.00, taskTotal: 5, taskFinish: 3, show: true },
{ id: '2', name: '二级分销员', level: 2, percent1: 15.00, percent2: 8.00, taskTotal: 3, taskFinish: 2, show: true },
{ id: '3', name: '三级分销员', level: 3, percent1: 10.00, percent2: 5.00, taskTotal: 2, taskFinish: 1, show: true },
{ id: '4', name: '铂金分销员', level: 4, percent1: 25.00, percent2: 12.00, taskTotal: 8, taskFinish: 6, show: true },
{ id: '5', name: '钻石分销员', level: 5, percent1: 30.00, percent2: 15.00, taskTotal: 10, taskFinish: 8, show: false },
{ id: '6', name: '精英分销员', level: 6, percent1: 18.00, percent2: 9.00, taskTotal: 4, taskFinish: 4, show: true },
{ id: '7', name: '超级分销员', level: 7, percent1: 35.00, percent2: 18.00, taskTotal: 12, taskFinish: 10, show: true },
{ id: '8', name: '黄金分销员', level: 8, percent1: 22.00, percent2: 11.00, taskTotal: 6, taskFinish: 5, show: true },
{ id: '9', name: '白银分销员', level: 9, percent1: 12.00, percent2: 6.00, taskTotal: 3, taskFinish: 1, show: false },
{ id: '10', name: '青铜分销员', level: 10, percent1: 8.00, percent2: 4.00, taskTotal: 2, taskFinish: 0, show: true },
{ id: '11', name: '新人分销员', level: 11, percent1: 5.00, percent2: 2.00, taskTotal: 1, taskFinish: 0, show: true },
{ id: '12', name: 'VIP分销员', level: 12, percent1: 28.00, percent2: 14.00, taskTotal: 7, taskFinish: 7, show: true },
{ id: '13', name: '明星分销员', level: 13, percent1: 32.00, percent2: 16.00, taskTotal: 9, taskFinish: 8, show: true },
{ id: '14', name: '王者分销员', level: 14, percent1: 40.00, percent2: 20.00, taskTotal: 15, taskFinish: 12, show: false },
{ id: '15', name: '传奇分销员', level: 15, percent1: 45.00, percent2: 22.00, taskTotal: 20, taskFinish: 18, show: true },
{ id: '16', name: '荣耀分销员', level: 16, percent1: 38.00, percent2: 19.00, taskTotal: 11, taskFinish: 9, show: true },
{ id: '17', name: '至尊分销员', level: 17, percent1: 42.00, percent2: 21.00, taskTotal: 14, taskFinish: 11, show: true },
{ id: '18', name: '神话分销员', level: 18, percent1: 48.00, percent2: 24.00, taskTotal: 18, taskFinish: 15, show: false },
{ id: '19', name: '无双分销员', level: 19, percent1: 50.00, percent2: 25.00, taskTotal: 20, taskFinish: 20, show: true },
{ id: '20', name: '巅峰分销员', level: 20, percent1: 55.00, percent2: 28.00, taskTotal: 25, taskFinish: 22, show: true },
])
// ========== MOCK DATA END ==========
const editPopupVisible = ref(false)
const editForm = reactive<DistributionLevel>({
id: undefined,
name: '',
level: 1,
percent1: 0,
percent2: 0,
task_total: 0,
task_finish: 0,
is_visible: true
// ========== PAGINATION STATE ==========
const currentPage = ref(1)
const pageSize = ref(15)
const jumpPageInput = ref('')
const pageSizeOptions = [10, 15, 20, 30, 50]
const pageSizeOptionLabels = computed(() => pageSizeOptions.map((n: number) => `${n}条/页`))
const pageSizeIndex = computed(() => { const idx = pageSizeOptions.indexOf(pageSize.value); return idx >= 0 ? idx : 0 })
const total = computed(() => levelList.value.length)
const totalPage = computed(() => Math.max(1, Math.ceil(total.value / pageSize.value)))
const pagedList = computed(() => {
const start = (currentPage.value - 1) * pageSize.value
return levelList.value.slice(start, start + pageSize.value)
})
onMounted(() => {
loadLevels()
const visiblePages = computed((): number[] => {
const t = totalPage.value; const cur = currentPage.value
if (t <= 7) return Array.from({ length: t }, (_: any, i: number) => i + 1)
if (cur <= 4) return [1, 2, 3, 4, 5, -1, t]
if (cur >= t - 3) return [1, -1, t - 4, t - 3, t - 2, t - 1, t]
return [1, -1, cur - 1, cur, cur + 1, -1, t]
})
async function loadLevels() {
isLoading.value = true
try {
const res = await getDistributionLevelList()
levelList.value = res
} catch (e) {
uni.showToast({ title: '加载失败', icon: 'none' })
} finally {
isLoading.value = false
}
const handlePageChange = (p: number) => { currentPage.value = p }
const handlePageSizeChange = (e: any) => {
const idx = Number(e.detail.value)
pageSize.value = pageSizeOptions[idx] ?? pageSizeOptions[0]
currentPage.value = 1
}
function onSearch() {
loadLevels()
const handleJumpPage = () => {
const p = parseInt(jumpPageInput.value)
if (!isNaN(p) && p >= 1 && p <= totalPage.value) currentPage.value = p
}
// ========== END PAGINATION STATE ==========
function openEditModal(item: DistributionLevel | null) {
if (item != null) {
Object.assign(editForm, item)
} else {
Object.assign(editForm, {
id: undefined,
name: '',
level: levelList.value.length + 1,
percent1: 0,
percent2: 0,
task_total: 0,
task_finish: 0,
is_visible: true
})
}
editPopupVisible.value = true
}
function closeEditModal() {
editPopupVisible.value = false
}
async function handleSave() {
if (!editForm.name) {
uni.showToast({ title: '请输入等级名称', icon: 'none' })
return
}
isLoading.value = true
try {
const success = await saveDistributionLevel(editForm as DistributionLevel)
if (success) {
uni.showToast({ title: '保存成功', icon: 'success' })
closeEditModal()
loadLevels()
} else {
uni.showToast({ title: '保存失败', icon: 'none' })
}
} catch (e) {
uni.showToast({ title: '保存异常', icon: 'none' })
} finally {
isLoading.value = false
}
}
async function onDelete(id: string | undefined) {
if (id == null) return
uni.showModal({
title: '确认删除',
content: '确定要删除该分销等级吗?',
success: async (res) => {
if (res.confirm) {
isLoading.value = true
try {
const success = await deleteDistributionLevel(id)
if (success) {
uni.showToast({ title: '删除成功' })
loadLevels()
}
} finally {
isLoading.value = false
}
}
}
})
}
async function onToggleVisible(item: DistributionLevel) {
const updated = { ...item, is_visible: !item.is_visible } as DistributionLevel
const success = await saveDistributionLevel(updated)
if (success) {
loadLevels()
}
}
function onSearch() { uni.showToast({ title: '查询中...', icon: 'none' }) }
function onAdd() { uni.showToast({ title: '添加中...', icon: 'none' }) }
</script>
<style scoped lang="scss">
.admin-page { padding: 0; }
@@ -242,103 +156,11 @@ async function onToggleVisible(item: DistributionLevel) {
.table-header { display: flex; flex-direction: row; background: #f8faff; border-bottom: 1px solid #f0f0f0; padding: 12px 0; }
.table-row { display: flex; flex-direction: row; border-bottom: 1px solid #f0f0f0; padding: 12px 0; align-items: center; &:hover { background: #fafafa; } }
.col { padding: 0 8px; display: flex; align-items: center; font-size: 14px; color: #333; }
.col-id { width: 50px; } .col-img { width: 80px; justify-content: center; } .col-name { width: 120px; } .col-level { width: 80px; justify-content: center; } .col-percent { width: 120px; justify-content: center; } .col-stat { width: 100px; justify-content: center; } .col-status { width: 100px; justify-content: center; } .col-ops { flex: 1; justify-content: flex-end; padding-right: 16px; }
.col-id { width: 50px; } .col-img { width: 80px; justify-content: center; } .col-name { width: 120px; } .col-level { width: 80px; justify-content: center; } .col-percent { width: 120px; justify-content: center; } .col-stat { width: 100px; justify-content: center; } .col-status { width: 100px; justify-content: center; }
.col-ops { flex: 1; justify-content: flex-end; padding-right: 16px; display: flex; flex-direction: row; }
.table-img { width: 32px; height: 32px; border-radius: 2px; }
.op-link { color: #1890ff; cursor: pointer; }
.op-divider { color: #e8e8e8; margin: 0 8px; }
.pagination { padding: 16px 24px; border-top: 1px solid #f0f0f0; }
.page-info { font-size: 14px; color: #999; }
/* 弹窗样式 */
.popup-mask {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: rgba(0, 0, 0, 0.5);
display: flex;
align-items: center;
justify-content: center;
z-index: 999;
}
.popup-card {
width: 500px;
background-color: #fff;
border-radius: 8px;
display: flex;
flex-direction: column;
overflow: hidden;
}
.popup-header {
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
padding: 16px 20px;
border-bottom: 1px solid #f0f0f0;
}
.popup-title {
font-size: 16px;
font-weight: bold;
color: #333;
}
.popup-close {
font-size: 20px;
color: #999;
cursor: pointer;
padding: 4px;
}
.popup-body {
padding: 24px;
display: flex;
flex-direction: column;
gap: 16px;
}
.popup-item {
display: flex;
flex-direction: column;
gap: 8px;
}
.popup-row {
flex-direction: row;
align-items: center;
justify-content: space-between;
}
.popup-label {
font-size: 14px;
color: #666;
}
.popup-input {
border: 1px solid #d9d9d9;
border-radius: 4px;
height: 36px;
padding: 0 12px;
font-size: 14px;
width: 100%;
}
.popup-footer {
padding: 16px 24px;
border-top: 1px solid #f0f0f0;
display: flex;
flex-direction: row;
justify-content: flex-end;
gap: 12px;
}
.btn.ghost {
background-color: #fff;
color: #666;
border: 1px solid #d9d9d9;
}
</style>

View File

@@ -1,4 +1,4 @@
<template>
<template>
<view class="admin-page">
<view class="content-card">
<view class="tabs-row">