wangzhibo
4 天以前 ae6f40460dcd56af6c5f60ba52c883854c3bac55
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="utf-8"/>
  <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1"/>
  <title>登录</title>
  <link rel="stylesheet" href="css.css"/>
</head>
<body>
<div class="wrap">
  <h1>分拣员登录</h1>
  <div class="card">
    <label>手机号</label>
    <input id="phone" type="tel" placeholder="请输入手机号" autocomplete="username"/>
    <label>密码</label>
    <input id="password" type="password" placeholder="请输入密码" autocomplete="current-password"/>
    <div id="err" class="err"></div>
    <button class="btn" id="loginBtn" onclick="login()">登录</button>
    <p class="muted">手机号和密码会保存在本机,下次打开自动填入。登录后 7 天内无需重新登录。</p>
  </div>
</div>
<script src="app.js"></script>
<script>
function fillSaved() {
  try {
    $("phone").value = Womp.getSavedPhone() || "";
    $("password").value = Womp.getSavedPassword() || "";
  } catch (e) {}
}
fillSaved();
function login() {
  var phone = $("phone").value.trim();
  var password = $("password").value;
  var btn = $("loginBtn");
  $("err").textContent = "";
  if (!phone || !password) { $("err").textContent = "请输入手机号和密码"; return; }
  try { Womp.saveCredentials(phone, password); } catch (e) {}
  btn.disabled = true;
  btn.textContent = "登录中…";
  api("/app/user/login/sorterPassword", { phone: phone, password: password }).then(function (data) {
    data.phone = phone;
    data.password = password;
    Womp.loginSuccess(JSON.stringify(data));
  }).catch(function (e) {
    $("err").textContent = loginErrMsg(e);
  }).then(function () {
    btn.disabled = false;
    btn.textContent = "登录";
  });
}
</script>
</body>
</html>