|
|
@@ -43,12 +43,34 @@ var baseInfoDefault = { |
|
|
|
} |
|
|
|
|
|
|
|
var curAdIndex = 0; |
|
|
|
|
|
|
|
var errorMsg = { |
|
|
|
ERR_MAC_GET:'设备编号获取错误', |
|
|
|
ERR_DATA_GET:'广告数据获取错误' |
|
|
|
|
|
|
|
ERR_START_AD:'广告播放系统错误', |
|
|
|
ERR_DATA_GET:'广告数据获取错误', |
|
|
|
ERR_HEARTBEAT:'设备心跳数据错误' |
|
|
|
} |
|
|
|
var animationThemes = [ |
|
|
|
{ |
|
|
|
first:"slideInDown", |
|
|
|
second:"slideInLeft", |
|
|
|
third:"slideInRight" |
|
|
|
}, |
|
|
|
{ |
|
|
|
first:"fadeInDownBig", |
|
|
|
second:"fadeInLeftBig", |
|
|
|
third:"fadeInRightBig" |
|
|
|
}, |
|
|
|
{ |
|
|
|
first:"zoomInDown", |
|
|
|
second:"zoomInLeft", |
|
|
|
third:"zoomInRight" |
|
|
|
}, |
|
|
|
{ |
|
|
|
first:"bounceInDown", |
|
|
|
second:"bounceInLeft", |
|
|
|
third:"bounceInRight" |
|
|
|
} |
|
|
|
] |
|
|
|
|
|
|
|
export default class MyPage extends Component { |
|
|
|
constructor(props) { |
|
|
@@ -59,12 +81,15 @@ export default class MyPage extends Component { |
|
|
|
contentItem0:null, |
|
|
|
contentItem1:null, |
|
|
|
contentItem2:null, |
|
|
|
|
|
|
|
animationTheme:{}, |
|
|
|
heartConfig:{ |
|
|
|
heartbeatInterval:1000*60*5, |
|
|
|
dataRefreshInterval:1000*60*60, |
|
|
|
pageChangeInterval:1000*10, |
|
|
|
}, |
|
|
|
contentDisplayStatus:false, |
|
|
|
|
|
|
|
syncMessage: "初始化..." , |
|
|
|
errorMessage: '加载中...', |
|
|
|
|
|
|
|
progress: { |
|
|
|
receivedBytes:0, |
|
|
|
totalBytes:0 |
|
|
@@ -103,8 +128,6 @@ codePushStatusDidChange(syncStatus) { |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
codePushDownloadDidProgress(progress) { |
|
|
|
this.setState({ progress }); |
|
|
|
} |
|
|
@@ -112,7 +135,7 @@ codePushStatusDidChange(syncStatus) { |
|
|
|
updateContent() { |
|
|
|
if (this.state.adDataList.length <=0) |
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
|
|
if (curAdIndex >= this.state.adDataList.length) { |
|
|
|
curAdIndex = 0 |
|
|
|
} |
|
|
@@ -138,8 +161,37 @@ codePushStatusDidChange(syncStatus) { |
|
|
|
+encodeURIComponent(this.state.macAddress), |
|
|
|
{version:this.state.versionInfo}) |
|
|
|
.then(result => { |
|
|
|
this.setState({ |
|
|
|
// heartConfig:{ |
|
|
|
// heartbeatInterval:JSON.parse(result.data.config).heartbeatInterval, |
|
|
|
// dataRefreshInterval:JSON.parse(result.data.config).dataRefreshInterval, |
|
|
|
// pageChangeInterval:JSON.parse(result.data.config).pageChangeInterval |
|
|
|
// } |
|
|
|
}) |
|
|
|
// 动画 |
|
|
|
this.setState({ |
|
|
|
animationTheme:animationThemes[2] |
|
|
|
}) |
|
|
|
// if(JSON.parse(result.data.config).animationThem == 0){ |
|
|
|
// this.setState({ |
|
|
|
// animationTheme:animationThemes[0] |
|
|
|
// }) |
|
|
|
// }else if(JSON.parse(result.data.config).animationThem == 1){ |
|
|
|
// this.setState({ |
|
|
|
// animationTheme:animationThemes[1] |
|
|
|
// }) |
|
|
|
// }else if(JSON.parse(result.data.config).animationThem == 2){ |
|
|
|
// this.setState({ |
|
|
|
// animationTheme:animationThemes[2] |
|
|
|
// }) |
|
|
|
// }else if(JSON.parse(result.data.config).animationThem == 3){ |
|
|
|
// this.setState({ |
|
|
|
// animationTheme:animationThemes[3] |
|
|
|
// }) |
|
|
|
// } |
|
|
|
}) |
|
|
|
.catch(error => { |
|
|
|
this.setState({ errorMessage : ERR_HEARTBEAT}); |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
@@ -165,7 +217,7 @@ codePushStatusDidChange(syncStatus) { |
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
// |
|
|
|
|
|
|
|
getBaseInfo() { |
|
|
|
HttpUtils.get(NativeModules.BuildConfig.apiHost + 'api/wxDeviceScreenAd/info?deviceId='+encodeURIComponent(this.state.macAddress)) |
|
|
|
.then(result => { |
|
|
@@ -200,37 +252,34 @@ componentDidMount() { |
|
|
|
}, (error: any) => { |
|
|
|
this.setState({ versionInfo: "Unknown"}); |
|
|
|
}); |
|
|
|
|
|
|
|
DeviceInfo.getMACAddress().then((mac)=>{ |
|
|
|
if (mac=='') { |
|
|
|
if (NativeModules.BuildConfig.buildType == 'debug') { |
|
|
|
this.setState({macAddress : this.testMac}) |
|
|
|
this.startAd() |
|
|
|
} else { |
|
|
|
this.setState({ contentDisplayStatus: false}) |
|
|
|
this.setState({ errorMessage : errorMsg.ERR_MAC_GET}); |
|
|
|
} |
|
|
|
} else { |
|
|
|
this.setState({macAddress : mac}) |
|
|
|
DeviceInfo.getMACAddress().then((mac)=>{ |
|
|
|
if (mac=='' || mac==null ) { |
|
|
|
if (NativeModules.BuildConfig.buildType == 'debug') { |
|
|
|
this.setState({macAddress : this.testMac}) |
|
|
|
this.startAd() |
|
|
|
} |
|
|
|
this.setState({ contentDisplayStatus: true}) |
|
|
|
}).catch(e => { |
|
|
|
this.setState({ contentDisplayStatus: false}) |
|
|
|
this.setState({ errorMessage : errorMsg.ERR_MAC_GET}); |
|
|
|
}) |
|
|
|
} else { |
|
|
|
this.setState({ contentDisplayStatus: false}) |
|
|
|
this.setState({ errorMessage : errorMsg.ERR_MAC_GET}); |
|
|
|
} |
|
|
|
} else { |
|
|
|
this.setState({macAddress : mac}) |
|
|
|
this.startAd() |
|
|
|
} |
|
|
|
}).catch(e => { |
|
|
|
this.setState({ contentDisplayStatus: false}) |
|
|
|
this.setState({ errorMessage : errorMsg.ERR_START_AD}); |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
startAd() { |
|
|
|
this.getBaseInfo() |
|
|
|
this.hbRequest() |
|
|
|
this.getAdDataList() |
|
|
|
setInterval( |
|
|
|
()=>{ |
|
|
|
if (this.state.contentDisplayStatus) { |
|
|
|
|
|
|
|
this.setState({ contentDisplayStatus: false}) |
|
|
|
if (this.updateContent()) { |
|
|
|
|
|
|
|
this.setState({ contentDisplayStatus: true}) |
|
|
|
} |
|
|
|
} else { |
|
|
@@ -238,26 +287,31 @@ startAd() { |
|
|
|
this.getAdDataList() |
|
|
|
} |
|
|
|
}, |
|
|
|
1000*10, //10秒更新一下页面 |
|
|
|
//页面切换间隔 |
|
|
|
this.state.heartConfig.pageChangeInterval |
|
|
|
// 1000*10, //10秒更新一下页面 |
|
|
|
); |
|
|
|
setInterval( |
|
|
|
()=>{ |
|
|
|
this.getAdDataList() |
|
|
|
}, |
|
|
|
1000*60*60, //1小时一次 |
|
|
|
// 数据获取间隔 |
|
|
|
this.state.heartConfig.dataRefreshInterval |
|
|
|
// 1000*60*60, //1小时一次 |
|
|
|
); |
|
|
|
setInterval( |
|
|
|
()=>{ |
|
|
|
this.hbRequest() |
|
|
|
}, |
|
|
|
1000*60*5, //5分钟一次 |
|
|
|
// 心跳间隔 |
|
|
|
this.state.heartConfig.heartbeatInterval |
|
|
|
// 1000*60*5, //5分钟一次 |
|
|
|
); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
getContentViewItemUplayer(contentItem) { |
|
|
|
if (contentItem.type == 0) { |
|
|
|
|
|
|
|
if (contentItem.subType == 2) |
|
|
|
return (<Image source={require('./image/timed.png')} resizeMode='center' style={styles.contentItemUpLayer} /> ) |
|
|
|
if (contentItem.subType == 6) |
|
|
@@ -320,7 +374,6 @@ getContentViewItem(contentItem, annomation) { |
|
|
|
<View style={styles.contentItemTopDetail}> |
|
|
|
{/* 券的title */} |
|
|
|
<Text style={styles.contentItemTopDetailTitle} numberOfLines={2} ellipsizeMode="tail">{contentItem.target.title}</Text> |
|
|
|
{/* <Text style={styles.contentItemTopDetailTitle} numberOfLines={2} ellipsizeMode="tail">你好世界你好你是你好宿舍熟话说术后</Text> */} |
|
|
|
{/* <Text style={styles.contentItemTopDetailRemark} numberOfLines={1} ellipsizeMode="tail">{contentItem.target.remark}</Text> */} |
|
|
|
<View style={styles.contentItemTopDetailPrice}> |
|
|
|
{/* 售价 */} |
|
|
@@ -351,9 +404,9 @@ getContentViewItem(contentItem, annomation) { |
|
|
|
getContentView() { |
|
|
|
if (this.state.contentDisplayStatus) { |
|
|
|
return (<View style={styles.content}> |
|
|
|
{this.getContentViewItem(this.state.contentItem0,"slideInDown")} |
|
|
|
{this.getContentViewItem(this.state.contentItem1,"slideInLeft")} |
|
|
|
{this.getContentViewItem(this.state.contentItem2,"slideInRight")} |
|
|
|
{this.getContentViewItem(this.state.contentItem0,this.state.animationTheme.first)} |
|
|
|
{this.getContentViewItem(this.state.contentItem1,this.state.animationTheme.second)} |
|
|
|
{this.getContentViewItem(this.state.contentItem2,this.state.animationTheme.third)} |
|
|
|
</View>) |
|
|
|
}else{ |
|
|
|
return ( |
|
|
@@ -408,6 +461,8 @@ render() { |
|
|
|
<Text style={styles.bottomQrcode1Str}>公众号</Text> |
|
|
|
</View> |
|
|
|
<Text style={styles.bottomPlacehold}>{this.state.versionInfo}</Text> |
|
|
|
{/* <Text style={styles.bottomPlacehold}>{this.state.heartConfig}</Text> */} |
|
|
|
|
|
|
|
</View> |
|
|
|
</ImageBackground> |
|
|
|
); |
|
|
|