|
@@ -14,7 +14,7 @@ import {
|
|
|
DeviceEventEmitter,
|
|
|
ScrollView,
|
|
|
Modal,
|
|
|
- Animated
|
|
|
+ Animated,
|
|
|
} from "react-native";
|
|
|
import BasePage from "../BasePage";
|
|
|
import Dimensions from '../utils/dimensions';
|
|
@@ -29,7 +29,8 @@ export default class Buy extends BasePage {
|
|
|
],
|
|
|
currentTapindex: 0,
|
|
|
slideAnim: new Animated.Value(-150),
|
|
|
- ifDialogShow: false
|
|
|
+ ifDialogShow: false,
|
|
|
+ payType: 1
|
|
|
};
|
|
|
itemTap = (index) => {
|
|
|
this.setState({
|
|
@@ -45,17 +46,43 @@ export default class Buy extends BasePage {
|
|
|
</TouchableOpacity>
|
|
|
)
|
|
|
}
|
|
|
- changeMethod = () => {
|
|
|
- this.setState({
|
|
|
- ifDialogShow: !this.state.ifDialogShow
|
|
|
- }, () => {
|
|
|
+ dialogComeout = (index) => {
|
|
|
+ if (index) {
|
|
|
+ this.setState({
|
|
|
+ ifDialogShow: true
|
|
|
+ }, () => {
|
|
|
+ Animated.timing(
|
|
|
+ this.state.slideAnim,
|
|
|
+ {
|
|
|
+ toValue: 0,
|
|
|
+ duration: 300,
|
|
|
+ }
|
|
|
+ ).start();
|
|
|
+ })
|
|
|
+ } else {
|
|
|
Animated.timing(
|
|
|
this.state.slideAnim,
|
|
|
{
|
|
|
- toValue: 0,
|
|
|
- duration: 300,
|
|
|
+ toValue: -150,
|
|
|
+ duration: 200,
|
|
|
}
|
|
|
).start();
|
|
|
+ setTimeout(() => {
|
|
|
+ this.setState({
|
|
|
+ ifDialogShow: false
|
|
|
+ })
|
|
|
+ }, 210)
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ setPayMethod = (type) => {
|
|
|
+ this.setState({
|
|
|
+ payType: type
|
|
|
+ },()=>{
|
|
|
+ setTimeout(() => {
|
|
|
+ this.dialogComeout(false)
|
|
|
+ }, 100)
|
|
|
+
|
|
|
})
|
|
|
}
|
|
|
render() {
|
|
@@ -82,7 +109,7 @@ export default class Buy extends BasePage {
|
|
|
{this.state.shopData.map((item, index) => this.renderItem(item, index))}
|
|
|
</View>
|
|
|
</View>
|
|
|
- <TouchableOpacity style={styles.payment} onPress={() => this.changeMethod()}>
|
|
|
+ <TouchableOpacity style={styles.payment} onPress={() => this.dialogComeout(true)}>
|
|
|
<Text style={styles.left}>支付方式</Text>
|
|
|
<View style={styles.right}>
|
|
|
<Text style={styles.method}>微信支付</Text>
|
|
@@ -98,14 +125,45 @@ export default class Buy extends BasePage {
|
|
|
{
|
|
|
this.state.ifDialogShow
|
|
|
?
|
|
|
- <View style={{ ...styles.dialog }}>
|
|
|
- <Animated.View style={{ ...styles.payMethod, bottom: this.state.slideAnim }}>
|
|
|
- <Text>选择支付方式</Text>
|
|
|
- {/* <View> */}
|
|
|
+ <TouchableHighlight
|
|
|
+ onPress={() => { this.dialogComeout(false) }}
|
|
|
+ style={{ ...styles.dialog }}
|
|
|
+ underlayColor={0.1}
|
|
|
+ >
|
|
|
+ <Animated.View
|
|
|
+ style={{ ...styles.payMethod, bottom: this.state.slideAnim }}
|
|
|
+ onPress={() => { alert(12311) }}
|
|
|
+ >
|
|
|
+ <Text style={styles.payText}>选择支付方式</Text>
|
|
|
+ <TouchableOpacity activeOpacity={0.9} style={styles.payDialog} onPress={() => this.setPayMethod(1)}>
|
|
|
+ <View style={styles.dialogRow}>
|
|
|
+ <Image style={styles.payIcon} source={require('../images/common/wxPay.png')} />
|
|
|
+ <Text>微信支付</Text>
|
|
|
+ </View>
|
|
|
+ {
|
|
|
+ this.state.payType === 1
|
|
|
+ ?
|
|
|
+ <Image source={require('../images/common/check.png')} />
|
|
|
+ :
|
|
|
+ null
|
|
|
+ }
|
|
|
|
|
|
- {/* </View> */}
|
|
|
+ </TouchableOpacity>
|
|
|
+ <TouchableOpacity activeOpacity={0.9} style={styles.payDialog} onPress={() => this.setPayMethod(2)}>
|
|
|
+ <View style={styles.dialogRow}>
|
|
|
+ <Image style={styles.payIcon} source={require('../images/common/aliPay.png')} />
|
|
|
+ <Text>支付宝支付</Text>
|
|
|
+ </View>
|
|
|
+ {
|
|
|
+ this.state.payType === 2
|
|
|
+ ?
|
|
|
+ <Image source={require('../images/common/check.png')} />
|
|
|
+ :
|
|
|
+ null
|
|
|
+ }
|
|
|
+ </TouchableOpacity>
|
|
|
</Animated.View>
|
|
|
- </View>
|
|
|
+ </TouchableHighlight>
|
|
|
:
|
|
|
null
|
|
|
}
|
|
@@ -242,8 +300,7 @@ const styles = StyleSheet.create({
|
|
|
width: Dimensions.width,
|
|
|
height: Dimensions.height,
|
|
|
position: 'absolute',
|
|
|
- backgroundColor: '#000',
|
|
|
- opacity: 0.4
|
|
|
+ backgroundColor: 'rgba(0,0,0,0.4)',
|
|
|
|
|
|
},
|
|
|
payMethod: {
|
|
@@ -251,6 +308,32 @@ const styles = StyleSheet.create({
|
|
|
height: 150,
|
|
|
position: 'absolute',
|
|
|
// bottom: 0,
|
|
|
- backgroundColor: '#fff'
|
|
|
+ backgroundColor: '#fff',
|
|
|
+ flexDirection: 'column',
|
|
|
+ alignItems: 'center',
|
|
|
+ justifyContent: 'flex-start'
|
|
|
+ },
|
|
|
+ payDialog: {
|
|
|
+ width: '90%',
|
|
|
+ borderTopWidth: 1,
|
|
|
+ borderColor: '#e4e4e4',
|
|
|
+ flexDirection: 'row',
|
|
|
+ alignItems: 'center',
|
|
|
+ justifyContent: 'space-between',
|
|
|
+ flex: 1
|
|
|
+ },
|
|
|
+ dialogRow: {
|
|
|
+ flexDirection: 'row',
|
|
|
+ alignItems: 'center',
|
|
|
+ },
|
|
|
+ payIcon: {
|
|
|
+ marginRight: 17
|
|
|
+ },
|
|
|
+ payText: {
|
|
|
+ fontSize: 16,
|
|
|
+ color: '#191919',
|
|
|
+ alignContent: 'center',
|
|
|
+ flex: 1,
|
|
|
+ lineHeight: 50
|
|
|
}
|
|
|
})
|