广告屏react-native项目
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

1256 lines
36 KiB

  1. import React, { Component } from 'react';
  2. import {
  3. Platform,
  4. StyleSheet,
  5. Text,
  6. View,
  7. Image,
  8. ImageBackground,
  9. PixelRatio,
  10. NativeModules,
  11. } from 'react-native';
  12. //引用插件
  13. import Package from './package.json'
  14. import HttpUtils from './HttpUtils.js';
  15. import CodePush from "react-native-code-push";
  16. import DeviceInfo from "react-native-device-info";
  17. import * as Animatable from 'react-native-animatable';
  18. import Swiper from 'react-native-swiper';
  19. import Carousel from 'react-native-snap-carousel';
  20. import {BoxShadow} from 'react-native-shadow';
  21. var testMac = 'FF:FF:FF:FF:FF:FF'
  22. var curAdIndex = 0;
  23. var errorMsg = {
  24. ERR_MAC_GET:'设备编号获取错误',
  25. ERR_START_AD:'广告播放系统错误',
  26. ERR_DATA_GET:'广告数据获取错误',
  27. ERR_HEARTBEAT:'设备心跳数据错误',
  28. ERR_NO_DATA:'暂无优惠信息'
  29. }
  30. var animationThemes = [
  31. // 滑入
  32. {
  33. first:"slideInDown",
  34. second:"slideInLeft",
  35. third:"slideInRight"
  36. },
  37. // 放大
  38. {
  39. first:"zoomInDown",
  40. second:"zoomInLeft",
  41. third:"zoomInRight"
  42. },
  43. // 翻转
  44. {
  45. first:"flipInX",
  46. second:"flipInY",
  47. third:"flipInX"
  48. },
  49. // 弹出
  50. {
  51. first:"bounceInDown",
  52. second:"bounceInLeft",
  53. third:"bounceInRight"
  54. }
  55. ]
  56. const shadowOpt = {
  57. width: 800/PixelRatio.get(),
  58. height: 240/PixelRatio.get(),
  59. color:"#000",
  60. border:2,
  61. radius:3,
  62. opacity:0.5,
  63. x:2,
  64. y:3,
  65. style:{marginVertical:5}
  66. }
  67. var curTimer = null;
  68. var hbRequestCount
  69. var getAdDataCount
  70. var pageChangeCount
  71. var adDataList = [];
  72. var adDataBgList = [];
  73. var heartConfig = {
  74. heartbeatInterval:300,
  75. dataRefreshInterval:3600,
  76. pageChangeInterval:10,
  77. }
  78. var requestFailedCount = 0;
  79. var versionInfo = '';
  80. let codePushOptions = {
  81. //设置检查更新的频率
  82. //ON_APP_RESUME APP恢复到前台的时候
  83. //ON_APP_START APP开启的时候
  84. //MANUAL 手动检查
  85. checkFrequency : CodePush.CheckFrequency.ON_APP_START
  86. };
  87. export default class MyPage extends Component {
  88. constructor(props) {
  89. super(props);
  90. this.state = {
  91. baseInfo: null,
  92. contentItem0:null,
  93. contentItem1:null,
  94. contentItem2:null,
  95. animationTheme:animationThemes[0],
  96. contentDisplayStatus:false,
  97. syncMessage: "初始化..." ,
  98. errorMessage: '加载中...',
  99. progress: {
  100. receivedBytes:0,
  101. totalBytes:0
  102. },
  103. updating:true,
  104. macAddress: '',
  105. versionInfo:'未知',
  106. adType: 0,
  107. curAdType02Index: 0, //广告图index
  108. curCoverImgUrl: 'https://iformall-net.s3.cn-northwest-1.amazonaws.com.cn/456/37d833d7-263f-4f97-8588-e827c2f43db4.jpg',
  109. };
  110. /* this.codePushUpdate = this.codePushUpdate.bind(this);
  111. this.startAd = this.startAd.bind(this);
  112. this.showErrMsg = this.showErrMsg.bind(this); */
  113. }
  114. componentDidMount() {
  115. this.codePushUpdate();
  116. DeviceInfo.getMACAddress().then((mac)=>{
  117. if (mac=='' || mac==null ) {
  118. if (NativeModules.BuildConfig.buildType == 'debug') {
  119. this.setState({macAddress : this.testMac})
  120. this.startAd()
  121. } else {
  122. this.showErrMsg(errorMsg.ERR_MAC_GET);
  123. }
  124. } else {
  125. this.setState({macAddress : mac})
  126. this.startAd()
  127. }
  128. }).catch(e => {
  129. this.showErrMsg(errorMsg.ERR_START_AD);
  130. })
  131. }
  132. componentDidUpdate() {
  133. /* console.log(this.refs.scrollView)
  134. if (this.refs.scrollView != undefined) {
  135. var ScrollView = this.refs.scrollView;
  136. ScrollView.scrollBy(0, true);
  137. } */
  138. }
  139. //更新函数
  140. async codePushUpdate() {
  141. CodePush.allowRestart();
  142. await CodePush.getUpdateMetadata(CodePush.UpdateState.RUNNING)
  143. .then((metadata: LocalPackage) => {
  144. this.setState({ versionInfo: metadata ? 'b'+NativeModules.BuildConfig.versionCode+"-" + metadata.label : 'b'+ NativeModules.BuildConfig.versionCode});
  145. versionInfo = this.state.versionInfo;
  146. }, (error: any) => {
  147. this.setState({ versionInfo: "Unknown"});
  148. versionInfo = this.state.versionInfo;
  149. });
  150. await CodePush.sync(
  151. { mandatoryInstallMode: CodePush.InstallMode.ON_NEXT_RESTART,
  152. installMode: CodePush.InstallMode.ON_NEXT_RESTART},
  153. this.codePushStatusDidChange.bind(this),
  154. this.codePushDownloadDidProgress.bind(this)
  155. ).then((status: SyncStatus) => {
  156. }, (error: any) => {
  157. CodePush.restartApp();
  158. });
  159. }
  160. // 监听更新状态
  161. codePushStatusDidChange(syncStatus) {
  162. switch(syncStatus) {
  163. case CodePush.SyncStatus.CHECKING_FOR_UPDATE:
  164. this.setState({ syncMessage: "检查更新" });
  165. break;
  166. case CodePush.SyncStatus.DOWNLOADING_PACKAGE:
  167. this.setState({ syncMessage: "下载更新" });
  168. break;
  169. case CodePush.SyncStatus.AWAITING_USER_ACTION:
  170. this.setState({ syncMessage: "等待用户操作" });
  171. break;
  172. case CodePush.SyncStatus.INSTALLING_UPDATE:
  173. this.setState({ syncMessage: "安装更新" });
  174. break;
  175. case CodePush.SyncStatus.UP_TO_DATE:
  176. this.setState({ syncMessage: "已更新到最新程序", updating: false });
  177. break;
  178. case CodePush.SyncStatus.UPDATE_IGNORED:
  179. this.setState({ syncMessage: "更新被取消", updating: false });
  180. break;
  181. case CodePush.SyncStatus.UPDATE_INSTALLED:
  182. this.setState({ syncMessage: "更新已安装,重启应用后生效", updating: false });
  183. break;
  184. case CodePush.SyncStatus.UNKNOWN_ERROR:
  185. this.setState({ syncMessage: "未知错误", updating: false });
  186. break;
  187. }
  188. }
  189. codePushDownloadDidProgress(progress) {
  190. this.setState({ progress });
  191. }
  192. // 列表滚动
  193. updateContent() {
  194. if (adDataList.length <=0)
  195. return false;
  196. if (curAdIndex >= adDataList.length) {
  197. curAdIndex = 0;
  198. }
  199. this.setState({contentItem0:adDataList[curAdIndex]});
  200. if (curAdIndex + 1 < adDataList.length)
  201. this.setState({contentItem1:adDataList[curAdIndex+1]});
  202. else
  203. this.setState({contentItem1:null});
  204. if (curAdIndex + 2 < adDataList.length)
  205. this.setState({contentItem2:adDataList[curAdIndex+2]});
  206. else
  207. this.setState({contentItem2:null});
  208. curAdIndex+=3
  209. return true;
  210. }
  211. hbRequest() {
  212. return HttpUtils.post(NativeModules.BuildConfig.apiHost
  213. + 'api/wxDeviceScreenAd/heartbeat?deviceId='
  214. + encodeURIComponent(this.state.macAddress),
  215. {version:this.state.versionInfo})
  216. .then(result => {
  217. if (result.code == 200) {
  218. let config = JSON.parse(result.data.config);
  219. heartConfig.heartbeatInterval = config.heartbeatInterval
  220. heartConfig.dataRefreshInterval=config.dataRefreshInterval
  221. heartConfig.pageChangeInterval=config.pageChangeInterval
  222. // 动画划入
  223. if(config.animationTheme == 0){
  224. this.setState({
  225. animationTheme:animationThemes[0]
  226. })
  227. }else if(config.animationTheme == 1){
  228. // 放大
  229. this.setState({
  230. animationTheme:animationThemes[1]
  231. })
  232. }else if(config.animationTheme == 2){
  233. // 淡入
  234. this.setState({
  235. animationTheme:animationThemes[2]
  236. })
  237. }else if(config.animationTheme == 3){
  238. // 弹入
  239. this.setState({
  240. animationTheme:animationThemes[3]
  241. })
  242. }
  243. } else {
  244. //do nothing
  245. }
  246. })
  247. .catch(error => {
  248. requestFailedCount++
  249. this.setState({ versionInfo: versionInfo+`[${requestFailedCount}]`});
  250. })
  251. }
  252.  showErrMsg(errMsg) {
  253. this.setState({contentDisplayStatus: false})
  254. this.setState({errorMessage : errMsg});
  255. }
  256. //判断播放类型adType
  257. dealLoopType(dataList) {
  258. adDataList = dataList.filter((item) => {
  259. return item.type == 0;
  260. })
  261. adDataBgList = dataList.filter((item) => {
  262. return item.type == 2;
  263. })
  264. //aaa
  265. let num = 0;
  266. if (adDataList.length > 0 && adDataBgList.length > 0) {
  267. num = 2;
  268. } else if (adDataList.length > 0 && !adDataBgList.length) {
  269. num = 0;
  270. } else if (!adDataList.length && adDataBgList.length > 0) {
  271. num = 1;
  272. }
  273. this.setState({adType: num })
  274. }
  275. getAdDataList(first) {
  276. HttpUtils.get(NativeModules.BuildConfig.apiHost
  277. + 'api/wxDeviceScreenAd/list?deviceId='
  278. + encodeURIComponent(this.state.macAddress)
  279. + '&pageNum=1&pageSize=1000')
  280. .then(result => {
  281. if (result.code != 200) {
  282. this.showErrMsg(result.message+'\n'+this.state.macAddress);
  283. } else if (result.data.list) {
  284. //aaa
  285. /* result.data.list[0].type = 2;
  286. result.data.list[1].type = 2;
  287. result.data.list[2].type = 2;
  288. result.data.list[3].type = 2;
  289. result.data.list[4].type = 2;
  290. result.data.list[5].type = 2; */
  291. console.log(result.data)
  292. //type==0的是券 1是? 2是广告大图
  293. let curData = result.data.list;
  294. this.dealLoopType(curData);
  295. if (this.updateContent()) {
  296. this.setState({contentDisplayStatus: true})
  297. } else {
  298. this.showErrMsg(errorMsg.ERR_NO_DATA);
  299. }
  300. } else {
  301.  this.showErrMsg(errorMsg.ERR_DATA_GET);
  302. }
  303. })
  304. .catch(error => {
  305. if (first) {
  306. this.showErrMsg(error.message);
  307. }
  308. else {
  309. requestFailedCount++
  310. this.setState({ versionInfo: versionInfo+`[${requestFailedCount}]`});
  311. }
  312. })
  313. }
  314. getBaseInfo() {
  315. HttpUtils.get(NativeModules.BuildConfig.apiHost
  316. + 'api/wxDeviceScreenAd/info?deviceId='
  317. + encodeURIComponent(this.state.macAddress))
  318. .then(result => {
  319. if (result.code != 200) {
  320. this.showErrMsg(result.message+'\n'+this.state.macAddress);
  321. } else if (result.data) {
  322. this.setState({baseInfo:result.data});
  323. } else {
  324. this.showErrMsg(errorMsg.ERR_DATA_GET);
  325. }
  326. })
  327. .catch(error => {
  328. this.showErrMsg(error.message);
  329. })
  330. }
  331. componentWillUnmount(){
  332. if (curTimer)
  333. clearTimeout(curTimer)
  334. }
  335. async routine() {
  336. hbRequestCount -=1;
  337. getAdDataCount -=1;
  338. pageChangeCount -=1;
  339. try {
  340. if (getAdDataCount<=0) {
  341. this.getAdDataList(false)
  342. getAdDataCount = heartConfig.dataRefreshInterval
  343. } else if (hbRequestCount<=0) {
  344. this.hbRequest()
  345. hbRequestCount = heartConfig.heartbeatInterval
  346. }
  347. //如果是adType == 2时间间隔到了,要检验轮播是否走完在决定切换
  348. if (this.state.adType == 2) {
  349. if (pageChangeCount<=0) {
  350. let curNum = this.state.curAdType02Index + 1;
  351. if (curNum >= adDataBgList.length) {
  352. curNum = 0;
  353. }
  354. this.setState({
  355. curAdType02Index: curNum,
  356. curCoverImgUrl:adDataBgList[curNum].coverImg
  357. })
  358. pageChangeCount = heartConfig.pageChangeInterval
  359. }
  360. } else if (this.state.adType == 0) {
  361. if (pageChangeCount <= 0) { //页面切换间隔
  362. if (this.state.contentDisplayStatus && this.state.baseInfo) {
  363. this.setState({ contentDisplayStatus: false})
  364. if (this.updateContent()) {
  365. this.setState({ contentDisplayStatus: true})
  366. }
  367. } else {
  368. await this.getBaseInfo()
  369. await this.getAdDataList(true)
  370. getAdDataCount = heartConfig.dataRefreshInterval
  371. hbRequestCount = heartConfig.heartbeatInterval
  372. }
  373. pageChangeCount = heartConfig.pageChangeInterval
  374. }
  375. }
  376. } catch(e){
  377. this.setState({ versionInfo: versionInfo+'[E]'});
  378. }
  379. curTimer = setTimeout(()=>{
  380. this.routine();
  381. },1000);
  382. }
  383. startAd() {
  384. hbRequestCount = 0;
  385. getAdDataCount = 0;
  386. pageChangeCount = 0;
  387. this.routine();
  388. }
  389. getContentViewItemUplayer(contentItem) {
  390. if (contentItem.type == 0) {
  391. if (contentItem.subType == 2)
  392. return (<Image source={require('./image/timed.png')} resizeMode='center' style={styles.contentItemUpLayer} /> )
  393. if (contentItem.subType == 6)
  394. return (<Image source={require('./image/discount.png')} resizeMode='center' style={styles.contentItemUpLayer} /> )
  395. if (contentItem.subType == 7)
  396. return (<Image source={require('./image/groupbuy.png')} resizeMode='center' style={styles.contentItemUpLayer} /> )
  397. return null;
  398. }
  399. }
  400. getContentViewItemActionStr(contentItem) {
  401. if (contentItem.type == 0) {
  402. if (contentItem.subType == 2)
  403. return '扫码秒杀';
  404. else if (contentItem.subType == 6)
  405. return '扫码砍价';
  406. else if (contentItem.subType == 7)
  407. return '扫码拼团';
  408. else
  409. return '扫码领取';
  410. }
  411. }
  412. getContentViewItemMerchantName(contentItem) {
  413. if (contentItem.type == 0) {
  414. if (contentItem.target.merchantVoList.length > 1)
  415. return '多商户通用';
  416. else
  417. return contentItem.target.merchantVoList[0].merchantName;
  418. }
  419. }
  420. getContentViewItem(contentItem, annomation) {
  421. if (!contentItem)
  422. return (
  423. <View style={styles.contentItem}>
  424. </View>
  425. )
  426. actionText = this.getContentViewItemActionStr(contentItem);
  427. merchantName = this.getContentViewItemMerchantName(contentItem);
  428. // console.warn(annomation)
  429. return (
  430. <Animatable.View animation={annomation} style={styles.contentItem}>
  431. <ImageBackground source={require('./image/item-background.png')} resizeMode='center' style={styles.contentItemDownLayer} >
  432. {/* 列表 */}
  433. <View style={styles.contentItemTop}>
  434. <Image source={{uri: contentItem.coverImg}} resizeMode='cover' style={styles.contentItemTopCoverImg} />
  435. <View style={styles.contentItemTopDetail}>
  436. {/* 券的title */}
  437. <Text style={styles.contentItemTopDetailTitle} numberOfLines={2} ellipsizeMode="tail">{contentItem.target.title}</Text>
  438. <View style={styles.contentItemTopDetailPrice}>
  439. {/* 售价 */}
  440. <View style={styles.contentItemTopDetailCurPrice}>
  441. <Text style={styles.contentItemTopDetailCurPriceStrUnit}>¥</Text>
  442. <Text style={styles.contentItemTopDetailCurPriceStr}>{contentItem.target.salePriceStr}</Text>
  443. </View>
  444. {/* 面额 */}
  445. <View style={styles.contentItemTopDetailSalePrice}>
  446. <Text style={styles.contentItemTopDetailSalePriceStr} >¥{contentItem.target.priceStr}</Text>
  447. </View>
  448. </View>
  449. </View>
  450. {/* <Image source={{uri:'data:image/png;base64,'+contentItem.qrcode}} resizeMode='contain' style={styles.contentItemTopQrcode} /> */}
  451. <Image source={{uri:contentItem.target.qrCode}} resizeMode='contain' style={styles.contentItemTopQrcode} />
  452. </View>
  453. {/* 优惠券底部商户名称 */}
  454. <View style={styles.contentItemBottom}>
  455. <Text style={styles.contentItemBottomMerchantName}>{merchantName}</Text>
  456. <Text style={styles.contentItemBottomPlacehold}>{contentItem.target.merchantVoList[0].buildingName}{contentItem.target.merchantVoList[0].floorName}</Text>
  457. <Text style={styles.contentItemBottomAction}>{actionText}</Text>
  458. </View>
  459. </ImageBackground>
  460. {this.getContentViewItemUplayer(contentItem)}
  461. </Animatable.View>
  462. )
  463. }
  464. getContentView() {
  465. if (this.state.contentDisplayStatus) {
  466. return (<View style={styles.content}>
  467. {this.getContentViewItem(this.state.contentItem0,this.state.animationTheme.first)}
  468. {this.getContentViewItem(this.state.contentItem1,this.state.animationTheme.second)}
  469. {this.getContentViewItem(this.state.contentItem2,this.state.animationTheme.third)}
  470. </View>)
  471. }else{
  472. return (
  473. <View style={styles.content}>
  474. <Text style={styles.updatePage}>{this.state.errorMessage}</Text>
  475. </View>)
  476. }
  477. }
  478. setAdSwiperItemDom(item) {
  479. let contentItem = item.item;
  480. return (
  481. <View style={styles.onlyAdSwiperItem}>
  482. <Image source={{uri: contentItem.coverImg}} resizeMode='stretch' style={styles.onlyAdTypeItemImg} />
  483. </View>
  484. )
  485. }
  486. setSwiperItemDom(item) {
  487. let contentItem = item.item;
  488. let index = item.index;
  489. return (
  490. <View style={styles.carouselItemWrap}>
  491. <BoxShadow setting={shadowOpt}>
  492. <View style={styles.contentItemTopForAd} key={index}>
  493. {/* <ImageBackground style={styles.adTypeSwiper02} resizeMode="stretch" source={require('./image/item-background.png')}></ImageBackground> */}
  494. <Image source={{uri: contentItem.coverImg}} resizeMode='cover' style={styles.adTypeItemImg} />
  495. <View style={styles.contentItemTopDetail}>
  496. {/* 券的title */}
  497. <Text style={styles.contentItemTopDetailTitle02} numberOfLines={2} ellipsizeMode="tail">{contentItem.target.title}</Text>
  498. <View style={styles.contentItemTopDetailPrice}>
  499. {/* 售价 */}
  500. <View style={styles.contentItemTopDetailCurPrice}>
  501. <Text style={styles.contentItemTopDetailCurPriceStrUnit02}>¥</Text>
  502. <Text style={styles.contentItemTopDetailCurPriceStr02}>{contentItem.target.salePriceStr}</Text>
  503. </View>
  504. {/* 面额 */}
  505. <View style={styles.contentItemTopDetailSalePrice02}>
  506. <Text style={styles.contentItemTopDetailSalePriceStr02} >¥{contentItem.target.priceStr}</Text>
  507. </View>
  508. </View>
  509. </View>
  510. {/* <Image source={{uri:'data:image/png;base64,'+contentItem.qrcode}} resizeMode='contain' style={styles.contentItemTopQrcode} /> */}
  511. <View style={styles.contentItemTopQrcodeBox}>
  512. <Image source={{uri:contentItem.target.qrCode}} resizeMode='contain' style={styles.contentItemTopQrcode02} />
  513. </View>
  514. </View>
  515. </BoxShadow>
  516. </View>
  517. )
  518. }
  519. renderAdTypeSwiper() {
  520. if (this.state.contentDisplayStatus) {
  521. let adSwiperDomStack = [];
  522. //aaa
  523. adDataList.map((item,index) => {
  524. item.target.qrCode = 'https://iformall-net.s3.cn-northwest-1.amazonaws.com.cn/null/73ddb1e4-8f19-4d5d-8387-742d3d5d2c77.png'
  525. adSwiperDomStack.push(this.setSwiperItemDom(item, index))
  526. })
  527. return adSwiperDomStack;
  528. }else{
  529. return (
  530. <View style={styles.content}>
  531. <Text style={styles.updatePage}>{this.state.errorMessage}</Text>
  532. </View>
  533. )
  534. }
  535. }
  536. getUpdateView() {
  537. if (this.state.progress.totalBytes > 0)
  538. return (
  539. <Text style={styles.updatePage}>{this.state.syncMessage}{'\n'}
  540. {this.state.progress.receivedBytes} of {this.state.progress.totalBytes} bytes received{'\n'}
  541. </Text>
  542. );
  543. return (
  544. <Text style={styles.updatePage}>{this.state.syncMessage}
  545. </Text>
  546. );
  547. }
  548. getAdView(){
  549. if (this.state.baseInfo) {
  550. if (this.state.adType == 0) {
  551. return (
  552. <ImageBackground style={styles.background} resizeMode='center' source={require('./image/background.png')}>
  553. {/* 头部title二维码开始 */}
  554. <View style={styles.title}>
  555. <View style={styles.titleImagePlace}>
  556. <Image source={require('./image/title.png')} resizeMode='center' style={styles.titleImage} />
  557. </View>
  558. <ImageBackground source={require('./image/title-qrcode.png') } resizeMode='center' style={styles.titleQrcodeBonder} >
  559. <View style={styles.titleQrcodePlacehold}></View>
  560. <Image source={{uri: this.state.baseInfo.imgQrcodeWeapp}} resizeMode='center' style={styles.titleQrcode} />
  561. <View style={styles.titleQrcodePlacehold}></View>
  562. </ImageBackground>
  563. </View>
  564. {/* 券列表展示列表开始 */}
  565. {this.getContentView()}
  566. {/* 底部商场信息展示开始 */}
  567. <View style={styles.bottom}>
  568. <View style={styles.bottomLogoBackground}>
  569. <Image source={{ uri: this.state.baseInfo.imgUrlH}} resizeMode='contain' style={styles.bottomLogo} />
  570. </View>
  571. <View style={styles.bottomQrcode1Background}>
  572. <Image source={{ uri: this.state.baseInfo.imgQrcodeWeapp}} resizeMode='center' style={styles.bottomQrcode1} />
  573. <Text style={styles.bottomQrcode1Str}>小程序</Text>
  574. </View>
  575. <View style={styles.bottomQrcode2Background}>
  576. <Image source={{ uri: this.state.baseInfo.imgQrcodeWemp}} resizeMode='center' style={styles.bottomQrcode2} />
  577. <Text style={styles.bottomQrcode1Str}>公众号</Text>
  578. </View>
  579. <Text style={styles.bottomPlacehold}>{this.state.versionInfo}</Text>
  580. </View>
  581. </ImageBackground>
  582. );
  583. } else if (this.state.adType == 2) {
  584. let curWidthNum = 1080/(PixelRatio.get())
  585. return (
  586. // <ImageBackground style={styles.adTypeBg} source={require('./image/ad1.jpg')}>
  587. <ImageBackground style={styles.adTypeBg} resizeMode="stretch" source={{ uri: this.state.curCoverImgUrl}}>
  588. {/* adType == 2 滚动轮播 */}
  589. {/* <Swiper ref='scrollView' style={styles.adTypeSwiper02} autoplay={true} autoplayTimeout={1} showPagination={false}
  590. dotColor="transparent" activeDotColor="transparent" horizontal={true} showsButtons={false}>
  591. {this.renderAdTypeSwiper()}
  592. </Swiper> */}
  593. <View style={styles.adTypeSwiper02}>
  594. <Carousel
  595. ref={'carousel02'}
  596. data={adDataList}
  597. renderItem={this.setSwiperItemDom}
  598. sliderWidth={curWidthNum}
  599. itemWidth={curWidthNum}
  600. layout={'stack'}
  601. itemHeight={134}
  602. sliderHeight={134}
  603. activeSlideOffset={0}
  604. autoplay={true}
  605. loop={true}
  606. autoplayInterval={3000}
  607. />
  608. </View>
  609. {/* <View style={styles.bottomBox}>
  610. <View style={styles.bottomLogoBackground}>
  611. <Image source={{ uri: this.state.baseInfo.imgUrlH}} resizeMode='contain' style={styles.bottomLogo} />
  612. </View>
  613. <View style={styles.bottomQrcode1Background}>
  614. <Image source={{ uri: this.state.baseInfo.imgQrcodeWeapp}} resizeMode='center' style={styles.bottomQrcode1} />
  615. <Text style={styles.bottomQrcode1Str}>小程序</Text>
  616. </View>
  617. <View style={styles.bottomQrcode2Background}>
  618. <Image source={{ uri: this.state.baseInfo.imgQrcodeWemp}} resizeMode='center' style={styles.bottomQrcode2} />
  619. <Text style={styles.bottomQrcode1Str}>公众号</Text>
  620. </View>
  621. <Text style={styles.bottomPlacehold}>{this.state.versionInfo}</Text>
  622. </View> */}
  623. </ImageBackground>
  624. );
  625. } else if (this.state.adType == 1) {
  626. return(
  627. <Carousel
  628. ref={'carousel01'}
  629. data={adDataBgList}
  630. renderItem={this.setAdSwiperItemDom}
  631. sliderWidth={1080}
  632. itemWidth={1080}
  633. itemHeight={1920}
  634. sliderHeight={1920}
  635. activeSlideOffset={0}
  636. autoplay={true}
  637. loop={true}
  638. autoplayInterval={3000}
  639. />
  640. )
  641. }
  642. }
  643. else {
  644. return (
  645. <ImageBackground style={styles.background} resizeMode='center' source={require('./image/background.png')}>
  646. {/* 头部title二维码开始 */}
  647. <View style={styles.title}>
  648. </View>
  649. {/* 券列表展示列表开始 */}
  650. {this.getContentView()}
  651. {/* 底部商场信息展示开始 */}
  652. <View style={styles.bottom}>
  653. <View style={styles.bottomLogoBackground}>
  654. </View>
  655. <View style={styles.bottomQrcode1Background}>
  656. </View>
  657. <View style={styles.bottomQrcode2Background}>
  658. </View>
  659. <Text style={styles.bottomPlacehold}>{this.state.versionInfo}</Text>
  660. </View>
  661. </ImageBackground>
  662. );
  663. }
  664. }
  665. render() {
  666. if (this.state.updating) {
  667. return this.getUpdateView();
  668. }
  669. return this.getAdView();
  670. }
  671. }
  672. MyPage = CodePush(codePushOptions)(MyPage);
  673. const styles = StyleSheet.create({
  674. updatePage:{
  675. flex: 2,
  676. width:'100%',
  677. height:'100%',
  678. backgroundColor:'transparent',
  679. textAlign :'center',
  680. textAlignVertical:'center',
  681. fontSize: 63/PixelRatio.get(),
  682. color: 'darkblue'
  683. },
  684. //layer background
  685. background:{
  686. flex: 1,
  687. width:'100%',
  688. height:'100%'
  689. },
  690. //layer top
  691. title:{
  692. flex: 6,
  693. flexDirection: 'row',
  694. alignItems: 'center',
  695. paddingLeft:42/PixelRatio.get(),
  696. paddingRight:42/PixelRatio.get(),
  697. backgroundColor:'transparent'
  698. },
  699. content:{
  700. flex: 18,
  701. flexDirection: 'column',
  702. alignItems: 'center',
  703. backgroundColor:'transparent'
  704. },
  705. bottom:{
  706. flex: 2,
  707. flexDirection: 'row',
  708. alignItems: 'center',
  709. paddingLeft:42/PixelRatio.get(),
  710. paddingRight:42/PixelRatio.get(),
  711. backgroundColor:'transparent'
  712. },
  713. //layer title
  714. titleImagePlace: {
  715. flex: 2,
  716. paddingTop: '20%',
  717. paddingLeft: '15%',
  718. alignItems: 'center',
  719. backgroundColor:'transparent'
  720. },
  721. titleImage: {
  722. width:'100%',
  723. height:'100%',
  724. flex: 1,
  725. backgroundColor:'transparent'
  726. },
  727. titleQrcodeBonder: {
  728. width:'100%',
  729. height:'100%',
  730. alignItems: 'center',
  731. flexDirection: 'column',
  732. flex: 1,
  733. backgroundColor:'transparent'
  734. },
  735. titleQrcodePlacehold: {
  736. flex: 5,
  737. backgroundColor:'transparent'
  738. },
  739. titleQrcode: {
  740. flex: 6,
  741. width:'100%',
  742. height:'100%',
  743. backgroundColor:'transparent'
  744. },
  745. //layer bottom
  746. bottomLogoBackground: {
  747. flex: 3,
  748. borderRadius:16/PixelRatio.get(),
  749. marginTop: 26/PixelRatio.get(),
  750. marginBottom: 26/PixelRatio.get(),
  751. backgroundColor:'transparent',//'rgba(255,255,255,0.5)',
  752. },
  753. bottomLogo: {
  754. width:'100%',
  755. height:'100%',
  756. backgroundColor:'transparent'
  757. },
  758. bottomQrcode1Background : {
  759. flex: 1,
  760. width:'100%',
  761. height:'100%',
  762. marginLeft: 21/PixelRatio.get(),
  763. paddingTop: 27/PixelRatio.get(),
  764. paddingBottom: 11/PixelRatio.get(),
  765. flexDirection: 'column',
  766. backgroundColor:'transparent'
  767. },
  768. bottomQrcode2Background : {
  769. flex: 1,
  770. width:'100%',
  771. height:'100%',
  772. marginLeft: 21/PixelRatio.get(),
  773. paddingTop: 26/PixelRatio.get(),
  774. paddingBottom: 11/PixelRatio.get(),
  775. flexDirection: 'column',
  776. backgroundColor:'transparent'
  777. },
  778. bottomQrcode1: {
  779. flex: 2,
  780. width:'100%',
  781. height:'100%',
  782. backgroundColor:'transparent'
  783. },
  784. bottomQrcode2: {
  785. flex: 2,
  786. width:'100%',
  787. height:'100%',
  788. backgroundColor:'transparent'
  789. },
  790. bottomQrcode1Str: {
  791. flex: 1,
  792. textAlign :'center',
  793. textAlignVertical:'center',
  794. fontSize: 16/PixelRatio.get(),
  795. color : 'white',
  796. backgroundColor:'transparent'
  797. },
  798. bottomQrcode2Str: {
  799. flex: 1,
  800. textAlign :'center',
  801. textAlignVertical:'center',
  802. fontSize: 16/PixelRatio.get(),
  803. color : 'white',
  804. backgroundColor:'transparent'
  805. },
  806. bottomPlacehold: {
  807. flex: 8,
  808. width:'100%',
  809. height:'100%',
  810. backgroundColor:'transparent',
  811. textAlign :'right',
  812. textAlignVertical:'bottom',
  813. fontSize: 27/PixelRatio.get(),
  814. color : 'gray'
  815. },
  816. //layer content item
  817. contentItem:{
  818. flex: 1,
  819. width:'100%',
  820. height:'100%',
  821. flexDirection: 'column',
  822. backgroundColor:'transparent'
  823. },
  824. contentItemDownLayer:{
  825. position:'absolute',
  826. width:'100%',
  827. height:'100%',
  828. flexDirection: 'column',
  829. alignItems: 'center',
  830. backgroundColor:'transparent'
  831. },
  832. contentItemUpLayer:{
  833. width:210/PixelRatio.get(),
  834. height:153/PixelRatio.get(),
  835. position:'absolute',
  836. backgroundColor:'transparent'
  837. },
  838. contentItemTop:{
  839. flex: 3,
  840. width:'100%',
  841. height:'100%',
  842. paddingLeft: 66/PixelRatio.get(),
  843. paddingRight: 53/PixelRatio.get(),
  844. paddingTop: 40/PixelRatio.get(),
  845. flexDirection: 'row',
  846. alignItems: 'center',
  847. backgroundColor:'transparent'
  848. },
  849. contentItemBottom:{
  850. flex: 1,
  851. width:'100%',
  852. height:'100%',
  853. paddingLeft: 66/PixelRatio.get(),
  854. paddingRight: 53/PixelRatio.get(),
  855. paddingBottom: 40/PixelRatio.get(),
  856. flexDirection: 'row',
  857. alignItems: 'center',
  858. backgroundColor:'transparent'
  859. },
  860. //layer content item top
  861. contentItemTopCoverImg:{
  862. flex: 5,
  863. width:'100%',
  864. height:'100%',
  865. borderRadius:27/PixelRatio.get(),
  866. backgroundColor:'transparent'
  867. },
  868. contentItemTopDetail:{
  869. flex: 6,
  870. width:'100%',
  871. height:'100%',
  872. paddingLeft: 20/PixelRatio.get(),
  873. paddingRight: 20/PixelRatio.get(),
  874. alignItems: 'center',
  875. backgroundColor:'transparent'
  876. },
  877. contentItemTopQrcode:{
  878. flex: 5,
  879. width:'100%',
  880. height:'100%',
  881. marginLeft:18/PixelRatio.get(),
  882. // backgroundColor:'transparent'
  883. },
  884. contentItemTopQrcodeBox:{
  885. flex: 5,
  886. width:'100%',
  887. height:'100%',
  888. flexDirection: 'column',
  889. alignItems: 'center',
  890. justifyContent: 'center',
  891. marginLeft: -28/PixelRatio.get(),
  892. // backgroundColor:'transparent'
  893. },
  894. contentItemTopQrcode02:{
  895. width:'90%',
  896. height:'90%',
  897. },
  898. //layer content item bottom
  899. contentItemBottomMerchantName:{
  900. flex: 5,
  901. width:'100%',
  902. height:'100%',
  903. alignItems: 'center',
  904. color:"black",
  905. backgroundColor:'transparent',
  906. textAlign :'center',
  907. textAlignVertical:'center',
  908. fontSize: 27/PixelRatio.get(),
  909. fontWeight : 'bold',
  910. },
  911. contentItemBottomPlacehold:{
  912. flex: 6,
  913. fontSize: 27/PixelRatio.get(),
  914. paddingLeft: 27/PixelRatio.get(),
  915. paddingRight: 79/PixelRatio.get(),
  916. width:'100%',
  917. height:'100%',
  918. color:"black",
  919. textAlignVertical:'center',
  920. backgroundColor:'transparent',
  921. },
  922. contentItemBottomAction:{
  923. flex: 5,
  924. width:'100%',
  925. height:'100%',
  926. backgroundColor:'transparent',
  927. textAlign :'center',
  928. textAlignVertical:'center',
  929. fontSize: 36/PixelRatio.get(),
  930. color: 'black',
  931. },
  932. contentItemBottomAction02:{
  933. width:'100%',
  934. height: 60/PixelRatio.get(),
  935. backgroundColor:'transparent',
  936. textAlign :'center',
  937. textAlignVertical:'center',
  938. fontSize: 36/PixelRatio.get(),
  939. color: 'black',
  940. },
  941. // 券的title
  942. contentItemTopDetailTitle:{
  943. flex: 2,
  944. // height:'100%',
  945. width:'100%',
  946. marginTop:"2%",
  947. backgroundColor:'transparent',
  948. textAlign :'left',
  949. color:"black",
  950. textAlignVertical:'center',
  951. fontSize: 53/PixelRatio.get(),
  952. },
  953. // 券的title
  954. contentItemTopDetailTitle02:{
  955. flex: 2,
  956. // height:'100%',
  957. width:'100%',
  958. marginTop:"2%",
  959. paddingRight: 14/PixelRatio.get(),
  960. backgroundColor:'transparent',
  961. textAlign :'left',
  962. color:"black",
  963. textAlignVertical:'center',
  964. fontSize: 42/PixelRatio.get(),
  965. },
  966. /*
  967. contentItemTopDetailRemark:{
  968. flex: 1,
  969. width:'100%',
  970. height:'100%',
  971. backgroundColor:'transparent',
  972. textAlign :'left',
  973. textAlignVertical:'center',
  974. fontSize: 27/PixelRatio.get(),
  975. color : 'gray'
  976. },
  977. */
  978. contentItemTopDetailPrice:{
  979. flex: 2,
  980. width:'100%',
  981. height:'100%',
  982. backgroundColor:'transparent',
  983. flexDirection: 'row',
  984. },
  985. // 售价的样式
  986. contentItemTopDetailCurPrice:{
  987. position:"absolute",
  988. bottom:10,
  989. left:0,
  990. width:'100%',
  991. height:'100%',
  992. flexDirection: 'row',
  993. backgroundColor:'transparent',
  994. },
  995. contentItemTopDetailCurPriceStr:{
  996. backgroundColor:'transparent',
  997. fontSize:96/PixelRatio.get(),
  998. fontFamily:"PingFangSC-Bold",
  999. fontWeight: "bold",
  1000. textAlign :'left',
  1001. textAlignVertical:'bottom',
  1002. color : 'red'
  1003. },
  1004. contentItemTopDetailCurPriceStr02:{
  1005. backgroundColor:'transparent',
  1006. fontSize:72/PixelRatio.get(),
  1007. fontFamily:"PingFangSC-Bold",
  1008. fontWeight: "bold",
  1009. textAlign :'left',
  1010. color : 'red'
  1011. },
  1012. contentItemTopDetailCurPriceStrUnit:{
  1013. backgroundColor:'transparent',
  1014. textAlign :'left',
  1015. textAlignVertical:'bottom',
  1016. paddingBottom: 16/PixelRatio.get(),
  1017. fontSize: 48/PixelRatio.get(),
  1018. color : 'red'
  1019. },
  1020. contentItemTopDetailCurPriceStrUnit02:{
  1021. backgroundColor:'transparent',
  1022. textAlign :'left',
  1023. textAlignVertical:'center',
  1024. paddingBottom: 16/PixelRatio.get(),
  1025. fontSize: 48/PixelRatio.get(),
  1026. color : 'red'
  1027. },
  1028. // 面额的样式
  1029. contentItemTopDetailSalePrice:{
  1030. position:"absolute",
  1031. bottom:2,
  1032. left:0,
  1033. // flex: 1,
  1034. paddingTop:138/PixelRatio.get(),
  1035. width:'100%',
  1036. // height:'100%',
  1037. backgroundColor:'transparent',
  1038. },
  1039. contentItemTopDetailSalePrice02:{
  1040. position:"absolute",
  1041. bottom:14/PixelRatio.get(),
  1042. left:0,
  1043. // flex: 1,
  1044. paddingTop:138/PixelRatio.get(),
  1045. width:'100%',
  1046. // height:'100%',
  1047. backgroundColor:'transparent',
  1048. },
  1049. contentItemTopDetailSalePriceStr:{
  1050. width:'100%',
  1051. height:'100%',
  1052. backgroundColor:'transparent',
  1053. textAlign :'left',
  1054. textAlignVertical:'bottom',
  1055. fontSize: 27/PixelRatio.get(),
  1056. textDecorationLine: 'line-through',
  1057. color : 'gray'
  1058. },
  1059. contentItemTopDetailSalePriceStr02:{
  1060. width:'100%',
  1061. height:'100%',
  1062. backgroundColor:'transparent',
  1063. textAlignVertical:'center',
  1064. textAlign :'left',
  1065. fontSize: 27/PixelRatio.get(),
  1066. textDecorationLine: 'line-through',
  1067. color : 'gray'
  1068. },
  1069. adTypeBg:{
  1070. flex: 1,
  1071. width: '100%',
  1072. height: '100%',
  1073. },
  1074. adTypeSwiper02:{
  1075. flex: 1,
  1076. alignItems: 'center',
  1077. position: 'absolute',
  1078. left: 0,
  1079. bottom: 60/PixelRatio.get(),
  1080. width: '100%',
  1081. height: 270/PixelRatio.get(),
  1082. },
  1083. adTypeItemImgWrap:{
  1084. flex: 1,
  1085. width: '100%',
  1086. height: 369/PixelRatio.get(),
  1087. flexDirection: 'row',
  1088. alignItems: 'center',
  1089. },
  1090. adTypeItemImg:{
  1091. width: 200/PixelRatio.get(),
  1092. height: 200/PixelRatio.get(),
  1093. marginLeft: 8/PixelRatio.get(),
  1094. marginTop: 20/PixelRatio.get(),
  1095. borderRadius:27/PixelRatio.get(),
  1096. backgroundColor:'transparent'
  1097. },
  1098. bottomBox:{
  1099. position: 'absolute',
  1100. bottom: 20/PixelRatio.get(),
  1101. left: 0,
  1102. width: '100%',
  1103. height: 130/PixelRatio.get(),
  1104. flexDirection: 'row',
  1105. alignItems: 'center',
  1106. backgroundColor:'transparent',
  1107. },
  1108. contentItemTopForAd:{
  1109. flex: 1,
  1110. width: 800/PixelRatio.get(),
  1111. // width: '100%',
  1112. height:'100%',
  1113. paddingLeft: 12/PixelRatio.get(),
  1114. paddingRight: 26/PixelRatio.get(),
  1115. flexDirection: 'row',
  1116. alignItems: 'flex-start',
  1117. borderRadius: 6,
  1118. backgroundColor:'rgba(255,255,255,.8)',
  1119. },
  1120. onlyAdSwiperItem:{
  1121. width: '100%',
  1122. height: '100%',
  1123. },
  1124. onlyAdTypeItemImg:{
  1125. width: '100%',
  1126. height: '100%',
  1127. },
  1128. carouselItemWrap: {
  1129. flex: 1,
  1130. width: '100%',
  1131. backgroundColor: 'transparent',
  1132. alignItems: 'center',
  1133. }
  1134. });