From 01b43945f4f182f66933a7ed3ba2c35891f2f116 Mon Sep 17 00:00:00 2001 From: linbin <495561397@qq.com> Date: Fri, 1 Aug 2025 16:40:17 +0800 Subject: [PATCH] =?UTF-8?q?=E6=89=B9=E9=87=8F=E4=BC=9A=E5=91=98=E7=AD=89?= =?UTF-8?q?=E7=BA=A7=E4=BF=AE=E6=94=B9=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- new_web/merchant/js/batch-level-edit.js | 175 ++++++++ new_web/merchant/js/level-settings.js | 13 +- new_web/merchant/pages/batch-level-edit.html | 419 +++++++++++++++++++ new_web/merchant/pages/level-settings.html | 2 +- 4 files changed, 607 insertions(+), 2 deletions(-) create mode 100644 new_web/merchant/js/batch-level-edit.js create mode 100644 new_web/merchant/pages/batch-level-edit.html diff --git a/new_web/merchant/js/batch-level-edit.js b/new_web/merchant/js/batch-level-edit.js new file mode 100644 index 0000000..6fe6e8d --- /dev/null +++ b/new_web/merchant/js/batch-level-edit.js @@ -0,0 +1,175 @@ +/** + * 批量会员等级编辑功能模块 + * 提供批量编辑多个摊位的会员等级配置 + */ + +// 页面初始化函数 +function initBatchLevelEdit() { + console.log('批量等级编辑页面已初始化'); + + // 初始化摊位选择状态 + updateStallSelection(); + + // 绑定表单事件 + bindFormEvents(); +} + +// 绑定表单事件 +function bindFormEvents() { + // 可以在这里添加其他表单事件绑定 + console.log('表单事件已绑定'); +} + +// 全选/取消全选摊位 +function selectAllStalls(checkbox) { + const stallCheckboxes = document.querySelectorAll('.stall-checkbox input[type="checkbox"]:not([value="all"])'); + + stallCheckboxes.forEach(cb => { + cb.checked = checkbox.checked; + }); + + updateStallSelection(); +} + +// 更新摊位选择状态 +function updateStallSelection() { + const stallCheckboxes = document.querySelectorAll('.stall-checkbox input[type="checkbox"]:not([value="all"])'); + const allCheckbox = document.querySelector('.stall-checkbox input[value="all"]'); + const countElement = document.getElementById('selectedStallsCount'); + + let selectedCount = 0; + let selectedStalls = []; + + stallCheckboxes.forEach(cb => { + if (cb.checked) { + selectedCount++; + selectedStalls.push(cb.value); + } + }); + + // 更新全选状态 + if (allCheckbox) { + allCheckbox.checked = selectedCount === stallCheckboxes.length; + allCheckbox.indeterminate = selectedCount > 0 && selectedCount < stallCheckboxes.length; + } + + // 更新选择计数显示 + if (countElement) { + countElement.textContent = `已选择 ${selectedCount} 个摊位`; + if (selectedCount > 0) { + countElement.textContent += `:${selectedStalls.join('、')}`; + } + } +} + +// 保存批量等级编辑 +function saveBatchLevelEdit() { + const selectedStalls = getSelectedStalls(); + + if (selectedStalls.length === 0) { + alert('请至少选择一个摊位'); + return; + } + + // 获取等级配置数据 + const levelConfig = getLevelConfigData(); + + // 模拟保存过程 + console.log('保存批量等级编辑:', { + stalls: selectedStalls, + config: levelConfig + }); + + // 显示保存成功提示 + alert(`已成功为 ${selectedStalls.length} 个摊位(${selectedStalls.join('、')})批量更新等级配置!`); + + // 可以在这里添加实际的保存逻辑,比如发送到后端API +} + +// 获取选中的摊位列表 +function getSelectedStalls() { + const selectedStalls = []; + const stallCheckboxes = document.querySelectorAll('.stall-checkbox input[type="checkbox"]:not([value="all"])'); + + stallCheckboxes.forEach(cb => { + if (cb.checked) { + selectedStalls.push(cb.value); + } + }); + + return selectedStalls; +} + +// 获取等级配置数据 +function getLevelConfigData() { + const tbody = document.getElementById('batchLevelEditBody'); + const rows = tbody.querySelectorAll('tr'); + const config = []; + + rows.forEach(row => { + const cells = row.cells; + const level = cells[0].textContent; + + const levelData = { + level: level, + name: cells[1].querySelector('input').value, + growthRange: { + start: parseInt(cells[2].querySelectorAll('input')[0].value), + end: parseInt(cells[2].querySelectorAll('input')[1].value) + }, + memberDiscount: { + enabled: cells[3].querySelector('input[type="checkbox"]').checked, + rate: parseInt(cells[4].querySelector('input').value) + }, + pointExchange: cells[5].querySelector('input[type="checkbox"]').checked, + birthdayCoupon: cells[6].querySelector('input[type="checkbox"]').checked, + birthdayDoublePoints: cells[8].querySelector('input[type="checkbox"]').checked + }; + + config.push(levelData); + }); + + return config; +} + +// 添加优惠券(重用现有功能) +function addCoupon(level) { + // 这里可以调用现有的优惠券添加功能 + // 或者实现新的批量优惠券添加逻辑 + console.log(`为等级 ${level} 添加优惠券`); + + // 检查是否已经加载了优惠券弹窗相关功能 + if (typeof showCouponModal === 'function') { + showCouponModal(level); + } else { + // 如果没有加载,可以动态加载相关功能 + loadCouponModalFunction().then(() => { + if (typeof showCouponModal === 'function') { + showCouponModal(level); + } + }); + } +} + +// 动态加载优惠券弹窗功能 +async function loadCouponModalFunction() { + try { + // 这里可以动态加载优惠券相关的JavaScript + console.log('动态加载优惠券功能...'); + // 实际项目中可以通过import或script标签动态加载 + } catch (error) { + console.error('加载优惠券功能失败:', error); + } +} + +// 页面清理函数 +function cleanupBatchLevelEdit() { + console.log('清理批量等级编辑页面'); + // 清理事件监听器等资源 +} + +// 暴露到全局作用域供HTML调用 +window.selectAllStalls = selectAllStalls; +window.updateStallSelection = updateStallSelection; +window.saveBatchLevelEdit = saveBatchLevelEdit; +window.addCoupon = addCoupon; \ No newline at end of file diff --git a/new_web/merchant/js/level-settings.js b/new_web/merchant/js/level-settings.js index 2aadc38..163f07d 100644 --- a/new_web/merchant/js/level-settings.js +++ b/new_web/merchant/js/level-settings.js @@ -97,8 +97,19 @@ function openLevelDetails(merchantName) { } } +// 打开批量等级编辑页面 +function openBatchLevelEdit() { + const tabTitle = '批量会员等级编辑'; + if (typeof window.openTab === 'function') { + window.openTab(tabTitle, 'batch-level-edit'); + } else { + console.error('openTab函数未找到'); + } +} + // 将函数暴露到全局作用域,以便HTML中的onclick可以调用 window.toggleDropdown = toggleDropdown; window.selectAll = selectAll; window.updateSelection = updateSelection; -window.openLevelDetails = openLevelDetails; \ No newline at end of file +window.openLevelDetails = openLevelDetails; +window.openBatchLevelEdit = openBatchLevelEdit; \ No newline at end of file diff --git a/new_web/merchant/pages/batch-level-edit.html b/new_web/merchant/pages/batch-level-edit.html new file mode 100644 index 0000000..611c3c1 --- /dev/null +++ b/new_web/merchant/pages/batch-level-edit.html @@ -0,0 +1,419 @@ +
+ + + +
+

选择要编辑的摊位

+
+ + + + + + +
+
+ 已选择 0 个摊位 +
+
+ + +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
等级等级名称成长值范围开启会员折扣折扣率(%)开启积分兑换开启生日优惠券生日优惠券操作开启生日双倍积分
LV1 + + +
+ - + +
+
+ + + + + + + + + + + +
LV2 + + +
+ - + +
+
+ + + + + + + + + + + +
LV3 + + +
+ - + +
+
+ + + + + + + + + + + +
LV4 + + +
+ - + +
+
+ + + + + + + + + + + +
+
+ + \ No newline at end of file diff --git a/new_web/merchant/pages/level-settings.html b/new_web/merchant/pages/level-settings.html index a4a31cb..71147ca 100644 --- a/new_web/merchant/pages/level-settings.html +++ b/new_web/merchant/pages/level-settings.html @@ -38,7 +38,7 @@ - +