|
|
@@ -18,8 +18,8 @@ import HttpUtils from './HttpUtils.js'; |
|
|
|
import CodePush from "react-native-code-push"; |
|
|
|
import DeviceInfo from "react-native-device-info"; |
|
|
|
import * as Animatable from 'react-native-animatable'; |
|
|
|
import Swiper from 'react-native-swiper'; |
|
|
|
var testMac = 'FF:FF:FF:FF:FF:FF' |
|
|
|
|
|
|
|
var curAdIndex = 0; |
|
|
|
var errorMsg = { |
|
|
|
ERR_MAC_GET:'设备编号获取错误', |
|
|
@@ -61,7 +61,8 @@ var hbRequestCount |
|
|
|
var getAdDataCount |
|
|
|
var pageChangeCount |
|
|
|
|
|
|
|
var adDataList = [] |
|
|
|
var adDataList = []; |
|
|
|
var adDataBgList = []; |
|
|
|
|
|
|
|
var heartConfig = { |
|
|
|
heartbeatInterval:10, |
|
|
@@ -100,8 +101,43 @@ export default class MyPage extends Component { |
|
|
|
}, |
|
|
|
updating:true, |
|
|
|
macAddress: '', |
|
|
|
versionInfo:'未知' |
|
|
|
versionInfo:'未知', |
|
|
|
adType: 0, |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
/* this.codePushUpdate = this.codePushUpdate.bind(this); |
|
|
|
this.startAd = this.startAd.bind(this); |
|
|
|
this.showErrMsg = this.showErrMsg.bind(this); */ |
|
|
|
} |
|
|
|
|
|
|
|
componentDidMount() { |
|
|
|
this.codePushUpdate(); |
|
|
|
|
|
|
|
DeviceInfo.getMACAddress().then((mac)=>{ |
|
|
|
if (mac=='' || mac==null ) { |
|
|
|
if (NativeModules.BuildConfig.buildType == 'debug') { |
|
|
|
this.setState({macAddress : this.testMac}) |
|
|
|
this.startAd() |
|
|
|
} else { |
|
|
|
this.showErrMsg(errorMsg.ERR_MAC_GET); |
|
|
|
} |
|
|
|
} else { |
|
|
|
this.setState({macAddress : mac}) |
|
|
|
this.startAd() |
|
|
|
} |
|
|
|
}).catch(e => { |
|
|
|
this.showErrMsg(errorMsg.ERR_START_AD); |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
componentDidUpdate() { |
|
|
|
console.log(this.refs.scrollView) |
|
|
|
if (this.refs.scrollView != undefined) { |
|
|
|
var ScrollView = this.refs.scrollView; |
|
|
|
ScrollView.scrollBy(0.1, false); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
//更新函数 |
|
|
@@ -167,7 +203,13 @@ codePushStatusDidChange(syncStatus) { |
|
|
|
return false; |
|
|
|
|
|
|
|
if (curAdIndex >= adDataList.length) { |
|
|
|
curAdIndex = 0 |
|
|
|
curAdIndex = 0; |
|
|
|
if (this.state.adType == 0) { |
|
|
|
this.setState({adType: 2}); |
|
|
|
} else if (this.state.adType == 2) { |
|
|
|
this.setState({adType: 0}); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
this.setState({contentItem0:adDataList[curAdIndex]}); |
|
|
@@ -194,9 +236,13 @@ codePushStatusDidChange(syncStatus) { |
|
|
|
.then(result => { |
|
|
|
if (result.code == 200) { |
|
|
|
let config = JSON.parse(result.data.config); |
|
|
|
heartConfig.heartbeatInterval = config.heartbeatInterval |
|
|
|
heartConfig.dataRefreshInterval=config.dataRefreshInterval |
|
|
|
heartConfig.pageChangeInterval=config.pageChangeInterval |
|
|
|
console.log(config) |
|
|
|
// heartConfig.heartbeatInterval = config.heartbeatInterval |
|
|
|
// heartConfig.dataRefreshInterval=config.dataRefreshInterval |
|
|
|
// heartConfig.pageChangeInterval=config.pageChangeInterval |
|
|
|
heartConfig.heartbeatInterval = 20 |
|
|
|
heartConfig.dataRefreshInterval=20 |
|
|
|
heartConfig.pageChangeInterval=2 |
|
|
|
|
|
|
|
// 动画划入 |
|
|
|
if(config.animationTheme == 0){ |
|
|
@@ -244,7 +290,21 @@ codePushStatusDidChange(syncStatus) { |
|
|
|
if (result.code != 200) { |
|
|
|
this.showErrMsg(result.message+'\n'+this.state.macAddress); |
|
|
|
} else if (result.data.list) { |
|
|
|
adDataList = result.data.list; |
|
|
|
//aaa |
|
|
|
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; |
|
|
|
}) |
|
|
|
console.log(adDataList) |
|
|
|
console.log(adDataBgList) |
|
|
|
//aaa |
|
|
|
// this.setState({adType: 2 }) |
|
|
|
|
|
|
|
if (this.updateContent()) { |
|
|
|
this.setState({contentDisplayStatus: true}) |
|
|
|
} else { |
|
|
@@ -283,26 +343,6 @@ codePushStatusDidChange(syncStatus) { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
componentDidMount() { |
|
|
|
this.codePushUpdate(); |
|
|
|
|
|
|
|
DeviceInfo.getMACAddress().then((mac)=>{ |
|
|
|
if (mac=='' || mac==null ) { |
|
|
|
if (NativeModules.BuildConfig.buildType == 'debug') { |
|
|
|
this.setState({macAddress : this.testMac}) |
|
|
|
this.startAd() |
|
|
|
} else { |
|
|
|
this.showErrMsg(errorMsg.ERR_MAC_GET); |
|
|
|
} |
|
|
|
} else { |
|
|
|
this.setState({macAddress : mac}) |
|
|
|
this.startAd() |
|
|
|
} |
|
|
|
}).catch(e => { |
|
|
|
this.showErrMsg(errorMsg.ERR_START_AD); |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
componentWillUnmount(){ |
|
|
|
if (timer) |
|
|
|
clearTimeout(timer) |
|
|
@@ -449,6 +489,48 @@ getContentView() { |
|
|
|
</View>) |
|
|
|
} |
|
|
|
} |
|
|
|
setSwiperItemDom(contentItem, index) { |
|
|
|
return ( |
|
|
|
<View style={styles.contentItemTopForAd} key={index}> |
|
|
|
<Image source={{uri: contentItem.coverImg}} resizeMode='cover' style={styles.adTypeItemImg} /> |
|
|
|
<View style={styles.contentItemTopDetail}> |
|
|
|
{/* 券的title */} |
|
|
|
<Text style={styles.contentItemTopDetailTitle} numberOfLines={2} ellipsizeMode="tail">{contentItem.target.title}</Text> |
|
|
|
<View style={styles.contentItemTopDetailPrice}> |
|
|
|
{/* 售价 */} |
|
|
|
<View style={styles.contentItemTopDetailCurPrice}> |
|
|
|
<Text style={styles.contentItemTopDetailCurPriceStrUnit}>¥</Text> |
|
|
|
<Text style={styles.contentItemTopDetailCurPriceStr}>{contentItem.target.salePriceStr}</Text> |
|
|
|
</View> |
|
|
|
{/* 面额 */} |
|
|
|
<View style={styles.contentItemTopDetailSalePrice}> |
|
|
|
<Text style={styles.contentItemTopDetailSalePriceStr} >¥{contentItem.target.priceStr}</Text> |
|
|
|
</View> |
|
|
|
</View> |
|
|
|
</View> |
|
|
|
{/* <Image source={{uri:'data:image/png;base64,'+contentItem.qrcode}} resizeMode='contain' style={styles.contentItemTopQrcode} /> */} |
|
|
|
<Image source={{uri:contentItem.target.qrCode}} resizeMode='contain' style={styles.contentItemTopQrcode} /> |
|
|
|
</View> |
|
|
|
) |
|
|
|
} |
|
|
|
renderAdTypeSwiper() { |
|
|
|
if (this.state.contentDisplayStatus) { |
|
|
|
let adSwiperDomStack = []; |
|
|
|
//aaa |
|
|
|
adDataList.map((item,index) => { |
|
|
|
item.target.qrCode = 'https://iformall-net.s3.cn-northwest-1.amazonaws.com.cn/null/73ddb1e4-8f19-4d5d-8387-742d3d5d2c77.png' |
|
|
|
adSwiperDomStack.push(this.setSwiperItemDom(item, index)) |
|
|
|
}) |
|
|
|
return adSwiperDomStack; |
|
|
|
|
|
|
|
}else{ |
|
|
|
return ( |
|
|
|
<View style={styles.content}> |
|
|
|
<Text style={styles.updatePage}>{this.state.errorMessage}</Text> |
|
|
|
</View> |
|
|
|
) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
getUpdateView() { |
|
|
|
if (this.state.progress.totalBytes > 0) |
|
|
@@ -465,38 +547,66 @@ getUpdateView() { |
|
|
|
|
|
|
|
getAdView(){ |
|
|
|
if (this.state.baseInfo) { |
|
|
|
return ( |
|
|
|
<ImageBackground style={styles.background} resizeMode='center' source={require('./image/background.png')}> |
|
|
|
{/* 头部title二维码开始 */} |
|
|
|
<View style={styles.title}> |
|
|
|
<View style={styles.titleImagePlace}> |
|
|
|
<Image source={require('./image/title.png')} resizeMode='center' style={styles.titleImage} /> |
|
|
|
</View> |
|
|
|
<ImageBackground source={require('./image/title-qrcode.png') } resizeMode='center' style={styles.titleQrcodeBonder} > |
|
|
|
<View style={styles.titleQrcodePlacehold}></View> |
|
|
|
<Image source={{uri: this.state.baseInfo.imgQrcodeWeapp}} resizeMode='center' style={styles.titleQrcode} /> |
|
|
|
<View style={styles.titleQrcodePlacehold}></View> |
|
|
|
</ImageBackground> |
|
|
|
</View> |
|
|
|
{/* 券列表展示列表开始 */} |
|
|
|
{this.getContentView()} |
|
|
|
{/* 底部商场信息展示开始 */} |
|
|
|
<View style={styles.bottom}> |
|
|
|
<View style={styles.bottomLogoBackground}> |
|
|
|
<Image source={{ uri: this.state.baseInfo.imgUrlH}} resizeMode='contain' style={styles.bottomLogo} /> |
|
|
|
</View> |
|
|
|
<View style={styles.bottomQrcode1Background}> |
|
|
|
<Image source={{ uri: this.state.baseInfo.imgQrcodeWeapp}} resizeMode='center' style={styles.bottomQrcode1} /> |
|
|
|
<Text style={styles.bottomQrcode1Str}>小程序</Text> |
|
|
|
</View> |
|
|
|
<View style={styles.bottomQrcode2Background}> |
|
|
|
<Image source={{ uri: this.state.baseInfo.imgQrcodeWemp}} resizeMode='center' style={styles.bottomQrcode2} /> |
|
|
|
<Text style={styles.bottomQrcode1Str}>公众号</Text> |
|
|
|
if (this.state.adType == 0) { |
|
|
|
return ( |
|
|
|
<ImageBackground style={styles.background} resizeMode='center' source={require('./image/background.png')}> |
|
|
|
{/* 头部title二维码开始 */} |
|
|
|
<View style={styles.title}> |
|
|
|
<View style={styles.titleImagePlace}> |
|
|
|
<Image source={require('./image/title.png')} resizeMode='center' style={styles.titleImage} /> |
|
|
|
</View> |
|
|
|
<ImageBackground source={require('./image/title-qrcode.png') } resizeMode='center' style={styles.titleQrcodeBonder} > |
|
|
|
<View style={styles.titleQrcodePlacehold}></View> |
|
|
|
<Image source={{uri: this.state.baseInfo.imgQrcodeWeapp}} resizeMode='center' style={styles.titleQrcode} /> |
|
|
|
<View style={styles.titleQrcodePlacehold}></View> |
|
|
|
</ImageBackground> |
|
|
|
</View> |
|
|
|
{/* 券列表展示列表开始 */} |
|
|
|
{this.getContentView()} |
|
|
|
{/* 底部商场信息展示开始 */} |
|
|
|
<View style={styles.bottom}> |
|
|
|
<View style={styles.bottomLogoBackground}> |
|
|
|
<Image source={{ uri: this.state.baseInfo.imgUrlH}} resizeMode='contain' style={styles.bottomLogo} /> |
|
|
|
</View> |
|
|
|
<View style={styles.bottomQrcode1Background}> |
|
|
|
<Image source={{ uri: this.state.baseInfo.imgQrcodeWeapp}} resizeMode='center' style={styles.bottomQrcode1} /> |
|
|
|
<Text style={styles.bottomQrcode1Str}>小程序</Text> |
|
|
|
</View> |
|
|
|
<View style={styles.bottomQrcode2Background}> |
|
|
|
<Image source={{ uri: this.state.baseInfo.imgQrcodeWemp}} resizeMode='center' style={styles.bottomQrcode2} /> |
|
|
|
<Text style={styles.bottomQrcode1Str}>公众号</Text> |
|
|
|
</View> |
|
|
|
<Text style={styles.bottomPlacehold}>{this.state.versionInfo}</Text> |
|
|
|
</View> |
|
|
|
</ImageBackground> |
|
|
|
); |
|
|
|
} else if (this.state.adType == 2) { |
|
|
|
return ( |
|
|
|
<ImageBackground style={styles.adTypeBg} source={require('./image/ad1.jpg')}> |
|
|
|
{/* adType == 2 滚动轮播 */} |
|
|
|
<Swiper ref='scrollView' style={styles.adTypeSwiper02} autoplay={true} autoplayTimeout={0.5} showPagination={false} |
|
|
|
dotColor="gray" activeDotColor="#fff" horizontal={true} loop={true} index={0} showsButtons={false}> |
|
|
|
{this.renderAdTypeSwiper()} |
|
|
|
</Swiper> |
|
|
|
|
|
|
|
<View style={styles.bottomBox}> |
|
|
|
<View style={styles.bottomLogoBackground}> |
|
|
|
<Image source={{ uri: this.state.baseInfo.imgUrlH}} resizeMode='contain' style={styles.bottomLogo} /> |
|
|
|
</View> |
|
|
|
<View style={styles.bottomQrcode1Background}> |
|
|
|
<Image source={{ uri: this.state.baseInfo.imgQrcodeWeapp}} resizeMode='center' style={styles.bottomQrcode1} /> |
|
|
|
<Text style={styles.bottomQrcode1Str}>小程序</Text> |
|
|
|
</View> |
|
|
|
<View style={styles.bottomQrcode2Background}> |
|
|
|
<Image source={{ uri: this.state.baseInfo.imgQrcodeWemp}} resizeMode='center' style={styles.bottomQrcode2} /> |
|
|
|
<Text style={styles.bottomQrcode1Str}>公众号</Text> |
|
|
|
</View> |
|
|
|
<Text style={styles.bottomPlacehold}>{this.state.versionInfo}</Text> |
|
|
|
</View> |
|
|
|
<Text style={styles.bottomPlacehold}>{this.state.versionInfo}</Text> |
|
|
|
</View> |
|
|
|
</ImageBackground> |
|
|
|
);} |
|
|
|
</ImageBackground> |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
return ( |
|
|
|
<ImageBackground style={styles.background} resizeMode='center' source={require('./image/background.png')}> |
|
|
@@ -761,11 +871,10 @@ MyPage = CodePush(codePushOptions)(MyPage); |
|
|
|
flex: 5, |
|
|
|
width:'100%', |
|
|
|
height:'100%', |
|
|
|
// borderStyle:"solid", |
|
|
|
// borderWidth:1, |
|
|
|
// borderColor:"red", |
|
|
|
borderWidth:1, |
|
|
|
borderColor:"blue", |
|
|
|
marginLeft:18/PixelRatio.get(), |
|
|
|
backgroundColor:'transparent' |
|
|
|
// backgroundColor:'transparent' |
|
|
|
}, |
|
|
|
|
|
|
|
//layer content item bottom |
|
|
@@ -894,4 +1003,64 @@ MyPage = CodePush(codePushOptions)(MyPage); |
|
|
|
textDecorationLine: 'line-through', |
|
|
|
color : 'gray' |
|
|
|
}, |
|
|
|
|
|
|
|
adTypeBg:{ |
|
|
|
flex: 1, |
|
|
|
width: '100%', |
|
|
|
height: '100%' |
|
|
|
}, |
|
|
|
|
|
|
|
adTypeSwiper02:{ |
|
|
|
position: 'absolute', |
|
|
|
left: 0, |
|
|
|
bottom: 120, |
|
|
|
width: '100%', |
|
|
|
height: 134, |
|
|
|
marginLeft: 10, |
|
|
|
borderColor: 'red', |
|
|
|
borderWidth: 10 |
|
|
|
}, |
|
|
|
|
|
|
|
adTypeItemImgWrap:{ |
|
|
|
flex: 1, |
|
|
|
width: '100%', |
|
|
|
height: 134, |
|
|
|
flexDirection: 'row', |
|
|
|
alignItems: 'center', |
|
|
|
}, |
|
|
|
|
|
|
|
adTypeItemImg:{ |
|
|
|
width: 90, |
|
|
|
height: 90, |
|
|
|
borderRadius:27/PixelRatio.get(), |
|
|
|
backgroundColor:'transparent' |
|
|
|
}, |
|
|
|
|
|
|
|
bottomBox:{ |
|
|
|
position: 'absolute', |
|
|
|
bottom: 0, |
|
|
|
left: 0, |
|
|
|
flex: 2, |
|
|
|
flexDirection: 'row', |
|
|
|
alignItems: 'center', |
|
|
|
backgroundColor:'transparent', |
|
|
|
borderColor: 'red', |
|
|
|
borderWidth: 1 |
|
|
|
}, |
|
|
|
|
|
|
|
contentItemTopForAd:{ |
|
|
|
flex: 1, |
|
|
|
width:'100%', |
|
|
|
height:'100%', |
|
|
|
paddingLeft: 30/PixelRatio.get(), |
|
|
|
paddingRight: 26/PixelRatio.get(), |
|
|
|
paddingTop: 10/PixelRatio.get(), |
|
|
|
flexDirection: 'row', |
|
|
|
alignItems: 'center', |
|
|
|
backgroundColor:'#fff', |
|
|
|
borderColor: 'red', |
|
|
|
borderWidth: 1, |
|
|
|
borderRadius: 6, |
|
|
|
}, |
|
|
|
|
|
|
|
}); |