108 lines
		
	
	
		
			3.9 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
		
		
			
		
	
	
			108 lines
		
	
	
		
			3.9 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
| 
								 | 
							
								// H5会员管理 - 通用功能
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								// 返回上一页
							 | 
						||
| 
								 | 
							
								function goBack() {
							 | 
						||
| 
								 | 
							
								    if (document.referrer && document.referrer.includes('/H5/merchant/')) {
							 | 
						||
| 
								 | 
							
								        history.back();
							 | 
						||
| 
								 | 
							
								    } else {
							 | 
						||
| 
								 | 
							
								        window.location.href = 'index.html';
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								// 页面跳转
							 | 
						||
| 
								 | 
							
								function navigateTo(url) {
							 | 
						||
| 
								 | 
							
								    window.location.href = url;
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								// 显示通知消息
							 | 
						||
| 
								 | 
							
								function showNotification(message, type = 'info') {
							 | 
						||
| 
								 | 
							
								    const notification = document.createElement('div');
							 | 
						||
| 
								 | 
							
								    notification.className = `notification ${type}`;
							 | 
						||
| 
								 | 
							
								    notification.textContent = message;
							 | 
						||
| 
								 | 
							
								    
							 | 
						||
| 
								 | 
							
								    document.body.appendChild(notification);
							 | 
						||
| 
								 | 
							
								    
							 | 
						||
| 
								 | 
							
								    setTimeout(() => {
							 | 
						||
| 
								 | 
							
								        if (notification.parentNode) {
							 | 
						||
| 
								 | 
							
								            notification.parentNode.removeChild(notification);
							 | 
						||
| 
								 | 
							
								        }
							 | 
						||
| 
								 | 
							
								    }, 3000);
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								// 确认对话框
							 | 
						||
| 
								 | 
							
								function confirmAction(message, callback) {
							 | 
						||
| 
								 | 
							
								    if (confirm(message)) {
							 | 
						||
| 
								 | 
							
								        callback();
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								// 表单提交后返回
							 | 
						||
| 
								 | 
							
								function submitAndGoBack(message = '提交成功') {
							 | 
						||
| 
								 | 
							
								    showNotification(message, 'success');
							 | 
						||
| 
								 | 
							
								    setTimeout(() => {
							 | 
						||
| 
								 | 
							
								        goBack();
							 | 
						||
| 
								 | 
							
								    }, 1000);
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								// 切换开关状态
							 | 
						||
| 
								 | 
							
								function toggleSwitch(switchElement) {
							 | 
						||
| 
								 | 
							
								    const isChecked = switchElement.checked;
							 | 
						||
| 
								 | 
							
								    console.log(`开关状态: ${isChecked ? '开启' : '关闭'}`);
							 | 
						||
| 
								 | 
							
								    showNotification(`已${isChecked ? '开启' : '关闭'}`, 'info');
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								// 删除筛选标签
							 | 
						||
| 
								 | 
							
								function removeFilterTag(tagElement, value) {
							 | 
						||
| 
								 | 
							
								    tagElement.remove();
							 | 
						||
| 
								 | 
							
								    console.log(`移除筛选条件: ${value}`);
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								// 模拟数据 - 摊位列表
							 | 
						||
| 
								 | 
							
								const mockStalls = [
							 | 
						||
| 
								 | 
							
								    { name: '时尚服装店', enabled: true, levels: 'lv1, lv2, lv3, lv4' },
							 | 
						||
| 
								 | 
							
								    { name: '数码电子城', enabled: false, levels: 'lv1, lv2, lv3' },
							 | 
						||
| 
								 | 
							
								    { name: '美食餐厅', enabled: true, levels: 'lv1, lv2, lv3, lv4' },
							 | 
						||
| 
								 | 
							
								    { name: '家居生活馆', enabled: false, levels: 'lv1, lv2' },
							 | 
						||
| 
								 | 
							
								    { name: '运动健身店', enabled: true, levels: 'lv1, lv2, lv3, lv4' }
							 | 
						||
| 
								 | 
							
								];
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								// 模拟数据 - 等级详情
							 | 
						||
| 
								 | 
							
								const mockLevelDetails = [
							 | 
						||
| 
								 | 
							
								    { 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 mockMembers = [
							 | 
						||
| 
								 | 
							
								    { id: 1, name: '张三', phone: '138****1234', level: 'LV2', points: 1250, joinDate: '2024-01-15' },
							 | 
						||
| 
								 | 
							
								    { id: 2, name: '李四', phone: '139****5678', level: 'LV3', points: 2800, joinDate: '2024-02-20' },
							 | 
						||
| 
								 | 
							
								    { id: 3, name: '王五', phone: '137****9012', level: 'LV1', points: 580, joinDate: '2024-03-10' },
							 | 
						||
| 
								 | 
							
								    { id: 4, name: '赵六', phone: '136****3456', level: 'LV4', points: 5200, joinDate: '2024-01-08' }
							 | 
						||
| 
								 | 
							
								];
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								// 模拟数据 - 积分任务
							 | 
						||
| 
								 | 
							
								const mockPointTasks = [
							 | 
						||
| 
								 | 
							
								    { id: 1, name: '每日签到', points: 10, description: '每天签到获得积分' },
							 | 
						||
| 
								 | 
							
								    { id: 2, name: '完善资料', points: 50, description: '完善个人资料获得积分' },
							 | 
						||
| 
								 | 
							
								    { id: 3, name: '首次购买', points: 100, description: '首次购买商品获得积分' },
							 | 
						||
| 
								 | 
							
								    { id: 4, name: '邀请好友', points: 200, description: '邀请好友注册获得积分' }
							 | 
						||
| 
								 | 
							
								];
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								// 模拟数据 - 积分商品
							 | 
						||
| 
								 | 
							
								const mockPointProducts = [
							 | 
						||
| 
								 | 
							
								    { id: 1, name: '5元优惠券', points: 500, stock: 100, description: '满50元可用' },
							 | 
						||
| 
								 | 
							
								    { id: 2, name: '10元优惠券', points: 1000, stock: 50, description: '满100元可用' },
							 | 
						||
| 
								 | 
							
								    { id: 3, name: '精美水杯', points: 2000, stock: 20, description: '品牌水杯' },
							 | 
						||
| 
								 | 
							
								    { id: 4, name: '购物袋', points: 800, stock: 30, description: '环保购物袋' }
							 | 
						||
| 
								 | 
							
								];
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								// 导出函数到全局
							 | 
						||
| 
								 | 
							
								window.goBack = goBack;
							 | 
						||
| 
								 | 
							
								window.navigateTo = navigateTo;
							 | 
						||
| 
								 | 
							
								window.showNotification = showNotification;
							 | 
						||
| 
								 | 
							
								window.confirmAction = confirmAction;
							 | 
						||
| 
								 | 
							
								window.submitAndGoBack = submitAndGoBack;
							 | 
						||
| 
								 | 
							
								window.toggleSwitch = toggleSwitch;
							 | 
						||
| 
								 | 
							
								window.removeFilterTag = removeFilterTag;
							 |