login.json 1.0 KB

123456789101112131415161718192021222324252627282930313233343536
  1. {
  2. "code": function({
  3. _req,
  4. Mock
  5. }) {
  6. let body = _req.body;
  7. if ((body.username === 'admin' && body.password === 'e10adc3949ba59abbe56e057f20f883e') || (body.username === 'user' && body.password === 'e10adc3949ba59abbe56e057f20f883e')) {
  8. return 200
  9. } else {
  10. return 500;
  11. }
  12. },
  13. "data": function({
  14. _req,
  15. Mock
  16. }) {
  17. let body = _req.body;
  18. if (body.username === 'admin' && body.password === 'e10adc3949ba59abbe56e057f20f883e') return Mock.mock({
  19. 'token': "bqddxxwqmfncffacvbpkuxvwvqrhln"
  20. })
  21. if (body.username === 'user' && body.password === 'e10adc3949ba59abbe56e057f20f883e') return Mock.mock({
  22. 'token': "unufvdotdqxuzfbdygovfmsbftlvbn"
  23. })
  24. },
  25. "msg": function({
  26. _req,
  27. Mock
  28. }) {
  29. let body = _req.body;
  30. if ((body.username === 'admin' && body.password === 'e10adc3949ba59abbe56e057f20f883e') || (body.username === 'user' && body.password === 'e10adc3949ba59abbe56e057f20f883e')) {
  31. return '成功'
  32. } else {
  33. return '用户名或密码错误';
  34. }
  35. },
  36. }