修改功能,现已测试注册登录忘记密码
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
<title id="page-title">彩先知 - 分销中心</title>
|
||||
<script src="../public/css/layui/layui.js"></script>
|
||||
<script src="../config.js"></script>
|
||||
<script src="../public/js/qrcode.min.js"></script>
|
||||
<script src="../utils/ApiClient.js"></script>
|
||||
<script src="../utils/DateUtil.js"></script>
|
||||
<script src="../utils/CommonUtil.js"></script>
|
||||
@@ -102,6 +103,16 @@
|
||||
|
||||
<!-- Action Section -->
|
||||
<div class="action-section">
|
||||
<div class="action-card">
|
||||
<div class="action-card-title">
|
||||
<i class="layui-icon layui-icon-share"></i> 推广分享
|
||||
</div>
|
||||
<div class="action-card-desc">
|
||||
复制分销链接,邀请好友注册获得佣金;也可以生成推广二维码进行分享。
|
||||
</div>
|
||||
<button class="action-card-btn btn-apply-dist" id="fzlj" type="button">复制链接</button>
|
||||
<button class="action-card-btn btn-apply-expert" id="tgewm" type="button">推广二维码</button>
|
||||
</div>
|
||||
<div class="action-card">
|
||||
<div class="action-card-title">
|
||||
<i class="layui-icon layui-icon-group"></i> 申请分销
|
||||
@@ -210,6 +221,7 @@
|
||||
// Check login state for topbar
|
||||
checkLogin();
|
||||
renderNav();
|
||||
initShareFunctions();
|
||||
|
||||
// Check auth and load user detail
|
||||
CommonUtil.requireAuth(function () {
|
||||
@@ -264,6 +276,99 @@
|
||||
: $("#backTop").removeClass("is-visible");
|
||||
});
|
||||
|
||||
function getApiBaseUrl() {
|
||||
return (ApiClient.baseUrl || (window.CONFIG && CONFIG.API_BASE_URL) || window.location.origin || "").replace(/\/$/, "");
|
||||
}
|
||||
|
||||
function normalizeShareLink(data) {
|
||||
var affUrl = (data && (data.affUrl || data.shareUrl || data.inviteUrl || data.url)) || "";
|
||||
if (!affUrl) return "";
|
||||
if (/^https?:\/\//i.test(affUrl)) return affUrl;
|
||||
return getApiBaseUrl() + "/html/reg.html?affUrl=" + String(affUrl).replace(/^\//, "");
|
||||
}
|
||||
|
||||
function getAffInfo() {
|
||||
return ApiClient.post("/api/web/rebate/getAffInfo", {}, { headers: CommonUtil.authHeaders() });
|
||||
}
|
||||
|
||||
function copyText(text) {
|
||||
if (navigator.clipboard && navigator.clipboard.writeText) {
|
||||
return navigator.clipboard.writeText(text);
|
||||
}
|
||||
var $input = $("<textarea>").val(text).css({ position: "fixed", left: "-9999px", top: "-9999px" });
|
||||
$("body").append($input);
|
||||
$input[0].select();
|
||||
document.execCommand("copy");
|
||||
$input.remove();
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
function initShareFunctions() {
|
||||
$("#fzlj").on("click", copyShareLink);
|
||||
$("#tgewm").on("click", showQrCodeModal);
|
||||
}
|
||||
|
||||
function copyShareLink() {
|
||||
CommonUtil.requireAuth(function () {
|
||||
getAffInfo()
|
||||
.then(function (res) {
|
||||
if (res.code !== 0 || !res.data) throw new Error(res.msg || "获取分享链接失败");
|
||||
var shareLink = normalizeShareLink(res.data);
|
||||
if (!shareLink) throw new Error("接口未返回分享链接");
|
||||
return copyText(shareLink);
|
||||
})
|
||||
.then(function () {
|
||||
layer.msg("链接已复制到剪贴板", { icon: 1, time: 1500 });
|
||||
})
|
||||
.catch(function (err) {
|
||||
layer.msg(err.message || "复制失败,请手动复制", { icon: 2 });
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function showQrCodeModal() {
|
||||
CommonUtil.requireAuth(function () {
|
||||
getAffInfo()
|
||||
.then(function (res) {
|
||||
if (res.code !== 0 || !res.data) throw new Error(res.msg || "获取推广信息失败");
|
||||
var shareLink = normalizeShareLink(res.data);
|
||||
if (res.data.affCodeUrl && res.data.affUrl) {
|
||||
shareLink = String(res.data.affCodeUrl).replace(/\/$/, "") + "/" + String(res.data.affUrl).replace(/^\//, "");
|
||||
}
|
||||
if (!shareLink) throw new Error("接口未返回推广二维码链接");
|
||||
createCustomModal(shareLink);
|
||||
})
|
||||
.catch(function (err) {
|
||||
layer.msg(err.message || "生成二维码失败", { icon: 2 });
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function createCustomModal(shareLink) {
|
||||
var $mask = $('<div class="custom-modal-mask"></div>');
|
||||
var $modal = $('<div class="custom-modal-content"></div>');
|
||||
var $qrContainer = $('<div class="custom-qr-container"></div>');
|
||||
$modal.append('<h3 class="custom-modal-title">推广二维码</h3>');
|
||||
$modal.append($qrContainer);
|
||||
$modal.append('<button class="custom-modal-close" type="button">关闭</button>');
|
||||
$mask.append($modal);
|
||||
$("body").append($mask);
|
||||
new QRCode($qrContainer[0], {
|
||||
text: shareLink,
|
||||
width: 200,
|
||||
height: 200,
|
||||
colorDark: "#000000",
|
||||
colorLight: "#ffffff",
|
||||
correctLevel: QRCode.CorrectLevel.H,
|
||||
});
|
||||
$mask.on("click", function (event) {
|
||||
if (event.target === $mask[0]) $mask.remove();
|
||||
});
|
||||
$modal.find(".custom-modal-close").on("click", function () {
|
||||
$mask.remove();
|
||||
});
|
||||
}
|
||||
|
||||
function loadUserDetail() {
|
||||
CommonUtil.getCurrentUserDetail(
|
||||
function (data) {
|
||||
|
||||
Reference in New Issue
Block a user