| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125 |
- (function($) {
- if (typeof $.cookie == 'undefined') {
- $.cookie = {};
- $.cookie.set = function(c, a, d) {
- d = d || 30;
- var b = new Date();
- b.setTime(b.getTime() + d * 24 * 60 * 60 * 1000);
- document.cookie = c + "=" + escape(a) + ";expires=" + b.toGMTString()
- };
- $.cookie.get = function(b) {
- var a = document.cookie.match(new RegExp("(^| )" + b + "=([^;]*)(;|$)"));
- if (a != null) {
- return unescape(a[2])
- }
- return null
- };
- $.cookie.del = function(b) {
- $.cookie.set(b, 1, -1);
- };
- }
- if (typeof $.location == 'undefined') {
- $.location = function(name) {
- var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
- var r = window.location.search.substr(1).match(reg);
- if (r != null)
- return decodeURI(r[2]);
- return null;
- };
- }
- var _username = $.cookie.get('s_username'), _password = $.cookie.get('s_password'), _remember = $.cookie
- .get('s_remember');
- if (_username && _username != '')
- $('#s_username').val(_username);
- $('#s_password').val(_password);
- if (_remember != null && _remember == 0) {
- $('#remember').attr('checked', false);
- }
- window.basePath = (function() {
- var fullPath = window.document.location.href;
- var path = window.document.location.pathname;
- var subpos = fullPath.indexOf('//');
- var subpath = subpos > -1 ? fullPath.substring(0, subpos + 2) : '';
- if (subpos > -1)
- fullPath = fullPath.substring(subpos + 2);
- var pos = fullPath.indexOf(path);
- return subpath + fullPath.substring(0, pos) + path.substring(0, path.substr(1).indexOf('/') + 1) + "/";
- })();
- (function() {
- if(typeof basePath == 'undefined')
- return;
- $.ajax({
- type : "GET",
- contentType : "application/json",
- url : basePath + "/common/saas/master.action?basePath=" + basePath,
- success : function(c) {
- setLoading(false);
- if(c && c.ma_name) {
- if(!c.enable)
- window.location.href = basePath + "common/saas/disable.action";
- else {
- window._init = c.init;
- window.sob = c.ma_name;
- $('#en-info h1').text(c.ma_function);
- // 演示模式,自动登录
- if('guest' == c.type && c.tempName) {
- $.cookie.set("s_username_" + c.ma_name, c.tempName);
- $('#login-wrap').addClass('hide');
- $('#guest-wrap').addClass('slidein');
- var page = $.location("_page");
- if(!page || page != 'logout') {
- login(c.tempName, '111111');
- }
- }
- }
- } else
- window.location.href = basePath + "common/saas/error.action";
- }
- });
- })();
- })(jQuery);
- function login(username, password) {
- username = username || $("#s_username").val();
- password = password || $("#s_password").val();
- setLoading(true, '登录中...');
- $.ajax({
- type : "POST",
- contentType : "application/json",
- url : basePath + "/common/login.action?username=" + username + "&password=" + password + "&sob=" + sob,
- success : function(c) {
- setLoading(false);
- if (c.success) {
- $.cookie.set("s_username", username);
- if ($("#remember").attr("checked")) {
- $.cookie.del('s_remember');
- $.cookie.set("s_password", password);
- } else {
- $.cookie.set("s_remember", '0');
- $.cookie.del("s_password");
- }
- var path = basePath, mobile = $.location("mobile");
- if(!window._init) {
- path += 'system/init.action';
- }
- if (mobile != null) {
- path += "?mobile=0";
- }
- document.location.href = path;
- } else {
- if (c.reason) {
- $.showtip(c.reason, 6000);
- } else {
- $.showtip(c.exceptionInfo, 6000);
- }
- }
- }
- });
- }
- // loading
- function setLoading(isLoading, loadingText) {
- $('.loading-container').css('display', isLoading ? 'block' : 'none');
- $('.loading-back').css('display', isLoading ? 'block' : 'none');
- if(isLoading) {
- $('.loading-container').text(loadingText);
- }
- };
|