From 9aca51ef5abacc99979d5bb10be1898b2dbbda3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=9C=E6=81=92?= <2323333339@qq.com> Date: Sat, 20 Feb 2021 09:18:12 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/js/joe.index.js | 199 +++++++++++++++++++++-------------------- core/function.php | 2 +- 2 files changed, 102 insertions(+), 99 deletions(-) diff --git a/assets/js/joe.index.js b/assets/js/joe.index.js index 21486c7..5c2724d 100644 --- a/assets/js/joe.index.js +++ b/assets/js/joe.index.js @@ -1,29 +1,29 @@ document.addEventListener('DOMContentLoaded', () => { - /* 激活轮播图功能 */ - { - if ($('.joe_index__banner .swiper-container').length !== 0) { - let direction = 'horizontal' - if (!Joe.IS_MOBILE && $('.joe_index__banner-recommend .item').length === 2) direction = 'vertical' - new Swiper('.swiper-container', { - keyboard: true, - direction, - loop: true, - autoplay: true, - mousewheel: true, - pagination: { el: '.swiper-pagination' }, - navigation: { - nextEl: '.swiper-button-next', - prevEl: '.swiper-button-prev' - } - }) - } - } + /* 激活轮播图功能 */ + { + if ($('.joe_index__banner .swiper-container').length !== 0) { + let direction = 'horizontal'; + if (!Joe.IS_MOBILE && $('.joe_index__banner-recommend .item').length === 2) direction = 'vertical'; + new Swiper('.swiper-container', { + keyboard: true, + direction, + loop: true, + autoplay: true, + mousewheel: true, + pagination: { el: '.swiper-pagination' }, + navigation: { + nextEl: '.swiper-button-next', + prevEl: '.swiper-button-prev' + } + }); + } + } - /* 初始化首页列表功能 */ - { - const getListMode = _ => { - if (_.mode === 'default') { - return ` + /* 初始化首页列表功能 */ + { + const getListMode = _ => { + if (_.mode === 'default') { + return `
  • @@ -55,9 +55,9 @@ document.addEventListener('DOMContentLoaded', () => {
  • - ` - } else if (_.mode === 'single') { - return ` + `; + } else if (_.mode === 'single') { + return `
  • @@ -91,9 +91,9 @@ document.addEventListener('DOMContentLoaded', () => { ${_.abstract}
  • - ` - } else if (_.mode === 'multiple') { - return ` + `; + } else if (_.mode === 'multiple') { + return `
  • @@ -104,12 +104,12 @@ document.addEventListener('DOMContentLoaded', () => {
    ${_.image - .map((item, index) => { - if (index < 3) { - return `${_.title}` - } - }) - .join('')} + .map((item, index) => { + if (index < 3) { + return `${_.title}`; + } + }) + .join('')}
  • - ` - } else { - return ` + `; + } else { + return `
  • @@ -152,65 +152,68 @@ document.addEventListener('DOMContentLoaded', () => {
  • - ` - } - } - let queryData = { page: 1, pageSize: 12, type: 'created' } - const initDom = () => { - $('.joe_index__list .joe_list').html('') - let activeItem = $('.joe_index__title-title .item[data-type="' + queryData.type + '"]') - let activeLine = $('.joe_index__title-title .line') - activeItem.addClass('active').siblings().removeClass('active') - activeLine.css({ left: activeItem.position().left, width: activeItem.width() }) - } - const pushDom = () => { - return new Promise((reslove, reject) => { - $('.joe_load').attr('loading', true) - $('.joe_load').html('加载中') - $('.joe_index__list .joe_list__loading').show() - $.ajax({ - url: Joe.BASE_API, - type: 'POST', - data: { routeType: 'publish_list', page: queryData.page, pageSize: queryData.pageSize, type: queryData.type }, - success(res) { - if (res.data.length === 0) { - $('.joe_load').remove() - $('.joe_index__list .joe_list__loading').hide() - return - } - res.data.forEach(_ => $('.joe_index__list .joe_list').append(getListMode(_))) - $('.joe_load').removeAttr('loading') - $('.joe_load').html('查看更多') - $('.joe_index__list .joe_list__loading').hide() - reslove(res.data.length > 0 ? res.data.length - 1 : 0) - } - }) - }) - } - initDom() - pushDom() + `; + } + }; + let queryData = { page: 1, pageSize: 12, type: 'created' }; + const initDom = () => { + $('.joe_index__list .joe_list').html(''); + $('.joe_load').show(); + let activeItem = $('.joe_index__title-title .item[data-type="' + queryData.type + '"]'); + let activeLine = $('.joe_index__title-title .line'); + activeItem.addClass('active').siblings().removeClass('active'); + activeLine.css({ left: activeItem.position().left, width: activeItem.width() }); + }; + const pushDom = () => { + return new Promise((reslove, reject) => { + $('.joe_load').attr('loading', true); + $('.joe_load').html('loading...'); + $('.joe_index__list .joe_list__loading').show(); + $.ajax({ + url: Joe.BASE_API, + type: 'POST', + data: { routeType: 'publish_list', page: queryData.page, pageSize: queryData.pageSize, type: queryData.type }, + success(res) { + if (res.data.length === 0) { + $('.joe_load').removeAttr('loading'); + $('.joe_load').html('查看更多'); + $('.joe_load').hide(); + $('.joe_index__list .joe_list__loading').hide(); + return Qmsg.warning('没有更多内容了'); + } + res.data.forEach(_ => $('.joe_index__list .joe_list').append(getListMode(_))); + $('.joe_load').removeAttr('loading'); + $('.joe_load').html('查看更多'); + $('.joe_index__list .joe_list__loading').hide(); + reslove(res.data.length > 0 ? res.data.length - 1 : 0); + } + }); + }); + }; + initDom(); + pushDom(); - $('.joe_index__title-title .item').on('click', async function () { - if ($(this).attr('data-type') === queryData.type) return - queryData = { page: 1, pageSize: 12, type: $(this).attr('data-type') } - initDom() - pushDom() - }) + $('.joe_index__title-title .item').on('click', async function () { + if ($(this).attr('data-type') === queryData.type) return; + queryData = { page: 1, pageSize: 12, type: $(this).attr('data-type') }; + initDom(); + pushDom(); + }); - $('.joe_load').on('click', async function () { - if ($(this).attr('loading')) return - queryData.page++ - let length = await pushDom() - length = $('.joe_index__list .joe_list .joe_list__item').length - length - const queryElement = `.joe_index__list .joe_list .joe_list__item:nth-child(${length})` - const offset = $(queryElement).offset().top - $('.joe_header').height() - window.scrollTo({ top: offset - 15, behavior: 'smooth' }) - }) - } + $('.joe_load').on('click', async function () { + if ($(this).attr('loading')) return; + queryData.page++; + let length = await pushDom(); + length = $('.joe_index__list .joe_list .joe_list__item').length - length; + const queryElement = `.joe_index__list .joe_list .joe_list__item:nth-child(${length})`; + const offset = $(queryElement).offset().top - $('.joe_header').height(); + window.scrollTo({ top: offset - 15, behavior: 'smooth' }); + }); + } - /* 激活列表特效 */ - { - const wow = $('.joe_index__list').attr('data-wow') - if (wow !== 'off' && wow) new WOW({ boxClass: 'wow', animateClass: `animated ${wow}`, offset: 0, mobile: true, live: true, scrollContainer: null }).init() - } -}) + /* 激活列表特效 */ + { + const wow = $('.joe_index__list').attr('data-wow'); + if (wow !== 'off' && wow) new WOW({ boxClass: 'wow', animateClass: `animated ${wow}`, offset: 0, mobile: true, live: true, scrollContainer: null }).init(); + } +}); diff --git a/core/function.php b/core/function.php index 2205c75..d2c498d 100644 --- a/core/function.php +++ b/core/function.php @@ -3,7 +3,7 @@ /* 获取主题当前版本号 */ function _getVersion() { - return "5.2.3"; + return "5.2.4"; }; /* 判断是否是手机 */