Skip to content

Commit

Permalink
修改readPageNum,只有往后翻才算,往前翻不算,从目录进入阅读器则重新开始计算 (#589)
Browse files Browse the repository at this point in the history
* 修改readPageNum,只有往后翻才算,往前翻不算,从目录进入阅读器则重新开始计算

* code review
  • Loading branch information
craigchencc authored Apr 10, 2019
1 parent f7db7b8 commit 2d27824
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 4 deletions.
21 changes: 20 additions & 1 deletion components/mip-shell-xiaoshuo/common/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand All @@ -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',
Expand All @@ -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',
Expand All @@ -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',
Expand All @@ -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',
Expand Down
14 changes: 14 additions & 0 deletions components/mip-shell-xiaoshuo/feature/catalog.js
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,7 @@ class Catalog {
$catalogSidebar.removeChild($catalogSidebar.querySelector('.mip-shell-catalog'))
$catalogSidebar.appendChild($catalog)
}
this.clickCatalogToResetReadPageNum()
this.bindClickCatalogMessageEvent()
this.bindShellCatalogMessageEvent()
this.bindPageCatalogMessageEvent()
Expand All @@ -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
}
})
}
/**
* 发送 搜索点出/二跳 日志
* 点击目录章节绑定发送日志函数
Expand Down
4 changes: 1 addition & 3 deletions components/mip-shell-xiaoshuo/mip-shell-xiaoshuo.js
Original file line number Diff line number Diff line change
Expand Up @@ -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++
}
}
// 如果有前端广告缓存,则走此处的逻辑
Expand Down

0 comments on commit 2d27824

Please sign in to comment.