(function () { 'use strict'; if (window.__mobV34) return; window.__mobV34 = true; var API = 'https://api-gateway.duoweiying.cn'; function $(i) { return document.getElementById(i); } function U() { var u = null; try { u = JSON.parse(localStorage.getItem('user_info') || '{}'); } catch (e) {} return (u && (u.id || u.username)) || localStorage.getItem('user_id') || 'anonymous'; } function E(s) { return String(s == null ? '' : s).replace(/[&<>"']/g, function (c) { return { '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c]; }); } function T(t) { try { var o = $('v34tip'); if (o) o.remove(); var d = document.createElement('div'); d.id = 'v34tip'; d.style.cssText = 'position:fixed;left:50%;bottom:120px;transform:translateX(-50%);z-index:49000;background:#0f172a;color:#fff;font-size:13px;padding:9px 16px;border-radius:18px;max-width:84%;text-align:center;'; d.textContent = t; document.body.appendChild(d); setTimeout(function () { d.remove(); }, 2600); } catch (e) {} } window.loadUserProfile = function () { var box = $('profile-container'); if (!box) return; box.style.display = 'block'; box.innerHTML = '
加载中…
'; var u = U(); Promise.all([ fetch(API + '/api/user-settings/profile?user_id=' + encodeURIComponent(u)).then(function (r) { return r.json().catch(function () { return {}; }); }), fetch(API + '/api/user-settings/status?user_id=' + encodeURIComponent(u)).then(function (r) { return r.json().catch(function () { return {}; }); }) ]).then(function (rs) { var pf = rs[0] && (rs[0].data || rs[0]) || {}, st = rs[1] && (rs[1].data || rs[1]) || {}; try { window.v34SetPf(pf); } catch (e) {} var nm = pf.nickname || pf.username || '未登录', em = pf.email || '', u2 = pf.username || u; var bl = st.balance_yuan == null ? '--' : '¥' + Number(st.balance_yuan).toFixed(2); var sb = (st.subscription && st.subscription.length) ? (st.subscription[0].plan_name || st.subscription[0].type || '订阅中') : '无'; var tc = (st.usage && st.usage.today_calls) || 0; var M = [['👤 个人资料', 'profile'], ['🔒 账号安全', 'pwd'], ['🔗 第三方账号', 'bind'], ['💎 会员与充值订阅', 'vip'], ['🔑 API Key', 'key'], ['📡 发布中心', 'pub'], ['🔔 通知中心', 'nt'], ['🗄️ 文件存储管理', 'sto'], ['📚 我的生成库', 'lib'], ['❓ 帮助 / AI 客服', 'help']]; var mk = function (m) { return '
' + m[0] + '›
'; }; box.innerHTML = '
' + '
' + E((nm || '?').slice(0, 1)) + '
' + '
' + E(nm) + ' ✅已登录
' + '
' + E(u2) + (em ? ' · ' + E(em) : '') + '
' + '
' + bl + '
余额
' + E(sb) + '
订阅
' + tc + '
今日调用
' + '
' + M.map(mk).join('') + '
退出登录
' + '
多模态消耗从余额扣除;点头像或编辑资料可传头像
'; 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] 保险渲染器就绪'); })();