(function () {
'use strict';
if (window.__mobV37) return; window.__mobV37 = 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 = $('v37tip'); if (o) o.remove(); var d = document.createElement('div'); d.id = 'v37tip'; 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) {} }
function CR(x) { return '
' + x + '
'; }
function I(id, ph, typ, val) { return ''; }
function B(id, txt) { return ''; }
var UID = U();
window.loadUserProfile = function () {
var box = $('profile-container'); if (!box) return;
box.style.display = 'block'; box.innerHTML = '加载中…
';
Promise.all([
fetch(API + '/api/user-settings/profile?user_id=' + encodeURIComponent(UID)).then(function (r) { return r.json().catch(function () { return {}; }); }),
fetch(API + '/api/user-settings/status?user_id=' + encodeURIComponent(UID)).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]) || {};
var nm = pf.nickname || pf.username || '未登录', em = pf.email || '', un = pf.username || UID;
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 H = '';
H += CR('' + E((nm || '?').slice(0, 1)) + '
' +
'
' + E(nm) + ' ✅已登录
' +
'
' + E(un) + (em ? ' · ' + E(em) : '') + '
' +
'
点头像修改头像
' +
'');
H += CR('👤 个人资料(修改昵称)' +
'' + I('v37N', '昵称(账号名称)', 'text', nm) + B('v37SN', '保存昵称'));
H += CR('🔒 账号安全(修改密码)' +
'' + I('v37O', '当前密码(首次可留空)', 'password') +
'' + I('v37P', '新密码(至少6位)', 'password') + B('v37SP', '修改密码') +
'第三方(微信)绑定:公众号/桌面端微信扫码登录即自动绑定,跨端免密。
');
box.innerHTML = H;
box.insertAdjacentHTML('beforeend', '');
}).catch(function (err) {
box.innerHTML = '加载失败:' + E((err && err.message) || '网络异常') + '
';
});
};
console.log('[MobV37a] 部分就绪');
})();
(function () {
'use strict';
if (window.__mobV37B) return; window.__mobV37B = true;
var API2 = 'https://api-gateway.duoweiying.cn';
function $(i) { return document.getElementById(i); }
function U2() { 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 E2(s) { return String(s == null ? '' : s).replace(/[&<>"']/g, function (c) { return { '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c]; }); }
function T2(t) { try { var o = $('v37tip'); if (o) o.remove(); var d = document.createElement('div'); d.id = 'v37tip'; 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) {} }
var KD = 'https://api-gateway.duoweiying.cn';
function bind() {
try {
var pc = document.getElementById('profile-container');
var sn = $('v37SN');
if (!pc || !sn || pc._v37b) return;
pc._v37b = true;
var UID = U2();
$('v37SN').onclick = function () { var nv = $('v37N').value.trim(); if (!nv) { T2('昵称不能为空'); return; } fetch(KD + '/api/user-settings/profile', { method: 'PUT', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ user_id: UID, nickname: nv }) }).then(function (r) { return r.json(); }).then(function (d) { T2((d && d.success) ? '昵称已保存' : '保存失败'); setTimeout(function () { try { window.loadUserProfile(); } catch (e) {} }, 400); }); };
var sp = $('v37SP');
if (sp) sp.onclick = function () { var np = $('v37P').value; if (np.length < 6) { T2('新密码至少6位'); return; } fetch(KD + '/api/user-settings/password', { method: 'PUT', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ user_id: UID, old_password: $('v37O').value, new_password: np }) }).then(function (r) { return r.json(); }).then(function (d) { T2((d && d.success) ? '密码已更新' : '失败:' + ((d && d.message) || '旧密码不对')); }); };
var av = $('v37av');
if (av) av.onclick = function () { var i = document.createElement('input'); i.type = 'file'; i.accept = 'image/*'; i.style.display = 'none'; document.body.appendChild(i); i.onchange = function () { var f = i.files && i.files[0]; if (!f) return; T2('上传中…'); var fd = new FormData(); fd.append('file', f); fetch(KD + '/ai-army/upload?user_id=' + encodeURIComponent(UID) + '&material_type=image', { method: 'POST', body: fd }).then(function (r) { return r.json(); }).then(function (d) { var url = d && (d.url || (d.data && d.data.url) || d.file_path); if (!url) { T2('上传失败'); return; } fetch(KD + '/api/user-settings/profile', { method: 'PUT', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ user_id: UID, avatar_url: url }) }).then(function () { T2('头像已更新'); setTimeout(function () { try { window.loadUserProfile(); } catch (e) {} }, 400); }); }); }; i.click(); };
var rest = $('v37rest');
if (rest) {
rest.innerHTML =
'❓ AI 客服(使用引导)' +
'
AI 客服在线:可咨询如何使用系统(创作/发布/充值/绑定等)。
' +
'
' +
'
' +
'' +
'' +
'' +
'' +
'' +
'' +
'
';
var k = $('v37K');
function ask() { var q = $('v37Q').value.trim(); if (!q) return; $('v37Q').value = '';
k.innerHTML += '' + E2(q) + '
AI 回复中…
'; k.scrollTop = k.scrollHeight;
fetch(KD + '/ai-army/dispatch?agent_id=customer_service_agent', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ user_input: q, user_id: UID }) }).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 = $('v37W'); if (w) w.remove(); k.innerHTML += '' + E2(String(txt).substring(0, 3000)) + '
'; k.scrollTop = k.scrollHeight; })
.catch(function () { var w = $('v37W'); if (w) w.textContent = '回复失败,请稍后重试'; });
}
$('v37S').onclick = ask;
$('v37Q').addEventListener('keydown', function (e) { if (e.key === 'Enter' && !e.shiftKey) { e.preventDefault(); ask(); } });
}
} catch (e) {}
}
setInterval(bind, 500);
setTimeout(bind, 200);
console.log('[MobV37] 我的-常驻操作版就绪');
})();