';
box.onclick = function (e) {
var r = e.target && e.target.closest ? e.target.closest('[data-a]') : null; if (!r) return;
var a = r.getAttribute('data-a');
if (a === 'vip' && window.mksOpenModule) window.mksOpenModule({ id: 'membership' });
else if (a === 'key' && window.mksOpenModule) window.mksOpenModule({ id: 'tool_api_key' });
else if (a === 'pub' && window.mksOpenModule) window.mksOpenModule({ id: 'multi_platform' });
else if (a === 'nt' && window.mksOpenModule) window.mksOpenModule({ id: 'tool_notify' });
else if (a === 'lib') { if (window.v27OpenLib) window.v27OpenLib(); else T('长按 AI 回复可保存到生成库'); }
else if (a === 'help') T('帮助:对话说需求即执行;市场卡片进操作台;充值订阅在会员中心;在对话页可直接问 AI 客服问题。');
else if (a === 'sto') { fetch(API + '/ai-army/materials?user_id=' + encodeURIComponent(u) + '&limit=500').then(function (r) { return r.json(); }).then(function (d) { T('✅ 个人 OBS 存储已开通(按账号隔离),已存 ' + ((d && (d.data || d.materials)) || []).length + ' 个文件'); }); }
else if (a === 'out') { try { ['user_token', 'user_info', 'user_id', 'authToken', 'smart_center_token'].forEach(function (k) { localStorage.removeItem(k); }); } catch (e) {} location.reload(); }
else if (a === 'profile') { T('点头像可上传修改头像;昵称/简介:请使用「编辑资料」或联系 AI 客服协助修改'); }
else if (a === 'pwd') T('修改密码:请在桌面端「个人设置-账号安全」或通过 AI 客服引导修改(首次设置需旧密码留空)');
};
}).catch(function (err) { box.innerHTML = '
加载失败:' + E((err && err.message) || '网络异常') + '
'; });
};
function inlBox(html) {
var pc = document.getElementById('profile-container');
var old = document.getElementById('v34inl'); if (old) old.remove();
var d = document.createElement('div');
d.id = 'v34inl';
d.style.cssText = 'background:#fff;border-radius:12px;margin:0 10px 8px;padding:12px 14px;box-shadow:0 1px 4px rgba(15,23,42,.06);';
d.innerHTML = '
×
' + html + '
';
pc.insertBefore(d, pc.firstChild);
d.querySelector('#v34ix').onclick = function () { d.remove(); };
d.scrollIntoView({ block: 'nearest' });
return d;
}
function inlForm(t, inner, btn, onSave) {
var d = inlBox(inner + '');
d.querySelector('#v34it').textContent = t;
d.querySelector('#v34is').onclick = function () { var r = true; try { r = onSave(); } catch (e) {} if (r !== false) d.remove(); };
}
function inlHelp() {
var d = inlBox('
AI 客服在线:可咨询如何使用系统(创作/发布/充值/绑定等),AI 会引导您操作。
' +
'');
d.querySelector('#v34it').textContent = 'AI 客服';
var k = d.querySelector('#v34hk');
function ask() { var q = d.querySelector('#v34hq').value.trim(); if (!q) return; d.querySelector('#v34hq').value = '';
k.innerHTML += '
' + E(q) + '
AI 回复中…
'; k.scrollTop = k.scrollHeight;
fetch(API + '/ai-army/dispatch?agent_id=customer_service_agent', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ user_input: q, user_id: U() }) }).then(function (r) { return r.json().catch(function () { return {}; }); })
.then(function (res) { var rr = res && res.result || {}; var txt = rr.reply || rr.response || rr.message || (res && res.message) || '已收到,客服会尽快跟进'; var w = d.querySelector('#v34hw'); if (w) w.remove(); k.innerHTML += '
' + E(String(txt).substring(0, 3000)) + '
'; k.scrollTop = k.scrollHeight; })
.catch(function () { var w = d.querySelector('#v34hw'); if (w) w.textContent = '回复失败,请稍后重试'; });
}
d.querySelector('#v34hs').onclick = ask;
d.querySelector('#v34hq').addEventListener('keydown', function (e) { if (e.key === 'Enter' && !e.shiftKey) { e.preventDefault(); ask(); } });
}
window.v34go = function (a) {
var u = U();
if (a === 'vip' && window.mksOpenModule) window.mksOpenModule({ id: 'membership' });
else if (a === 'key' && window.mksOpenModule) window.mksOpenModule({ id: 'tool_api_key' });
else if (a === 'pub' && window.mksOpenModule) window.mksOpenModule({ id: 'multi_platform' });
else if (a === 'nt' && window.mksOpenModule) window.mksOpenModule({ id: 'tool_notify' });
else if (a === 'lib') { if (window.v27OpenLib) window.v27OpenLib(); else T('长按 AI 回复可保存到生成库'); }
else if (a === 'sto') { fetch(API + '/ai-army/materials?user_id=' + encodeURIComponent(u) + '&limit=500').then(function (r) { return r.json(); }).then(function (d) { T('个人 OBS 存储已开通(按账号隔离),已存 ' + ((d && (d.data || d.materials)) || []).length + ' 个文件'); }); }
else if (a === 'bind') { inlForm('第三方账号绑定', '
', '知道了', function () {}); }
else if (a === 'pwd') { inlForm('修改密码', '', '修改', function () { if ($('v34P').value.length < 6) { T('至少6位'); return false; } fetch(API + '/api/user-settings/password', { method: 'PUT', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ user_id: u, old_password: $('v34O').value, new_password: $('v34P').value }) }).then(function (r) { return r.json(); }).then(function (d) { T((d && d.success) ? '密码已更新' : '失败:' + ((d && d.message) || '旧密码不对或需先设密码')); }); }); }
else if (a === 'profile') { inlForm('修改资料', '
头像:点击「我的」页顶部圆形头像即可拍照/上传修改
', '保存', function () { var nv = $('v34N').value.trim(); if (!nv) { T('昵称不能为空'); return false; } fetch(API + '/api/user-settings/profile', { method: 'PUT', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ user_id: u, nickname: nv }) }).then(function (r) { return r.json(); }).then(function (d) { T((d && d.success) ? '昵称已保存' : '保存失败'); try { window.loadUserProfile(); } catch (e) {} }); }); }
else if (a === 'help') inlHelp();
else if (a === 'help') cs34();
else if (a === 'out') { try { ['user_token', 'user_info', 'user_id', 'authToken', 'smart_center_token'].forEach(function (k) { localStorage.removeItem(k); }); } catch (e) {} location.reload(); }
};
var _pfC = {};
function pfv() { return _pfC; }
window.v34SetPf = function (o) { _pfC = o || {}; };
function cs34() {
var d = document.createElement('div'); d.style.cssText = 'position:fixed;inset:0;z-index:45000;background:rgba(15,23,42,.55);display:flex;align-items:center;justify-content:center;';
d.innerHTML = '
AI 客服(使用引导/问题解答)×
' +
'
AI 客服在线:可咨询如何使用系统(创作/发布/充值/绑定等),会引导您操作。
' +
'
';
document.body.appendChild(d);
$('c34x').onclick = function () { d.remove(); };
var k = $('c34k');
function ask() { var q = $('c34q').value.trim(); if (!q) return; $('c34q').value = '';
k.innerHTML += '
' + E(q) + '
AI 回复中…
'; k.scrollTop = k.scrollHeight;
fetch(API + '/ai-army/dispatch?agent_id=customer_service_agent', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ user_input: q, user_id: U() }) }).then(function (r) { return r.json().catch(function () { return {}; }); })
.then(function (d) { var rr = d && d.result || {}; var txt = rr.reply || rr.response || rr.message || (d && d.message) || '已收到,客服会尽快跟进'; var w = $('c34w'); if (w) w.remove(); k.innerHTML += '
' + E(String(txt).substring(0, 3000)) + '
'; k.scrollTop = k.scrollHeight; })
.catch(function () { var w = $('c34w'); if (w) w.textContent = '回复失败,请稍后重试'; });
}
$('c34b').onclick = ask;
$('c34q').addEventListener('keydown', function (e) { if (e.key === 'Enter' && !e.shiftKey) { e.preventDefault(); ask(); } });
}
console.log('[MobV34] 保险渲染器就绪');
})();