ShareDetail.js
4.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
import React, { Component, PureComponent } from 'react';
import { Dimensions, ScrollView, StyleSheet, Text, TouchableOpacity, View } from 'react-native';
const { width } = Dimensions.get('window');
export default class ShareDetail extends Component {
state = { opacity: 0 }
render() {
return (
<View style={styles.container}>
<View style={{backgroundColor: 'black', height: 42, width, opacity: this.state.opacity, position: 'absolute', top: 0, zIndex: 10}}>
</View>
<View style={{backgroundColor: 'black', height: 24, width: 24, opacity: 0.5 - this.state.opacity, borderWidth: 1, borderColor: 'transparent', borderRadius: 12, position: 'absolute', top: 9, left: 20}} />
<ScrollView
style={styles.container}
contentContainerStyle={styles.contentContainerStyle}
showsVerticalScrollIndicator={false}
onScroll={(e) => this.changeOpacity(e)}>
<View style={[styles.imgContainer]}>
</View>
<View style={styles.nameContainer}>
<Text style={styles.name}>HUMAN MADE 字母印花圆领T恤</Text>
</View>
<View style={[styles.priceContainer, styles.border]}>
<Text style={styles.price}>¥ 99.9</Text>
<Text style={styles.origPrice}>¥ 239</Text>
</View>
<View style={[styles.promContainer, styles.border]}>
<Text style={styles.proDesc}>新客订单返现10%,老客订单返现3%(预计最高返现¥9.9)</Text>
</View>
<View style={[styles.recommendContainer, styles.border]}>
<TouchableOpacity onPress={() => null}>
<Text style={styles.recommendText}>查看其它推荐商品</Text>
</TouchableOpacity>
</View>
</ScrollView>
<View style={[styles.bottomBar, styles.border]}>
<View style={[styles.favContainer, styles.center]}>
<TouchableOpacity onPress={() => null} style={styles.favorite} />
</View>
<View style={styles.buttonContainer}>
<TouchableOpacity onPress={() => null}>
<View style={[styles.button, styles.center]}>
<Text style={styles.btnText}>查看商品详情</Text>
</View>
</TouchableOpacity>
<TouchableOpacity onPress={() => null}>
<View style={[styles.button, styles.center, styles.red]}>
<Text style={styles.btnText}>分享可赚¥9.9</Text>
</View>
</TouchableOpacity>
</View>
</View>
</View>
);
}
changeOpacity(e) {
let opacity = 1 - (600 - e.nativeEvent.contentOffset.y) / 600;
this.setState({opacity: opacity < 0.5 ? opacity : 0.5});
console.log(e.nativeEvent.contentOffset.y);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
},
contentContainerStyle: {
height: 1000,
},
center: {
justifyContent: 'center',
alignItems: 'center',
},
imgContainer: {
flex: 1,
},
nameContainer: {
height: 46,
paddingLeft: 20,
backgroundColor: '#393939',
justifyContent: 'center',
},
name: {
color: '#fff',
},
border: {
borderTopWidth: 1,
borderColor: '#5d5d5d'
},
priceContainer: {
height: 46,
paddingLeft: 20,
flexDirection: 'row',
alignItems: 'center',
},
price: {
fontSize: 16,
fontWeight: '500',
color: '#D0021B'
},
origPrice: {
color: '#909090',
marginLeft: 12
},
promContainer: {
height: 46,
paddingLeft: 20,
flexDirection: 'row',
alignItems: 'center',
},
proDesc: {
color: '#909090',
fontSize: 10,
},
recommendContainer: {
height: 80,
justifyContent: 'center',
alignItems: 'center',
},
recommendText: {
fontWeight: '500',
fontSize: 12,
},
bottomBar: {
flexDirection: 'row',
height: 64,
alignItems: 'center',
},
favContainer: {
width: width / 5,
},
favorite: {
height: 24,
width: 24,
borderWidth: 1,
borderRadius: 12,
marginHorizontal: 25
},
buttonContainer: {
flex: 1,
marginRight: 20,
flexDirection: 'row',
justifyContent: 'space-between',
},
button: {
backgroundColor: 'black',
borderRadius: 3,
height: 50,
width: width / 3,
},
red: {
backgroundColor: '#D0021B'
},
btnText: {
color: '#fff',
fontSize: 13,
}
})