(function(){
var API='/static/api-bridge.php?path=';
var token=localStorage.getItem('token')||'';
var msg=document.getElementById('msg');
if(!token){msg.style.display='block';msg.textContent='请先登录';return;}
function get(p){return fetch(API+encodeURIComponent(p),{headers:{Accept:'application/json',token:token,uniacid:'666',Authorization:'Bearer '+token}}).then(function(r){return r.json();});}
function fmt(v){return window.JWCurrency?JWCurrency.format(v):'$'+Number(v||0).toFixed(2);}
Promise.all([get('/massage/coach/income'),get('/massage/coach/workbench/stats')]).then(function(arr){
var inc=arr[0].data||arr[0]||{};var st=arr[1].data||arr[1]||{};
document.getElementById('balance').textContent=fmt(inc.balanceCash||inc.withdrawable||0);
document.getElementById('pending').textContent=fmt(inc.checkCash||inc.pending||0);
var rows=[
['今日收益',fmt(st.todayIncome||st.todayCash||inc.todayIncome||0)],
['本月收益',fmt(st.monthIncome||st.monthCash||inc.monthIncome||0)],
['本月佣金',fmt(st.monthCommission||st.commission||inc.monthCommission||0)],
['累计提现',fmt(inc.totalWithdraw||inc.withdrawTotal||0)]
];
document.getElementById('detail').innerHTML=rows.map(function(r){return '