jquery.jobslist.js 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418
  1. /* ============================================================
  2. * jquery.jobslist.js 职位搜索列表页面js集合
  3. * ============================================================
  4. * Copyright aix.
  5. * ============================================================ */
  6. !function($) {
  7. // 搜索类型切换
  8. $('.J_sli').click(function() {
  9. $(this).addClass('select').siblings().removeClass('select');
  10. var indexValue = $('.J_sli').index(this);
  11. var typeValue = $.trim($(this).data('type'));
  12. $('input[name="search_type"]').val(typeValue);
  13. });
  14. // 收起、展开筛选条件
  15. foldAction('.J_showbtn', '.J_so_condition');
  16. function foldAction(trigger, performer) {
  17. $(trigger).click(function() {
  18. $(this).addClass('none').siblings().removeClass('none');
  19. var indexValue = $(trigger).index(this);
  20. if (indexValue) {
  21. $(performer).slideUp();
  22. } else {
  23. $(performer).slideDown();
  24. }
  25. })
  26. }
  27. $('.J_showJobConditions').off().on('click', function(event) {
  28. $(this).addClass('none').siblings().removeClass('none');
  29. var indexValue = $('.J_showJobConditions').index(this);
  30. if (indexValue) {
  31. $('.for_up').slideDown();
  32. } else {
  33. $('.for_up').slideUp();
  34. }
  35. });
  36. // 列表详细和简易切换
  37. $('.J_detailList').click(function() {
  38. $(this).addClass('select').siblings('.J_detailList').removeClass('select');
  39. var indexValue = $('.J_detailList').index(this),
  40. type = $(this).attr('show_type');
  41. if (indexValue) {
  42. $('.J_allListBox').find('.detail').hide();
  43. $('.J_allListBox').find('.J_jobsStatus').addClass('show');
  44. } else {
  45. $('.J_allListBox').find('.detail').show();
  46. $('.J_allListBox').find('.J_jobsStatus').removeClass('show');
  47. }
  48. $.getJSON(list_show_type_url,{action:'jobs',type:type});
  49. });
  50. // 周边职位和热门职位切换
  51. $('.J_job_hotnear').click(function() {
  52. $(this).addClass('select').siblings('.J_job_hotnear').removeClass('select');
  53. var indexValue = $('.J_job_hotnear').index(this);
  54. $('.J_job_hotnear_show').removeClass('show');
  55. $('.J_job_hotnear_show').eq(indexValue).addClass('show');
  56. });
  57. // 列表详细展开收起
  58. $('.J_jobsStatus').click(function(){
  59. if($(this).hasClass('show')){
  60. $(this).removeClass('show');
  61. $(this).closest('.J_jobsList').find('.detail').show();
  62. }else{
  63. $(this).addClass('show');
  64. $(this).closest('.J_jobsList').find('.detail').hide();
  65. }
  66. });
  67. // 全选、反选
  68. $('.J_allSelected').click(function() {
  69. var isChecked = $(this).hasClass('select');
  70. var listArray = $('.J_allListBox .J_allList');
  71. if (isChecked) {
  72. $(this).removeClass('select');
  73. $.each(listArray, function(index, val) {
  74. $(this).removeClass('select');
  75. });
  76. $('.J_jobsList').removeClass('select');
  77. } else {
  78. $(this).addClass('select');
  79. $.each(listArray, function(index, val) {
  80. $(this).addClass('select');
  81. });
  82. $('.J_jobsList').addClass('select');
  83. }
  84. });
  85. $('.J_allList').click(function(){
  86. var isChecked = $(this).hasClass('select');
  87. if (isChecked) {
  88. $(this).removeClass('select');
  89. $(this).closest('.J_jobsList').removeClass('select');
  90. $('.J_allSelected').removeClass('select');
  91. } else {
  92. $(this).addClass('select');
  93. $(this).closest('.J_jobsList').addClass('select');
  94. var listArray = $('.J_allListBox .J_allList');
  95. var listCheckedArray = $('.J_allListBox .J_allList.select');
  96. if (listArray.length == listCheckedArray.length) {
  97. $('.J_allSelected').addClass('select');
  98. }
  99. }
  100. });
  101. var qrcode_bind_time,
  102. waiting_weixin_bind = function(){
  103. $.getJSON(qscms.root+"?m=Home&c=Members&a=waiting_weixin_bind");
  104. };
  105. // 申请、收藏职位
  106. jobSomething('.J_applyForJob', '申请成功!', true);
  107. jobSomething('.J_collectForJob', '收藏成功!', false);
  108. function jobSomething (trigger, successMsg, iscreate) {
  109. $(trigger).click(function() {
  110. var hasFavor = false;
  111. if (trigger =='.J_applyForJob' && $(this).hasClass('has-deliver')) {
  112. return false;
  113. }
  114. if (trigger =='.J_collectForJob' && $(this).hasClass('has-favor')) {
  115. // return false;
  116. hasFavor = true;
  117. }
  118. var that = this;
  119. var batch = eval($(this).data('batch'));
  120. var url = $(this).data('url');
  121. var hasAllowance = false;
  122. var jidValue = '';
  123. if (batch) { // 是否是批量
  124. if (listCheckEmpty()) {
  125. disapperTooltip('remind','您还没有选择职位!');
  126. return false;
  127. } else {
  128. var listCheckedObjs = $('.J_allListBox .J_allList.select');
  129. var jidArray = new Array();
  130. $.each(listCheckedObjs, function(index, val) {
  131. jidArray[index] = $(this).closest('.J_jobsList').data('jid');
  132. if ($(this).closest('.J_jobsList').find('.i-m').length) {
  133. hasAllowance = true;
  134. }
  135. });
  136. jidValue = jidArray.join(',');
  137. }
  138. } else {
  139. jidValue = $(this).closest('.J_jobsList').data('jid');
  140. }
  141. if (visitor_log == 'per') {
  142. ajaxFroJob(hasFavor);
  143. }else if (visitor_log == 'com') {
  144. disapperTooltip("remind", '请登录个人账号!');
  145. } else {
  146. trigger_login('per');
  147. }
  148. function ajaxFroJob(hasFavor) {
  149. if (iscreate) {
  150. var qsDialog = $(this).dialog({
  151. title:'申请职位',
  152. loading: true,
  153. footer: false,
  154. border: false,
  155. backdrop: true
  156. });
  157. $.ajax({
  158. url: url,
  159. type: 'POST',
  160. dataType: 'json',
  161. data: {jobs_id: jidValue,_token:csrf_token}
  162. }).done(function(data) {
  163. qsDialog.hide();
  164. if (parseInt(data.status) == 2) { //多份简历,选择简历弹窗
  165. var qsDialogSon = $(this).dialog({
  166. title: '选择投递简历',
  167. border: false,
  168. content:data.html,
  169. yes:function(){
  170. qsDialogSon.setCloseDialog(false);
  171. //获取所选简历id
  172. var resume_id = $('#resume_id').val();
  173. //申请职位
  174. var apply_url = url;
  175. $.post(url,{jobs_id:jidValue,resume_id:resume_id,_token:csrf_token},function(res){
  176. var dail_jids = res.fail_jids;
  177. //简历完善度不够
  178. qsDialogSon.hide();
  179. if (res.status == 0) {
  180. if(res.resume_id){
  181. var qsDialogSon1 = $(this).dialog({
  182. title: '申请职位',
  183. content: res.html,
  184. yes: function () {
  185. location.href = resume_update_url+'/'+res.resume_id;
  186. },
  187. btns: ['完善简历', '放弃申请']
  188. });
  189. }
  190. } else {
  191. //申请职位的最后弹出信息
  192. var qsDialogSons1 = $(this).dialog({
  193. title: '申请职位',
  194. content: res.html
  195. });
  196. //清除选中效果、修改收藏按钮效果
  197. var listArray = $('.J_allListBox .J_jobsList.select .J_allList');
  198. $('.J_allSelected').removeClass('select');
  199. $.each(listArray, function(index, val) {
  200. $(this).removeClass('select');
  201. if (dail_jids.length <1) {
  202. $(this).parent().parent().find('.detail .rbtn .deliver').text("已申请").addClass('has-deliver');
  203. } else {
  204. if (dail_jids.indexOf($(this).parent().parent().data('jid').toString()) == -1) {
  205. $(this).parent().parent().find('.detail .rbtn .deliver').text("已申请").addClass('has-deliver');
  206. }
  207. }
  208. });
  209. $('.J_jobsList').removeClass('select');
  210. if (!batch) {
  211. if (dail_jids.length <1) {
  212. $(that).text("已申请").addClass('has-deliver');
  213. }
  214. }
  215. }
  216. });
  217. }
  218. });
  219. } else {
  220. //只有一份审核通过的简历
  221. if (data.status == 0) {
  222. if(data.resume_id){
  223. var qsDialogSon1 = $(this).dialog({
  224. title: '申请职位',
  225. content: data.html,
  226. yes: function () {
  227. var url = resume_update_url+'/'+data.resume_id;
  228. location.href = url;
  229. },
  230. btns: ['完善简历', '放弃申请']
  231. });
  232. }
  233. } else {
  234. //申请职位的最后弹出信息
  235. var qsDialogSons1 = $(this).dialog({
  236. title: '申请职位',
  237. content: data.html
  238. });
  239. //清除选中效果、修改收藏按钮效果
  240. var listArray = $('.J_allListBox .J_jobsList.select .J_allList');
  241. $('.J_allSelected').removeClass('select');
  242. var dail_jids = data.fail_jids;
  243. $.each(listArray, function(index, val) {
  244. $(this).removeClass('select');
  245. if (dail_jids.length <1) {
  246. $(this).parent().parent().find('.detail .rbtn .deliver').text("已申请").addClass('has-deliver');
  247. } else {
  248. if (dail_jids.indexOf($(this).parent().parent().data('jid').toString()) == -1) {
  249. $(this).parent().parent().find('.detail .rbtn .deliver').text("已申请").addClass('has-deliver');
  250. }
  251. }
  252. });
  253. $('.J_jobsList').removeClass('select');
  254. if (!batch) {
  255. if (dail_jids.length <1) {
  256. $(that).text("已申请").addClass('has-deliver');
  257. }
  258. }
  259. }
  260. }
  261. }).error(function(result){
  262. qsDialog.hide();
  263. if(result.status == 500 || result.status == 400){
  264. disapperTooltip('remind',result.responseJSON.message);
  265. } else {
  266. disapperTooltip('remind','操作失败!');
  267. }
  268. });
  269. }else {
  270. if (hasFavor) {
  271. $.ajax({
  272. url: url,
  273. type: 'POST',
  274. dataType: 'json',
  275. data: {jid: jidValue,_token:csrf_token}
  276. }).done(function(data) {
  277. if(data.status==1){
  278. disapperTooltip('success','取消收藏成功!');
  279. //清除选中效果、修改已收藏按钮效果
  280. var listArray = $('.J_allListBox .J_jobsList.select .J_allList');
  281. $('.J_allSelected').removeClass('select');
  282. $.each(listArray, function(index, val) {
  283. $(this).removeClass('select');
  284. $(this).parent().parent().find('.detail .rbtn .favorites').text("收藏").removeClass('has-favor');
  285. });
  286. $('.J_jobsList').removeClass('select');
  287. if (!batch) {
  288. if($(that).text().length>0){
  289. $(that).text("收藏");
  290. }
  291. $(that).removeClass('has-favor');
  292. }
  293. } else {
  294. disapperTooltip('remind',data.msg);
  295. }
  296. }).error(function(result){
  297. if(result.status == 500 || result.status == 400){
  298. disapperTooltip('remind',result.responseJSON.message);
  299. } else {
  300. disapperTooltip('remind','操作失败!');
  301. }
  302. });
  303. } else {
  304. $.ajax({
  305. url: url,
  306. type: 'POST',
  307. dataType: 'json',
  308. data: {jid: jidValue,_token:csrf_token}
  309. }).done(function(data) {
  310. if(data.status==1){
  311. disapperTooltip('success',data.msg);
  312. //清除选中效果、修改收藏按钮效果
  313. var listArray = $('.J_allListBox .J_jobsList.select .J_allList');
  314. $('.J_allSelected').removeClass('select');
  315. $.each(listArray, function(index, val) {
  316. $(this).removeClass('select');
  317. $(this).parent().parent().find('.detail .rbtn .favorites').text("已收藏").addClass('has-favor');
  318. });
  319. $('.J_jobsList').removeClass('select');
  320. if (!batch) {
  321. if($(that).text().length>0){
  322. $(that).text("已收藏");
  323. }
  324. $(that).addClass('has-favor');
  325. }
  326. } else {
  327. disapperTooltip('remind',data.msg);
  328. }
  329. }).error(function(result){
  330. if(result.status == 500 || result.status == 400){
  331. disapperTooltip('remind',result.responseJSON.message);
  332. } else {
  333. disapperTooltip('remind','操作失败!');
  334. }
  335. });
  336. }
  337. }
  338. }
  339. });
  340. }
  341. function trigger_login(type){
  342. var qsDialog = $(this).dialog({
  343. loading: true,
  344. footer: false,
  345. header: false,
  346. border: false,
  347. backdrop: true
  348. });
  349. $.post(login_dig_url, {_token:csrf_token,type:type,redirect_url:redirect_url},function(result){
  350. if(result.status==1){
  351. qsDialog.hide();
  352. if (type == 'per') {
  353. var type_title = '个人会员登录';
  354. }else{
  355. var type_title = '企业会员登录';
  356. }
  357. var qsDialogSon = $(this).dialog({
  358. title: type_title,
  359. footer: false,
  360. border: false
  361. });
  362. qsDialogSon.setInnerPadding(false);
  363. qsDialogSon.setContent(result.html)
  364. } else {
  365. qsDialog.hide();
  366. disapperTooltip('remind','操作失败');
  367. }
  368. });
  369. }
  370. // 判断列表中是否有选中的项目
  371. function listCheckEmpty() {
  372. var listCheckedArray = $('.J_allListBox .J_allList.select');
  373. if (listCheckedArray.length) {
  374. return false;
  375. } else {
  376. return true;
  377. }
  378. }
  379. // 关键字改变,搜索条件清空
  380. $('#ajax_search_location').submit(function(){
  381. var nowKeyValue = $.trim($('input[name="key"]').val());
  382. var orgKeyValue = $.trim($('input[name="key"]').data('original'));
  383. if(nowKeyValue.length && nowKeyValue.length<2){
  384. disapperTooltip("remind",'关健字长度需大于2个字!');
  385. return !1;
  386. }
  387. if (!(nowKeyValue == orgKeyValue)) {
  388. $('.J_forclear').val('');
  389. }
  390. $('input[name="key"]').val(htmlspecialchars($('input[name="key"]').val()));
  391. var post_data = $('#ajax_search_location').serialize();
  392. if(qscms.keyUrlencode==1){
  393. post_data = encodeURI(post_data);
  394. }
  395. $.post($('#ajax_search_location').attr('action'),post_data,function(result){
  396. window.location=result.data;
  397. },'json');
  398. return false;
  399. });
  400. }(window.jQuery);