浏览代码

[系统][修改]:心跳访问,抢购角标添加

tags/jenkins-front-end-screenad-67^0
hupeng 6 年前
父节点
当前提交
b7f5f1f8e1
共有 3 个文件被更改,包括 104 次插入33 次删除
  1. +104
    -33
      App.js
  2. 二进制
      image/groupbuy.png
  3. 二进制
      image/timed.png

+ 104
- 33
App.js 查看文件

@@ -17,6 +17,8 @@ import DeviceInfo from "react-native-device-info";
import * as Animatable from 'react-native-animatable'; import * as Animatable from 'react-native-animatable';


contentItemDefault = { contentItemDefault = {
type:0,
subType:0,
qrcode:[], qrcode:[],
target:{ target:{
coverImg:'', coverImg:'',
@@ -36,6 +38,14 @@ baseInfoDefault = {


curAdIndex = 0; curAdIndex = 0;


testMac = '11:AA:33:BB:44'

errorMsg = {
ERR_MAC_GET:'MAC地址获取错误',
ERR_DATA_GET:'数据获取错误'

}

export default class MyPage extends Component { export default class MyPage extends Component {


constructor(props) { constructor(props) {
@@ -47,20 +57,18 @@ export default class MyPage extends Component {
contentItem1:null, contentItem1:null,
contentItem2:null, contentItem2:null,


contentDisplayStatus:true,
contentDisplayStatus:false,


syncMessage: "INIT" , syncMessage: "INIT" ,
errorMessage: 'Loading...',

progress: { progress: {
receivedBytes:0, receivedBytes:0,
totalBytes:0 totalBytes:0
}, },
macAddress: "NULL",

text:'',
macAddress: '',
versionInfo:'UNKNOWN' versionInfo:'UNKNOWN'
}; };
DeviceInfo.getMACAddress().then(mac=>{this.setState({macAddress:mac})})
DeviceInfo.getIPAddress().then(mac=>{this.setState({macAddress:mac})})
} }


// 监听更新状态 // 监听更新状态
@@ -118,22 +126,58 @@ codePushStatusDidChange(syncStatus) {
curAdIndex+=3 curAdIndex+=3
} }
hbRequest() {
HttpUtils.post('https://mall.youlane.cn/api/wxDeviceScreenAd/heartbeat?deviceId='
+encodeURIComponent(this.state.macAddress),
{version:this.state.versionInfo})
.then(result => {
})
.catch(error => {
})
}

getAdDataList() { getAdDataList() {
HttpUtils.get('https://mall.youlane.cn/api/wxDeviceScreenAd/list?deviceId=11%3AAA%3A33%3ABB%3A44&pageNum=1&pageSize=30')
HttpUtils.get('https://mall.youlane.cn/api/wxDeviceScreenAd/list?deviceId='+encodeURIComponent(this.state.macAddress)+'&pageNum=1&pageSize=1000')
.then(result => { .then(result => {
this.setState({adDataList : result.data.list});
this.updateContent();
})
.catch(error => console.error(error))
if (result.code != 200) {
this.setState({errorMessage : result.message});
this.setState({contentDisplayStatus: false})
}
if (result.data.list) {
this.setState({adDataList : result.data.list});
this.updateContent();
} else {
this.setState({errorMessage : errorMsg.ERR_DATA_GET});
this.setState({contentDisplayStatus: false})
}
})
.catch(error => {
console.error(error)
this.setState({errorMessage : error});
this.setState({contentDisplayStatus: false})
})
} }


getBaseInfo() { getBaseInfo() {
HttpUtils.get('https://mall.youlane.cn/api/wxDeviceScreenAd/info?deviceId=11%3AAA%3A33%3ABB%3A44')
HttpUtils.get('https://mall.youlane.cn/api/wxDeviceScreenAd/info?deviceId='+encodeURIComponent(this.state.macAddress))
.then(result => { .then(result => {
this.setState({
baseInfo:result.data});
if (result.code != 200) {
this.setState({errorMessage : result.message});
this.setState({contentDisplayStatus: false})
}
if (result.data) {
this.setState({baseInfo:result.data});
}
else {
this.setState({errorMessage : errorMsg.ERR_DATA_GET});
this.setState({contentDisplayStatus: false})
}
})
.catch(error => {
console.error(error)
this.setState({errorMessage : error});
this.setState({contentDisplayStatus: false})
}) })
.catch(error => console.error(error))
} }




@@ -152,32 +196,56 @@ componentDidMount() {
this.setState({ versionInfo: "Unknown"}); this.setState({ versionInfo: "Unknown"});
}); });


DeviceInfo.getMACAddress().then(mac=>{
if (mac=='') {
this.startAd(testMac)
} else {
this.startAd(mac)
}
this.setState({ contentDisplayStatus: true})
}).catch(e => {
this.setState({errorMessage : errorMsg.ERR_MAC_GET});
})
}

startAd(mac) {
this.getBaseInfo() this.getBaseInfo()
this.getAdDataList() this.getAdDataList()

setInterval( setInterval(
()=>{ ()=>{
this.setState({ contentDisplayStatus: false}) this.setState({ contentDisplayStatus: false})
this.updateContent(); this.updateContent();
this.setState({ contentDisplayStatus: true}) this.setState({ contentDisplayStatus: true})
}, },
1000 * 10, //10秒更新一下页面
1000*10, //10秒更新一下页面
); );
setInterval( setInterval(
()=>{ ()=>{
this.setState({ contentDisplayStatus: false}) this.setState({ contentDisplayStatus: false})
this.updateContent();
this.getAdDataList()
this.setState({ contentDisplayStatus: true}) this.setState({ contentDisplayStatus: true})
}, },
1000*60*60, //1小时一次 1000*60*60, //1小时一次
); );
setInterval(
()=>{
this.hbRequest()
},
1000*60*5, //5分钟一次
);

} }


