function isLogin() { return window._hasAccountInfo; } /** * 引入piwik脚本,详情见http://piwik.ubtob.com */ function piwik() { var _paq = _paq || []; /* tracker methods like "setCustomDimension" should be called before "trackPageView" */ _paq.push(['trackPageView']); _paq.push(['enableLinkTracking']); (function() { var u="//piwik.ubtob.com/"; _paq.push(['setTrackerUrl', u+'piwik.php']); _paq.push(['setSiteId', '2']); var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s); })(); }; piwik(); /** * 引入toaster方法 */ document.write(""); /** * 获取用户信息 */ function getAccountInfo() { $.get('/account', function(data){ if (data.content) { window.loginInfo = data; $('.x-nologin').hide(); $('.x-login').show(); if(null != data.content.spaceName) { $('.x-login').find('.title').text(data.content.name + ',' + data.content.spaceName); } else { $('.x-login').find('.title').text(data.content.name); } window._hasAccountInfo = true; var user = data.content; if(null != data.space) { // 管理员 if(user.uid == data.space.adminTel) { // 如果是hr if(user.hr == 1) { $('.link-job-get').show(); $('.link-hr-set').hide(); } else { $('.link-hr-set').show(); $('.link-job-get').hide(); } } else {// 非管理员 $('.link-job-get').show(); $('.link-hr-set').hide(); var location = window.location.pathname; if(location.indexOf('setHrAccount') > -1) {// 如果是在设置hr页面,非管理员跳转到首页 window.location.href = 'http://www.ubtob.com/#/uuzcJob'; } } } } else { var location = window.location.pathname; if(location.indexOf('setHrAccount') > -1) {// 如果是在设置hr页面,没有登录的话跳转到登录页面 login(event); } } }); } /** * 登录 * @param event */ function login(event) { event.preventDefault(); $.get('account/login', function(data) { data.content && (window.location.href = data.content); }); } /** * 退出 */ function logout() { $.get('account/logout', function(data) { if(data.success) { logoutUuzc(); logoutUuzcJob(); logoutMall(); setTimeout("window.location.reload()", 200); } }); } function logoutMall() { var url = 'https://www.usoftmall.com/logout'; $.ajax(url, { dataType: 'jsonp', crossDomain: true, success: function(data) { if(data && data.resultcode == '200'){ console.log(data.result.today); } } }); } /** * 通知众创登出 */ function logoutUuzc() { var url = 'https://login.uuzcc.com/index/ubtob/logout'; $.ajax(url, { dataType: 'jsonp', crossDomain: true, success: function(data) { if(data && data.resultcode == '200'){ console.log(data.result.today); } } }); } /** * 通知众创人才招聘退出 */ function logoutUuzcJob() { var url = 'https://job.uuzcc.com/index.php?m=&c=ubtob&a=logout'; $.ajax(url, { dataType: 'jsonp', crossDomain: true, success: function(data) { if(data && data.resultcode == '200'){ console.log(data.result.today); } } }); } /** * 点击顶部导航栏跳转到人才招聘 */ function jobUuzc() { var url = 'https://job.uuzcc.com/'; var loginUrl = 'https://job.uuzcc.com/index.php?m=&c=ubtob&a=login'; if (!window.loginInfo) { // 未登录,跳转人才招聘首页 window.location.href = url; } if (!window.loginInfo.space) { // 个人账号也跳转人才招聘首页 loginJobUuzc(window.loginInfo.content.userUU, loginUrl); setTimeout(window.location.href = url, 200); } $.get("https://job.uuzcc.com/index.php?m=&c=ubtob&a=check_space_uu", { "spaceUU": window.loginInfo.space.spaceUU }, function (data) { // 企业有HR则跳转人才招聘 if (data.data.code == 1) { loginJobUuzc(window.loginInfo.content.userUU, loginUrl); setTimeout(window.location.href = url, 200); } }) // // 判断当前登录账号是否已注册 // $.get("https://job.uuzcc.com/index.php", { // "c": "ubtob", // "a": "check_user", // "uc_uid": window.loginInfo.content.userUU // }, function (data) { // if (data.data && data.data.code == 0 && window.loginInfo.space) { // // 在人才招聘未注册并且为企业账号,则判断是否有hr // $.get("https://job.uuzcc.com/index.php", { // "c": "ubtob", // "a": "company_hr", // "company_name": window.loginInfo.space.spaceName // }, function (data) { // if (data.data.code == 1) { // // 有hr则跳转人才招聘登录 // loginJobUuzc(window.loginInfo.content.userUU, loginUrl); // setTimeout(window.location.href = url, 200); // } else if (window.loginInfo.content.userUU == window.loginInfo.space.adminUU) { // // 管理员则不操作 // return; // } // }) // } else { // // 否则跳转人才招聘登录 // loginJobUuzc(window.loginInfo.content.userUU, loginUrl); // setTimeout(window.location.href = url, 200); // } // // }) } /** * 存储hrInfo,不用重新加载 * * @type {null} */ var hrInfo = null; function getHrInfo() { if(hrInfo == null) { $.get('uuzc/hrInfo', function(userInfo) { if(null != userInfo.user) { hrInfo = userInfo.user; // 默认给相关字段赋值 $('#hrname').val(hrInfo.name); $('#hremail').val(hrInfo.secondUID); $('#hrtel').val(hrInfo.uid); $('#username').val(hrInfo.name); $('#usertel').val(hrInfo.uid); $('#useruu').val(hrInfo.dialectUID); $('#useremail').val(hrInfo.secondUID); $('#userList').css('display','none'); } }); } } /** * 链接到优软众创人才招聘(招聘入口) */ function jobUuzcGet() { var url = 'https://job.uuzcc.com/'; var loginUrl = 'https://job.uuzcc.com/index.php?m=&c=ubtob&a=login'; if (!window.loginInfo) { // 未登录,跳转登录页面 $.get('/uuzc/account/check', function(data) { data.content && (window.location.href = data.content); }) } if (!window.loginInfo.space) { // 个人账号 toastr.error("您的账号为个人账号,不可进行此操作"); } $.get("https://job.uuzcc.com/index.php?m=&c=ubtob&a=check_space_uu", { "spaceUU": window.loginInfo.space.spaceUU }, function (data) { // 企业有HR则跳转人才招聘 if (data.data.code == 1) { // 企业有hr // TODO 判断是否为当前用户是否为本企业hr if (false) { toastr.error("您的账号为非HR账号,不可进行此操作"); } else { loginJobUuzc(window.loginInfo.content.userUU, loginUrl); setTimeout(window.location.href = url, 200); } } else if (window.loginInfo.content.userUU == window.loginInfo.space.adminUU) { // 是管理员则跳转设置HR页面 window.location.href = window.location.origin + window.location.pathname + "setHrAccount"; } else { // 提示通知管理员设置HR toastr.error('请通知管理员' + window.loginInfo.space.admin.vipName + '设置HR账号'); } }) // // $.get("https://job.uuzcc.com/index.php", { // "c": "ubtob", // "a": "check_user", // "uc_uid": window.loginInfo.content.userUU // }, function (data) { // switch (data.data.code) { // case 0: // $.get("https://job.uuzcc.com/index.php?c=ubtob&a=company_hr", { // "company_name": window.loginInfo.space.spaceName // }, function (data) { // if (data.data.code == 1) { // toastr.error("您的账号为非HR账号,不可进行此操作"); // } else if (window.loginInfo.content.userUU == window.loginInfo.space.adminUU) { // // 管理员账号,跳转设置HR页面 // window.location.href = window.location.origin + window.location.pathname + "setHrAccount"; // } else { // toastr.error('请通知管理员' + window.loginInfo.space.admin.vipName + '设置HR账号'); // } // }) // break; // case 1: // toastr.error("您的账号为非HR账号,不可进行此操作"); // break; // case 2: // loginJobUuzc(window.loginInfo.content.userUU, loginUrl); // setTimeout(window.location.href = url, 200); // break; // default: // break; // } // }); } /** * 人才招聘求职入口 */ function jobUuzcPost() { var url = 'https://job.uuzcc.com/'; var loginUrl = 'https://job.uuzcc.com/index.php?m=&c=ubtob&a=login'; if(window.loginInfo) { $.get("https://job.uuzcc.com/index.php", { "c": "ubtob", "a": "check_user", "uc_uid": window.loginInfo.content.userUU }, function (data) { if (data.data.code == 1) { toastr.error('您的账号为HR账号,不能进行此操作'); } else { loginJobUuzc(window.loginInfo.content.userUU, loginUrl); setTimeout(window.location.href = url, 200); } }); } else {// 求职时可以未登录 window.location.href = url; } } /** * 通知众创人才招聘登录 * @param user * @param userLoginUrl */ function loginJobUuzc(uc_uid, url) { $('#J_commenting').attr("action", url); $('#uc_uid').val(uc_uid); $('#J_commenting').submit(); } /** * 添加hr账号 */ function addHrAccount() { var user = { username: $('#hrname').val(), password: null, email: $('#hremail').val(), mobile: $('#hrtel').val(), uc_uid: '', salt: null, companyname: window.loginInfo.space.spaceName, contact: $('#hrname').val(), telephone: $('#hrtel').val(), landline_tel: null, license: window.loginInfo.space.businessCode, spaceUU: window.loginInfo.space.spaceUU, registered: null, currency: null, website: null }; $.ajax({ url: 'uuzc/setHrAccount', data: user, method: 'POST', async: false, success: function(data) { if(data.success) { var result = data.content; user.uc_uid = result.userUU; user.password = result.userUU; uuzcSetHr(user); } }, error: function (error) { toastr.error(error); } }); } /** * 设置hr账号 */ function setHrAccount() { var user = { username: $('#username').val(), password: $('#useruu').val(), email: $('#useremail').val(), mobile: $('#usertel').val(), uc_uid: $('#useruu').val(), salt: null, companyname: window.loginInfo.space.spaceName, contact: $('#username').val(), telephone: $('#usertel').val(), landline_tel: null, license: window.loginInfo.space.businessCode, spaceUU: window.loginInfo.space.spaceUU, registered: null, currency: null, website: null }; uuzcSetHr(user); } function uuzcSetHr(user) { $.ajax({ url: 'https://job.uuzcc.com/index.php?m=&c=ubtob&a=reg_hr', data: user, method: 'POST', async: false, success: function(data) { if(data) { if (!data.code || data.code == 0) { // 设置失败 toastr.error(data.msg); } else { toastr.info("hr设置成功"); } } }, error: function (error) { toastr.error(error); } }); } /** * 获取的用户信息存放,全局调用,不用多次发生请求 * * @type {Array} */ var users = []; /** * 获取当前企业已存在的用户的信息 */ function getExistUser() { if(users.length == 0) { $.ajax('uuzc/existusers', { dataType: 'json', method: 'GET', async: false, success: function(data) { users = data.content; if(users.length == 0) { $('#userList').css('display','none'); } var ul = document.getElementById("userList"); for(var i = 0; i < users.length; i++) { var li = document.createElement('li'); var b = document.createElement('b'); b.innerHTML = users[i].vipName; li.appendChild(b); var span = document.createElement('span'); span.class = "phone" span.innerHTML = users[i].mobile; li.appendChild(span); var span2 = document.createElement('span'); span2.innerHTML = users[i].email; li.appendChild(span2); li.id = 'btn_' + i; ul.appendChild(li); (function(i) { $("#btn_" + i ).click(function() { setAccount(users[i]); $('#userList').css('display','none'); }); })(i) } } }); } } /** * 选择现有的人员赋值 * * @param user */ function setAccount(user) { $('#username').val(user.vipName); $('#useremail').val(user.email); $('#usertel').val(user.mobile); $('#useruu').val(user.userUU); } /** * 相关提示信息 */ function suspendMessage() { toastr.error('网站正在升级中,敬请期待!'); } function toB2B() { if (!window.loginInfo || !window.loginInfo.space) { window.location.href = 'https://www.usoftmall.com/btbBusiness'; } else { window.location.href = 'http://uas.ubtob.com'; } } function toSaaS() { if (!window.loginInfo || !window.loginInfo.space) { window.location.href = "/saas/about"; } // if (window.loginInfo.space.) var pattern = new RegExp("(.saas.ubtob.com)[/]?$"); var website = window.loginInfo.space.website; if (pattern.test(website)) { window.location.href = website; } else { window.location.href = "https://saas-admin.ubtob.com/apply"; } } /** * 监听输入框值的变化设置联想 */ $('#username').bind('input propertychange', function() { var nameList = []; $("#userList").find("li").remove();// 先清除以前的样式 for(var i = 0; i < users.length; i++) { if(users[i].name.indexOf($('#username').val()) > -1) { nameList.push(users[i]); } } if(nameList.length == 0) { $('#userList').css('display','none'); } else { $('#userList').css('display','show'); } var ul = document.getElementById("userList"); for(var i = 0; i < nameList.length; i++) { var li = document.createElement('li'); var b = document.createElement('b'); b.innerHTML = nameList[i].name; li.appendChild(b); var span = document.createElement('span'); span.class = "phone" span.innerHTML = nameList[i].uid; li.appendChild(span); var span2 = document.createElement('span'); span2.innerHTML = nameList[i].secondUID; li.appendChild(span2); li.id = 'btn_' + i; ul.appendChild(li); (function(i) { $("#btn_" + i ).click(function() { setAccount(nameList[i]); $('#userList').css('display','none'); }); })(i) } }); $(function() { 'use strict'; // 监听页面滚动 $(window).scroll(function() { if($(window).scrollTop() >= 400) { $('#nav').addClass('on'); } else { $('#nav').removeClass('on'); } }); // 查询登录信息 getAccountInfo(); // 获取当前企业HR信息 getHrInfo(); // 登录点击 $('.link-login').click(login); // 退出点击 $('.link-logout').click(logout); // 点击B2B $('.link-b2b').click(toB2B); // 点击链接到众创人才招聘(招聘) $('.link-job-get').click(jobUuzcGet); // 连接到众创招聘 $('.link-job').click(jobUuzc); // 点击链接到众创人才招聘(求职) $('.link-job-post').click(jobUuzcPost); // 点击链接到众创人才招聘(设置hr) $('.link-hr-set').click(jobUuzcGet); // 添加hr账号(新增) $('#addHrAccount').click(addHrAccount); // 添加hr账户(现有) $('#setHrAccount').click(setHrAccount); // 获取当前企业用户信息 $('#existUsers').click(getExistUser); // 点击众创链接给出提示 $('.x-link-info').click(suspendMessage); // 点击优企云服获取跳转地址 $('.link-saas').click(toSaaS); });