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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
//
// opinion
//
// gmalpha_flutter
// Created by Mikasa on 2019/2/19.
// Copyright © 2019 Gengmei. All rights reserved.
// 意见与建议页面
import 'package:dio/dio.dart';
import 'package:flutter_boost/flutter_boost.dart';
import 'package:flutter/material.dart';
import 'commonModel/ui/ALColors.dart';
import 'commonModel/ui/ALDevice.dart';
import 'commonModel/net/DioUtil.dart';
import 'commonModel/toast/toast.dart';
//import 'package:native_flutter_transfer_plugin/native_flutter_transfer_plugin.dart';
class CommentSuggest extends StatelessWidget {
final Map params;
CommentSuggest(this.params);
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: '意见与建议',
color: Color(0xFFffffff),
theme: ThemeData(
splashColor: Colors.white10, //水波纹的颜色
),
home: CommentSuggestPage(nativeCookie: this.params,title: '意见与建议',)
);
}
}
class CommentSuggestPage extends StatefulWidget {
final String title;
final Map nativeCookie;
CommentSuggestPage({Key key, this.title, this.nativeCookie}) : super(key: key);
@override
_CommentSuggestPageState createState() => _CommentSuggestPageState();
}
class _CommentSuggestPageState extends State<CommentSuggestPage> {
TextEditingController opinionCtrl = TextEditingController();
TextEditingController telCtrl = TextEditingController();
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Color(0xFFffffff),
title: Text('意见与建议',
style: new TextStyle(fontSize: 16.0,color: ALColors.Color323232),
),
elevation: 0,
brightness: Brightness.light,
leading: new GestureDetector(
child: new ImageIcon(
AssetImage('images/nav_back.png'),
color: ALColors.Color323232,
),
onTap: () {
print('123-------');
// FlutterBoost.singleton.closePageForContext(context);
FlutterBoost.singleton.closePageForContext(context);
}),
),
// floatingActionButton: new FloatingActionButton(
// onPressed: () {
// print('33333-------');
// FlutterBoost.singleton.openPage('second', {});
// },
// child: new Icon(Icons.add_box),
// elevation: 3.0,
// highlightElevation: 2.0,
// backgroundColor: Colors.red, // 红色
// ),
body: new SingleChildScrollView(
child: Center(
child: Column(
// mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
Container(
alignment: Alignment.topCenter,
margin:
EdgeInsets.only(left: 30, top: 50, right: 30, bottom: 0),
height: 215,
decoration: BoxDecoration(
border: Border.all(color: ALColors.ColorC4C4C4, width: 1),
),
child: TextField(
maxLines: 10,
controller: opinionCtrl,
decoration: InputDecoration(
border: InputBorder.none,
contentPadding: EdgeInsets.all(10),
hintText: '意见与建议',
hintStyle: TextStyle(
color: ALColors.ColorC4C4C4,
fontSize: 14,
),
labelStyle:
TextStyle(color: ALColors.Color323232, fontSize: 19),
),
),
),
Container(
height: 30,
margin: EdgeInsets.only(left: 30, right: 30, top: 40),
// padding: EdgeInsets.only(bottom: 10),
decoration: BoxDecoration(
border: Border(
bottom: BorderSide(color: ALColors.ColorC4C4C4),
)),
alignment: Alignment.centerLeft,
child: TextField(
controller: telCtrl,
decoration: InputDecoration(
border: InputBorder.none,
contentPadding: EdgeInsets.all(10),
hintText: '联系方式',
hintStyle: TextStyle(
color: ALColors.ColorC4C4C4,
fontSize: 14,
),
labelStyle:
TextStyle(color: ALColors.Color323232, fontSize: 19),
),
),
),
Container(
alignment: Alignment.bottomCenter,
decoration: BoxDecoration(
border:
Border.all(color: ALColors.Color323232, width: 1.5)),
margin: EdgeInsets.only(left: 30, right: 30, bottom: 30, top: 180),
// padding: EdgeInsets.all(0),
constraints:
BoxConstraints(minWidth: ALDevice.width, minHeight: 45),
child: FlatButton(
onPressed: confirmClick,
child: Text(
'提交',
style:
TextStyle(fontSize: 14, color: ALColors.Color323232),
),
),
),
],
),
),
));
}
@override
void didUpdateWidget (CommentSuggestPage oldWidget) {
super.didUpdateWidget(oldWidget);
print('aaaaaaaaa--------');
print(oldWidget);
}
void confirmClick() {
// NativeFlutterTransferPlugin.track('click_comment_suggest', {'comment_id': '10086'});
confimSuggestInfo();
}
void confimSuggestInfo() {
BaseOptions options = DioUtil.getDefOptions();
final cookie = new Map<String, dynamic>.from(widget.nativeCookie);
HttpConfig config = new HttpConfig(options: options, nativeCookie: cookie);
DioUtil().setConfig(config);
String content = (this.opinionCtrl.text.length > 0)? this.opinionCtrl.text : '';
String phone = (this.telCtrl.text.length > 0)? this.telCtrl.text : '';
DioUtil().requestR(Method.post, "api/v1/suggestion",data: {"content": content, "phone": phone}).then((res){
if (res.code == 0) {
Toast.show(context, '提交成功');
FlutterBoost.singleton.closePageForContext(context);
} else {
Toast.show(context, res.msg);
}
}
).then((error){
if (error != null) {
Toast.show(context, '提交失败');
print(error);
} else {
// FlutterBoost.singleton.closePageForContext(context);
}
});
}
}