common.js 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358
  1. function isLogin() {
  2. return window._hasAccountInfo;
  3. }
  4. /**
  5. * 引入toaster方法
  6. */
  7. document.write("<script language=javascript src='static/js/common/toastr.js'></script>");
  8. /**
  9. * 获取用户信息
  10. */
  11. function getAccountInfo() {
  12. $.get('account', function(data){
  13. if (data.content) {
  14. $('.x-nologin').hide();
  15. $('.x-login').show();
  16. if(null != data.content.spaceName) {
  17. $('.x-login').find('.title').text(data.content.name + ',' + data.content.spaceName);
  18. } else {
  19. $('.x-login').find('.title').text(data.content.name);
  20. }
  21. $('.link-mall').attr('href', 'http://www.usoftmall.com/login/proxy');
  22. window._hasAccountInfo = true;
  23. }
  24. });
  25. }
  26. /**
  27. * 登录
  28. * @param event
  29. */
  30. function login(event) {
  31. event.preventDefault();
  32. $.get('account/login', function(data) {
  33. data.content && (window.location.href = data.content);
  34. });
  35. }
  36. /**
  37. * 退出
  38. */
  39. function logout() {
  40. $.get('account/logout', function(data) {
  41. if(data.success) {
  42. logoutUuzc();
  43. logoutUuzcJob();
  44. setTimeout("window.location.reload()", 200);
  45. }
  46. });
  47. }
  48. /**
  49. * 通知众创登出
  50. */
  51. function logoutUuzc() {
  52. var url = 'http://login.uuzcc.com/index/ubtob/logout';
  53. $.ajax(url, {
  54. dataType: 'jsonp',
  55. crossDomain: true,
  56. success: function(data) {
  57. if(data && data.resultcode == '200'){
  58. console.log(data.result.today);
  59. }
  60. }
  61. });
  62. }
  63. /**
  64. * 通知众创人才招聘退出
  65. */
  66. function logoutUuzcJob() {
  67. var url = 'http://job.uuzcc.com/index.php?m=&c=ubtob&a=logout';
  68. $.ajax(url, {
  69. dataType: 'jsonp',
  70. crossDomain: true,
  71. success: function(data) {
  72. if(data && data.resultcode == '200'){
  73. console.log(data.result.today);
  74. }
  75. }
  76. });
  77. }
  78. /**
  79. * 点击顶部导航栏跳转到人才招聘
  80. */
  81. function jobUuzc() {
  82. var url = 'http://job.uuzcc.com/';
  83. var loginUrl = 'http://job.uuzcc.com/index.php?m=&c=ubtob&a=login';
  84. $.get('uuzc/account/check', function(data) {
  85. var user = data.user;
  86. if(data.usertype == 'hr') { // 账号类型是hr直接登录
  87. loginJobUuzc(user, loginUrl, 'hr');
  88. setTimeout(window.location.href = url, 200);
  89. } else if(data.usertype == 'company' && !data.ishr) {// 如果是企业账号并且未设置hr账号,停留在当前页,其他的都跳转到人才招聘页
  90. if(data.hr) {// 如果企业存在hr账号,直接跳转
  91. loginJobUuzc(user, loginUrl, data.usertype);
  92. setTimeout(window.location.href = url, 200);
  93. } else {
  94. return;
  95. }
  96. } else if(data.usertype == 'personal') {
  97. loginJobUuzc(user, loginUrl, data.usertype);
  98. setTimeout(window.location.href = url, 200);
  99. } else {
  100. window.location.href = url;
  101. }
  102. });
  103. }
  104. /**
  105. * 链接到优软众创人才招聘(招聘入口)
  106. */
  107. function jobUuzcGet() {
  108. var url = 'http://job.uuzcc.com/';
  109. var loginUrl = 'http://job.uuzcc.com/index.php?m=&c=ubtob&a=login';
  110. $.get('uuzc/account/check', function(data) {
  111. var user = data.user;
  112. if(null != data && 'personal' == data.usertype) {
  113. toastr.error("您的账号为个人账号,不可进行此操作");
  114. } else if(null != data && 'company' == data.usertype) {
  115. if(!data.hr) {// 企业不存在hr账号
  116. if(data.manager) {// 管理员停留设置hr
  117. window.location.href = window.location.origin + window.location.pathname + "setHrAccount";
  118. } else {
  119. toastr.error('请通知管理员' + data.managerName + '设置HR账号');
  120. }
  121. } else {// 如果企业存在hr
  122. toastr.error('您的账号非HR账号,不可进行此操作');
  123. }
  124. } else if(data.usertype =='hr') {
  125. loginJobUuzc(user, loginUrl, 'hr');
  126. setTimeout(window.location.href = url, 200);
  127. } else {
  128. data.content && (window.location.href = data.content);
  129. }
  130. });
  131. }
  132. /**
  133. * 人才招聘求职入口
  134. */
  135. function jobUuzcPost() {
  136. var url = 'http://job.uuzcc.com/';
  137. var loginUrl = 'http://job.uuzcc.com/index.php?m=&c=ubtob&a=login';
  138. $.get('uuzc/account/check', function(data) {
  139. if(null != data.usertype) {
  140. var user = data.user;
  141. if(data.usertype == 'hr') {
  142. toastr.error('您的账号为HR账号,不能进行此操作');
  143. return;
  144. } else {
  145. loginJobUuzc(user, loginUrl, data.usertype);
  146. setTimeout(window.location.href = url, 200);
  147. }
  148. } else {// 求职时可以未登录
  149. data.content && (window.location.href = url);
  150. }
  151. });
  152. }
  153. /**
  154. * 通知众创人才招聘登录
  155. * @param user
  156. * @param userLoginUrl
  157. */
  158. function loginJobUuzc(user, url, type) {
  159. $('#J_commenting').attr("action", url);
  160. $('#username').val(user.username);
  161. $('#password').val(user.password);
  162. $('#email').val(user.email);
  163. $('#mobile').val(user.mobile);
  164. $('#uc_uid').val(user.uc_uid);
  165. $('#salt').val(user.salt);
  166. if(type == 'hr') {// 只有hr会带出当前企业的信息
  167. $('#companyname').val(user.companyname);
  168. $('#license').val(user.license);
  169. $('#website').val(user.website);
  170. $('#landine_tel').val(user.landine_tel);
  171. $('#telephone').val(user.telephone);
  172. }
  173. $('#J_commenting').submit();
  174. }
  175. /**
  176. * 添加hr账号
  177. */
  178. function addHrAccount() {
  179. var user = {
  180. username: $('#hrname').val(),
  181. email: $('#hremail').val(),
  182. mobile: $('#hrtel').val()
  183. };
  184. $.ajax({
  185. url: 'uuzc/setHrAccount',
  186. data: user,
  187. method: 'POST',
  188. async: false,
  189. success: function(data) {
  190. if(data) {
  191. var result = data.result;
  192. if(result == 'success') {
  193. toastr.success('设置HR账号成功');
  194. setTimeout(window.location.href = 'http://www.ubtob.com/#/uuzcJob', 500);
  195. }
  196. if(result == 'exist') {
  197. toastr.error('该企业HR账号已存在');
  198. }
  199. if(result == 'setFailure') {
  200. toastr.erroror('设置HR账号失败');
  201. }
  202. }
  203. },
  204. error: function (error) {
  205. toastr.erroror(error);
  206. }
  207. });
  208. }
  209. /**
  210. * 设置hr账号
  211. */
  212. function setHrAccount() {
  213. var user = {
  214. username: $('#username').val(),
  215. email: $('#useremail').val(),
  216. mobile: $('#usertel').val()
  217. };
  218. $.ajax({
  219. url: 'uuzc/setHrAccount',
  220. data: user,
  221. method: 'POST',
  222. async: false,
  223. success: function(data) {
  224. if(data) {
  225. console.log(data);
  226. var result = data.result;
  227. if(result == 'success') {
  228. toastr.success('设置HR账号成功');
  229. setTimeout(window.location.href = 'http://www.ubtob.com/#/uuzcJob', 500);
  230. }
  231. if(result == 'exist') {
  232. toastr.error('该企业HR账号已存在');
  233. }
  234. if(result == 'setFailure') {
  235. toastr.erroror('设置HR账号失败');
  236. }
  237. }
  238. },
  239. error: function (error) {
  240. toastr.erroror(error);
  241. }
  242. });
  243. }
  244. /**
  245. * 获取当前企业已存在的用户的信息
  246. */
  247. function getExistUser() {
  248. var users = [];
  249. $.ajax('uuzc/existusers', {
  250. dataType: 'json',
  251. method: 'GET',
  252. async: false,
  253. success: function(data) {
  254. users = data.content;
  255. if(users.length == 0) {
  256. $('#userList').css('display','none');
  257. }
  258. var ul = document.getElementById("userList");
  259. for(var i = 0; i < users.length; i++) {
  260. var li = document.createElement('li');
  261. var b = document.createElement('b');
  262. b.innerHTML = users[i].name;
  263. li.appendChild(b);
  264. var span = document.createElement('span');
  265. span.class = "phone"
  266. span.innerHTML = users[i].uid;
  267. li.appendChild(span);
  268. var span2 = document.createElement('span');
  269. span2.innerHTML = users[i].secondUID;
  270. li.appendChild(span2);
  271. li.id = 'btn_' + i;
  272. ul.appendChild(li);
  273. (function(i) {
  274. $("#btn_" + i ).click(function() {
  275. setAccount(users[i]);
  276. $('#userList').css('display','none');
  277. });
  278. })(i)
  279. }
  280. }
  281. });
  282. }
  283. /**
  284. * 选择现有的人员赋值
  285. *
  286. * @param user
  287. */
  288. function setAccount(user) {
  289. $('#username').val(user.name);
  290. $('#useremail').val(user.secondUID);
  291. $('#usertel').val(user.uid);
  292. $('#useruu').val(user.dialectUID);
  293. }
  294. /**
  295. * 相关提示信息
  296. */
  297. function suspendMessage() {
  298. toastr.error('网站正在升级中,敬请期待!');
  299. }
  300. $(function() {
  301. 'use strict';
  302. // 监听页面滚动
  303. $(window).scroll(function() {
  304. if($(window).scrollTop() >= 400) {
  305. $('#nav').addClass('on');
  306. } else {
  307. $('#nav').removeClass('on');
  308. }
  309. });
  310. // 查询登录信息
  311. getAccountInfo();
  312. // 登录点击
  313. $('.link-login').click(login);
  314. // 退出点击
  315. $('.link-logout').click(logout);
  316. // 点击链接到众创人才招聘(招聘)
  317. $('.link-job-get').click(jobUuzcGet);
  318. // 连接到众创招聘
  319. $('.link-job').click(jobUuzc);
  320. // 求职
  321. $('.link-job-post').click(jobUuzcPost);
  322. // 添加hr账号(新增)
  323. $('#addHrAccount').click(addHrAccount);
  324. // 添加hr账户(现有)
  325. $('#setHrAccount').click(setHrAccount);
  326. // 获取当前企业用户信息
  327. $('#existUsers').click(getExistUser);
  328. // 点击众创链接给出提示
  329. $('.x-link-info').click(suspendMessage);
  330. });