| @@ -84,9 +84,9 @@ var pageChangeCount | |||
| var adDataList = [] | |||
| var heartConfig = { | |||
| heartbeatInterval:1000*10, | |||
| dataRefreshInterval:1000*60*60, | |||
| pageChangeInterval:1000*10, | |||
| heartbeatInterval:10, | |||
| dataRefreshInterval:3600, | |||
| pageChangeInterval:10, | |||
| } | |||
| export default class MyPage extends Component { | |||
| @@ -186,7 +186,7 @@ codePushStatusDidChange(syncStatus) { | |||
| } | |||
| hbRequest() { | |||
| HttpUtils.post(NativeModules.BuildConfig.apiHost + 'api/wxDeviceScreenAd/heartbeat?deviceId=' | |||
| return HttpUtils.post(NativeModules.BuildConfig.apiHost + 'api/wxDeviceScreenAd/heartbeat?deviceId=' | |||
| +encodeURIComponent(this.state.macAddress), | |||
| {version:this.state.versionInfo}) | |||
| .then(result => { | |||
| @@ -233,7 +233,7 @@ codePushStatusDidChange(syncStatus) { | |||
| } | |||
| getAdDataList() { | |||
| HttpUtils.get(NativeModules.BuildConfig.apiHost + 'api/wxDeviceScreenAd/list?deviceId='+encodeURIComponent(this.state.macAddress)+'&pageNum=1&pageSize=1000') | |||
| return HttpUtils.get(NativeModules.BuildConfig.apiHost + 'api/wxDeviceScreenAd/list?deviceId='+encodeURIComponent(this.state.macAddress)+'&pageNum=1&pageSize=1000') | |||
| .then((result) => { | |||
| if (result.code != 200) { | |||
| this.showErrMsg(result.message+'\n'+this.state.macAddress); | |||
| @@ -253,7 +253,7 @@ codePushStatusDidChange(syncStatus) { | |||
| }) | |||
| } | |||
| getBaseInfo() { | |||
| HttpUtils.get(NativeModules.BuildConfig.apiHost + 'api/wxDeviceScreenAd/info?deviceId='+encodeURIComponent(this.state.macAddress)) | |||
| return HttpUtils.get(NativeModules.BuildConfig.apiHost + 'api/wxDeviceScreenAd/info?deviceId='+encodeURIComponent(this.state.macAddress)) | |||
| .then(result => { | |||
| if (result.code != 200) { | |||
| this.showErrMsg(result.message+'\n'+this.state.macAddress); | |||
| @@ -289,39 +289,50 @@ componentDidMount() { | |||
| }) | |||
| } | |||
| async routine() { | |||
| hbRequestCount -=1; | |||
| getAdDataCount -=1; | |||
| pageChangeCount -=1; | |||
| startAd() { | |||
| this.getBaseInfo() | |||
| this.getAdDataList() | |||
| this.hbRequest() | |||
| if (getAdDataCount<=0) { | |||
| await this.getAdDataList() | |||
| getAdDataCount = heartConfig.dataRefreshInterval | |||
| } else if (hbRequestCount<=0) { | |||
| await this.hbRequest() | |||
| hbRequestCount = heartConfig.heartbeatInterval | |||
| } | |||
| if (pageChangeCount <= 0) { //页面切换间隔 | |||
| if (this.state.contentDisplayStatus) { | |||
| this.setState({ contentDisplayStatus: false}) | |||
| if (this.updateContent()) { | |||
| this.setState({ contentDisplayStatus: true}) | |||
| } | |||
| } else { | |||
| await this.getBaseInfo() | |||
| await this.getAdDataList() | |||
| } | |||
| pageChangeCount = heartConfig.pageChangeInterval | |||
| } | |||
| setTimeout(()=>{ | |||
| this.routine(); | |||
| },1000); | |||
| } | |||
| async startAd() { | |||
| await this.getBaseInfo() | |||
| await this.getAdDataList() | |||
| await this.hbRequest() | |||
| hbRequestCount =heartConfig.heartbeatInterval; | |||
| hbRequestCount = heartConfig.heartbeatInterval; | |||
| getAdDataCount =heartConfig.dataRefreshInterval; | |||
| pageChangeCount =heartConfig.pageChangeInterval; | |||
| setInterval(()=>{ | |||
| hbRequestCount -=1000; | |||
| getAdDataCount -=1000; | |||
| pageChangeCount -=1000; | |||
| if (pageChangeCount <= 0) { //页面切换间隔 | |||
| if (this.state.contentDisplayStatus) { | |||
| this.setState({ contentDisplayStatus: false}) | |||
| if (this.updateContent()) { | |||
| this.setState({ contentDisplayStatus: true}) | |||
| } | |||
| } else { | |||
| this.getBaseInfo() | |||
| this.getAdDataList() | |||
| } | |||
| pageChangeCount = heartConfig.pageChangeInterval | |||
| } else if (getAdDataCount<=0) { | |||
| this.getAdDataList() | |||
| getAdDataCount = heartConfig.dataRefreshInterval | |||
| }else if (hbRequestCount<=0) { | |||
| this.hbRequest() | |||
| hbRequestCount = heartConfig.heartbeatInterval | |||
| } | |||
| },1000) | |||
| setTimeout(()=>{ | |||
| this.routine(); | |||
| },1000); | |||
| } | |||
| getContentViewItemUplayer(contentItem) { | |||
| @@ -337,6 +348,7 @@ getContentViewItemUplayer(contentItem) { | |||
| } | |||
| getContentViewItemActionStr(contentItem) { | |||
| if (contentItem.type == 0) { | |||
| if (contentItem.subType == 2) | |||
| return '扫码秒杀'; | |||