登录页按员工配置下拉选账号并保留原密码校验

This commit is contained in:
summer committed 2026-12-04 02:45:54 +08:00
1 parent 8379805328
commit 43ca89254f
6 files changed
+17 -9

No files matched your search

+2 -2
View File
@@ -164,8 +164,8 @@ function login(){
$('#shell').hidden=true;
if(typeof applyShopBrand==='function')applyShopBrand();
const intro=session.mode==='demo'?'用虚构订单练习完整流程,演示数据与新账隔离。':'先设置账号。当前是本机试用,正式云端开账另行配置。';
const options=session.loginOptions||[{member:'owner',loginName:'麦麦',label:'麦麦'},{member:'assistant',loginName:'助理1',label:'娜娜'},{member:'assistant2',loginName:'助理2',label:'小昊'}];
$('#login').innerHTML=`<section class="login-wrap"><div class="brand-mark">${e(Array.from(shopBrandName())[0]||'店')}</div><h1>${e(shopBrandName())} · 新账系统</h1><p class="muted">${session.setup||session.mode==='demo'?intro:'录入、收款与复核,从同一张订单开始。'}</p><div id="login-error"></div>${session.mode==='demo'?options.map(row=>button(e('以'+row.label+'身份进入演示'),'demo-'+row.member,row.member==='owner'?'primary':'')).join(''):session.setup?`<form id="setup-form">${field('店铺名称','storeName','','text','required maxlength="80"')}${field('店主显示名','ownerLabel','店主','text','required maxlength="30"')}${field('店主登录名','ownerLoginName','owner','text','required maxlength="60"')}${field('店主密码(至少12个字符)','ownerPassword','','password','required minlength="12" autocomplete="new-password"')}<p class="muted">进入系统后,在设置 → 员工管理中添加员工。</p><button class="primary">建立试用账号</button></form>`:`<form id="login-form">${field('手机号/原登录账号','name','','text','required autocomplete="username"')}${field('密码','password','','password','required autocomplete="current-password"')}<button class="primary">登录</button></form>`}<p class="small muted" style="margin-top:25px">云端数据库和飞书同步的真实状态,会在系统内显示。</p></section>`;
const options=session.loginOptions||[];
$('#login').innerHTML=`<section class="login-wrap"><div class="brand-mark">${e(Array.from(shopBrandName())[0]||'店')}</div><h1>${e(shopBrandName())} · 新账系统</h1><p class="muted">${session.setup||session.mode==='demo'?intro:'录入、收款与复核,从同一张订单开始。'}</p><div id="login-error"></div>${session.mode==='demo'?options.map(row=>button(e('以'+row.label+'身份进入演示'),'demo-'+row.member,row.member==='owner'?'primary':'')).join(''):session.setup?`<form id="setup-form">${field('店铺名称','storeName','','text','required maxlength="80"')}${field('店主显示名','ownerLabel','店主','text','required maxlength="30"')}${field('店主登录名','ownerLoginName','owner','text','required maxlength="60"')}${field('店主密码(至少12个字符)','ownerPassword','','password','required minlength="12" autocomplete="new-password"')}<p class="muted">进入系统后,在设置 → 员工管理中添加员工。</p><button class="primary">建立试用账号</button></form>`:`<form id="login-form"><label>登录账号<select name="member" required autocomplete="username">${opts([['','请选择账号'],...options.map(row=>[row.member,row.label])],'')}</select></label>${field('密码','password','','password','required autocomplete="current-password"')}<button class="primary">登录</button></form>`}<p class="small muted" style="margin-top:25px">云端数据库和飞书同步的真实状态,会在系统内显示。</p></section>`;
}
async function refresh(renderPage=true,stillCurrent){const latest=await api('/api/state');if(stillCurrent&&!stillCurrent())return;state=latest;if(typeof applyShopBrand==='function')applyShopBrand();$('#identity').textContent=state.user.label||state.user.name;$('#mode').textContent=state.mode==='demo'?'团队功能预览 · 虚构数据':state.mode==='production'?'云端系统':'本机试用';$('#notice').textContent=state.mode==='production'?`主账保存于云端服务器。飞书${state.sync.enabled?'待同步 '+state.sync.pending+' 项':'尚未连接'}。`:state.mode==='demo'?'团队功能预览·虚构数据,可在设置中切换成员身份练习。此预览使用独立样例账本,不影响原账;不会写入飞书。':'当前为本机试用数据,请先练习核对。正式云端数据库尚未部署;不会写入原飞书账。';if(renderPage)await render();}
function heading(kicker,title,desc,actions=''){return `<div class="page-heading"><div><div class="eyebrow">${kicker}</div><h1>${title}</h1><p class="muted">${desc}</p></div><div class="actions">${actions}</div></div>`;}