@@ -38,46 +38,72 @@ const styles = StyleSheet.create({
3838 alignSelf : 'center' ,
3939 borderBottomColor :'#FFFFFF' ,
4040 borderBottomWidth :1
41+
4142 } ,
42- buttonview : {
43+ textView : {
4344 backgroundColor : '#1DBAF1' ,
4445 margin : 20 ,
4546 borderRadius : 6 ,
46- justifyContent : 'center' ,
47- alignItems : 'center'
47+ width :75
4848 } ,
49- logintext : {
49+ infoText : {
5050 fontSize : 17 ,
5151 color : '#FFFFFF' ,
5252 marginTop : 10 ,
53- marginBottom : 10
54- } ,
53+ marginBottom : 10 ,
54+ width :70
55+ }
5556} ) ;
5657class MessInfo extends React . Component {
5758 // 初始化模拟数据
5859 constructor ( props ) {
5960 super ( props ) ;
6061 this . state = {
6162 language :"" ,
62- infoDataId :this . props . infoDataId ,
6363 infoData :this . props . infoData
6464 } ;
65+ this . updateArticle = this . updateArticle . bind ( this ) ;
66+ this . backListView = this . backListView . bind ( this ) ;
67+ this . addArticle = this . addArticle . bind ( this ) ;
68+ }
69+
70+ updateArticle ( ) {
71+ let title = this . refs . title . _lastNativeText ;
72+ let url = this . refs . url . _lastNativeText ;
73+ let author = this . refs . author . _lastNativeText ;
74+ let pickerDate = this . refs . pickerDate . value ;
75+ let p = {
76+ tableName :"article" ,
77+ filed :" title=" + title + ",url=" + url + ",author=" + author + ",type=" + this . state . language ,
78+ condition :"id = " + this . state . infoData . id
79+ } ;
80+ this . props . updateArticleInfoById ( p ) ;
81+ }
82+
83+ backListView ( ) {
84+
85+ }
86+
87+ addArticle ( ) {
88+ let title = this . refs . title . _lastNativeText ;
89+ let url = this . refs . url . _lastNativeText ;
90+ let author = this . refs . author . _lastNativeText ;
91+ let pickerDate = this . refs . pickerDate . value ;
92+ let p = {
93+ tableName :"article" ,
94+ filed :" title=" + title + ",url=" + url + ",author=" + author + ",type=" + this . state . language ,
95+ condition :"id = " + this . state . infoData . id
96+ } ;
97+ this . props . addArticleInfoById ( p ) ;
6598 }
6699
67100 componentWillReceiveProps ( nextProps ) {
68101 this . setState ( {
69- infoDataId :nextProps . infoDataId ,
70102 infoData :nextProps . infoData
71103 } ) ;
72104 }
73105
74- componentWillMount ( ) {
75- //控件加载的时候先发起服务请求
76- //var p={tableName:"article",condition:"id = "+this.state.infoDataId}
77- alert ( 114 ) ;
78- var p = { tableName :"article" , condition :"id = 114" }
79- this . props . getArticleInfoById ( p ) ;
80- }
106+
81107
82108 render ( ) {
83109 return (
@@ -87,7 +113,9 @@ class MessInfo extends React.Component {
87113 < Text style = { styles . textTitle } > 文章名称:</ Text >
88114 </ View >
89115 < View style = { { borderBottomColor :'#FFFFFF' , borderBottomWidth :1 } } >
90- < TextInput placeholder = "请输入文章名称" placeholderTextColor = '#E0E0E0' underlineColorAndroid = 'transparent' style = { styles . inputText } value = { this . state . infoData . title } >
116+ < TextInput placeholder = "请输入文章名称" placeholderTextColor = '#E0E0E0'
117+ underlineColorAndroid = 'transparent' style = { styles . inputText }
118+ value = { this . state . infoData . title } ref = "title" >
91119
92120 </ TextInput >
93121 </ View >
@@ -99,7 +127,11 @@ class MessInfo extends React.Component {
99127 </ View >
100128 < View style = { { borderBottomColor :'#FFFFFF' , borderBottomWidth :1 } } >
101129
102- < TextInput placeholder = "请输入文章链接" placeholderTextColor = '#E0E0E0' underlineColorAndroid = 'transparent' style = { styles . inputText } > </ TextInput >
130+ < TextInput placeholder = "请输入文章链接" placeholderTextColor = '#E0E0E0'
131+ underlineColorAndroid = 'transparent' style = { styles . inputText }
132+ value = { this . state . infoData . url } ref = "url" >
133+
134+ </ TextInput >
103135
104136 </ View >
105137 </ View >
@@ -111,11 +143,13 @@ class MessInfo extends React.Component {
111143 < Picker
112144 mode = { 'dropdown' }
113145 prompt = "请选择文章类型"
146+ ref = "type"
114147 style = { styles . inputText } placeholderTextColor = '#E0E0E0' underlineColorAndroid = 'transparent'
115- selectedValue = { this . state . language }
148+ selectedValue = { this . state . infoData . type }
116149 onValueChange = { ( lang ) => this . setState ( { language : lang } ) } >
117- < Picker . Item label = "测试" value = "test" />
118- < Picker . Item label = "开发" value = "js" />
150+ < Picker . Item label = "测试" value = "0" />
151+ < Picker . Item label = "开发" value = "1" />
152+ < Picker . Item label = "杂记" value = "2" />
119153 </ Picker >
120154 </ View >
121155 </ View >
@@ -124,7 +158,11 @@ class MessInfo extends React.Component {
124158 < Text style = { styles . textTitle } > 文章作者:</ Text >
125159 </ View >
126160 < View style = { { borderBottomColor :'#FFFFFF' , borderBottomWidth :1 } } >
127- < TextInput placeholder = "请输入文章作者" placeholderTextColor = '#E0E0E0' underlineColorAndroid = 'transparent' style = { styles . inputText } > </ TextInput >
161+ < TextInput placeholder = "请输入文章作者" placeholderTextColor = '#E0E0E0'
162+ underlineColorAndroid = 'transparent' style = { styles . inputText }
163+ value = { this . state . infoData . author } ref = "author" >
164+
165+ </ TextInput >
128166
129167 </ View >
130168 </ View >
@@ -133,7 +171,7 @@ class MessInfo extends React.Component {
133171 < Text style = { styles . textTitle } > 发表时间:</ Text >
134172 </ View >
135173 < View style = { { borderBottomColor :'#FFFFFF' , borderBottomWidth :1 } } >
136- < DataPickerDemo underlineColorAndroid = 'transparent' />
174+ < DataPickerDemo Times = { this . state . infoData . date } underlineColorAndroid = 'transparent' />
137175 </ View >
138176 </ View >
139177 < View style = { styles . container } >
@@ -146,11 +184,14 @@ class MessInfo extends React.Component {
146184 </ View >
147185
148186 < View style = { styles . container } >
149- < View style = { styles . buttonview } >
150- < Text style = { styles . logintext } onPress = { this . login } > 修改</ Text >
187+ < View style = { styles . textView } >
188+ < Text style = { styles . infoText } onPress = { this . updateArticle } > 修改</ Text >
189+ </ View >
190+ < View style = { styles . textView } >
191+ < Text style = { styles . infoText } onPress = { this . addArticle } > 新增</ Text >
151192 </ View >
152- < View style = { styles . buttonview } >
153- < Text style = { styles . logintext } onPress = { this . login } > 返回</ Text >
193+ < View style = { styles . textView } >
194+ < Text style = { styles . infoText } onPress = { this . backListView } > 返回</ Text >
154195 </ View >
155196 </ View >
156197
@@ -162,7 +203,6 @@ class MessInfo extends React.Component {
162203
163204function mapStateToProps ( state ) {
164205 return {
165- infoDataId :state . articleInfoReducer . infoDataId ,
166206 infoData :state . articleInfoReducer . infoData
167207 }
168208}
0 commit comments