Просмотр исходного кода

【大屏】【优化】【图片预加载】

tags/jenkins-front-end-screenad-250-v42^0
caserKing 5 лет назад
Родитель
Сommit
285a1b7c75
1 измененных файлов: 26 добавлений и 12 удалений
  1. +26
    -12
      App.js

+ 26
- 12
App.js Просмотреть файл

@@ -118,7 +118,8 @@ export default class MyPage extends Component {
versionInfo:'未知', versionInfo:'未知',
adType: 0, adType: 0,
curAdType02Index: 0, //广告图index curAdType02Index: 0, //广告图index
curCoverImgUrl: '',
coverImgUrl: 'https://iformall-net.s3.cn-northwest-1.amazonaws.com.cn/456/37d833d7-263f-4f97-8588-e827c2f43db4.jpg',
previewImg: 'https://iformall-net.s3.cn-northwest-1.amazonaws.com.cn/456/37d833d7-263f-4f97-8588-e827c2f43db4.jpg',


}; };


@@ -398,7 +399,7 @@ async routine() {
} }
this.setState({ this.setState({
curAdType02Index: curNum, curAdType02Index: curNum,
curCoverImgUrl:adDataBgList[curNum].coverImg
previewImg:adDataBgList[curNum].coverImg
}) })
pageChangeCount = heartConfig.pageChangeInterval pageChangeCount = heartConfig.pageChangeInterval
} }
@@ -657,19 +658,23 @@ getAdView(){
); );
} else if (this.state.adType == 2) { } else if (this.state.adType == 2) {
let curWidthNum = 1080/(PixelRatio.get()); let curWidthNum = 1080/(PixelRatio.get());
let curImgObj = null;
if (!this.state.curCoverImgUrl) {
curImgObj = require('./image/background.png');
} else {
curImgObj = {
uri: this.state.curCoverImgUrl
}
}
return ( return (
// <ImageBackground style={styles.adTypeBg} source={require('./image/ad1.jpg')}> slideInDown zoomInDown // <ImageBackground style={styles.adTypeBg} source={require('./image/ad1.jpg')}> slideInDown zoomInDown
<View style={styles.adWrapBox}> <View style={styles.adWrapBox}>
<Animatable.View animation="slideInDown" style={styles.adWrap} key={this.state.curCoverImgUrl}>
<ImageBackground style={styles.adTypeBg} resizeMode="stretch" source={curImgObj}>
<Image style={styles.adWrapHideImg}
onLoadStart={() => {

}}
onLoad={() => {
this.setState({
coverImgUrl: this.state.previewImg
})
}}
resizeMode="stretch" source={{uri: this.state.previewImg}}>
</Image>

<Animatable.View animation="slideInDown" style={styles.adWrap} key={this.state.coverImgUrl}>
<ImageBackground style={styles.adTypeBg} resizeMode="stretch" source={{uri: this.state.coverImgUrl}}>
</ImageBackground> </ImageBackground>
</Animatable.View> </Animatable.View>
@@ -1227,6 +1232,15 @@ MyPage = CodePush(codePushOptions)(MyPage);
top: 0, top: 0,
zIndex: 10, zIndex: 10,
}, },
adWrapHideImg: {
width: '100%',
height: '100%',
position: 'absolute',
left: 0,
top: 0,
zIndex: -1,
opacity:0,
},


adTypeSwiper02:{ adTypeSwiper02:{
flex: 1, flex: 1,


Загрузка…
Отмена
Сохранить