function page_login(c){
  c.innerHTML = '<div style="max-width:400px;margin:60px auto"><div class="card"><div class="card-title">管理后台登录</div>'+
    '<div class="form-group"><label>密码</label><input id="pwd" class="form-control" type="password" onkeydown="if(event.key===\'Enter\')doLogin()"></div>'+
    '<button class="btn btn-pri" onclick="doLogin()">登录</button></div></div>';
}

function doLogin(){
  var pwd = document.getElementById('pwd').value;
  api('/api/admin/login', {method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({password:pwd})})
    .then(function(d){
      if(d.token){ localStorage.setItem('admin_token', d.token); TOKEN = d.token; nav('dashboard'); }
      else{ toast(d.error||'密码错误','error'); }
    });
}
