340 lines
11 KiB
HTML
340 lines
11 KiB
HTML
<!doctype html>
|
|
<html lang="zh-CN">
|
|
<head>
|
|
<meta charset="UTF-8" />
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
<title id="page-title">神彩算 - 我的分销</title>
|
|
<script src="../public/css/layui/layui.js"></script>
|
|
<script src="../config.js"></script>
|
|
<script src="../utils/ApiClient.js"></script>
|
|
<script src="../utils/DateUtil.js"></script>
|
|
<script src="../utils/CommonUtil.js"></script>
|
|
<link rel="stylesheet" href="../public/css/layui/css/layui.css" />
|
|
<link rel="stylesheet" href="../public/css/public.css" />
|
|
<link rel="stylesheet" href="../public/css/distribution.css" />
|
|
</head>
|
|
<body>
|
|
<!-- Header -->
|
|
<nav class="topbar" id="navbar">
|
|
<div class="topbar__inner">
|
|
<a href="index.html" class="topbar__brand">
|
|
<img
|
|
src="../images/home-logo.png"
|
|
alt="神彩算"
|
|
class="topbar__logo"
|
|
/>
|
|
</a>
|
|
<div class="topbar__nav" id="navLotteryItems">
|
|
<!-- <a href="index.html" class="topbar__nav-link">首页</a> -->
|
|
</div>
|
|
<div class="topbar__user">
|
|
<div id="notLoggedInBox" class="topbar__guest">
|
|
<a href="login.html" class="topbar__btn topbar__btn--ghost">登录</a>
|
|
<a href="reg.html" class="topbar__btn topbar__btn--primary"
|
|
>免费注册</a
|
|
>
|
|
</div>
|
|
<div id="loggedInBox" class="topbar__logged" style="display: none">
|
|
<a href="usercenter.html" class="topbar__profile">
|
|
<img
|
|
id="userAvatar"
|
|
src="../public/img/userimg.png"
|
|
alt=""
|
|
class="topbar__avatar"
|
|
/>
|
|
<div class="topbar__meta">
|
|
<span id="userName" class="topbar__uname">用户</span>
|
|
<span id="userLevel" class="topbar__ubadge">会员</span>
|
|
</div>
|
|
</a>
|
|
<button class="topbar__btn topbar__btn--logout" onclick="logout()">
|
|
退出登录
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</nav>
|
|
|
|
<!-- Main Content -->
|
|
<main class="page-main">
|
|
<!-- Stats -->
|
|
<div class="stats-grid">
|
|
<div class="stat-card">
|
|
<div class="stat-label">下级总数</div>
|
|
<div class="stat-value">
|
|
<span id="totalSubordinates">0</span><span class="unit">人</span>
|
|
</div>
|
|
</div>
|
|
<div class="stat-card">
|
|
<div class="stat-label">一级下级</div>
|
|
<div class="stat-value">
|
|
<span id="levelOneCount">0</span><span class="unit">人</span>
|
|
</div>
|
|
</div>
|
|
<div class="stat-card">
|
|
<div class="stat-label">二级下级</div>
|
|
<div class="stat-value">
|
|
<span id="levelTwoCount">0</span><span class="unit">人</span>
|
|
</div>
|
|
</div>
|
|
<div class="stat-card">
|
|
<div class="stat-label">分销收益</div>
|
|
<div class="stat-value">
|
|
<span id="distIncome">0.00</span><span class="unit">元</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Table -->
|
|
<div class="table-section">
|
|
<div class="table-section-title">
|
|
<i class="layui-icon layui-icon-group"></i> 下级用户列表
|
|
</div>
|
|
<table id="distTable" lay-filter="distTable" lay-even></table>
|
|
<div id="distPage"></div>
|
|
</div>
|
|
</main>
|
|
|
|
<!-- Footer -->
|
|
<footer class="site-footer">
|
|
<div class="site-footer__inner">
|
|
<img
|
|
src="../images/home-logo.png"
|
|
alt="神彩算"
|
|
class="site-footer__logo"
|
|
/>
|
|
<p id="copyright-info">神彩算以开奖数据、免费文章、资讯推荐为核心</p>
|
|
<div class="site-footer__meta">
|
|
<a
|
|
id="beian"
|
|
href="https://beian.miit.gov.cn/"
|
|
target="_blank"
|
|
style="font-size: 12px; color: rgba(255, 255, 255, 0.5)"
|
|
>工信部备案号</a
|
|
>
|
|
<span id="additional-info">本站仅供数据分析参考</span>
|
|
</div>
|
|
</div>
|
|
</footer>
|
|
<button
|
|
class="gotop"
|
|
id="backTop"
|
|
type="button"
|
|
onclick="window.scrollTo({ top: 0, behavior: 'smooth' })"
|
|
>
|
|
↑
|
|
</button>
|
|
|
|
<script>
|
|
layui.use(["layer", "jquery", "table", "laypage"], function () {
|
|
var layer = layui.layer;
|
|
var $ = layui.$;
|
|
var table = layui.table;
|
|
var laypage = layui.laypage;
|
|
|
|
// Load page config
|
|
CommonUtil.loadPageConfig({ ads: false, links: false });
|
|
|
|
// Check login state for topbar
|
|
checkLogin();
|
|
renderNav();
|
|
|
|
// Check auth and load data
|
|
CommonUtil.requireAuth(function () {
|
|
loadUserDetail();
|
|
loadDistList(1);
|
|
});
|
|
|
|
function checkLogin() {
|
|
var token = CommonUtil.getToken();
|
|
if (token) {
|
|
$("#notLoggedInBox").hide();
|
|
$("#loggedInBox").css("display", "flex");
|
|
CommonUtil.getCurrentUserDetail(
|
|
function (data) {
|
|
if (data) {
|
|
$("#userName").text(data.nickName || "用户");
|
|
$("#userLevel").text(data.isExpert === "1" ? "专家" : "会员");
|
|
if (data.avatar) {
|
|
$("#userAvatar").attr("src", data.avatar);
|
|
}
|
|
}
|
|
},
|
|
function () {
|
|
$("#notLoggedInBox").show();
|
|
$("#loggedInBox").hide();
|
|
},
|
|
);
|
|
}
|
|
}
|
|
|
|
function renderNav() {
|
|
ApiClient.post("/api/web/menu/getFormatList", {}).then(
|
|
function (res) {
|
|
if (res.code !== 0 || !res.data) return;
|
|
var $nav = $("#navLotteryItems");
|
|
$nav.find(".topbar__nav-link").not(":first").remove();
|
|
$.each(res.data, function (i, item) {
|
|
$nav.append(
|
|
'<a href="cai.html?id=' +
|
|
item.suoxie +
|
|
'" class="topbar__nav-link">' +
|
|
item.name +
|
|
"</a>",
|
|
);
|
|
});
|
|
},
|
|
);
|
|
}
|
|
|
|
$(window).on("scroll", function () {
|
|
$(window).scrollTop() > 320
|
|
? $("#backTop").addClass("is-visible")
|
|
: $("#backTop").removeClass("is-visible");
|
|
});
|
|
|
|
function loadUserDetail() {
|
|
CommonUtil.getCurrentUserDetail(function (data) {
|
|
if (!data) return;
|
|
$("#totalSubordinates").text(data.totalSubordinates || 0);
|
|
$("#levelOneCount").text(data.levelOneCount || 0);
|
|
$("#levelTwoCount").text(data.levelTwoCount || 0);
|
|
$("#distIncome").text((data.distributionIncome || 0).toFixed(2));
|
|
});
|
|
}
|
|
|
|
function loadDistList(pageNum) {
|
|
currentPage = pageNum;
|
|
ApiClient.post(
|
|
"/api/web/distribution/getPageList",
|
|
{
|
|
pageNum: pageNum,
|
|
pageSize: pageSize,
|
|
},
|
|
{
|
|
headers: CommonUtil.authHeaders(),
|
|
},
|
|
)
|
|
.then(function (res) {
|
|
if (res.code === 0 && res.data) {
|
|
renderTable(res.data.records || []);
|
|
renderPagination(res.data.total || 0);
|
|
} else {
|
|
layer.msg(res.msg || "获取数据失败", { icon: 2 });
|
|
}
|
|
})
|
|
.catch(function (err) {
|
|
layer.msg("网络错误,请稍后重试", { icon: 2 });
|
|
});
|
|
}
|
|
|
|
function renderTable(records) {
|
|
if (records.length === 0) {
|
|
$("#distTable").replaceWith(
|
|
'<div class="empty-state"><i class="layui-icon layui-icon-group"></i><p>暂无下级用户</p></div>',
|
|
);
|
|
return;
|
|
}
|
|
|
|
table.render({
|
|
elem: "#distTable",
|
|
cols: [
|
|
[
|
|
{
|
|
field: "nickName",
|
|
title: "昵称",
|
|
width: 160,
|
|
align: "center",
|
|
},
|
|
{
|
|
field: "phoneNumber",
|
|
title: "手机号",
|
|
width: 160,
|
|
align: "center",
|
|
templet: function (d) {
|
|
if (d.phoneNumber) {
|
|
return d.phoneNumber.replace(
|
|
/(\d{3})\d{4}(\d{4})/,
|
|
"$1****$2",
|
|
);
|
|
}
|
|
return "--";
|
|
},
|
|
},
|
|
{
|
|
field: "level",
|
|
title: "层级",
|
|
width: 100,
|
|
align: "center",
|
|
templet: function (d) {
|
|
return d.level === 1
|
|
? '<span style="color:#102b6a;font-weight:600;">一级</span>'
|
|
: '<span style="color:#5b2c8e;font-weight:600;">二级</span>';
|
|
},
|
|
},
|
|
{
|
|
field: "createTime",
|
|
title: "注册时间",
|
|
width: 180,
|
|
align: "center",
|
|
templet: function (d) {
|
|
return d.createTime
|
|
? d.createTime.substring(0, 19).replace("T", " ")
|
|
: "--";
|
|
},
|
|
},
|
|
{
|
|
field: "totalRecharge",
|
|
title: "累计充值",
|
|
width: 130,
|
|
align: "center",
|
|
templet: function (d) {
|
|
return (
|
|
'<span style="color:#f15a22;font-weight:600;">' +
|
|
(d.totalRecharge || 0).toFixed(2) +
|
|
"</span>"
|
|
);
|
|
},
|
|
},
|
|
{
|
|
field: "distributionIncome",
|
|
title: "分销收益",
|
|
width: 130,
|
|
align: "center",
|
|
templet: function (d) {
|
|
return (
|
|
'<span style="color:#fdb933;font-weight:600;">' +
|
|
(d.distributionIncome || 0).toFixed(2) +
|
|
"</span>"
|
|
);
|
|
},
|
|
},
|
|
],
|
|
],
|
|
data: records,
|
|
even: true,
|
|
skin: "line",
|
|
size: "lg",
|
|
});
|
|
}
|
|
|
|
function renderPagination(total) {
|
|
if (total <= pageSize) return;
|
|
laypage.render({
|
|
elem: "distPage",
|
|
count: total,
|
|
limit: pageSize,
|
|
curr: currentPage,
|
|
theme: "#102b6a",
|
|
jump: function (obj, first) {
|
|
if (!first) {
|
|
loadDistList(obj.curr);
|
|
}
|
|
},
|
|
});
|
|
}
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|