common.js 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  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.uuzcc.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 jobUuzcGet() {
  64. var url = 'http://job.uuzcc.com/';
  65. var loginUrl = 'http://job.uuzcc.com/index.php?m=&c=ubtob&a=login';
  66. $.get('uuzc/account/check', function(data) {
  67. if(data.info) {
  68. alert(data.info);
  69. }
  70. var user = data.user;
  71. if(null != data && 'personal' == data.usertype) {
  72. loginJobUuzc(user, loginUrl, 'user');
  73. window.location.href = url;
  74. } else if(null != data && 'company' == data.usertype) {
  75. if(data.manager) {// 管理员才能进行设置操作
  76. if(!data.hr) {// 没有hr账号先设置hr
  77. window.location.href = window.location.origin + window.location.pathname + "setHrAccount";
  78. } else {
  79. loginJobUuzc(user, loginUrl, 'company');
  80. window.location.href = url;
  81. }
  82. } else {
  83. loginJobUuzc(user, loginUrl, 'user');
  84. window.location.href = url;
  85. }
  86. } else {
  87. data.content && (window.location.href = data.content);
  88. }
  89. });
  90. }
  91. /**
  92. * 人才招聘求职入口
  93. */
  94. function jobUuzcPost() {
  95. var url = 'http://job.uuzcc.com/';
  96. var loginUrl = 'http://job.uuzcc.com/index.php?m=&c=ubtob&a=login';
  97. $.get('uuzc/account/check', function(data) {
  98. if(data.info) {
  99. alert(data.info);
  100. }
  101. var user = data.user;
  102. if(null != data && null != data.usertype) {
  103. loginJobUuzc(user, loginUrl, 'user');
  104. window.location.href = url;
  105. } else {
  106. data.content && (window.location.href = data.content);
  107. }
  108. });
  109. }
  110. /**
  111. * 通知众创人才招聘登录
  112. * @param user
  113. * @param userLoginUrl
  114. */
  115. function loginJobUuzc(user, url, type) {
  116. $('#J_commenting').attr("action", url);
  117. $('#username').val(user.username);
  118. $('#password').val(user.password);
  119. $('#email').val(user.email);
  120. $('#mobile').val(user.mobile);
  121. $('#uc_uid').val(user.uc_uid);
  122. $('#salt').val(user.salt);
  123. if(type == 'company') {
  124. $('#companyname').val(user.companyname);
  125. $('#license').val(user.license);
  126. $('#website').val(user.website);
  127. $('#landine_tel').val(user.landine_tel);
  128. $('#telephone').val(user.telephone);
  129. }
  130. $('#J_commenting').submit();
  131. }
  132. /**
  133. * 添加hr账号
  134. */
  135. function addHrAccount() {
  136. var user = {
  137. username: $('#hrname').val(),
  138. email: $('#hremail').val(),
  139. mobile: $('#hrtel').val()
  140. };
  141. $.ajax({
  142. url: 'uuzc/setHrAccount',
  143. data: user,
  144. method: 'POST',
  145. async: false,
  146. success: function(data) {
  147. if(data) {
  148. console.log(data);
  149. var result = data.result;
  150. if(result == 'success') {
  151. alert('设置hr账号成功');
  152. window.location.href = window.location.origin + window.location.pathname;
  153. }
  154. if(result == 'exist') {
  155. alert('该企业hr账号已存在');
  156. }
  157. if(result == 'setFailure') {
  158. alert('设置hr账号失败');
  159. }
  160. }
  161. },
  162. error: function (error) {
  163. }
  164. });
  165. }
  166. /**
  167. * 设置hr账号
  168. */
  169. function setHrAccount() {
  170. var user = {
  171. username: $('#username').val(),
  172. email: $('#useremail').val(),
  173. mobile: $('#usertel').val()
  174. };
  175. $.ajax({
  176. url: 'uuzc/setHrAccount',
  177. data: user,
  178. method: 'POST',
  179. async: false,
  180. success: function(data) {
  181. if(data) {
  182. console.log(data);
  183. var result = data.result;
  184. if(result == 'success') {
  185. alert('设置hr账号成功');
  186. window.location.href = window.location.origin + window.location.pathname;
  187. }
  188. if(result == 'exist') {
  189. alert('该企业hr账号已存在');
  190. }
  191. if(result == 'setFailure') {
  192. alert('设置hr账号失败');
  193. }
  194. }
  195. },
  196. error: function (error) {
  197. alert('设置hr账号失败');
  198. }
  199. });
  200. }
  201. /**
  202. * 获取当前企业已存在的用户的信息
  203. */
  204. function getExistUser() {
  205. var users = [];
  206. $.ajax('uuzc/existusers', {
  207. dataType: 'json',
  208. method: 'GET',
  209. async: false,
  210. success: function(data) {
  211. users = data.content;
  212. if(users.length == 0) {
  213. $('#userList').css('display','none');
  214. }
  215. var ul = document.getElementById("userList");
  216. for(var i = 0; i < users.length; i++) {
  217. var li = document.createElement('li');
  218. var b = document.createElement('b');
  219. b.innerHTML = users[i].name;
  220. li.appendChild(b);
  221. var span = document.createElement('span');
  222. span.class = "phone"
  223. span.innerHTML = users[i].uid;
  224. li.appendChild(span);
  225. var span2 = document.createElement('span');
  226. span2.innerHTML = users[i].secondUID;
  227. li.appendChild(span2);
  228. li.id = 'btn_' + i;
  229. ul.appendChild(li);
  230. (function(i) {
  231. $("#btn_" + i ).click(function() {
  232. setAccount(users[i]);
  233. $('#userList').css('display','none');
  234. });
  235. })(i)
  236. }
  237. }
  238. });
  239. }
  240. /**
  241. * 选择现有的人员赋值
  242. *
  243. * @param user
  244. */
  245. function setAccount(user) {
  246. $('#username').val(user.name);
  247. $('#useremail').val(user.secondUID);
  248. $('#usertel').val(user.uid);
  249. $('#useruu').val(user.dialectUID);
  250. }
  251. $(function() {
  252. 'use strict';
  253. // 监听页面滚动
  254. $(window).scroll(function() {
  255. if($(window).scrollTop() >= 400) {
  256. $('#nav').addClass('on');
  257. } else {
  258. $('#nav').removeClass('on');
  259. }
  260. });
  261. // 查询登录信息
  262. getAccountInfo();
  263. // 登录点击
  264. $('.link-login').click(login);
  265. // 退出点击
  266. $('.link-logout').click(logout);
  267. // 点击链接到众创人才招聘(招聘)
  268. $('.link-job-get').click(jobUuzcGet);
  269. // 求职
  270. $('.link-job-post').click(jobUuzcPost);
  271. // 添加hr账号(新增)
  272. $('#addHrAccount').click(addHrAccount);
  273. // 添加hr账户(现有)
  274. $('#setHrAccount').click(setHrAccount);
  275. // 获取当前企业用户信息
  276. $('#existUsers').click(getExistUser);
  277. });