57 lines
		
	
	
		
			2.1 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
		
		
			
		
	
	
			57 lines
		
	
	
		
			2.1 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
|  | // 等级明细页面的JavaScript逻辑
 | ||
|  | 
 | ||
|  | let currentShopName = ''; | ||
|  | 
 | ||
|  | // 获取URL参数
 | ||
|  | function getUrlParameter(name) { | ||
|  |     name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]'); | ||
|  |     const regex = new RegExp('[\\?&]' + name + '=([^&#]*)'); | ||
|  |     const results = regex.exec(location.search); | ||
|  |     return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' ')); | ||
|  | } | ||
|  | 
 | ||
|  | // 页面初始化
 | ||
|  | document.addEventListener('DOMContentLoaded', function() { | ||
|  |     currentShopName = getUrlParameter('shop'); | ||
|  |     if (currentShopName) { | ||
|  |         document.getElementById('page-title').textContent = `${currentShopName} - 等级设置明细`; | ||
|  |         loadLevelData(); | ||
|  |     } | ||
|  | }); | ||
|  | 
 | ||
|  | // 加载等级数据
 | ||
|  | function loadLevelData() { | ||
|  |     // 模拟等级数据
 | ||
|  |     const mockLevels = [ | ||
|  |         { name: 'LV1', growth: 100, members: 1250, benefits: '9.5折优惠' }, | ||
|  |         { name: 'LV2', growth: 500, members: 850, benefits: '9折优惠, 积分双倍' }, | ||
|  |         { name: 'LV3', growth: 1200, members: 450, benefits: '8.5折优惠, 积分双倍, 生日优惠券' }, | ||
|  |         { name: 'LV4', growth: 2500, members: 180, benefits: '8折优惠, 积分三倍, 生日优惠券, 专属客服' } | ||
|  |     ]; | ||
|  | 
 | ||
|  |     const tableBody = document.getElementById('level-table-body'); | ||
|  |     tableBody.innerHTML = mockLevels.map(level => `
 | ||
|  |         <tr> | ||
|  |             <td class="px-4 py-3 text-sm text-gray-900">${level.name}</td> | ||
|  |             <td class="px-4 py-3 text-sm text-gray-900">${level.growth}</td> | ||
|  |             <td class="px-4 py-3 text-sm text-gray-900">${level.members}</td> | ||
|  |             <td class="px-4 py-3 text-sm text-gray-900">${level.benefits}</td> | ||
|  |         </tr> | ||
|  |     `).join('');
 | ||
|  | } | ||
|  | 
 | ||
|  | // 打开等级编辑页面
 | ||
|  | function openLevelEdit() { | ||
|  |     const encodedShopName = encodeURIComponent(currentShopName); | ||
|  |     window.location.href = `level-edit.html?shop=${encodedShopName}`; | ||
|  | } | ||
|  | 
 | ||
|  | // 提交等级明细
 | ||
|  | function submitLevelDetail() { | ||
|  |     showNotification(`${currentShopName} 等级明细已提交`, 'success'); | ||
|  |     console.log('提交等级明细:', currentShopName); | ||
|  | } | ||
|  | 
 | ||
|  | // 导出函数
 | ||
|  | window.openLevelEdit = openLevelEdit; | ||
|  | window.submitLevelDetail = submitLevelDetail; |