common.js 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. function isLogin() {
  2. return window._hasAccountInfo;
  3. }
  4. // 获取用户信息
  5. function getAccountInfo() {
  6. $.get('account', function(data){
  7. if (data.content) {
  8. $('.x-nologin').hide();
  9. $('.x-login').show();
  10. $('.x-login').find('.title').text(data.content.name + ',' + data.content.spaceName);
  11. $('.link-mall').attr('href', 'http://www.usoftmall.com/login/proxy');
  12. window._hasAccountInfo = true;
  13. }
  14. });
  15. }
  16. // 登录
  17. function login(event) {
  18. event.preventDefault();
  19. $.get('account/login', function(data){
  20. data.content && (window.location.href = data.content);
  21. });
  22. }
  23. // 退出
  24. function logout() {
  25. $.get('account/logout', function(data) {
  26. if(data.success) {
  27. logoutUuzc();
  28. logoutUuzcJob();
  29. setTimeout("window.location.reload()", 200);
  30. }
  31. });
  32. }
  33. function logoutUuzc() { // 通知众创登出
  34. var url = 'http://login.uuzcc.com/index/ubtob/logout';
  35. $.ajax(url, {
  36. dataType: 'jsonp',
  37. crossDomain: true,
  38. success: function(data) {
  39. if(data && data.resultcode == '200'){
  40. console.log(data.result.today);
  41. }
  42. }
  43. });
  44. }
  45. /**
  46. * 通知众创人才招聘退出
  47. */
  48. function logoutUuzcJob() {
  49. var url = 'http://job.uutest.com/index.php?m=&c=ubtob&a=logout';
  50. $.ajax(url, {
  51. dataType: 'jsonp',
  52. crossDomain: true,
  53. success: function(data) {
  54. if(data && data.resultcode == '200'){
  55. console.log(data.result.today);
  56. }
  57. }
  58. });
  59. }
  60. /**
  61. * 链接到优软众创人才招聘
  62. */
  63. function jobUuzc(event) {
  64. var url = 'http://job.uuzcc.com/';
  65. var loginUrl = 'http://job.uutest.com/index.php?m=&c=ubtob&a=login';
  66. $.get('uuzc/account/check', function(data) {
  67. window.location.href = window.location.origin + window.location.pathname + "setHrAccount";
  68. var user = data.user;
  69. if(null != data && 'personal' == data.usertype) {
  70. loginJobUuzc(user, loginUrl, 'user');
  71. window.location.href = url;
  72. } else if(null != data && 'company' == data.usertype) {
  73. if(data.manager) {// 管理员才能进行设置操作
  74. if(!data.hr) {// 没有hr账号先设置hr
  75. window.location.href = window.location.origin + window.location.pathname + "setHrAccount";
  76. } else {
  77. loginJobUuzc(user, loginUrl, 'company');
  78. window.location.href = url;
  79. }
  80. } else {
  81. loginJobUuzc(user, loginUrl, 'user');
  82. window.location.href = url;
  83. }
  84. }
  85. });
  86. }
  87. /**
  88. * 通知众创人才招聘登录
  89. * @param user
  90. * @param userLoginUrl
  91. */
  92. function loginJobUuzc(user, url, type) {
  93. $('#J_commenting').attr("action", url);
  94. $('#username').val(user.username);
  95. $('#password').val(user.password);
  96. $('#email').val(user.email);
  97. $('#mobile').val(user.mobile);
  98. $('#uc_uid').val(user.uc_uid);
  99. $('#salt').val(user.salt);
  100. if(type == 'company') {
  101. $('#companyname').val(user.companyname);
  102. $('#license').val(user.license);
  103. $('#website').val(user.website);
  104. $('#landine_tel').val(user.landine_tel);
  105. $('#telephone').val(user.telephone);
  106. }
  107. $('#J_commenting').submit();
  108. }
  109. /**
  110. * 添加hr账号
  111. */
  112. function addHrAccount() {
  113. var user = {
  114. username: $('#hrname').val() != null ? $('#hrname').val() != null : $('#username').val(),
  115. email: $('#hremail').val() != null ? $('#hremail').val() : $('#useremail').val(),
  116. mobile: $('#hrtel').val() != null ? $('#hrtel').val() : $('#usertel')
  117. };
  118. $.ajax({
  119. url: 'uuzc/setHrAccount',
  120. data: user,
  121. method: 'POST',
  122. async: false,
  123. success: function(data) {
  124. if(data) {
  125. console.log(data);
  126. var result = data.result;
  127. if(result == 'success') {
  128. alert('设置hr账号成功');
  129. window.location.href = window.location.origin + window.location.pathname;
  130. }
  131. if(result == 'exist') {
  132. alert('该企业hr账号已存在');
  133. }
  134. if(result == 'setFailure') {
  135. alert('设置hr账号失败');
  136. }
  137. }
  138. },
  139. error: function (error) {
  140. }
  141. });
  142. }
  143. /**
  144. * 获取当前企业已存在的用户的信息
  145. */
  146. function getExistUser() {
  147. var users = [];
  148. $.ajax('uuzc/existusers', {
  149. dataType: 'json',
  150. method: 'GET',
  151. async: false,
  152. success: function(data) {
  153. users = data.content;
  154. if(users.length == 0) {
  155. $('#userList').css('display','none');
  156. }
  157. var ul = document.getElementById("userList");
  158. for(var i = 0; i < users.length; i++) {
  159. var li = document.createElement('li');
  160. var b = document.createElement('b');
  161. b.innerHTML = users[i].name;
  162. li.appendChild(b);
  163. var span = document.createElement('span');
  164. span.class = "phone"
  165. span.innerHTML = users[i].uid;
  166. li.appendChild(span);
  167. var span2 = document.createElement('span');
  168. span2.innerHTML = users[i].secondUID;
  169. li.appendChild(span2);
  170. li.id = 'btn_' + i;
  171. ul.appendChild(li);
  172. (function(i) {
  173. $("#btn_" + i ).click(function() {
  174. setAccount(users[i]);
  175. $('#userList').css('display','none');
  176. });
  177. })(i)
  178. }
  179. }
  180. });
  181. }
  182. /**
  183. * 选择现有的人员赋值
  184. *
  185. * @param user
  186. */
  187. function setAccount(user) {
  188. console.log(user);
  189. $('#username').val(user.name);
  190. $('#useremail').val(user.secondUID);
  191. $('#usertel').val(user.uid);
  192. $('#useruu').val(user.dialectUID);
  193. }
  194. $(function() {
  195. 'use strict';
  196. // 监听页面滚动
  197. $(window).scroll(function() {
  198. if($(window).scrollTop() >= 400) {
  199. $('#nav').addClass('on');
  200. } else {
  201. $('#nav').removeClass('on');
  202. }
  203. });
  204. // 查询登录信息
  205. getAccountInfo();
  206. // 登录点击
  207. $('.link-login').click(login);
  208. // 退出点击
  209. $('.link-logout').click(logout);
  210. // 点击链接到众创人才招聘
  211. $('.link-job').click(jobUuzc);
  212. // 添加hr账号(新增)
  213. $('#addHrAccount').click(addHrAccount);
  214. // 添加hr账户(现有)
  215. $('#setHrAccount').click(addHrAccount);
  216. // 获取当前企业用户信息
  217. $('#existUsers').click(getExistUser);
  218. });