/* v31b: "我的"补:文件存储管理(OBS个人空间)/点头像上传/会员台真实订阅方案 */ (function () { 'use strict'; if (window.__mobV31B) return; window.__mobV31B = true; var API = 'https://api-gateway.duoweiying.cn'; function $(id) { return document.getElementById(id); } function uidB() { 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 esc(s) { return String(s == null ? '' : s).replace(/[&<>"']/g, function (c) { return { '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c]; }); } function tip(t) { try { var o = $('v31tip'); if (o) o.remove(); var d = document.createElement('div'); d.id = 'v31tip'; 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;white-space:pre-line;'; d.textContent = t; document.body.appendChild(d); setTimeout(function () { d.remove(); }, 3200); } catch (e) {} } /* ① 我的页:文件存储管理行 + 点头像上传 */ function patchProfile() { try { var pc = $('profile-container'); if (!pc) return; var iv = setInterval(function () { if (pc._v31b || !pc.querySelector('[data-v23m]')) return; pc._v31b = true; clearInterval(iv); var card = document.createElement('div'); card.style.cssText = 'background:#fff;border-radius:12px;margin:10px 10px 0;padding:12px;box-shadow:0 1px 4px rgba(15,23,42,.08);display:flex;align-items:center;justify-content:space-between;cursor:pointer;'; card.innerHTML = '🗄️ 文件存储管理(OBS 个人空间)状态 ›'; pc.insertBefore(card, pc.querySelector('[data-v23m]')); card.onclick = function () { fetch(API + '/ai-army/materials?user_id=' + encodeURIComponent(uidB()) + '&limit=500').then(function (r) { return r.json().catch(function () { return {}; }); }) .then(function (d) { var n = ((d && (d.data || d.materials)) || []).length; tip('✅ 个人 OBS 存储已开通(按账号自动隔离)\n已存 ' + n + ' 个文件;素材/视频/文件/知识库跨端(桌面/公众号/手机)同一账号可见'); }).catch(function () { tip('存储状态查询失败,请稍后重试'); }); }; /* 点头像上传 */ var av = pc.querySelector('[style*="52px"]'); if (av) { av.style.cursor = 'pointer'; av.title = '点击修改头像'; av.onclick = function () { var old = $('v31av'); if (old) old.remove(); var i = document.createElement('input'); i.id = 'v31av'; 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; tip('⏳ 头像上传中…'); var fd = new FormData(); fd.append('file', f); fetch(API + '/ai-army/upload?user_id=' + encodeURIComponent(uidB()) + '&material_type=image', { method: 'POST', body: fd }) .then(function (r) { return r.json().catch(function () { return {}; }); }) .then(function (d) { var url = d && (d.url || (d.data && d.data.url) || d.file_path); if (!url) { tip('上传失败'); return; } fetch(API + '/api/user-settings/profile', { method: 'PUT', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ user_id: uidB(), avatar_url: url }) }) .then(function (r2) { return r2.json().catch(function () { return {}; }); }) .then(function (d2) { tip((d2 && d2.success) ? '✅ 头像已更新(云端同步)' : '保存失败'); if (typeof loadUserProfile === 'function') { try { loadUserProfile(); } catch (e) {} } }); }); }; i.click(); }; } }, 700); } catch (e) {} } /* ② 会员台:注入真实订阅方案(GET /billing/plans,与桌面同源) */ function patchVip() { // 20260909-2: 撤除方案列表注入(不把订阅方案直连手机端,支付二维码/下单须在订阅中心/微信内完成,避免误导) return; try { var iv = setInterval(function () { var body = $('v26BBody'); if (!body || body._v31v) return; if (!body.querySelector('a[href*="subscribe"]')) return; body._v31v = true; clearInterval(iv); fetch(API + '/billing/plans?plan_type=' + encodeURIComponent('basic,pro,enterprise,lifetime')).then(function (r) { return r.json().catch(function () { return []; }); }) .then(function (d) { var arr = Array.isArray(d) ? d : (d.data || d.plans || []); if (!arr.length) return; var box = document.createElement('div'); box.style.cssText = 'background:#fff;border-radius:12px;padding:12px;margin-top:12px;'; box.innerHTML = '