join.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394
  1. $(function() {
  2. var isLast = false,
  3. currentPage = 0,
  4. categoryId = '',
  5. locationId = '',
  6. searchText = '',
  7. arrLocation = [],
  8. arrCategories = [],
  9. arrList = [];
  10. function getCookie(c_name) {
  11. if (document.cookie.length > 0) {
  12. c_start = document.cookie.indexOf(c_name + "=")
  13. if (c_start != -1) {
  14. c_start = c_start + c_name.length + 1
  15. c_end = document.cookie.indexOf(";", c_start)
  16. if (c_end == -1) c_end = document.cookie.length
  17. return unescape(document.cookie.substring(c_start, c_end))
  18. }
  19. }
  20. return ''
  21. }
  22. var _templang = getCookie('language') ? getCookie('language') : 'zh';
  23. // console.log(lang)
  24. function _ajax(url, type, data, callback) {
  25. $.ajax({
  26. url: url,
  27. dataType: "json",
  28. type: type || 'GET',
  29. header: {
  30. 'content-type': 'application/x-www-form-urlencoded'
  31. },
  32. data: data,
  33. success: function(data) {
  34. callback(data)
  35. },
  36. error: function(msg) {
  37. }
  38. });
  39. }
  40. function getLocationData() {
  41. _ajax('/recruitment/location/api/get', 'GET', { rnd: Math.random() }, function(data) {
  42. if (data && data.length > 0) {
  43. //
  44. arrLocation = data;
  45. appendLocationHtml(data)
  46. }
  47. })
  48. }
  49. function appendLocationHtml(arr) {
  50. $("._location").empty();
  51. var html = '',
  52. result = arr,
  53. len = arr.length,
  54. i = 0;
  55. if (_templang == 'zh') {
  56. //循环数据
  57. for (; i < len; i++) {
  58. var rs = result[i],
  59. _id = rs.id,
  60. _position = rs.name,
  61. _englishName = rs.englishName;
  62. html += '<span data-id="' + _id + '">' + _position + '</span>';
  63. }
  64. } else {
  65. //循环数据
  66. for (; i < len; i++) {
  67. var rs = result[i],
  68. _id = rs.id,
  69. _position = rs.name,
  70. _englishName = rs.englishName;
  71. html += '<span data-id="' + _id + '">' + _englishName + '</span>';
  72. }
  73. }
  74. //渲染数据
  75. $("._location").append(html);
  76. }
  77. function getCategoryData() {
  78. _ajax('/recruitment/category/api/get', 'GET', { rnd: Math.random() }, function(data) {
  79. console.log(data)
  80. if (data && data.length > 0) {
  81. //
  82. arrCategories = data;
  83. // var html = '',
  84. // result = data,
  85. // len = result.length,
  86. // i = 0;
  87. // //循环数据
  88. // for (; i < len; i++) {
  89. // var rs = result[i],
  90. // _id = rs.id,
  91. // _category = rs.name,
  92. // _englishName = rs.englishName;
  93. // html += '<span data-id="' + _id + '">' + _category + '</span>';
  94. // }
  95. // //渲染数据
  96. // $(".work_list_search_title_con").append(html);
  97. appendCategoryHtml(data)
  98. }
  99. })
  100. }
  101. function appendCategoryHtml(arr) {
  102. $(".work_list_search_title_con").empty();
  103. var html = '',
  104. result = arr,
  105. len = arr.length,
  106. i = 0;
  107. if (_templang == 'zh') {
  108. //循环数据
  109. for (; i < len; i++) {
  110. var rs = result[i],
  111. _id = rs.id,
  112. _category = rs.name,
  113. _englishName = rs.englishName;
  114. html += '<span data-id="' + _id + '">' + _category + '</span>';
  115. }
  116. } else {
  117. //循环数据
  118. for (; i < len; i++) {
  119. for (; i < len; i++) {
  120. var rs = result[i],
  121. _id = rs.id,
  122. _category = rs.name,
  123. _englishName = rs.englishName;
  124. html += '<span data-id="' + _id + '">' + _englishName + '</span>';
  125. }
  126. }
  127. }
  128. //渲染数据
  129. $(".work_list_search_title_con").append(html);
  130. }
  131. function getPositionData(page, categoryId, locationId, searchText) {
  132. var obj = {
  133. page: page,
  134. categoryId: categoryId,
  135. locationId: locationId,
  136. searchText: searchText,
  137. rnd: Math.random()
  138. }
  139. _ajax('/recruitment/position/api/get', 'GET', obj, function(data) {
  140. if (data && data.content.length > 0) {
  141. //
  142. arrList = data;
  143. isLast = data.last;
  144. currentPage = data.number
  145. appendPositionHtml(data);
  146. }
  147. if (isLast) {
  148. var tempLast = getCookie('language') == 'zh'?'没有更多~':'No more~';
  149. $('.load_more').text(tempLast)
  150. }
  151. })
  152. }
  153. function appendPositionHtml(arr) {
  154. $(".work_list_con").empty();
  155. if (_templang == 'zh') {
  156. var html = '',
  157. result = arr.content,
  158. len = result.length,
  159. i = 0;
  160. //循环数据
  161. for (; i < len; i++) {
  162. var rs = result[i],
  163. _id = rs.id,
  164. _category = rs.categories[0].name,
  165. _categoriesEnglishName = rs.categories[0].englishName,
  166. _englishName = rs.englishName,
  167. _name = rs.name,
  168. _releaseTime = rs.releaseTime,
  169. _demand = rs.demand,
  170. _description = rs.description,
  171. _city = rs.locations[0].name
  172. _city_en = rs.locations[0].englishName
  173. _count = rs.count,
  174. html += '<div class="work_list_search_item">' +
  175. '<div class="work_list_search_item_con">' +
  176. '<div class="work_list_search_item_con_title">' + _name + '</div>' +
  177. '<div class="work_list_search_item_con_sub">' + _city + ', 招' + _count + '人,发布于' + _releaseTime + '</div>' +
  178. '</div>' +
  179. '<div data-id = ' + i + ' class="apply-btn">' +
  180. '加入我们' +
  181. '</div>' +
  182. '</div>';
  183. }
  184. //渲染数据
  185. $(".work_list_con").append(html);
  186. showDetail()
  187. } else {
  188. var html = '',
  189. result = arr.content,
  190. len = result.length,
  191. i = 0;
  192. //循环数据
  193. for (; i < len; i++) {
  194. var rs = result[i],
  195. _id = rs.id,
  196. _category = rs.categories[0].name,
  197. _categoriesEnglishName = rs.categories[0].englishName,
  198. _englishName = rs.englishName,
  199. _name = rs.name,
  200. _releaseTime = rs.releaseTime,
  201. _demand = rs.demand,
  202. _description = rs.description,
  203. _city = rs.locations[0].name
  204. _city_en = rs.locations[0].englishName
  205. _count = rs.count,
  206. html += '<div class="work_list_search_item">' +
  207. '<div class="work_list_search_item_con">' +
  208. '<div class="work_list_search_item_con_title">' + _englishName + '</div>' +
  209. '<div class="work_list_search_item_con_sub">' + _city_en + ', number:' + _count + ',time:' + _releaseTime + '</div>' +
  210. '</div>' +
  211. '<div data-id = ' + i + ' class="apply-btn">' +
  212. 'Apply Now' +
  213. '</div>' +
  214. '</div>';
  215. }
  216. //渲染数据
  217. $(".work_list_con").append(html);
  218. showDetail()
  219. }
  220. }
  221. getLocationData();
  222. getCategoryData();
  223. getPositionData(0, categoryId, locationId, searchText);
  224. $('._location').on('click', 'span', function(e) {
  225. var target = $(e.target)
  226. // console.log()
  227. locationId = $(target)[0].dataset.id;
  228. console.log(categoryId)
  229. $('.all_location').removeClass('click_active');
  230. target.siblings().removeClass('click_active');
  231. target.addClass('click_active');
  232. $(".work_list_con").empty();
  233. getPositionData(currentPage, categoryId, locationId, searchText);
  234. })
  235. $('.all_location').click(function(e) {
  236. locationId = "";
  237. $(".work_list_con").empty();
  238. $('.all_location').addClass('click_active');
  239. $('._location').find('span').removeClass('click_active');
  240. getPositionData(currentPage, categoryId, locationId, searchText);
  241. })
  242. $('.work_list_search_title_con').on('click', 'span', function(e) {
  243. var target = $(e.target)
  244. categoryId = $(target)[0].dataset.id;
  245. target.siblings().removeClass('click_active');
  246. target.addClass('click_active');
  247. $(".work_list_con").empty();
  248. getPositionData(currentPage, categoryId, locationId, searchText);
  249. })
  250. $('.form_input').on('input', function() {
  251. searchText = $('.form_input').val()
  252. })
  253. $('.search-btn').click(function() {
  254. $(".work_list_con").empty();
  255. getPositionData(currentPage, categoryId, locationId, searchText);
  256. })
  257. $('.load_more').click(function() {
  258. if (!isLast) {
  259. getPositionData(Number(currentPage) + 1, categoryId, locationId, searchText);
  260. } else {
  261. return
  262. }
  263. })
  264. function getCookie(c_name) {
  265. if (document.cookie.length > 0) {
  266. c_start = document.cookie.indexOf(c_name + "=")
  267. if (c_start != -1) {
  268. c_start = c_start + c_name.length + 1
  269. c_end = document.cookie.indexOf(";", c_start)
  270. if (c_end == -1) c_end = document.cookie.length
  271. return unescape(document.cookie.substring(c_start, c_end))
  272. }
  273. }
  274. return ''
  275. }
  276. function showDetail() {
  277. // $(.)
  278. $('.apply-btn').click(function(e) {
  279. var _lang = getCookie('language')
  280. $('.content_mask_con_bottom_con').empty();
  281. $('.content_mask_con_bottom_con_yaoqiu').empty();
  282. var currentIdx = e.currentTarget.dataset.id,
  283. html1 = _lang == 'zh' ? arrList.content[currentIdx].description : arrList.content[currentIdx].englishDescription,
  284. html2 = _lang == 'zh' ? arrList.content[currentIdx].demand : arrList.content[currentIdx].englishDemand,
  285. name = _lang == 'zh' ? arrList.content[currentIdx].name : arrList.content[currentIdx].englishName,
  286. _count = arrList.content[currentIdx].count,
  287. _releaseTime = arrList.content[currentIdx].releaseTime,
  288. _category = _lang == 'zh' ? arrList.content[currentIdx].categories[0].name : arrList.content[currentIdx].categories[0].englishName,
  289. _location = _lang == 'zh' ? arrList.content[currentIdx].locations[0].name : arrList.content[currentIdx].locations[0].englishName,
  290. fix_sub = _lang == 'zh' ? _category + ',' + _location + ',招' + _count + '人,发布于' + _releaseTime : _category + ',' + _location + ', number' + _count + ', time' + _releaseTime;
  291. // console.log(html)
  292. $('.content_mask_con_top_title').text(name);
  293. $('.content_mask_con_top_sub').text(fix_sub);
  294. $('.content_mask_con_bottom_con').append(html1);
  295. $('.content_mask_con_bottom_con_yaoqiu').append(html2);
  296. $('.join_mask').show();
  297. })
  298. }
  299. $('.content_mask_con').click(function() {
  300. return false;
  301. });
  302. $('.join_mask').click(function() {
  303. $('.join_mask').hide();
  304. });
  305. $('.btn').click(function() {
  306. _templang = getCookie('language');
  307. console.log('asd', _templang)
  308. appendLocationHtml(arrLocation)
  309. appendCategoryHtml(arrCategories);
  310. appendPositionHtml(arrList);
  311. })
  312. baguetteBox.run('.company_detail');
  313. baguetteBox.run('.our_detail');
  314. baguetteBox.run('.middle_img');
  315. })