vendLogin.js 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. function keyDown(b) {
  2. var a = (navigator.appName == "Netscape") ? b.which : b.keyCode;
  3. if (a == 13) {
  4. login()
  5. }
  6. };
  7. function SetCookie(c, a) {
  8. var d = 30;
  9. var b = new Date();
  10. b.setTime(b.getTime() + d * 24 * 60 * 60 * 1000);
  11. document.cookie = c + "=" + escape(a) + ";expires=" + b.toGMTString()
  12. }
  13. function getCookie(b) {
  14. var a = document.cookie.match(new RegExp("(^| )" + b + "=([^;]*)(;|$)"));
  15. if (a != null) {
  16. return unescape(a[2])
  17. }
  18. return null
  19. }
  20. function showVendLoginDiv(isSessionOut){
  21. if(!Ext.getCmp('login')){
  22. var title = '重 新 登 录';
  23. if(isSessionOut){
  24. title = '会话过期,请重新登录';
  25. }
  26. Ext.create('erp.view.vendbarcode.main.vendReLogin', {
  27. isSessionOut: isSessionOut,
  28. title: title,
  29. id: 'login'
  30. });
  31. } else {
  32. Ext.getCmp('login').show();
  33. Ext.getCmp('login').refresh();
  34. }
  35. }
  36. function delCookie(b) {
  37. var a = new Date();
  38. a.setTime(a.getTime() - 1);
  39. var c = getCookie(b);
  40. if (c != null) {
  41. document.cookie = b + "=" + c + ";expires=" + a.toGMTString()
  42. }
  43. }
  44. var checked=true;
  45. /* $(function(){
  46. var $x = $(window).height()
  47. var $h = $x*0.68;
  48. $('.container').height($h);
  49. }) */
  50. function getMa(){
  51. $.ajax({
  52. type : "GET",
  53. url : basePath+"vendbarcode/getAllMasters.action",
  54. success : function(c) {
  55. if (c.success) {
  56. var rmbUser = getCookie('_rmb');
  57. if(rmbUser != null && rmbUser == 0) {
  58. $("#RmbUser").attr("checked", false);
  59. }else{
  60. $("#username").val(getCookie("username"));
  61. $("#password").val(getCookie("password"));
  62. }
  63. var json=eval(c)["masters"];
  64. var list="";
  65. $.each(json, function (index, item) {
  66. var Name = json[index].ma_name;
  67. var func = json[index].ma_function;
  68. if(index==0){
  69. $("#master1").val(Name);
  70. document.getElementById('master').innerHTML = func;
  71. }
  72. $("#box").append("<li role='"+"presentation"+"'><a role='"+"menuitem"+"' tabindex='"+"-1"+"' align=left value='"+Name+"' style='"+"cursor: pointer;margin:0px 32px"+"' onclick='changeMaster(this)'>"+func+"</a></li>");
  73. });
  74. if(getCookie("master_fun")!=null){
  75. document.getElementById('master').innerHTML = getCookie("master_fun");
  76. $("#master1").val(getCookie("master_name"));
  77. }
  78. } else {
  79. }
  80. }
  81. })
  82. }
  83. function checkboxOnclick(checkbox){
  84. if (checkbox.checked == true){
  85. checked=true;
  86. }else{
  87. checked=false;
  88. }
  89. console.log(checkbox.checked);
  90. }
  91. function changeMaster(f){
  92. $("#master1").val(f.getAttribute('value'));
  93. document.getElementById('master').innerHTML = f.innerHTML;
  94. }
  95. var basePath = (function() {
  96. var fullPath = window.document.location.href;
  97. var path = window.document.location.pathname;
  98. var subpos = fullPath.indexOf('//');
  99. var subpath = subpos > -1 ? fullPath.substring(0, subpos + 2) : '';
  100. if (subpos > -1)
  101. fullPath = fullPath.substring(subpos + 2);
  102. var pos = fullPath.indexOf(path);
  103. return subpath + fullPath.substring(0, pos) + path.substring(0, path.substr(1).indexOf('/') + 1) + '/';
  104. })();
  105. function showMenu(id){
  106. document.getElementById(id).style.visibility = 'visible';
  107. $("#"+id).show(100);
  108. initDiv(id);
  109. }
  110. function initDiv(id){
  111. var setime=null;
  112. $("#" + id).hover(function(){
  113. window.clearTimeout(setime);
  114. $(this).slideDown(200);
  115. return false;
  116. },function(){
  117. $tis= $(this);
  118. setime= setTimeout(function(){
  119. $tis.slideUp();
  120. },200);
  121. return false;
  122. });
  123. }
  124. function languageSwitch(){
  125. SetCookie('language', $(":radio:checked").val());
  126. window.location.href = '<%=basePath %>';
  127. }
  128. function login()
  129. {
  130. $.ajaxSetup({
  131. async : false
  132. });
  133. if ($("#username").val() == "")
  134. {
  135. $.showtip("请输入用户名!", 2500);
  136. $("#username").focus();
  137. return
  138. } else
  139. {
  140. if ($("#password").val() == "") {
  141. $.showtip("请输入密码!", 2500);
  142. $("#password").focus();
  143. return
  144. } else
  145. {
  146. $("#loading").show();
  147. $("#waitMsg").show();
  148. $("#loginBtn").text("登录中......");
  149. document.getElementById("loginBtn").disabled=true;
  150. var b = {};
  151. b.username = $("#username").val();
  152. b.password =$.md5($("#password").val());
  153. // encodeURIComponent($("#password").val());
  154. b.language = $(":radio:checked").val();
  155. b.sob = $("#master1").val();
  156. _postflag = 1;
  157. $.ajax({
  158. type : "GET",
  159. contentType : "application/json",
  160. url : basePath + "vendbarcode/login.action?username="
  161. + b.username + "&password=" + b.password
  162. + "&language=" + b.language + "&sob="
  163. + b.sob,
  164. success : function(c) {
  165. $("#loginBtn").text("登录");
  166. document.getElementById("loginBtn").disabled=false;
  167. _postflag = 0;
  168. if (c.success) {
  169. SetCookie("master_name", $("#master1").val());
  170. SetCookie("master_fun", $("#master").html());
  171. SetCookie("username", b.username);
  172. SetCookie("ve_code", c.ve_code);
  173. SetCookie("em_code", c.em_code);
  174. SetCookie("em_name", c.em_name);
  175. if ($("#RmbUser").is(':checked')) {
  176. delCookie('_rmb');
  177. SetCookie("password", b.password)
  178. } else {
  179. SetCookie("_rmb", '0');
  180. SetCookie("password", "")
  181. }
  182. SetCookie("language", b.language);
  183. var path = basePath;
  184. document.location.href = path+"vendbarcode/loginSuc.action";
  185. } else {
  186. if (c.reason) {
  187. $.showtip(c.reason, 6000);
  188. }
  189. }
  190. }
  191. })
  192. }
  193. }
  194. }
  195. $(function(){
  196. var language = getCookie("language");
  197. $("#"+language).attr('checked', 'checked');
  198. if(language == 'zh_TW'){
  199. document.getElementById('loginBtn').src = '<%=basePath %>resource/images/tab7_zh_TW.jpg';
  200. } else if(language == 'en_US'){
  201. document.getElementById('loginBtn').src = '<%=basePath %>resource/images/tab7_en_US.jpg';
  202. }
  203. });