123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394 |
- $(function() {
- var isLast = false,
- currentPage = 0,
- categoryId = '',
- locationId = '',
- searchText = '',
- arrLocation = [],
- arrCategories = [],
- arrList = [];
- function getCookie(c_name) {
- if (document.cookie.length > 0) {
- c_start = document.cookie.indexOf(c_name + "=")
- if (c_start != -1) {
- c_start = c_start + c_name.length + 1
- c_end = document.cookie.indexOf(";", c_start)
- if (c_end == -1) c_end = document.cookie.length
- return unescape(document.cookie.substring(c_start, c_end))
- }
- }
- return ''
- }
- var _templang = getCookie('language') ? getCookie('language') : 'zh';
- // console.log(lang)
- function _ajax(url, type, data, callback) {
- $.ajax({
- url: url,
- dataType: "json",
- type: type || 'GET',
- header: {
- 'content-type': 'application/x-www-form-urlencoded'
- },
- data: data,
- success: function(data) {
- callback(data)
- },
- error: function(msg) {
- }
- });
- }
- function getLocationData() {
- _ajax('/recruitment/location/api/get', 'GET', { rnd: Math.random() }, function(data) {
- if (data && data.length > 0) {
- //
- arrLocation = data;
-
- appendLocationHtml(data)
- }
- })
- }
- function appendLocationHtml(arr) {
- $("._location").empty();
- var html = '',
- result = arr,
- len = arr.length,
- i = 0;
- if (_templang == 'zh') {
- //循环数据
- for (; i < len; i++) {
- var rs = result[i],
- _id = rs.id,
- _position = rs.name,
- _englishName = rs.englishName;
- html += '<span data-id="' + _id + '">' + _position + '</span>';
- }
- } else {
- //循环数据
- for (; i < len; i++) {
- var rs = result[i],
- _id = rs.id,
- _position = rs.name,
- _englishName = rs.englishName;
- html += '<span data-id="' + _id + '">' + _englishName + '</span>';
- }
- }
- //渲染数据
- $("._location").append(html);
- }
- function getCategoryData() {
- _ajax('/recruitment/category/api/get', 'GET', { rnd: Math.random() }, function(data) {
- console.log(data)
- if (data && data.length > 0) {
- //
- arrCategories = data;
- // var html = '',
- // result = data,
- // len = result.length,
- // i = 0;
- // //循环数据
- // for (; i < len; i++) {
- // var rs = result[i],
- // _id = rs.id,
- // _category = rs.name,
- // _englishName = rs.englishName;
- // html += '<span data-id="' + _id + '">' + _category + '</span>';
- // }
- // //渲染数据
- // $(".work_list_search_title_con").append(html);
- appendCategoryHtml(data)
- }
- })
- }
- function appendCategoryHtml(arr) {
- $(".work_list_search_title_con").empty();
- var html = '',
- result = arr,
- len = arr.length,
- i = 0;
- if (_templang == 'zh') {
- //循环数据
- for (; i < len; i++) {
- var rs = result[i],
- _id = rs.id,
- _category = rs.name,
- _englishName = rs.englishName;
- html += '<span data-id="' + _id + '">' + _category + '</span>';
- }
- } else {
- //循环数据
- for (; i < len; i++) {
- for (; i < len; i++) {
- var rs = result[i],
- _id = rs.id,
- _category = rs.name,
- _englishName = rs.englishName;
- html += '<span data-id="' + _id + '">' + _englishName + '</span>';
- }
- }
- }
- //渲染数据
- $(".work_list_search_title_con").append(html);
- }
- function getPositionData(page, categoryId, locationId, searchText) {
- var obj = {
- page: page,
- categoryId: categoryId,
- locationId: locationId,
- searchText: searchText,
- rnd: Math.random()
- }
- _ajax('/recruitment/position/api/get', 'GET', obj, function(data) {
- if (data && data.content.length > 0) {
- //
- arrList = data;
- isLast = data.last;
- currentPage = data.number
- appendPositionHtml(data);
- }
- if (isLast) {
- var tempLast = getCookie('language') == 'zh'?'没有更多~':'No more~';
- $('.load_more').text(tempLast)
- }
- })
- }
- function appendPositionHtml(arr) {
- $(".work_list_con").empty();
- if (_templang == 'zh') {
- var html = '',
- result = arr.content,
- len = result.length,
- i = 0;
- //循环数据
- for (; i < len; i++) {
- var rs = result[i],
- _id = rs.id,
- _category = rs.categories[0].name,
- _categoriesEnglishName = rs.categories[0].englishName,
- _englishName = rs.englishName,
- _name = rs.name,
- _releaseTime = rs.releaseTime,
- _demand = rs.demand,
- _description = rs.description,
- _city = rs.locations[0].name
- _city_en = rs.locations[0].englishName
- _count = rs.count,
- html += '<div class="work_list_search_item">' +
- '<div class="work_list_search_item_con">' +
- '<div class="work_list_search_item_con_title">' + _name + '</div>' +
- '<div class="work_list_search_item_con_sub">' + _city + ', 招' + _count + '人,发布于' + _releaseTime + '</div>' +
- '</div>' +
- '<div data-id = ' + i + ' class="apply-btn">' +
- '加入我们' +
- '</div>' +
- '</div>';
- }
- //渲染数据
- $(".work_list_con").append(html);
- showDetail()
- } else {
- var html = '',
- result = arr.content,
- len = result.length,
- i = 0;
- //循环数据
- for (; i < len; i++) {
- var rs = result[i],
- _id = rs.id,
- _category = rs.categories[0].name,
- _categoriesEnglishName = rs.categories[0].englishName,
- _englishName = rs.englishName,
- _name = rs.name,
- _releaseTime = rs.releaseTime,
- _demand = rs.demand,
- _description = rs.description,
- _city = rs.locations[0].name
- _city_en = rs.locations[0].englishName
- _count = rs.count,
- html += '<div class="work_list_search_item">' +
- '<div class="work_list_search_item_con">' +
- '<div class="work_list_search_item_con_title">' + _englishName + '</div>' +
- '<div class="work_list_search_item_con_sub">' + _city_en + ', number:' + _count + ',time:' + _releaseTime + '</div>' +
- '</div>' +
- '<div data-id = ' + i + ' class="apply-btn">' +
- 'Apply Now' +
- '</div>' +
- '</div>';
- }
- //渲染数据
- $(".work_list_con").append(html);
- showDetail()
- }
- }
- getLocationData();
- getCategoryData();
- getPositionData(0, categoryId, locationId, searchText);
- $('._location').on('click', 'span', function(e) {
- var target = $(e.target)
- // console.log()
- locationId = $(target)[0].dataset.id;
- console.log(categoryId)
- $('.all_location').removeClass('click_active');
- target.siblings().removeClass('click_active');
- target.addClass('click_active');
- $(".work_list_con").empty();
- getPositionData(currentPage, categoryId, locationId, searchText);
- })
- $('.all_location').click(function(e) {
- locationId = "";
- $(".work_list_con").empty();
- $('.all_location').addClass('click_active');
- $('._location').find('span').removeClass('click_active');
- getPositionData(currentPage, categoryId, locationId, searchText);
- })
- $('.work_list_search_title_con').on('click', 'span', function(e) {
- var target = $(e.target)
- categoryId = $(target)[0].dataset.id;
- target.siblings().removeClass('click_active');
- target.addClass('click_active');
- $(".work_list_con").empty();
- getPositionData(currentPage, categoryId, locationId, searchText);
- })
- $('.form_input').on('input', function() {
- searchText = $('.form_input').val()
- })
- $('.search-btn').click(function() {
- $(".work_list_con").empty();
- getPositionData(currentPage, categoryId, locationId, searchText);
- })
- $('.load_more').click(function() {
- if (!isLast) {
- getPositionData(Number(currentPage) + 1, categoryId, locationId, searchText);
- } else {
- return
- }
- })
- function getCookie(c_name) {
- if (document.cookie.length > 0) {
- c_start = document.cookie.indexOf(c_name + "=")
- if (c_start != -1) {
- c_start = c_start + c_name.length + 1
- c_end = document.cookie.indexOf(";", c_start)
- if (c_end == -1) c_end = document.cookie.length
- return unescape(document.cookie.substring(c_start, c_end))
- }
- }
- return ''
- }
- function showDetail() {
- // $(.)
- $('.apply-btn').click(function(e) {
- var _lang = getCookie('language')
- $('.content_mask_con_bottom_con').empty();
- $('.content_mask_con_bottom_con_yaoqiu').empty();
- var currentIdx = e.currentTarget.dataset.id,
- html1 = _lang == 'zh' ? arrList.content[currentIdx].description : arrList.content[currentIdx].englishDescription,
- html2 = _lang == 'zh' ? arrList.content[currentIdx].demand : arrList.content[currentIdx].englishDemand,
- name = _lang == 'zh' ? arrList.content[currentIdx].name : arrList.content[currentIdx].englishName,
- _count = arrList.content[currentIdx].count,
- _releaseTime = arrList.content[currentIdx].releaseTime,
- _category = _lang == 'zh' ? arrList.content[currentIdx].categories[0].name : arrList.content[currentIdx].categories[0].englishName,
- _location = _lang == 'zh' ? arrList.content[currentIdx].locations[0].name : arrList.content[currentIdx].locations[0].englishName,
- fix_sub = _lang == 'zh' ? _category + ',' + _location + ',招' + _count + '人,发布于' + _releaseTime : _category + ',' + _location + ', number' + _count + ', time' + _releaseTime;
- // console.log(html)
- $('.content_mask_con_top_title').text(name);
- $('.content_mask_con_top_sub').text(fix_sub);
- $('.content_mask_con_bottom_con').append(html1);
- $('.content_mask_con_bottom_con_yaoqiu').append(html2);
- $('.join_mask').show();
- })
- }
- $('.content_mask_con').click(function() {
- return false;
- });
- $('.join_mask').click(function() {
- $('.join_mask').hide();
- });
- $('.btn').click(function() {
- _templang = getCookie('language');
- console.log('asd', _templang)
- appendLocationHtml(arrLocation)
- appendCategoryHtml(arrCategories);
- appendPositionHtml(arrList);
- })
- baguetteBox.run('.company_detail');
- baguetteBox.run('.our_detail');
- baguetteBox.run('.middle_img');
- })
|