From 2d2782434171255093dbf841a8a46765762a4d50 Mon Sep 17 00:00:00 2001 From: craigchencc <41358202+craigchencc@users.noreply.github.com> Date: Wed, 10 Apr 2019 14:41:48 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9readPageNum=EF=BC=8C=E5=8F=AA?= =?UTF-8?q?=E6=9C=89=E5=BE=80=E5=90=8E=E7=BF=BB=E6=89=8D=E7=AE=97=EF=BC=8C?= =?UTF-8?q?=E5=BE=80=E5=89=8D=E7=BF=BB=E4=B8=8D=E7=AE=97=EF=BC=8C=E4=BB=8E?= =?UTF-8?q?=E7=9B=AE=E5=BD=95=E8=BF=9B=E5=85=A5=E9=98=85=E8=AF=BB=E5=99=A8?= =?UTF-8?q?=E5=88=99=E9=87=8D=E6=96=B0=E5=BC=80=E5=A7=8B=E8=AE=A1=E7=AE=97?= =?UTF-8?q?=20(#589)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 修改readPageNum,只有往后翻才算,往前翻不算,从目录进入阅读器则重新开始计算 * code review --- .../mip-shell-xiaoshuo/common/events.js | 21 ++++++++++++++++++- .../mip-shell-xiaoshuo/feature/catalog.js | 14 +++++++++++++ .../mip-shell-xiaoshuo/mip-shell-xiaoshuo.js | 4 +--- 3 files changed, 35 insertions(+), 4 deletions(-) diff --git a/components/mip-shell-xiaoshuo/common/events.js b/components/mip-shell-xiaoshuo/common/events.js index 5d8c8301..94c2b50b 100644 --- a/components/mip-shell-xiaoshuo/common/events.js +++ b/components/mip-shell-xiaoshuo/common/events.js @@ -5,9 +5,24 @@ */ import {Constant} from './constant-config' import {sendTCLog} from './log' +import state from '../common/state' +import {getCurrentWindow} from '../common/util' let event = window.MIP.util.event - +function changeReadPageNum (plus) { + let {novelInstance} = state(getCurrentWindow()) + if (novelInstance.currentPageMeta.pageType === 'page') { + if (novelInstance.readPageNum == null) { + novelInstance.readPageNum = 1 + return + } + if (plus) { + novelInstance.readPageNum++ + } else { + novelInstance.readPageNum-- + } + } +} export default class XiaoshuoEvents { // 每次搜索点出,同步刷新调用 bindRoot () { @@ -17,6 +32,7 @@ export default class XiaoshuoEvents { */ let nextPageButton = '.mip-shell-footer .page-next:not(.disabled)' event.delegate(document.documentElement, nextPageButton, 'click', function () { + changeReadPageNum(true) // tc日志打点 sendTCLog('interaction', { type: 'b', @@ -33,6 +49,7 @@ export default class XiaoshuoEvents { */ let previousPageButton = '.mip-shell-footer .page-previous:not(.disabled)' event.delegate(document.documentElement, previousPageButton, 'click', function () { + changeReadPageNum() // tc日志打点 sendTCLog('interaction', { type: 'b', @@ -57,6 +74,7 @@ export default class XiaoshuoEvents { */ bindPrePageButton () { event.delegate(document.documentElement, '.navigator a:first-child', 'click', function () { + changeReadPageNum() // tc日志打点 sendTCLog('interaction', { type: 'b', @@ -72,6 +90,7 @@ export default class XiaoshuoEvents { */ bindNextPageButton () { event.delegate(document.documentElement, '.navigator a:last-child', 'click', function () { + changeReadPageNum(true) // tc日志打点 sendTCLog('interaction', { type: 'b', diff --git a/components/mip-shell-xiaoshuo/feature/catalog.js b/components/mip-shell-xiaoshuo/feature/catalog.js index a82fa9ef..8324e108 100644 --- a/components/mip-shell-xiaoshuo/feature/catalog.js +++ b/components/mip-shell-xiaoshuo/feature/catalog.js @@ -406,6 +406,7 @@ class Catalog { $catalogSidebar.removeChild($catalogSidebar.querySelector('.mip-shell-catalog')) $catalogSidebar.appendChild($catalog) } + this.clickCatalogToResetReadPageNum() this.bindClickCatalogMessageEvent() this.bindShellCatalogMessageEvent() this.bindPageCatalogMessageEvent() @@ -424,6 +425,19 @@ class Catalog { }) } + /** + * 只要是点击目录进入阅读页,readPageNum 重新开始记为 1. + * + * @private + */ + clickCatalogToResetReadPageNum () { + event.delegate(document.documentElement, '.novel-catalog-content .catalog-page-content', 'click', () => { + let {novelInstance} = state(getCurrentWindow()) + if (novelInstance.currentPageMeta.pageType === 'page') { + novelInstance.readPageNum = 1 + } + }) + } /** * 发送 搜索点出/二跳 日志 * 点击目录章节绑定发送日志函数 diff --git a/components/mip-shell-xiaoshuo/mip-shell-xiaoshuo.js b/components/mip-shell-xiaoshuo/mip-shell-xiaoshuo.js index 9dd71509..cf4390ac 100644 --- a/components/mip-shell-xiaoshuo/mip-shell-xiaoshuo.js +++ b/components/mip-shell-xiaoshuo/mip-shell-xiaoshuo.js @@ -165,12 +165,10 @@ export default class MipShellNovel extends MIP.builtinComponents.MipShell { sendWebbLogLink(document.querySelector('.navigator a:last-child'), 'nextPageButton') // 用来记录翻页的次数,主要用来触发品专的广告 novelInstance.novelPageNum++ - // 目前除了 page 就 detail 是单独的,page_2 也是 page 的一种 + // 目前除了 page 就 detail 是单独的,page_2 也是 page 的一种,这里不是翻页操作,bindNextPageButton 才是真正的向后翻页 if (novelInstance.currentPageMeta.pageType === 'page') { if (novelInstance.readPageNum == null) { novelInstance.readPageNum = 1 - } else { - novelInstance.readPageNum++ } } // 如果有前端广告缓存,则走此处的逻辑