Ver a proveniência

添加像素比

tags/jenkins-front-end-screenad-212-v115^0
caserKing há 5 anos
ascendente
cometimento
c1d38c0c4e
1 ficheiros alterados com 49 adições e 39 eliminações
  1. +49
    -39
      App.js

+ 49
- 39
App.js Ver ficheiro

@@ -104,7 +104,8 @@ export default class MyPage extends Component {
macAddress: '', macAddress: '',
versionInfo:'未知', versionInfo:'未知',
adType: 0, adType: 0,
curAdType02Index: 0,
curAdType02Index: 0, //广告图index
curCoverImgUrl: '',


}; };


@@ -134,6 +135,7 @@ export default class MyPage extends Component {
} }


componentDidUpdate() { componentDidUpdate() {
console.log(PixelRatio.get())
/* console.log(this.refs.scrollView) /* console.log(this.refs.scrollView)
if (this.refs.scrollView != undefined) { if (this.refs.scrollView != undefined) {
var ScrollView = this.refs.scrollView; var ScrollView = this.refs.scrollView;
@@ -207,10 +209,6 @@ codePushStatusDidChange(syncStatus) {
if (curAdIndex >= adDataList.length) { if (curAdIndex >= adDataList.length) {
curAdIndex = 0; curAdIndex = 0;
this.setState({
adType: 2,
curAdType02Index: 0
});
} }


@@ -279,6 +277,24 @@ codePushStatusDidChange(syncStatus) {
this.setState({errorMessage : errMsg}); this.setState({errorMessage : errMsg});
} }


//判断播放类型adType
dealLoopType(dataList) {
adDataList = dataList.filter((item) => {
return item.type == 0;
})
adDataBgList = dataList.filter((item) => {
return item.type == 2;
})
//aaa
let num = 0;
if (adDataList.length > 0 && adDataBgList.length > 0) {
num = 2;
} else if (adDataList.length > 0 && !adDataBgList.length) {
num = 0;
}
this.setState({adType: num })
}

getAdDataList(first) { getAdDataList(first) {
HttpUtils.get(NativeModules.BuildConfig.apiHost HttpUtils.get(NativeModules.BuildConfig.apiHost
+ 'api/wxDeviceScreenAd/list?deviceId=' + 'api/wxDeviceScreenAd/list?deviceId='
@@ -293,14 +309,9 @@ codePushStatusDidChange(syncStatus) {
result.data.list[5].type = 2; result.data.list[5].type = 2;
console.log(result.data) console.log(result.data)
//type==0的是券 1是? 2是广告大图 //type==0的是券 1是? 2是广告大图
adDataList = result.data.list.filter((item) => {
return item.type == 0;
})
adDataBgList = result.data.list.filter((item) => {
return item.type == 2;
})
//aaa
// this.setState({adType: 2 })
let curData = result.data.list;
this.dealLoopType(curData);


if (this.updateContent()) { if (this.updateContent()) {
this.setState({contentDisplayStatus: true}) this.setState({contentDisplayStatus: true})
@@ -346,6 +357,7 @@ componentWillUnmount(){
} }





async routine() { async routine() {
hbRequestCount -=1; hbRequestCount -=1;
getAdDataCount -=1; getAdDataCount -=1;
@@ -359,23 +371,21 @@ async routine() {
this.hbRequest() this.hbRequest()
hbRequestCount = heartConfig.heartbeatInterval hbRequestCount = heartConfig.heartbeatInterval
} }
//如果是adType == 2时间间隔到了,要检验轮播是否走完在决定切换 //如果是adType == 2时间间隔到了,要检验轮播是否走完在决定切换
if (this.state.adType == 2) { if (this.state.adType == 2) {
if (this.refs.carousel != undefined && (this.refs.carousel.currentIndex == adDataList.length-1)) {
if (this.state.curAdType02Index+1 < adDataBgList.length) {
let curNum = this.state.curAdType02Index+1;
this.setState({curAdType02Index: curNum});
} else {
this.setState({
adType: 0,
curAdType02Index: 0
});
curAdIndex = 0;
pageChangeCount = heartConfig.pageChangeInterval;
this.updateContent();
if (pageChangeCount<=0) {
let curNum = this.state.curAdType02Index + 1;
if (curNum >= adDataList.length) {
curNum = 0;
} }
this.setState({
curAdType02Index: curNum,
curCoverImgUrl:adDataBgList[curNum].coverImg
})
pageChangeCount = heartConfig.pageChangeInterval
} }
} else if (this.state.adType == 0) { } else if (this.state.adType == 0) {
if (pageChangeCount <= 0) { //页面切换间隔 if (pageChangeCount <= 0) { //页面切换间隔
if (this.state.contentDisplayStatus && this.state.baseInfo) { if (this.state.contentDisplayStatus && this.state.baseInfo) {
@@ -400,7 +410,7 @@ async routine() {


timer = setTimeout(()=>{ timer = setTimeout(()=>{
this.routine(); this.routine();
},200);
},1000);
} }


startAd() { startAd() {
@@ -619,7 +629,7 @@ getAdView(){
} else if (this.state.adType == 2) { } else if (this.state.adType == 2) {
return ( return (
// <ImageBackground style={styles.adTypeBg} source={require('./image/ad1.jpg')}> // <ImageBackground style={styles.adTypeBg} source={require('./image/ad1.jpg')}>
<ImageBackground style={styles.adTypeBg} resizeMode="stretch" source={{ uri: adDataBgList[this.state.curAdType02Index].coverImg}}>
<ImageBackground style={styles.adTypeBg} resizeMode="stretch" source={{ uri: this.state.curCoverImgUrl}}>
{/* adType == 2 滚动轮播 */} {/* adType == 2 滚动轮播 */}
{/* <Swiper ref='scrollView' style={styles.adTypeSwiper02} autoplay={true} autoplayTimeout={1} showPagination={false} {/* <Swiper ref='scrollView' style={styles.adTypeSwiper02} autoplay={true} autoplayTimeout={1} showPagination={false}
dotColor="transparent" activeDotColor="transparent" horizontal={true} showsButtons={false}> dotColor="transparent" activeDotColor="transparent" horizontal={true} showsButtons={false}>
@@ -1077,7 +1087,7 @@ MyPage = CodePush(codePushOptions)(MyPage);
bottom:2, bottom:2,
left:0, left:0,
// flex: 1, // flex: 1,
paddingTop:50,
paddingTop:138/PixelRatio.get(),
width:'100%', width:'100%',
// height:'100%', // height:'100%',
backgroundColor:'transparent', backgroundColor:'transparent',
@@ -1085,10 +1095,10 @@ MyPage = CodePush(codePushOptions)(MyPage);


contentItemTopDetailSalePrice02:{ contentItemTopDetailSalePrice02:{
position:"absolute", position:"absolute",
bottom:14,
bottom:38/PixelRatio.get(),
left:0, left:0,
// flex: 1, // flex: 1,
paddingTop:50,
paddingTop:138/PixelRatio.get(),
width:'100%', width:'100%',
// height:'100%', // height:'100%',
backgroundColor:'transparent', backgroundColor:'transparent',
@@ -1126,24 +1136,24 @@ MyPage = CodePush(codePushOptions)(MyPage);
adTypeSwiper02:{ adTypeSwiper02:{
position: 'absolute', position: 'absolute',
left: 0, left: 0,
bottom: 59,
bottom: 165/PixelRatio.get(),
width: '100%', width: '100%',
height: 134,
height: 369/PixelRatio.get(),
}, },


adTypeItemImgWrap:{ adTypeItemImgWrap:{
flex: 1, flex: 1,
width: '100%', width: '100%',
height: 134,
height: 369/PixelRatio.get(),
flexDirection: 'row', flexDirection: 'row',
alignItems: 'center', alignItems: 'center',
}, },


adTypeItemImg:{ adTypeItemImg:{
width: 100,
height: 100,
marginLeft: 18,
marginTop: 11,
width: 275/PixelRatio.get(),
height: 275/PixelRatio.get(),
marginLeft: 50/PixelRatio.get(),
marginTop: 30/PixelRatio.get(),
borderRadius:27/PixelRatio.get(), borderRadius:27/PixelRatio.get(),
backgroundColor:'transparent' backgroundColor:'transparent'
}, },
@@ -1161,7 +1171,7 @@ MyPage = CodePush(codePushOptions)(MyPage);


contentItemTopForAd:{ contentItemTopForAd:{
flex: 1, flex: 1,
width: 410,
width: 1127/PixelRatio.get(),
height:'100%', height:'100%',
paddingLeft: 22/PixelRatio.get(), paddingLeft: 22/PixelRatio.get(),
paddingRight: 26/PixelRatio.get(), paddingRight: 26/PixelRatio.get(),


Carregando…
Cancelar
Guardar