buy.js 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. /*
  2. *
  3. */
  4. import React, { Component } from "react";
  5. import {
  6. Platform,
  7. StyleSheet,
  8. Text,
  9. View,
  10. Image,
  11. TouchableOpacity,
  12. FlatList,
  13. TouchableHighlight,
  14. DeviceEventEmitter,
  15. ScrollView
  16. } from "react-native";
  17. import BasePage from "../BasePage";
  18. import Dimensions from '../utils/dimensions';
  19. import TopicTitle from '../components/TopicTitle';
  20. export default class Buy extends BasePage {
  21. state = {
  22. shopData: [
  23. { title: '1个月', originPrice: '199', price: '49', },
  24. { title: '12个月', originPrice: '499', price: '199' }
  25. ],
  26. currentTapindex: 0
  27. };
  28. itemTap = (index) => {
  29. this.setState({
  30. currentTapindex: index
  31. })
  32. }
  33. renderItem = (item, index) => {
  34. return (
  35. <TouchableOpacity style={this.state.currentTapindex === index ? styles.itemWrapperTap : styles.itemWrapperNormal} onPress={() => { this.itemTap(index) }} key={index}>
  36. <Text style={this.state.currentTapindex === index ? styles.timeLengthTap : styles.timeLength}>{item.title}</Text>
  37. <Text style={this.state.currentTapindex === index ? styles.priceTap : styles.price}>¥{item.price}元</Text>
  38. <Text style={this.state.currentTapindex === index ? styles.originPriceTap : styles.originPrice}>原价:¥{item.originPrice}</Text>
  39. </TouchableOpacity>
  40. )
  41. }
  42. render() {
  43. return (
  44. <View style={{ flex: 1 }}>
  45. <View style={styles.top}>
  46. <Text style={styles.title}>套餐选择</Text>
  47. <View>
  48. {this.state.shopData.map((item, index) => this.renderItem(item, index))}
  49. </View>
  50. </View>
  51. <TouchableOpacity style={styles.payment} onPress={() => alert(123)}>
  52. <Text style={styles.left}>支付方式</Text>
  53. <View style={styles.right}>
  54. <Text style={styles.method}>微信支付</Text>
  55. <Image source={require('../images/common/arrowRight.png')} />
  56. </View>
  57. </TouchableOpacity>
  58. <View style={styles.bottom}>
  59. <Text style={styles.bottomLeft}>¥{this.state.shopData[this.state.currentTapindex].price}元</Text>
  60. <TouchableOpacity style={styles.bottomRight}>
  61. <Text style={styles.bottomRightText}>支付</Text>
  62. </TouchableOpacity>
  63. </View>
  64. </View>
  65. )
  66. }
  67. }
  68. const styles = StyleSheet.create({
  69. top: {
  70. width: Dimensions.width,
  71. flexDirection: 'column',
  72. alignItems: 'center',
  73. paddingBottom: 20
  74. },
  75. title: {
  76. fontSize: 20,
  77. color: '#a8674d',
  78. marginTop: 22,
  79. },
  80. itemWrapperNormal: {
  81. borderWidth: 1,
  82. borderColor: '#a8674d',
  83. borderRadius: 27,
  84. backgroundColor: '#fff',
  85. flexDirection: 'row',
  86. alignItems: 'center',
  87. justifyContent: 'space-around',
  88. width: '86%',
  89. height: Dimensions.getHeight(53),
  90. marginTop: 20,
  91. },
  92. itemWrapperTap: {
  93. // borderWidth: 1,
  94. // borderColor: '#a8674d',
  95. borderRadius: 27,
  96. backgroundColor: '#ff7525',
  97. flexDirection: 'row',
  98. alignItems: 'center',
  99. justifyContent: 'space-around',
  100. width: '86%',
  101. height: Dimensions.getHeight(53),
  102. marginTop: 20,
  103. },
  104. originPriceTap: {
  105. fontSize: 14,
  106. color: '#fff',
  107. textDecorationLine: 'line-through'
  108. },
  109. originPrice: {
  110. fontSize: 14,
  111. color: '#a8674d',
  112. textDecorationLine: 'line-through'
  113. },
  114. priceTap: {
  115. fontSize: 20,
  116. color: '#fff',
  117. },
  118. price: {
  119. fontSize: 20,
  120. color: '#a8674d',
  121. },
  122. timeLengthTap: {
  123. fontSize: 18,
  124. color: '#fff',
  125. },
  126. timeLength: {
  127. fontSize: 18,
  128. color: '#a8674d',
  129. },
  130. payment: {
  131. flexDirection: 'row',
  132. alignItems: 'center',
  133. width: Dimensions.width,
  134. height: 60,
  135. justifyContent: 'space-between',
  136. alignItems: 'center',
  137. borderColor: '#f3f2f7',
  138. borderTopWidth: 6,
  139. borderBottomWidth: 6,
  140. paddingHorizontal: 33
  141. },
  142. left: {
  143. fontSize: 16
  144. },
  145. right: {
  146. flexDirection: 'row',
  147. alignItems: 'center'
  148. },
  149. method: {
  150. color: '#a8674d',
  151. fontSize: 16,
  152. marginRight: 7
  153. },
  154. bottom: {
  155. width: Dimensions.width,
  156. height: 60,
  157. flexDirection: 'row',
  158. position: 'absolute',
  159. bottom: 0,
  160. },
  161. bottomLeft: {
  162. width: '58%',
  163. textAlign: 'center',
  164. lineHeight: 60,
  165. color: '#a8674d',
  166. fontSize: 20
  167. },
  168. bottomRight: {
  169. width: '42%',
  170. fontSize: 16,
  171. color: '#fff',
  172. backgroundColor: '#f5880d',
  173. alignItems: 'center'
  174. },
  175. bottomRightText: {
  176. fontSize: 20,
  177. color: '#fff',
  178. textAlign: 'center',
  179. lineHeight: 60,
  180. }
  181. })