| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- // 获取Url参数
- function getUrlParam(name){
- var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
- var r = window.location.search.substr(1).match(reg);
- if (r != null)
- return decodeURI(r[2]);
- return null;
- }
- // 获取跟路径
- function getRootPath() {
- var pathName = window.location.pathname.substring(1);
- var webName = pathName == '' ? '' : pathName.substring(0, pathName
- .indexOf('/'));
- if (webName == "") {
- return window.location.protocol + '//' + window.location.host;
- } else {
- return window.location.protocol + '//' + window.location.host + '/'
- + webName;
- }
- }
- var rootPath = getRootPath();
- $(function() {
- 'use strict';
-
- var b_username = getUrlParam('b_username');
- var b_password = getUrlParam('b_password');
- var b_enuu = getUrlParam('b_enuu');
- var page = getUrlParam('page');
-
- function checkError(reason) {
- $('#loading').hide();
- $('#chech-error .weui_msg_desc').text(reason);
- $('#chech-error').show();
- };
-
- function login() {
- $.ajax({
- type: 'POST',
- url: rootPath + '/j_spring_security_check',
- data: {
- j_username: b_username,
- j_password: b_password,
- t_enuu: b_enuu
- }, headers : {
- 'Content-Type' : 'application/x-www-form-urlencoded; charset=UTF-8'
- },
- success: function(data, status, res) {
- if(res.status === 200) {
- $('#loading .weui_toast_content').text('正在跳转...')
- window.location.href = rootPath + (page || '/');
- } else if(res.status === 207 && data instanceof Array) {
- var t;
- if(b_enuu) {
- t = '您的UAS商务平台账号并未绑定当前企业';
- } else {
- t = '您的UAS商务平台账号绑定了多个企业';
- }
- $('#loading').hide();
- $('#redirect-error .weui_msg_desc').text(t).show();
- $.each(data, function(k, v) {
- var html = '<a class="weui_cell">' +
- '<div class="weui_cell_bd weui_cell_primary">' +
- '<p>' + v.enName + '</p>' +
- '</div>' +
- '<div class="weui_cell_ft"></div>' +
- '</a>';
- var element = $(html);
- element.on('click', function(e) {
- b_enuu = v.uu;
- login();
- });
- $('#redirect-error .enterprises').append(element);
- });
- $('#redirect-error').show();
- }
- },
- error: function(res) {
- checkError(res.responseText);
- }
- });
- };
-
- if(b_username) {
- login();
- } else {
- checkError('用户名无效或不存在');
- };
-
- });
|