ShopBox.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. /**
  2. * @param:
  3. * data: 商品列表
  4. * discount: 优惠信息
  5. */
  6. import React, { Component } from "react";
  7. import {
  8. StyleSheet,
  9. Text,
  10. View,
  11. Image,
  12. TouchableOpacity,
  13. ImageBackground,
  14. } from "react-native";
  15. import Dimensions from '../utils/dimensions'
  16. const styles = StyleSheet.create({
  17. bigWrapper: {
  18. flexDirection: 'column',
  19. },
  20. wrapper: {
  21. // width: Dimensions.width,
  22. // height: 45,
  23. justifyContent: "center",
  24. flexDirection: 'row',
  25. justifyContent: 'space-around',
  26. paddingHorizontal: 7
  27. },
  28. item: {
  29. width: Dimensions.width * 168 / 375,
  30. height: Dimensions.width * 168 / 375 * 120 / 168,
  31. paddingLeft: 10
  32. },
  33. title: {
  34. fontSize: 20,
  35. color: '#fff',
  36. marginTop: 15,
  37. },
  38. line2: {
  39. flexDirection: 'row',
  40. alignItems: 'center',
  41. // marginTop: 3
  42. },
  43. price: {
  44. fontSize: 24,
  45. color: '#fff',
  46. fontWeight: 'bold',
  47. marginRight: 5
  48. },
  49. originPrice: {
  50. fontSize: 11,
  51. color: '#fff',
  52. textDecorationLine: 'line-through'
  53. },
  54. line3: {
  55. alignItems: 'center',
  56. flexDirection: 'row',
  57. marginTop: 8
  58. },
  59. buy: {
  60. fontSize: 18,
  61. color: '#fff'
  62. },
  63. discount: {
  64. width: Dimensions.width,
  65. alignItems: 'center',
  66. justifyContent: 'center',
  67. height: 100
  68. },
  69. discountIcon: {
  70. width: Dimensions.width * 343 / 375,
  71. height: Dimensions.width * 343 / 375 * 80 / 343
  72. }
  73. })
  74. export default class ShopBox extends Component {
  75. renderGoods = (item, index) => {
  76. return (
  77. <ImageBackground
  78. source={item.background}
  79. style={styles.item}
  80. key={index}
  81. >
  82. <Text
  83. style={styles.title}
  84. >{item.title}</Text>
  85. <View
  86. style={styles.line2}
  87. >
  88. <Text style={styles.price}>¥{item.price}</Text>
  89. <Text style={styles.originPrice}>原价: {item.originPrice}</Text>
  90. </View>
  91. <View
  92. style={styles.line3}
  93. >
  94. <Text style={styles.buy}>立即购买</Text>
  95. <Image
  96. source={require('../images/shopBox/arrow.png')}
  97. style={styles.arrow}
  98. />
  99. </View>
  100. </ImageBackground>
  101. )
  102. }
  103. render() {
  104. return (
  105. <View style={styles.bigWrapper}>
  106. <View style={styles.wrapper}>
  107. {this.props.data.map((item, index) => this.renderGoods(item, index))}
  108. </View>
  109. <View style={styles.discount}>
  110. <Image
  111. source={this.props.discount.icon}
  112. stytle={styles.discountIcon}
  113. />
  114. </View>
  115. </View>
  116. );
  117. }
  118. }