common.js 10 KB

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