login.js 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. $(function() {
  2. if (!jQuery.cookie) {
  3. jQuery.cookie = function(name, value, options) {
  4. if (typeof value != 'undefined') {
  5. options = options || {};
  6. if (value === null) {
  7. value = '';
  8. options.expires = -1;
  9. }
  10. var expires = '';
  11. if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
  12. var date;
  13. if (typeof options.expires == 'number') {
  14. date = new Date();
  15. date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
  16. } else {
  17. date = options.expires;
  18. }
  19. expires = '; expires=' + date.toUTCString();
  20. }
  21. var path = options.path ? '; path=' + options.path : '';
  22. var domain = options.domain ? '; domain=' + options.domain : '';
  23. var secure = options.secure ? '; secure' : '';
  24. document.cookie = [ name, '=', encodeURIComponent(value), expires, path, domain, secure ].join('');
  25. } else {
  26. var cookieValue = null;
  27. if (document.cookie && document.cookie != '') {
  28. var cookies = document.cookie.split(';');
  29. for (var i = 0; i < cookies.length; i++) {
  30. var cookie = jQuery.trim(cookies[i]);
  31. if (cookie.substring(0, name.length + 1) == (name + '=')) {
  32. cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
  33. break;
  34. }
  35. }
  36. }
  37. return cookieValue;
  38. }
  39. };
  40. }
  41. $("#username").val($.cookie('username'));
  42. $("#password").val($.cookie('password'));
  43. if ($.cookie('master')) {
  44. $("#master").val($.cookie('master'));
  45. }
  46. });
  47. function mobileLogin() {
  48. $.post(basePath + "common/login.action", {
  49. username : $("#username").val(),
  50. password : $("#password").val(),
  51. language : 'zh_CN',
  52. sob : $("#master")[0].value
  53. }, function(data, textStatus) {
  54. var rs = $.evalJSON(data);
  55. if(rs.reason) {
  56. alert(rs.reason);
  57. } else if(rs.exceptionInfo) {
  58. alert(rs.exceptionInfo);
  59. } else {
  60. $.cookie('username', $("#username").val());
  61. $.cookie('password', $("#password").val());
  62. $.cookie('master', $("#master")[0].value);
  63. window.location.href = basePath + '?master=' + $("#master")[0].value;
  64. }
  65. }, "application/json");
  66. }
  67. $(document).ready(function() {
  68. $.ajax({
  69. url: basePath + 'common/cross.action',
  70. type: 'GET',
  71. data: {
  72. path: 'http://113.105.74.141:8081/artifactory/libs-release-local/com/uas/android/pm/maven-metadata.xml'
  73. },
  74. dataType: 'xml',
  75. success: function(data) {
  76. if (data) {
  77. // latest version
  78. var version = $(data).find("metadata").find("versioning").find("latest").text();
  79. $('#download_client').attr('href', '//113.105.74.141:8081/artifactory/libs-release-local/com/uas/android/pm/' + version + '/pm-' + version + '.apk');
  80. }
  81. }
  82. });
  83. });