getContentViewItemUplayer(contentItem) { getContentViewItemUplayer(contentItem) {
if (contentItem.target.type == 8)
return (<Image source={require('./image/discount.png')} resizeMode='center' style={styles.contentItemUpLayer} /> )
else if (contentItem.target.type == 9)
return (<Image source={require('./image/groupbuy.png')} resizeMode='center' style={styles.contentItemUpLayer} /> )
if (contentItem.type == 0) {

if (contentItem.subType == 2)
return (<Image source={require('./image/groupbuy.png')} resizeMode='center' style={styles.contentItemUpLayer} /> )
if (contentItem.subType == 6)
return (<Image source={require('./image/discount.png')} resizeMode='center' style={styles.contentItemUpLayer} /> )
if (contentItem.subType == 7)
return (<Image source={require('./image/groupbuy.png')} resizeMode='center' style={styles.contentItemUpLayer} /> )
}
} }


getContentViewItem(contentItem, annomation) { getContentViewItem(contentItem, annomation) {
@@ -186,6 +254,7 @@ getContentViewItem(contentItem, annomation) {
<View style={styles.contentItem}> <View style={styles.contentItem}>
</View> </View>
) )

actionText = '扫码领取'; actionText = '扫码领取';


if (contentItem.target.type == 8) if (contentItem.target.type == 8)
@@ -244,7 +313,9 @@ getContentView() {
{this.getContentViewItem(this.state.contentItem2,"slideInRight")} {this.getContentViewItem(this.state.contentItem2,"slideInRight")}
</View>) </View>)
}else{ }else{
return (<View style={styles.content}>
return (
<View style={styles.content}>
<Text style={styles.updatePage}>{this.state.errorMessage}</Text>
</View>) </View>)
} }
} }
@@ -255,13 +326,11 @@ render() {
if (this.state.progress.totalBytes > 0) if (this.state.progress.totalBytes > 0)
return ( return (
<Text style={styles.updatePage}>{this.state.syncMessage}{'\n'} <Text style={styles.updatePage}>{this.state.syncMessage}{'\n'}
{this.state.progress.receivedBytes} of {this.state.progress.totalBytes} bytes received{'\n'}
{this.state.text}
{this.state.progress.receivedBytes} of {this.state.progress.totalBytes} bytes received{'\n'}
</Text> </Text>
); );
return ( return (
<Text style={styles.updatePage}>{this.state.syncMessage}{'\n'}
{this.state.text}
<Text style={styles.updatePage}>{this.state.syncMessage}
</Text> </Text>
); );
} }
@@ -309,15 +378,13 @@ render() {
flex: 2, flex: 2,
width:'100%', width:'100%',
height:'100%', height:'100%',
backgroundColor:'yellow',
backgroundColor:'transparent',
textAlign :'center', textAlign :'center',
textAlignVertical:'center', textAlignVertical:'center',
fontSize: 24, fontSize: 24,
color: 'green'
color: 'darkblue'
}, },




//layer background //layer background
background:{ background:{
flex: 1, flex: 1,
@@ -390,7 +457,7 @@ render() {
//layer bottom //layer bottom
bottomLogoBackground: { bottomLogoBackground: {
flex: 3, flex: 3,
borderRadius:10,
borderRadius:6,
marginTop: 10, marginTop: 10,
marginBottom: 10, marginBottom: 10,
backgroundColor:'white' backgroundColor:'white'
@@ -486,7 +553,7 @@ render() {


contentItemUpLayer:{ contentItemUpLayer:{
width:80, width:80,
height:60,
height:58,
position:'absolute', position:'absolute',
backgroundColor:'transparent' backgroundColor:'transparent'
}, },
@@ -553,6 +620,7 @@ render() {
fontSize: 10, fontSize: 10,
fontWeight : 'bold' fontWeight : 'bold'
}, },

contentItemBottomPlacehold:{ contentItemBottomPlacehold:{
flex: 6, flex: 6,
paddingLeft: 10, paddingLeft: 10,
@@ -561,6 +629,7 @@ render() {
height:'100%', height:'100%',
backgroundColor:'transparent', backgroundColor:'transparent',
}, },

contentItemBottomAction:{ contentItemBottomAction:{
flex: 5, flex: 5,
width:'100%', width:'100%',
@@ -593,6 +662,7 @@ render() {
fontSize: 10, fontSize: 10,
color : 'gray' color : 'gray'
}, },

contentItemTopDetailPrice:{ contentItemTopDetailPrice:{
flex: 2, flex: 2,
width:'100%', width:'100%',
@@ -608,6 +678,7 @@ render() {
flexDirection: 'row', flexDirection: 'row',
backgroundColor:'transparent', backgroundColor:'transparent',
}, },

contentItemTopDetailCurPriceStr:{ contentItemTopDetailCurPriceStr:{
backgroundColor:'transparent', backgroundColor:'transparent',
textAlign :'left', textAlign :'left',


二进制
image/groupbuy.png 查看文件

之前 之后
宽度: 142  |  高度: 142  |  大小: 28 KiB 宽度: 141  |  高度: 141  |  大小: 33 KiB

二进制
image/timed.png 查看文件

之前 之后
宽度: 141  |  高度: 141  |  大小: 33 KiB

正在加载...
取消
保存