MyCoupon.js
5.14 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
import React, { Component } from 'react';
import {Image, View, Text, StyleSheet,ScrollView,TouchableOpacity } from 'react-native';
import CouponeItem from '../CouponItem.1'
import StampItem from '../StampItem'
import {get} from 'axios'
import { SERVER } from '../../common/servername';
import AsyncStorage from '@react-native-community/async-storage';
import Loading from '../Pages/Loading'
import { createDeepLinkingHandler } from 'react-native-deep-link';
export default class AddTab extends Component {
static navigationOptions = {
headerShown: false
}
state = {
current:2,
Coupon:[
],
Stamp:[
],
isLoading_coupon:true,
isLoading_stamp:true,
user:{}
}
constructor(props) {
super(props)
}
componentDidMount() {
if(this.props.navigation.state.params && this.props.navigation.state.params.current ) {
this.setState({
current:this.props.navigation.state.params.current
})
}
AsyncStorage.getItem("user",(err,res) => {
if(res) {
this.setState({user:JSON.parse(res)})
get(`http://${SERVER}/coupons/user/${JSON.parse(res).id}`).then(res => {
this.setState({
Coupon:res.data.data,
isLoading_coupon:false
})
})
get(`http://${SERVER}/stamps/user/${JSON.parse(res).id}`).then(res => {
this.setState({
Stamp:res.data.data,
isLoading_stamp:false
})
})
}
else {
this.props.navigation.replace("LoginTab")
}
})
}
render() {
return (
<View>
<View style={{position:"relative",backgroundColor:"white",width:"100%",flexDirection:"row",paddingTop:16,paddingBottom:16,paddingLeft:16,backgroundColor:"#615F5F"}}>
<TouchableOpacity onPress={() => this.props.navigation.goBack(null)}>
<Image source={require('../../assets/back.png')}/>
</TouchableOpacity>
<Text style={{color:"white",fontSize:16,marginLeft:16}}>
내 쿠폰 & 스탬프
</Text>
</View>
<ScrollView style={{height:"90%"}}>
<View style={{
width:"100%",
shadowColor: "#000",
shadowOffset: {
width: 0,
height: 2,
},
backgroundColor:"white",
shadowOpacity: 0.25,
shadowRadius: 3.84,
elevation: 5,}}>
<View style={{flex:1,flexDirection:"row", }}>
<TouchableOpacity onPress={() => this.setState({current:1})} style={{width:"50%",paddingTop:8.9, paddingBottom:11.1,}}>
<Text style={[{textAlign:"center",borderRightColor:"#615F5F",borderRightWidth:1},this.state.current==1?{color:"#615F5F"}:{color:"#BDBCBC"}]}>
coupon
</Text>
</TouchableOpacity>
<TouchableOpacity onPress={() => this.setState({current:2})} style={{width:"50%",paddingTop:8.9, paddingBottom:11.1}}>
<Text style={[{textAlign:"center"},this.state.current==2?{color:"#615F5F"}:{color:"#BDBCBC"}]}>
stamp
</Text>
</TouchableOpacity>
</View>
</View>
<View>
{this.state.current==1?
<View style={{marginBottom:8}}>
{this.state.isLoading_coupon?<Loading/>:this.state.Coupon.length >0?
<CouponeItem user={this.state.user} setItemNum={()=>{}} item={this.state.Coupon} index={0} height={this.state.height}
handleHeight={(e) => {}}/>:undefined}
</View>
:
<View style={{marginBottom:8}}>
{this.state.isLoading_coupon?<Loading/>:
this.state.Stamp.length >0?
this.state.Stamp.map((e,i) => {
return (
<StampItem StoreData={e} user={this.state.user} setItemNum={()=>{}} index={0} height={this.state.height}
handleHeight={(e) => {}} item={e.StampConditions} />
)
}) :undefined}
</View>
}</View>
</ScrollView>
</View>
);
}
}
const style = StyleSheet.create({
container: {
flex: 1,
alignItems: 'center',
justifyContent: 'center',
}
});