瀏覽代碼

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

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';

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

curAdIndex = 0;

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

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

}

export default class MyPage extends Component {

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

contentDisplayStatus:true,
contentDisplayStatus:false,

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

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

text:'',
macAddress: '',
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
}
hbRequest() {
HttpUtils.post('https://mall.youlane.cn/api/wxDeviceScreenAd/heartbeat?deviceId='
+encodeURIComponent(this.state.macAddress),
{version:this.state.versionInfo})
.then(result => {
})
.catch(error => {
})
}

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 => {
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() {
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 => {
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"});
});

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.getAdDataList()

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

}

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

actionText = '扫码领取';

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



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

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

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

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

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

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


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

Before After
Width: 142  |  Height: 142  |  Size: 28 KiB Width: 141  |  Height: 141  |  Size: 33 KiB

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

Before After
Width: 141  |  Height: 141  |  Size: 33 KiB

Loading…
取消
儲存