(() => { let page = Number($(document).find('[data-products-page-number]').attr('data-products-page-number') || 1); let clickType = 0; const prevPage = (obj) => { clickType= 1; page -= 1; changeUrl(); } const nextPage = (obj) => { clickType= 1; page += 1; changeUrl(); } const goPage = (obj, pageNum) => { clickType= 1; page = pageNum; changeUrl(); } window.prevPage = prevPage; window.nextPage = nextPage; window.goPage = goPage; const changeUrl = () => { let curWwwPath = window.location.href; let pathName = window.location.pathname; let pos = curWwwPath.indexOf(pathName); let localhostPath = curWwwPath.substring(0, pos); let queryString = (checkedCategory.length > 0 ? '?c=' + checkedCategory.toString() : ''); if (queryString) { queryString = queryString + (clickType ? '&page=' + page : ''); } else { queryString = (clickType ? '?page=' + page : ''); } let newUrl = localhostPath + pathName + queryString; window.location.href = newUrl; } if ($('.swiper-natural-products').length > 0) { let mySwiper = new Swiper('.swiper-natural-products', { navigation: { nextEl: '.swiper-button-next-custom', prevEl: '.swiper-button-prev-custom', }, pagination: { el: '.swiper-pagination-custom', type: 'fraction', }, }) } $.each($('.hot-main-tit .icon-angle-right'),function(){ $(this).on('click',function(){ $(this).parent('.hot-main-tit').toggleClass('btn-toggle'); $(this).parent('.hot-main-tit').parent().find('.list-more').slideToggle(200); }) }); const clearResult = () => { $('.result-list .close-small').on('click',function(){ $('.result-list').html(''); }) } const categoryType =$(document).find('[data-category-page-adjuvant-type]').attr('data-category-page-adjuvant-type') || ''; const categoryUrl = categoryType === 'adjuvantProducts' ? 'adjuvant' : ''; $('#sourceSearchValue').on('keypress', function (e) { if (e.keyCode === 13) { let q = $('#sourceSearchValue').val(); if (q.trim() !== '') { $('#sourceSearchValue').removeClass("nonempty_submit"); $('#sourceSearch').attr('disabled', true); searchSource(q); } else { $('#sourceSearchValue').addClass("nonempty_submit"); } } }); $('#sourceSearch').on('click', function () { let q = $('#sourceSearchValue').val(); if (q.trim() !== '') { $('#sourceSearchValue').removeClass("nonempty_submit"); $('#sourceSearch').attr('disabled', true); searchSource(q); } else { $('#sourceSearchValue').addClass("nonempty_submit"); } }); const searchSource = (q) => { $.ajax({ url: '/otherCategory!searchCategory.shtml?mcenow=' + new Date().getTime(), data:{'q': q, 'categoryType': categoryType}, cache:false, dataType:'json', type: "post", success: function (data) { if (data.success) { let categories = data.categories; if (categories != null && categories.length > 0) { let resultsHtml = '

Results for "' + q+ '":

'; $('.result-list').html(resultsHtml); } else { $('.result-list').html('

No Results for "' + q+ '":

'); } } else { $('.result-list').html('

No Results for "' + q+ '":

'); } }, error: function (request) { $('.result-list').html('

搜索失败,请稍后再试!

'); }, complete: function(XMLHttpRequest, textStatus) { $('#sourceSearch').attr('disabled', false); clearResult(); } }); } let checkedCategory = []; const getCheckedCategory = () => { checkedCategory = []; if ($('.st-checkbox-group').length > 0) { $(".st-checkbox-group input[type='checkbox']:checked").each(function(){ if (!checkedCategory.includes($(this).val().trim())) { checkedCategory.push($(this).val().trim()); } }); } else { $("#model-classification label").each(function(){ let thisSignImg = $(this).find('img').attr('src'); if (thisSignImg.endsWith('yes1.gif')) { checkedCategory.push($(this).attr('data-category-name')); } }); } } getCheckedCategory(); $("#model-classification label").on('click', function (e) { e.stopPropagation(); let thisSignImg = $(this).find('img').attr('src'); let flag = thisSignImg.endsWith('yes1.gif') ? 1 : 0; if (flag === 0) { $(this).find('img').attr('src', '/new/images/web/yes1.gif'); checkedCategory.push($(this).attr('data-category-name')); } else { $(this).find('img').attr('src', '/new/images/web/non.gif'); checkedCategory.splice($.inArray($(this).attr('data-category-name'), checkedCategory), 1); } console.log(checkedCategory.join()); clickType= 0; changeUrl(); }); const changeUrl2 = () => { getCheckedCategory(); let curWwwPath = window.location.href; let pathName = window.location.pathname; let pos = curWwwPath.indexOf(pathName); let localhostPath = curWwwPath.substring(0, pos); let queryString = checkedCategory.length > 0 ? '?sc=' + checkedCategory.join(';') : ''; if (queryString) { queryString = queryString + (clickType ? '&page=' + page : ''); } else { queryString = (clickType ? '?page=' + page : ''); } let newUrl = localhostPath + pathName + queryString; window.location.href = newUrl; } const prevPage2 = (obj) => { page -= 1; clickType = 1; changeUrl2(); } const nextPage2 = (obj) => { page += 1; clickType = 1; changeUrl2(); } const goPage2 = (obj, pageNum) => { page = pageNum; clickType = 1; changeUrl2(); } window.prevPage2 = prevPage2; window.nextPage2 = nextPage2; window.goPage2 = goPage2; if ($('.st-checkbox-group').length > 0) { $(".st-checkbox-group input[type='checkbox']").click(function () { page = 1; clickType = 0; changeUrl2(); }); } const $searchText = $('#standardsParam'); $searchText.on('keypress', function (e){ if (e.keyCode === 13) { searchBlog(); } }); $searchText.on('keydown', function (e) { if (e.keyCode === 13) { searchBlog(); } }); $(".btn-search-source").click(function () { searchBlog(); }); const searchBlog = () => { let q = $searchText.val(); if (q.trim() == '') { $searchText.addClass("nonempty_submit"); } else { $(".btn-search-source").attr({"disabled":"disabled"}); $.ajax({ url: '/otherCategory!searchStandardProducts.shtml?mcenow=' + new Date().getTime(), data: {'q': q}, cache: false, dataType: 'json', type: "post", success: function (data) { if (data.param !== '') { $searchText.removeClass("nonempty_submit"); window.open('/' + data.param + '.html', '_blank'); $searchText.val(''); } else { $searchText.addClass("nonempty_submit"); } }, error: function (request) { $searchText.addClass("nonempty_submit"); }, complete: function (XMLHttpRequest, textStatus) { $(".btn-search-source").removeAttr("disabled"); } }); } } })();