login.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /**
  2. * Created by JKZL-A on 2017/10/20.
  3. */
  4. var loginRelyOn = ['jquery', 'layer', 'vue', 'jsHelper', 'apiServer', 'promise', 'bootstrap', 'validate'];
  5. require(loginRelyOn, function ($, layer, vue, jsHelper, apiServer, Promise) {
  6. jsHelper.setLayerCon();
  7. var load = null;
  8. var loginApp = new vue({
  9. el: '#loginApp',
  10. data: {
  11. userID: '',
  12. password: ''
  13. },
  14. methods: {
  15. setLoad: function () {
  16. load = layer.load(1, {
  17. shade: [0.5, '#000']
  18. });
  19. },
  20. sendFun: function () {
  21. if (this.userID == '') {
  22. this.tips('请输入账号', '#lUAn');
  23. return;
  24. }
  25. if (this.password == '') {
  26. this.tips('请输入密码', '#lUPwd');
  27. return;
  28. }
  29. this.setLoad();
  30. apiServer.login({
  31. data: {
  32. "username": this.userID,
  33. "password": this.password
  34. }
  35. }).then(function (res) {
  36. layer.close(load);
  37. if (res.successFlg) {
  38. sessionStorage.setItem("ZF_UID", res.obj.id);
  39. sessionStorage.setItem("ZF_UN", res.obj.realName);
  40. sessionStorage.setItem("ZF_U", res.obj);
  41. var indexurl = apiServer.indexPage();
  42. console.info(indexurl)
  43. location.href = indexurl;
  44. } else {
  45. layer.msg(res.message);
  46. }
  47. });
  48. },
  49. tips: function (msg, id) {
  50. layer.tips(msg, id, {
  51. tips: [2, '#ff5722'],
  52. time: 1000
  53. });
  54. }
  55. }
  56. });
  57. });