|
|
@@ -81,21 +81,23 @@ var hbRequestCount |
|
|
|
var getAdDataCount |
|
|
|
var pageChangeCount |
|
|
|
|
|
|
|
var adDataList = [] |
|
|
|
|
|
|
|
var heartConfig = { |
|
|
|
heartbeatInterval:1000*10, |
|
|
|
dataRefreshInterval:1000*60*60, |
|
|
|
pageChangeInterval:1000*10, |
|
|
|
} |
|
|
|
|
|
|
|
export default class MyPage extends Component { |
|
|
|
constructor(props) { |
|
|
|
super(props); |
|
|
|
this.state = { |
|
|
|
baseInfo: baseInfoDefault, |
|
|
|
adDataList:[], |
|
|
|
contentItem0:null, |
|
|
|
contentItem1:null, |
|
|
|
contentItem2:null, |
|
|
|
animationTheme:{}, |
|
|
|
heartConfig:{ |
|
|
|
heartbeatInterval:1000*10, |
|
|
|
dataRefreshInterval:1000*60*60, |
|
|
|
pageChangeInterval:1000*10, |
|
|
|
}, |
|
|
|
contentDisplayStatus:false, |
|
|
|
syncMessage: "初始化..." , |
|
|
|
errorMessage: '加载中...', |
|
|
@@ -160,22 +162,22 @@ codePushStatusDidChange(syncStatus) { |
|
|
|
} |
|
|
|
// 列表滚动 |
|
|
|
updateContent() { |
|
|
|
if (this.state.adDataList.length <=0) |
|
|
|
if (adDataList.length <=0) |
|
|
|
return false; |
|
|
|
|
|
|
|
if (curAdIndex >= this.state.adDataList.length) { |
|
|
|
if (curAdIndex >= adDataList.length) { |
|
|
|
curAdIndex = 0 |
|
|
|
} |
|
|
|
|
|
|
|
this.setState({contentItem0:this.state.adDataList[curAdIndex]}); |
|
|
|
this.setState({contentItem0:adDataList[curAdIndex]}); |
|
|
|
|
|
|
|
if (curAdIndex + 1 < this.state.adDataList.length) |
|
|
|
this.setState({contentItem1:this.state.adDataList[curAdIndex+1]}); |
|
|
|
if (curAdIndex + 1 < adDataList.length) |
|
|
|
this.setState({contentItem1:adDataList[curAdIndex+1]}); |
|
|
|
else |
|
|
|
this.setState({contentItem1:null}); |
|
|
|
|
|
|
|
if (curAdIndex + 2 < this.state.adDataList.length) |
|
|
|
this.setState({contentItem2:this.state.adDataList[curAdIndex+2]}); |
|
|
|
if (curAdIndex + 2 < adDataList.length) |
|
|
|
this.setState({contentItem2:adDataList[curAdIndex+2]}); |
|
|
|
else |
|
|
|
this.setState({contentItem2:null}); |
|
|
|
|
|
|
@@ -190,13 +192,10 @@ codePushStatusDidChange(syncStatus) { |
|
|
|
.then(result => { |
|
|
|
if (result.code == 200) { |
|
|
|
let config = JSON.parse(result.data.config); |
|
|
|
this.setState({ |
|
|
|
heartConfig:{ |
|
|
|
heartbeatInterval:config.heartbeatInterval, |
|
|
|
dataRefreshInterval:config.dataRefreshInterval, |
|
|
|
pageChangeInterval:config.pageChangeInterval |
|
|
|
} |
|
|
|
}) |
|
|
|
heartConfig.heartbeatInterval = config.heartbeatInterval |
|
|
|
heartConfig.dataRefreshInterval=config.dataRefreshInterval |
|
|
|
heartConfig.pageChangeInterval=config.pageChangeInterval |
|
|
|
|
|
|
|
// 动画划入 |
|
|
|
if(config.animationTheme == 0){ |
|
|
|
this.setState({ |
|
|
@@ -239,7 +238,7 @@ codePushStatusDidChange(syncStatus) { |
|
|
|
if (result.code != 200) { |
|
|
|
this.showErrMsg(result.message+'\n'+this.state.macAddress); |
|
|
|
} else if (result.data.list) { |
|
|
|
this.setState({adDataList : result.data.list}); |
|
|
|
adDataList = result.data.list; |
|
|
|
if (this.updateContent()) { |
|
|
|
this.setState({contentDisplayStatus: true}) |
|
|
|
} else { |
|
|
@@ -296,9 +295,9 @@ startAd() { |
|
|
|
this.getAdDataList() |
|
|
|
this.hbRequest() |
|
|
|
|
|
|
|
hbRequestCount =this.state.heartConfig.heartbeatInterval; |
|
|
|
getAdDataCount =this.state.heartConfig.dataRefreshInterval; |
|
|
|
pageChangeCount =this.state.heartConfig.pageChangeInterval; |
|
|
|
hbRequestCount =heartConfig.heartbeatInterval; |
|
|
|
getAdDataCount =heartConfig.dataRefreshInterval; |
|
|
|
pageChangeCount =heartConfig.pageChangeInterval; |
|
|
|
|
|
|
|
setInterval(()=>{ |
|
|
|
hbRequestCount -=1000; |
|
|
@@ -314,17 +313,13 @@ startAd() { |
|
|
|
this.getBaseInfo() |
|
|
|
this.getAdDataList() |
|
|
|
} |
|
|
|
pageChangeCount = this.state.heartConfig.pageChangeInterval |
|
|
|
} |
|
|
|
|
|
|
|
if (getAdDataCount<=0) { |
|
|
|
pageChangeCount = heartConfig.pageChangeInterval |
|
|
|
} else if (getAdDataCount<=0) { |
|
|
|
this.getAdDataList() |
|
|
|
getAdDataCount = this.state.heartConfig.dataRefreshInterval |
|
|
|
} |
|
|
|
|
|
|
|
if (hbRequestCount<=0) { |
|
|
|
getAdDataCount = heartConfig.dataRefreshInterval |
|
|
|
}else if (hbRequestCount<=0) { |
|
|
|
this.hbRequest() |
|
|
|
hbRequestCount = this.state.heartConfig.heartbeatInterval |
|
|
|
hbRequestCount = heartConfig.heartbeatInterval |
|
|
|
} |
|
|
|
},1000) |
|
|
|
} |
|
|
|