| @@ -104,7 +104,8 @@ export default class MyPage extends Component { | |||
| macAddress: '', | |||
| versionInfo:'未知', | |||
| adType: 0, | |||
| curAdType02Index: 0, | |||
| curAdType02Index: 0, //广告图index | |||
| curCoverImgUrl: '', | |||
| }; | |||
| @@ -134,6 +135,7 @@ export default class MyPage extends Component { | |||
| } | |||
| componentDidUpdate() { | |||
| console.log(PixelRatio.get()) | |||
| /* console.log(this.refs.scrollView) | |||
| if (this.refs.scrollView != undefined) { | |||
| var ScrollView = this.refs.scrollView; | |||
| @@ -207,10 +209,6 @@ codePushStatusDidChange(syncStatus) { | |||
| if (curAdIndex >= adDataList.length) { | |||
| curAdIndex = 0; | |||
| this.setState({ | |||
| adType: 2, | |||
| curAdType02Index: 0 | |||
| }); | |||
| } | |||
| @@ -279,6 +277,24 @@ codePushStatusDidChange(syncStatus) { | |||
| 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) { | |||
| HttpUtils.get(NativeModules.BuildConfig.apiHost | |||
| + 'api/wxDeviceScreenAd/list?deviceId=' | |||
| @@ -293,14 +309,9 @@ codePushStatusDidChange(syncStatus) { | |||
| result.data.list[5].type = 2; | |||
| console.log(result.data) | |||
| //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()) { | |||
| this.setState({contentDisplayStatus: true}) | |||
| @@ -346,6 +357,7 @@ componentWillUnmount(){ | |||
| } | |||
| async routine() { | |||
| hbRequestCount -=1; | |||
| getAdDataCount -=1; | |||
| @@ -359,23 +371,21 @@ async routine() { | |||
| this.hbRequest() | |||
| hbRequestCount = heartConfig.heartbeatInterval | |||
| } | |||
| //如果是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) { | |||
| if (pageChangeCount <= 0) { //页面切换间隔 | |||
| if (this.state.contentDisplayStatus && this.state.baseInfo) { | |||
| @@ -400,7 +410,7 @@ async routine() { | |||
| timer = setTimeout(()=>{ | |||
| this.routine(); | |||
| },200); | |||
| },1000); | |||
| } | |||
| startAd() { | |||
| @@ -619,7 +629,7 @@ getAdView(){ | |||
| } else if (this.state.adType == 2) { | |||
| return ( | |||
| // <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 滚动轮播 */} | |||
| {/* <Swiper ref='scrollView' style={styles.adTypeSwiper02} autoplay={true} autoplayTimeout={1} showPagination={false} | |||
| dotColor="transparent" activeDotColor="transparent" horizontal={true} showsButtons={false}> | |||
| @@ -1077,7 +1087,7 @@ MyPage = CodePush(codePushOptions)(MyPage); | |||
| bottom:2, | |||
| left:0, | |||
| // flex: 1, | |||
| paddingTop:50, | |||
| paddingTop:138/PixelRatio.get(), | |||
| width:'100%', | |||
| // height:'100%', | |||
| backgroundColor:'transparent', | |||
| @@ -1085,10 +1095,10 @@ MyPage = CodePush(codePushOptions)(MyPage); | |||
| contentItemTopDetailSalePrice02:{ | |||
| position:"absolute", | |||
| bottom:14, | |||
| bottom:38/PixelRatio.get(), | |||
| left:0, | |||
| // flex: 1, | |||
| paddingTop:50, | |||
| paddingTop:138/PixelRatio.get(), | |||
| width:'100%', | |||
| // height:'100%', | |||
| backgroundColor:'transparent', | |||
| @@ -1126,24 +1136,24 @@ MyPage = CodePush(codePushOptions)(MyPage); | |||
| adTypeSwiper02:{ | |||
| position: 'absolute', | |||
| left: 0, | |||
| bottom: 59, | |||
| bottom: 165/PixelRatio.get(), | |||
| width: '100%', | |||
| height: 134, | |||
| height: 369/PixelRatio.get(), | |||
| }, | |||
| adTypeItemImgWrap:{ | |||
| flex: 1, | |||
| width: '100%', | |||
| height: 134, | |||
| height: 369/PixelRatio.get(), | |||
| flexDirection: 'row', | |||
| alignItems: 'center', | |||
| }, | |||
| 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(), | |||
| backgroundColor:'transparent' | |||
| }, | |||
| @@ -1161,7 +1171,7 @@ MyPage = CodePush(codePushOptions)(MyPage); | |||
| contentItemTopForAd:{ | |||
| flex: 1, | |||
| width: 410, | |||
| width: 1127/PixelRatio.get(), | |||
| height:'100%', | |||
| paddingLeft: 22/PixelRatio.get(), | |||
| paddingRight: 26/PixelRatio.get(), | |||