/** * marketing.js - 营销服务逻辑(EDM行业+区域二级联动筛选+导出邮箱列表;数据定制/媒体批发占位) * 页面:edm.html / data_custom.html / media_wholesale.html */ $(function () { // 根据当前页面文件名决定初始化方式 var pageFile = location.pathname.split('/').pop(); if (pageFile === 'data_custom.html') { initDataCustom(); return; } if (pageFile === 'media_wholesale.html') { initMediaWholesale(); return; } /* ============ EDM 页面 ============ */ renderShell('营销服务', '营销服务 / EDM筛选'); renderEdmPage(); initPage('marketing', function (user) { if (!checkPagePermission('marketing')) return; loadIndustries(); loadRegions(); loadEmails(1); }); var currentPage = 1; /** 渲染 EDM 页面内容(工具栏+表格+分页) */ function renderEdmPage() { $('#page-content').html( '
' + '
' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' 命中 0 个邮箱' + ' ' + '
' + '
' + ' ' + ' ' + '
邮箱姓名当前公司工作所在地家乡
' + ' ' + '
' ); $('#check-all').on('change', function () { $('.row-check').prop('checked', this.checked); }); } function loadIndustries() { httpGet('marketing/edm.php', { action: 'industries' }).then(function (d) { var html = ''; (d.industries || []).forEach(function (i) { html += ''; }); $('#filter-industry').html(html); }); } function loadRegions() { httpGet('marketing/edm.php', { action: 'regions' }).then(function (d) { var regions = d.regions || {}; var html = ''; Object.keys(regions).forEach(function (p) { html += ''; }); $('#filter-province').html(html).data('regions', regions); $('#filter-city').html(''); }); } // 二级联动:选省后加载市 $('#filter-province').on('change', function () { var regions = $(this).data('regions') || {}; var province = $(this).val(); var html = ''; (regions[province] || []).forEach(function (c) { html += ''; }); $('#filter-city').html(html); }); function loadEmails(page) { currentPage = page; var params = buildFilterParam(); params.action = 'filter'; params.page = page; params.limit = PAGE_SIZE; httpGet('marketing/edm.php', params).then(function (data) { var rows = data.list || []; var html = ''; rows.forEach(function (r) { html += '' + '' + '' + escHtml(r.email) + '' + '' + escHtml(r.full_name || '-') + '' + '' + escHtml(r.company_name || '-') + '' + '' + escHtml(r.work_location || '-') + '' + '' + escHtml(r.hometown || '-') + ''; }); if (!rows.length) { html = '暂无匹配邮箱'; } $('#edm-tbody').html(html); renderPagination($('#pagination'), data, loadEmails); $('#email-total').text(data.total || 0); }); } $('#btn-search').on('click', function () { loadEmails(1); }); $('#btn-reset').on('click', function () { $('.toolbar [data-filter]').val(''); $('#filter-city').html(''); loadEmails(1); }); /* ---------- 导出CSV(仅导出勾选的邮箱,未勾选弹窗提醒) ---------- */ $('#btn-export').on('click', function () { var emails = []; $('.row-check:checked').each(function () { emails.push($(this).val()); }); if (!emails.length) { layer.alert('请先选择需要导出的邮箱', { icon: 2, title: '提示' }); return; } download('marketing/edm_export.php', { emails: emails.join(',') }); }); /* ============ 数据定制(占位) ============ */ function initDataCustom() { renderShell('数据定制', '营销服务 / 数据定制'); initPage('marketing', function (user) { if (!checkPagePermission('marketing')) return; httpGet('marketing/data_custom.php').then(function (d) { $('#page-content').html( '
' + '
' + (ICONS.data || '') + '
' + '

' + escHtml(d.title || '数据定制') + '

' + '

' + escHtml(d.description || '功能建设中') + '

' + '
' + '
' + '
' + '
' + '
' + '
' + '
' ); $('#dc-submit').on('click', function () { httpPost('marketing/data_custom.php', { action: 'submit', contact_name: $('#dc-name').val(), contact_phone: $('#dc-phone').val(), requirements: $('#dc-req').val() }).then(function (d) { Dialog.alert(d.msg || '已提交'); }); }); }); }); } /* ============ 媒体批发(占位) ============ */ function initMediaWholesale() { renderShell('媒体批发', '营销服务 / 媒体批发'); initPage('marketing', function (user) { if (!checkPagePermission('marketing')) return; httpGet('marketing/media_wholesale.php').then(function (d) { $('#page-content').html( '
' + '
' + (ICONS.media || '') + '
' + '

' + escHtml(d.title || '媒体批发') + '

' + '

' + escHtml(d.description || '功能建设中') + '

' + '
' + '
' + '
' + '
' + '
' + '
' ); $('#mw-submit').on('click', function () { httpPost('marketing/media_wholesale.php', { action: 'inquiry', media_ids: $('#mw-ids').val(), remark: $('#mw-req').val() }).then(function (d) { Dialog.alert(d.msg || '已提交'); }); }); }); }); } });