123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- $(function () {
- var isSSo = location.search.length > 0;//是否单点登录
- if (isSSo) {
- $('.container').hide();
- login();
- }
- var hasClick = false; //是否已经点击过登录按钮
- // 兼容ie的placeholder
- $('input, textarea').placeholder();
- // 登录点击
- $('#login').on('click', login);
- // 登录方法
- function login() {
- if (hasClick) return;
- hasClick = true;
- var name = $('#name').val()
- var pwd = $('#pwd').val()
- var data = {
- username: name,
- password: pwd
- }
- // 单点登录 start
- var ssoStr = '';
- var ssoJson;
- if (isSSo) {
- ssoStr = location.search.replace('?', '').split('&')[0].split('=')[1];
- ssoStr = Base64.decode(decodeURIComponent(ssoStr));
- ssoJson = JSON.parse(ssoStr);
- }
- var postData = isSSo ? { username: ssoJson.a, password: ssoJson.r, t: false } : data;
- // 单点登录 end
- $.ajax({
- type: "POST",
- contentType: "application/json;charset=UTF-8",
- url: baseUrl + "auth/reqlogin",
- data: JSON.stringify(postData),
- success: function (res) {
- if (res.state == 200) {
- sessionStorage.setItem('loginUser', JSON.stringify(res.data.requester));
- //判断版本类别
- $.ajax({
- type: "POST",
- contentType: "application/json;charset=UTF-8",
- url: baseUrl + "sysinfo/data/fetchDataList/systemConfiguration",
- data: JSON.stringify({ "idx": 0, "sum": 1000, "systemConfiguration": { "keyconfig": "repairMain" } }),
- success: function (result) {
- if (result.status == 200) {
- sessionStorage.setItem("repair_main", JSON.stringify(result.list[0]));
- // --------------
- //判断是否自动建单
- $.ajax({
- type: "POST",
- contentType: "application/json;charset=UTF-8",
- url: baseUrl + "sysinfo/data/fetchDataList/systemConfiguration",
- data: JSON.stringify({ "idx": 0, "sum": 1000, "systemConfiguration": { "keyconfig": "ifCreate" } }),
- success: function (result) {
- if (result.status == 200) {
- sessionStorage.setItem("ifCreate", JSON.stringify(result.list[0]));
- window.location.href = 'index.html';
- }
- hasClick = false;
- },
- //请求失败,包含具体的错误信息
- error: function (e) {
- console.log(e.status);
- console.log(e.responseText);
- }
- });
- // --------------
- }
- hasClick = false;
- },
- //请求失败,包含具体的错误信息
- error: function (e) {
- console.log(e.status);
- console.log(e.responseText);
- }
- });
- } else {
- alert('用户名或密码错误,请重试!');
- hasClick = false;
- }
- },
- //请求失败,包含具体的错误信息
- error: function (e) {
- console.log(e.status);
- console.log(e.responseText);
- }
- });
- }
- // enter登录
- $(document).bind('keypress', function (e) {
- var keyCode;
- if (window.event) {
- keyCode = e.keyCode
- } else if (e.which) {
- keycode = e.which;
- }
- if (e.keyCode != 13) {
- return;
- }
- $("#login").trigger("click");
- return false;
- });
- })
|