Commit d15d271d authored by 杜欣's avatar 杜欣

Merge branch 'dev' into dx/message

# Conflicts:
#	lib/TestPage.dart
parents 5ed9d645 256db5f0
...@@ -65,7 +65,7 @@ class MainActivity : FlutterActivity() { ...@@ -65,7 +65,7 @@ class MainActivity : FlutterActivity() {
val map = HashMap<String, String>() val map = HashMap<String, String>()
map.put("buildConfig", "debug") map.put("buildConfig", "debug")
//HERE //HERE
// map.put("proxy", "172.30.9.84:6666"); map.put("proxy", "172.30.9.84:6666");
result.success(map) result.success(map)
} else { } else {
result.notImplemented() result.notImplemented()
......
...@@ -12,14 +12,18 @@ import 'package:gmalpha_flutter/commonModel/net/DioUtil.dart'; ...@@ -12,14 +12,18 @@ import 'package:gmalpha_flutter/commonModel/net/DioUtil.dart';
import 'package:gmalpha_flutter/commonModel/toast/toast.dart'; import 'package:gmalpha_flutter/commonModel/toast/toast.dart';
class ReputationsModel extends BaseModel { class ReputationsModel extends BaseModel {
LiveData<PrestigeEntity> prestigeLive = new LiveData(); LiveData<PrestigeEntity> prestigeLive;
LiveData<String> titleLive = new LiveData();
LiveData<String> titleLive;
final int userId; final int userId;
final String userName; final String userName;
final String fromPage; final String fromPage;
ReputationsModel(this.userId, this.userName, this.fromPage); ReputationsModel(this.userId, this.userName, this.fromPage) {
prestigeLive = new LiveData();
titleLive = new LiveData();
}
init(BuildContext context) { init(BuildContext context) {
titleLive.notifyView(userName); titleLive.notifyView(userName);
......
...@@ -232,8 +232,8 @@ class ReputationsState extends BasePage<ReputationsPage> { ...@@ -232,8 +232,8 @@ class ReputationsState extends BasePage<ReputationsPage> {
@override @override
void dispose() { void dispose() {
super.dispose();
_model.dispose(); _model.dispose();
super.dispose();
} }
@override @override
......
...@@ -7,6 +7,7 @@ import 'package:flutter/material.dart'; ...@@ -7,6 +7,7 @@ import 'package:flutter/material.dart';
import 'package:gmalpha_flutter/Annotations/RouterCenterRestore.mark.dart'; import 'package:gmalpha_flutter/Annotations/RouterCenterRestore.mark.dart';
import 'package:gmalpha_flutter/commonModel/base/BaseComponent.dart'; import 'package:gmalpha_flutter/commonModel/base/BaseComponent.dart';
import 'package:gmalpha_flutter/commonModel/net/Api.dart'; import 'package:gmalpha_flutter/commonModel/net/Api.dart';
import 'package:gmalpha_flutter/res/anim/Anim.dart';
class TestPage extends StatelessWidget { class TestPage extends StatelessWidget {
TestPage() { TestPage() {
...@@ -40,9 +41,7 @@ class TestPage extends StatelessWidget { ...@@ -40,9 +41,7 @@ class TestPage extends StatelessWidget {
onPressed: () { onPressed: () {
Navigator.push( Navigator.push(
context, context,
new MaterialPageRoute( new CustomRoute(page));
builder: (context) => page,
));
}, },
child: Text(itemName), child: Text(itemName),
), ),
...@@ -89,7 +88,7 @@ class TestPage extends StatelessWidget { ...@@ -89,7 +88,7 @@ class TestPage extends StatelessWidget {
context, context,
RouterCenterImpl() RouterCenterImpl()
.findUserRouter() .findUserRouter()
?.getUserSettingPage("241765327", "NULL"), ?.getUserSettingPage("241765462", "NULL"),
"设置页面"); "设置页面");
} }
} }
/*
* @author lsy
* @date 2019-10-14
**/
import 'package:flutter/material.dart';
void jumpToPage(Widget page, BuildContext context) {
Navigator.push(context, MaterialPageRoute(builder: ((context) {
return page;
})));
}
...@@ -6,70 +6,6 @@ import 'package:gmalpha_flutter/commonModel/toast/toast.dart'; ...@@ -6,70 +6,6 @@ import 'package:gmalpha_flutter/commonModel/toast/toast.dart';
const bool inProduction = const bool.fromEnvironment("dart.vm.product"); const bool inProduction = const bool.fromEnvironment("dart.vm.product");
/// <BaseResp<T> 返回 status code msg data.
class BaseResp<T> {
String status;
int code;
String msg;
T data;
T extra;
T userType;
BaseResp(
this.status, this.code, this.msg, this.data, this.extra, this.userType);
@override
String toString() {
StringBuffer sb = new StringBuffer('{');
sb.write("\"status\":\"$status\"");
sb.write(",\"code\":$code");
sb.write(",\"msg\":\"$msg\"");
sb.write(",\"data\":\"$data\"");
sb.write(",\"extra\":\"$extra\"");
sb.write(",\"userType\":\"$userType\"");
sb.write('}');
return sb.toString();
}
}
/// <BaseRespR<T> 返回 status code msg data Response.
class BaseRespR<T> {
String status;
int code;
String msg;
T data;
T extra;
T userType;
Response response;
BaseRespR(this.status, this.code, this.msg, this.data, this.extra,
this.userType, this.response);
@override
String toString() {
StringBuffer sb = new StringBuffer('{');
sb.write("\"status\":\"$status\"");
sb.write(",\"code\":$code");
sb.write(",\"msg\":\"$msg\"");
sb.write(",\"data\":\"$data\"");
sb.write(",\"extra\":\"$extra\"");
sb.write(",\"userType\":\"$userType\"");
sb.write('}');
return sb.toString();
;
}
}
/// 请求方法.
class Method {
static final String get = "GET";
static final String post = "POST";
static final String put = "PUT";
static final String head = "HEAD";
static final String delete = "DELETE";
static final String patch = "PATCH";
}
///Http配置. ///Http配置.
class HttpConfig { class HttpConfig {
/// constructor. /// constructor.
...@@ -179,7 +115,7 @@ class DioUtil { ...@@ -179,7 +115,7 @@ class DioUtil {
}); });
} }
}, onResponse: (response) { }, onResponse: (response) {
print("响应之前"); print("响应之前 response${response}");
}, onError: (e) { }, onError: (e) {
print("网络错误 $e message ${e.message}"); print("网络错误 $e message ${e.message}");
}); });
...@@ -253,6 +189,7 @@ class DioUtil { ...@@ -253,6 +189,7 @@ class DioUtil {
*/ */
Future<Response> get(url, {data, options, cancelToken}) async { Future<Response> get(url, {data, options, cancelToken}) async {
Response response; Response response;
print("GET===> URL:$url data:$data");
try { try {
response = await _dio.get(url, response = await _dio.get(url,
queryParameters: data, options: options, cancelToken: cancelToken); queryParameters: data, options: options, cancelToken: cancelToken);
...@@ -275,9 +212,12 @@ class DioUtil { ...@@ -275,9 +212,12 @@ class DioUtil {
*/ */
Future<Response> post(url, {data, options, cancelToken}) async { Future<Response> post(url, {data, options, cancelToken}) async {
Response response; Response response;
print("POST===> URL:$url data:$data");
try { try {
response = await _dio.post(url, response = await _dio.post(url,
queryParameters: data, options: options, cancelToken: cancelToken); data: FormData.from(data),
options: options,
cancelToken: cancelToken);
print('post success---------${response.statusCode} ${response.data}'); print('post success---------${response.statusCode} ${response.data}');
} on DioError catch (e) { } on DioError catch (e) {
print('post error---------$e message${e.message}'); print('post error---------$e message${e.message}');
...@@ -305,60 +245,6 @@ class DioUtil { ...@@ -305,60 +245,6 @@ class DioUtil {
return response.data; return response.data;
} }
Future<BaseRespR<T>> requestR<T>(String method, String path,
{data, Options options, CancelToken cancelToken}) async {
Response response = await _dio.request(path,
data: data,
options: _checkOptions(method, options),
cancelToken: cancelToken);
_printHttpLog(response);
String _status;
int _code;
String _msg;
T _data;
T _extra;
T _userType;
_status = response.statusCode.toString();
if (response.statusCode == HttpStatus.ok ||
response.statusCode == HttpStatus.created) {
try {
if (response.data is Map) {
_code = (response.data[_codeKey] is String)
? int.tryParse(response.data[_codeKey])
: response.data[_codeKey];
_msg = response.data[_msgKey];
_data = response.data[_dataKey];
} else {
Map<String, dynamic> _dataMap = _decodeData(response);
_code = (_dataMap[_codeKey] is String)
? int.tryParse(_dataMap[_codeKey])
: _dataMap[_codeKey];
_msg = _dataMap[_msgKey];
_data = _dataMap[_dataKey];
_extra = response.data[_extraKey];
_userType = response.data[_userType];
}
return new BaseRespR(
_status, _code, _msg, _data, _extra, _userType, response);
} catch (e) {
return new Future.error(new DioError(
response: response,
message: "data parsing exception...",
type: DioErrorType.RESPONSE,
));
}
} else {
_code = 1;
_msg = '请求失败';
}
return new Future.error(new DioError(
response: response,
message: "statusCode: $response.statusCode, service error",
type: DioErrorType.RESPONSE,
));
}
void formatError(DioError e) { void formatError(DioError e) {
String reason = ""; String reason = "";
if (e.type == DioErrorType.CONNECT_TIMEOUT) { if (e.type == DioErrorType.CONNECT_TIMEOUT) {
...@@ -400,16 +286,6 @@ class DioUtil { ...@@ -400,16 +286,6 @@ class DioUtil {
cancelToken: cancelToken, data: data, options: options); cancelToken: cancelToken, data: data, options: options);
} }
/// decode response data.
Map<String, dynamic> _decodeData(Response response) {
if (response == null ||
response.data == null ||
response.data.toString().isEmpty) {
return new Map();
}
return json.decode(response.data.toString());
}
/// check Options. /// check Options.
Options _checkOptions(method, options) { Options _checkOptions(method, options) {
if (options == null) { if (options == null) {
...@@ -509,16 +385,6 @@ class DioUtil { ...@@ -509,16 +385,6 @@ class DioUtil {
return dio; return dio;
} }
static String getBaseUrl() {
// if (inProduction) {
// //正式环境的
// return APP_HOST_RELEASE;
// } else {
// return APP_HOST_DEBUG;
// }
return APP_HOST_DEBUG;
}
/// get Def Options. /// get Def Options.
static BaseOptions getDefOptions() { static BaseOptions getDefOptions() {
BaseOptions options = BaseOptions(); BaseOptions options = BaseOptions();
...@@ -527,9 +393,7 @@ class DioUtil { ...@@ -527,9 +393,7 @@ class DioUtil {
// options.contentType = ContentType.parse('application/x-www-form-urlencoded'); // options.contentType = ContentType.parse('application/x-www-form-urlencoded');
options.contentType = ContentType.json; options.contentType = ContentType.json;
options.responseType = ResponseType.plain; options.responseType = ResponseType.plain;
// options.baseUrl = 'https://earth.iyanzhi.com/'; options.baseUrl = APP_HOST_DEBUG + "/";
// options.baseUrl = 'http://earth.gmapp.env/';
options.baseUrl = getBaseUrl() + "/";
Map<String, dynamic> headers = Map<String, dynamic>(); Map<String, dynamic> headers = Map<String, dynamic>();
headers['Accept'] = 'application/json'; headers['Accept'] = 'application/json';
headers['version'] = '1.0.0'; headers['version'] = '1.0.0';
......
...@@ -12,7 +12,6 @@ import 'package:gmalpha_flutter/commonModel/cache/CacheManager.dart'; ...@@ -12,7 +12,6 @@ import 'package:gmalpha_flutter/commonModel/cache/CacheManager.dart';
import 'package:gmalpha_flutter/commonModel/net/Api.dart'; import 'package:gmalpha_flutter/commonModel/net/Api.dart';
import 'package:gmalpha_flutter/messageModel/home/message_home.dart'; import 'package:gmalpha_flutter/messageModel/home/message_home.dart';
import 'comment_suggest.dart';
void main() { void main() {
initParams(() => runApp(MyApp())); initParams(() => runApp(MyApp()));
...@@ -28,7 +27,7 @@ class _MyAppState extends State<MyApp> { ...@@ -28,7 +27,7 @@ class _MyAppState extends State<MyApp> {
void initState() { void initState() {
super.initState(); super.initState();
FlutterBoost.singleton.registerPageBuilders({ FlutterBoost.singleton.registerPageBuilders({
'comment_suggest': (pageName, params, _) => CommentSuggest(params), // 'comment_suggest': (pageName, params, _) => CommentSuggest(params),
'message_home': (pageName, params, _) => MessageHomePage(params), 'message_home': (pageName, params, _) => MessageHomePage(params),
'album': (pageName, params, _) { 'album': (pageName, params, _) {
if (params == null) { if (params == null) {
......
/*
* @author lsy
* @date 2019-10-14
**/
import 'package:flutter/material.dart';
class CustomRoute extends PageRouteBuilder{
final Widget widget;
CustomRoute(this.widget)
:super(
// 设置过度时间
transitionDuration:Duration(milliseconds: 500),
// 构造器
pageBuilder:(
// 上下文和动画
BuildContext context,
Animation<double> animaton1,
Animation<double> animaton2,
){
return widget;
},
transitionsBuilder:(
BuildContext context,
Animation<double> animaton1,
Animation<double> animaton2,
Widget child,
){
// 需要什么效果把注释打开就行了
// 渐变效果
// return FadeTransition(
// // 从0开始到1
// opacity: Tween(begin: 0.0,end: 1.0)
// .animate(CurvedAnimation(
// // 传入设置的动画
// parent: animaton1,
// // 设置效果,快进漫出 这里有很多内置的效果
// curve: Curves.fastOutSlowIn,
// )),
// child: child,
// );
// 缩放动画效果
// return ScaleTransition(
// scale: Tween(begin: 0.0,end: 1.0).animate(CurvedAnimation(
// parent: animaton1,
// curve: Curves.fastOutSlowIn
// )),
// child: child,
// );
// 旋转加缩放动画效果
// return RotationTransition(
// turns: Tween(begin: 0.0,end: 1.0)
// .animate(CurvedAnimation(
// parent: animaton1,
// curve: Curves.fastOutSlowIn,
// )),
// child: ScaleTransition(
// scale: Tween(begin: 0.0,end: 1.0)
// .animate(CurvedAnimation(
// parent: animaton1,
// curve: Curves.fastOutSlowIn
// )),
// child: child,
// ),
// );
// 左右滑动动画效果
return SlideTransition(
position: Tween<Offset>(
// 设置滑动的 X , Y 轴
begin: Offset(1.0, 0.0),
end: Offset(0.0,0.0)
).animate(CurvedAnimation(
parent: animaton1,
curve: Curves.fastOutSlowIn
)),
child: child,
);
}
);
}
\ No newline at end of file
/*
* @author lsy
* @date 2019-10-14
**/
import 'package:flutter/cupertino.dart';
import 'package:gmalpha_flutter/Annotations/RouterCenterRestore.mark.dart';
import 'package:gmalpha_flutter/commonModel/live/BaseModel.dart';
import 'package:gmalpha_flutter/commonModel/toast/toast.dart';
import 'package:gmalpha_flutter/userModel/service/UserRepository.dart';
class CommentModel extends BaseModel {
String refer;
CommentModel(this.refer) {}
@override
void dispose() {}
void confirmClick(BuildContext context, String content, String phone) {
RouterCenterImpl()
.findBuriedRouter()
?.onEvent('click_comment_suggest', {'comment_id': '10086'});
UserRepository.getInstance().commentSuggest(content, phone).listen((value) {
Navigator.pop(context);
}).onError((error){
Toast.debugShow(context, error.message);
print(error.message);
});
}
}
...@@ -9,77 +9,40 @@ ...@@ -9,77 +9,40 @@
import 'package:dio/dio.dart'; import 'package:dio/dio.dart';
import 'package:flutter_boost/flutter_boost.dart'; import 'package:flutter_boost/flutter_boost.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'commonModel/ui/ALColors.dart'; import 'package:gmalpha_flutter/commonModel/base/BaseComponent.dart';
import 'commonModel/ui/ALDevice.dart'; import 'package:gmalpha_flutter/commonModel/base/BasePage.dart';
import 'commonModel/net/DioUtil.dart'; import 'package:gmalpha_flutter/commonModel/base/BaseState.dart';
import 'commonModel/toast/toast.dart'; import 'package:gmalpha_flutter/userModel/page/comment/CommentModel.dart';
//import 'package:native_flutter_transfer_plugin/native_flutter_transfer_plugin.dart'; import '../../../commonModel/ui/ALColors.dart';
import '../../../commonModel/ui/ALDevice.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 { class CommentSuggestPage extends StatefulWidget {
var _model;
final String title; CommentSuggestPage(String refer) {
final Map nativeCookie; _model = CommentModel(refer);
}
CommentSuggestPage({Key key, this.title, this.nativeCookie}) : super(key: key);
@override @override
_CommentSuggestPageState createState() => _CommentSuggestPageState(); State<StatefulWidget> createState() => _CommentSuggestPageState(_model);
} }
class _CommentSuggestPageState extends State<CommentSuggestPage> { class _CommentSuggestPageState extends BasePage<CommentSuggestPage> {
TextEditingController opinionCtrl = TextEditingController(); TextEditingController opinionCtrl = TextEditingController();
TextEditingController telCtrl = TextEditingController(); TextEditingController telCtrl = TextEditingController();
CommentModel _model;
_CommentSuggestPageState(this._model);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
appBar: AppBar( appBar: baseAppBar(
backgroundColor: Color(0xFFffffff), title: '意见与建议',
title: Text('意见与建议', backClick: () {
style: new TextStyle(fontSize: 16.0,color: ALColors.Color323232), Navigator.pop(context);
),
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( body: new SingleChildScrollView(
child: Center( child: Center(
child: Column( child: Column(
...@@ -138,12 +101,16 @@ class _CommentSuggestPageState extends State<CommentSuggestPage> { ...@@ -138,12 +101,16 @@ class _CommentSuggestPageState extends State<CommentSuggestPage> {
decoration: BoxDecoration( decoration: BoxDecoration(
border: border:
Border.all(color: ALColors.Color323232, width: 1.5)), Border.all(color: ALColors.Color323232, width: 1.5)),
margin: EdgeInsets.only(left: 30, right: 30, bottom: 30, top: 180), margin: EdgeInsets.only(
left: 30, right: 30, bottom: 30, top: 180),
// padding: EdgeInsets.all(0), // padding: EdgeInsets.all(0),
constraints: constraints:
BoxConstraints(minWidth: ALDevice.width, minHeight: 45), BoxConstraints(minWidth: ALDevice.width, minHeight: 45),
child: FlatButton( child: FlatButton(
onPressed: confirmClick, onPressed: () {
_model.confirmClick(
context, opinionCtrl.text ?? "", telCtrl.text ?? "");
},
child: Text( child: Text(
'提交', '提交',
style: style:
...@@ -158,43 +125,19 @@ class _CommentSuggestPageState extends State<CommentSuggestPage> { ...@@ -158,43 +125,19 @@ class _CommentSuggestPageState extends State<CommentSuggestPage> {
} }
@override @override
void didUpdateWidget (CommentSuggestPage oldWidget) { void dispose() {
super.didUpdateWidget(oldWidget); super.dispose();
print('aaaaaaaaa--------'); opinionCtrl.dispose();
print(oldWidget); telCtrl.dispose();
}
void confirmClick() {
// NativeFlutterTransferPlugin.track('click_comment_suggest', {'comment_id': '10086'});
confimSuggestInfo();
} }
void confimSuggestInfo() { @override
BaseOptions options = DioUtil.getDefOptions(); String pageName() {
final cookie = new Map<String, dynamic>.from(widget.nativeCookie); return "comment_arguement";
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);
} }
}); @override
String referrer() {
return _model.refer;
} }
} }
...@@ -4,6 +4,9 @@ ...@@ -4,6 +4,9 @@
**/ **/
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:gmalpha_flutter/Annotations/RouterCenterRestore.mark.dart';
import 'package:gmalpha_flutter/commonModel/base/BaseUtil.dart';
import 'package:gmalpha_flutter/commonModel/live/BaseModel.dart'; import 'package:gmalpha_flutter/commonModel/live/BaseModel.dart';
import 'package:gmalpha_flutter/commonModel/net/Responce/SimpleResponce.dart'; import 'package:gmalpha_flutter/commonModel/net/Responce/SimpleResponce.dart';
import 'package:gmalpha_flutter/commonModel/toast/toast.dart'; import 'package:gmalpha_flutter/commonModel/toast/toast.dart';
...@@ -25,34 +28,42 @@ class UserSettingModel extends BaseModel { ...@@ -25,34 +28,42 @@ class UserSettingModel extends BaseModel {
UserSettingModel(this.userid, this.refere); UserSettingModel(this.userid, this.refere);
init(BuildContext context) { init(BuildContext context) {
if (UserEntityImpl().getuserId() == null || UserEntityImpl().getuserId().listen((value) {
UserEntityImpl().getuserId() != userid) { print("VALUEE $value");
if (value == null || value != userid) {
UserRepository.getInstance().getUserInfo(userid).listen((data) { UserRepository.getInstance().getUserInfo(userid).listen((data) {
print(data); print(data);
nameLive.notifyView(data?.data?.nickName);
cityLive.notifyView(data?.data?.countryInfo?.name);
headImgLive.notifyView(data?.data?.profilePic);
}).onError((error) { }).onError((error) {
print(error); print(error);
Toast.show(context, "error"); Toast.show(context, error);
}); });
} else { } else {
UserEntityImpl().getnickName().listen((data) { UserEntityImpl().getnickName().listen((data) {
print("NICK $data");
nameLive.notifyView(data); nameLive.notifyView(data);
}).onError((error) { }).onError((error) {
print(error); print(error);
Toast.debugShow(context, error); Toast.debugShow(context, error);
}); });
UserEntityImpl().getcountryInfoName().listen((data) { UserEntityImpl().getcountryInfoName().listen((data) {
print("con $data");
cityLive.notifyView(data); cityLive.notifyView(data);
}).onError((error) { }).onError((error) {
print(error); print(error);
Toast.debugShow(context, error); Toast.debugShow(context, error);
}); });
UserEntityImpl().getprofilePic().listen((value) { UserEntityImpl().getprofilePic().listen((value) {
print("head $value");
headImgLive.notifyView(value); headImgLive.notifyView(value);
}).onError((error) { }).onError((error) {
print(error); print(error);
Toast.debugShow(context, error); Toast.debugShow(context, error);
}); });
} }
});
} }
@override @override
...@@ -62,6 +73,4 @@ class UserSettingModel extends BaseModel { ...@@ -62,6 +73,4 @@ class UserSettingModel extends BaseModel {
cityLive.dispost(); cityLive.dispost();
saveLive.dispost(); saveLive.dispost();
} }
void gotoCommentPage(BuildContext context) {}
} }
...@@ -14,6 +14,7 @@ import 'package:gmalpha_flutter/commonModel/net/Responce/SimpleResponce.dart'; ...@@ -14,6 +14,7 @@ import 'package:gmalpha_flutter/commonModel/net/Responce/SimpleResponce.dart';
import 'package:gmalpha_flutter/userModel/page/userSetting/UserSettingModel.dart'; import 'package:gmalpha_flutter/userModel/page/userSetting/UserSettingModel.dart';
import 'package:gmalpha_flutter/userModel/service/remote/entity/TestUserEntity.dart'; import 'package:gmalpha_flutter/userModel/service/remote/entity/TestUserEntity.dart';
import 'package:gmalpha_flutter/userModel/service/remote/entity/UserEntity.dart'; import 'package:gmalpha_flutter/userModel/service/remote/entity/UserEntity.dart';
import 'package:gmalpha_flutter/userModel/util/JumpUtil.dart';
class UserSettingPage extends StatefulWidget { class UserSettingPage extends StatefulWidget {
UserSettingModel _model; UserSettingModel _model;
...@@ -153,7 +154,7 @@ class UserState extends BasePage<UserSettingPage> { ...@@ -153,7 +154,7 @@ class UserState extends BasePage<UserSettingPage> {
true), true),
divideLine(), divideLine(),
baseItem(() { baseItem(() {
_model.gotoCommentPage(context); jumpToComment(context, pageName());
}, "意见与建议", null, true), }, "意见与建议", null, true),
divideLine(), divideLine(),
baseItem(() {}, "隐私声明", null, true), baseItem(() {}, "隐私声明", null, true),
...@@ -165,7 +166,7 @@ class UserState extends BasePage<UserSettingPage> { ...@@ -165,7 +166,7 @@ class UserState extends BasePage<UserSettingPage> {
), ),
Container( Container(
width: double.maxFinite, width: double.maxFinite,
height: ScreenUtil.instance.setHeight(45), height: 45,
margin: EdgeInsets.only( margin: EdgeInsets.only(
bottom: ScreenUtil.instance.setHeight(30), bottom: ScreenUtil.instance.setHeight(30),
left: ScreenUtil.instance.setWidth(30), left: ScreenUtil.instance.setWidth(30),
...@@ -173,7 +174,7 @@ class UserState extends BasePage<UserSettingPage> { ...@@ -173,7 +174,7 @@ class UserState extends BasePage<UserSettingPage> {
child: OutlineButton( child: OutlineButton(
onPressed: () {}, onPressed: () {},
child: baseText("退出登入", 14, 0xff323232), child: baseText("退出登入", 14, 0xff323232),
borderSide:new BorderSide(color: Color(0xff323232)), borderSide: new BorderSide(color: Color(0xff323232)),
), ),
) )
], ],
...@@ -194,17 +195,17 @@ class UserState extends BasePage<UserSettingPage> { ...@@ -194,17 +195,17 @@ class UserState extends BasePage<UserSettingPage> {
baseItem(VoidCallback ontap, String left, Widget center, bool needRight) { baseItem(VoidCallback ontap, String left, Widget center, bool needRight) {
return GestureDetector( return GestureDetector(
onTap: () => ontap, onTap: () => ontap(),
child: Container( child: Container(
margin: EdgeInsets.only( margin: EdgeInsets.only(
right: ScreenUtil.instance.setWidth(30), right: ScreenUtil.instance.setWidth(30),
left: ScreenUtil.instance.setWidth(30)), left: ScreenUtil.instance.setWidth(30)),
height: ScreenUtil.instance.setHeight(60), height: 60,
child: Row( child: Row(
children: <Widget>[ children: <Widget>[
baseText(left, 13, 0xff323232), baseText(left, 13, 0xff323232),
Expanded( Expanded(
child: Container(), child: SizedBox(),
), ),
center ?? Container(), center ?? Container(),
needRight needRight
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
import 'package:gmalpha_flutter/commonModel/net/Responce/SimpleResponce.dart'; import 'package:gmalpha_flutter/commonModel/net/Responce/SimpleResponce.dart';
import 'package:gmalpha_flutter/userModel/service/local/UserLocal.dart'; import 'package:gmalpha_flutter/userModel/service/local/UserLocal.dart';
import 'package:gmalpha_flutter/userModel/service/remote/UserRemote.dart'; import 'package:gmalpha_flutter/userModel/service/remote/UserRemote.dart';
import 'package:gmalpha_flutter/userModel/service/remote/entity/CommentBean.dart';
import 'package:gmalpha_flutter/userModel/service/remote/entity/TestUserEntity.dart'; import 'package:gmalpha_flutter/userModel/service/remote/entity/TestUserEntity.dart';
import 'package:gmalpha_flutter/userModel/service/remote/entity/UserEntity.dart'; import 'package:gmalpha_flutter/userModel/service/remote/entity/UserEntity.dart';
import 'package:gmalpha_flutter/userModel/service/remote/entity/UserEntity.user.dart'; import 'package:gmalpha_flutter/userModel/service/remote/entity/UserEntity.user.dart';
...@@ -37,4 +38,8 @@ class UserRepository { ...@@ -37,4 +38,8 @@ class UserRepository {
return value; return value;
}); });
} }
Observable<CommentBean> commentSuggest(String content, String phone) {
return _remote.commentSuggest(content, phone);
}
} }
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
**/ **/
import 'package:gmalpha_flutter/commonModel/net/Responce/SimpleResponce.dart'; import 'package:gmalpha_flutter/commonModel/net/Responce/SimpleResponce.dart';
import 'package:gmalpha_flutter/userModel/service/remote/api/UserApi.serv.dart'; import 'package:gmalpha_flutter/userModel/service/remote/api/UserApi.serv.dart';
import 'package:gmalpha_flutter/userModel/service/remote/entity/CommentBean.dart';
import 'package:gmalpha_flutter/userModel/service/remote/entity/TestUserEntity.dart'; import 'package:gmalpha_flutter/userModel/service/remote/entity/TestUserEntity.dart';
import 'package:gmalpha_flutter/userModel/service/remote/entity/UserEntity.dart'; import 'package:gmalpha_flutter/userModel/service/remote/entity/UserEntity.dart';
import 'package:gmalpha_flutter/userModel/service/remote/entity/UserResultBean.dart'; import 'package:gmalpha_flutter/userModel/service/remote/entity/UserResultBean.dart';
...@@ -24,4 +25,8 @@ class UserRemote { ...@@ -24,4 +25,8 @@ class UserRemote {
Observable<UserResultBean> getUserInfo(String userID) { Observable<UserResultBean> getUserInfo(String userID) {
return UserApiImpl().getUserInfo(userID); return UserApiImpl().getUserInfo(userID);
} }
Observable<CommentBean> commentSuggest(String content, String phone) {
return UserApiImpl().comment(content, phone);
}
} }
...@@ -7,6 +7,7 @@ import 'package:gmalpha_flutter/Annotations/anno/Post.dart'; ...@@ -7,6 +7,7 @@ import 'package:gmalpha_flutter/Annotations/anno/Post.dart';
import 'package:gmalpha_flutter/Annotations/anno/Query.dart'; import 'package:gmalpha_flutter/Annotations/anno/Query.dart';
import 'package:gmalpha_flutter/Annotations/anno/ServiceCenter.dart'; import 'package:gmalpha_flutter/Annotations/anno/ServiceCenter.dart';
import 'package:gmalpha_flutter/commonModel/net/Responce/SimpleResponce.dart'; import 'package:gmalpha_flutter/commonModel/net/Responce/SimpleResponce.dart';
import 'package:gmalpha_flutter/userModel/service/remote/entity/CommentBean.dart';
import 'package:gmalpha_flutter/userModel/service/remote/entity/TestUserEntity.dart'; import 'package:gmalpha_flutter/userModel/service/remote/entity/TestUserEntity.dart';
import 'package:gmalpha_flutter/userModel/service/remote/entity/UserEntity.dart'; import 'package:gmalpha_flutter/userModel/service/remote/entity/UserEntity.dart';
import 'package:gmalpha_flutter/userModel/service/remote/entity/UserResultBean.dart'; import 'package:gmalpha_flutter/userModel/service/remote/entity/UserResultBean.dart';
...@@ -15,4 +16,7 @@ import 'package:gmalpha_flutter/userModel/service/remote/entity/UserResultBean.d ...@@ -15,4 +16,7 @@ import 'package:gmalpha_flutter/userModel/service/remote/entity/UserResultBean.d
abstract class UserApi { abstract class UserApi {
@Get("api/account/user_profile") @Get("api/account/user_profile")
UserResultBean getUserInfo(@Query("user_id") String userID); UserResultBean getUserInfo(@Query("user_id") String userID);
@Post("api/v1/suggestion")
CommentBean comment(@Query("content") String content, @Query("phone") String phone);
} }
...@@ -11,6 +11,7 @@ import 'dart:io'; ...@@ -11,6 +11,7 @@ import 'dart:io';
import 'package:rxdart/rxdart.dart'; import 'package:rxdart/rxdart.dart';
import 'package:gmalpha_flutter/userModel/service/remote/entity/UserResultBean.dart'; import 'package:gmalpha_flutter/userModel/service/remote/entity/UserResultBean.dart';
import 'package:gmalpha_flutter/userModel/service/remote/entity/CommentBean.dart';
import 'package:gmalpha_flutter/commonModel/net/DioUtil.dart'; import 'package:gmalpha_flutter/commonModel/net/DioUtil.dart';
...@@ -37,4 +38,14 @@ class UserApiImpl { ...@@ -37,4 +38,14 @@ class UserApiImpl {
} }
}); });
} }
Observable<CommentBean> comment(String content, String phone) {
return Observable.fromFuture(DioUtil().post('api/v1/suggestion',
data: {'content': content, 'phone': phone})).map((value) {
if (value != null && value.statusCode == 200) {
Map map = json.decode(value.toString());
return CommentBean.fromJson(map);
}
});
}
} }
/*
* @author lsy
* @date 2019-10-14
**/
class CommentBean {
int error;
String message;
Null extra;
UserType userType;
Data data;
CommentBean({this.error, this.message, this.extra, this.userType, this.data});
CommentBean.fromJson(Map<String, dynamic> json) {
error = json['error'];
message = json['message'];
extra = json['extra'];
userType = json['user_type'] != null
? new UserType.fromJson(json['user_type'])
: null;
data = json['data'] != null ? new Data.fromJson(json['data']) : null;
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['error'] = this.error;
data['message'] = this.message;
data['extra'] = this.extra;
if (this.userType != null) {
data['user_type'] = this.userType.toJson();
}
if (this.data != null) {
data['data'] = this.data.toJson();
}
return data;
}
}
class Data {
Data();
Data.fromJson(Map<String, dynamic> json) {}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
return data;
}
}
class UserType {
UserType();
UserType.fromJson(Map<String, dynamic> json) {}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
return data;
}
}
...@@ -24,64 +24,69 @@ class UserEntity { ...@@ -24,64 +24,69 @@ class UserEntity {
*/ */
@User(USER_ID, "") @User(USER_ID, "")
String userId; String userId;
/** /**
* 用户昵称 * 用户昵称
*/ */
@User(NICKNAME, "") @User(NICKNAME, "")
String nickName; String nickName;
/** /**
* 用户头像 * 用户头像
*/ */
@User(PORTRAIT,"") @User(PORTRAIT, "")
String profilePic; String profilePic;
/** /**
* 是否需要答题 * 是否需要答题
*/ */
@User(PERSONAL_QA,true) @User(PERSONAL_QA, true)
bool hasAnswered = true; bool hasAnswered = true;
/** /**
* 是否扫过脸 * 是否扫过脸
*/ */
@User(HAS_SCAN_FACE,true) @User(HAS_SCAN_FACE, true)
bool hasScanFace = false; bool hasScanFace = false;
String id; String id;
@User(GENDER,"") @User(GENDER, "")
String gender; String gender;
@User(CURRENT_CITY_ID,"") @User(CURRENT_CITY_ID, "")
String cityId; String cityId;
@User(BIRTHDAY,0) @User(BIRTHDAY, 0.0)
int birth; double birth;
@User(COUNTRY_ID,"") @User(COUNTRY_ID, "")
String countryId; String countryId;
bool logined; bool logined;
// 用户是否设置过个人信息 // 用户是否设置过个人信息
@User(DETAIL_SETTED,true) @User(DETAIL_SETTED, true)
bool detailSetted = true; bool detailSetted = true;
//用户是否选择了标签 //用户是否选择了标签
bool tagSetted = false; bool tagSetted = false;
//注册流程中断后返回之前的登录页面 //注册流程中断后返回之前的登录页面
@User(QUESTION_URL,"") @User(QUESTION_URL, "")
String questionUrl; String questionUrl;
@User(USER_BIND_MOBILE,true) @User(USER_BIND_MOBILE, true)
bool isBind; bool isBind;
@User(COUNTRY_NAME,"") @User(COUNTRY_NAME, "")
String countryInfoName; String countryInfoName;
@User(COUNTRY_ID,"") @User(COUNTRY_ID, "")
String countryInfoId; String countryInfoId;
@User(COUNTRY_LANGUAGE,"") @User(COUNTRY_LANGUAGE, "")
String countryInfoLanguage; String countryInfoLanguage;
String insBindId; String insBindId;
String registerTime; String registerTime;
...@@ -154,5 +159,4 @@ class UserEntity { ...@@ -154,5 +159,4 @@ class UserEntity {
data['register_time'] = this.registerTime; data['register_time'] = this.registerTime;
return data; return data;
} }
} }
...@@ -22,6 +22,7 @@ class UserEntityImpl { ...@@ -22,6 +22,7 @@ class UserEntityImpl {
} }
SpUtil spUtil = SpUtil.getInstance(); SpUtil spUtil = SpUtil.getInstance();
String _userId; String _userId;
Observable<bool> saveuserId(String userId) { Observable<bool> saveuserId(String userId) {
return Observable.fromFuture(spUtil.saveStringKv("user_uid", userId)) return Observable.fromFuture(spUtil.saveStringKv("user_uid", userId))
...@@ -149,9 +150,9 @@ class UserEntityImpl { ...@@ -149,9 +150,9 @@ class UserEntityImpl {
return Observable.fromFuture(spUtil.getStringKv("current_city_id")); return Observable.fromFuture(spUtil.getStringKv("current_city_id"));
} }
int _birth; double _birth;
Observable<bool> savebirth(int birth) { Observable<bool> savebirth(double birth) {
return Observable.fromFuture(spUtil.saveIntKv("birthday", birth)) return Observable.fromFuture(spUtil.saveDoubleKv("birthday", birth))
.map((value) { .map((value) {
if (value) { if (value) {
this._birth = birth; this._birth = birth;
...@@ -160,11 +161,11 @@ class UserEntityImpl { ...@@ -160,11 +161,11 @@ class UserEntityImpl {
}); });
} }
Observable<int> getbirth() { Observable<double> getbirth() {
if (_birth != null) { if (_birth != null) {
return Observable.fromFuture(Future.value(_birth)); return Observable.fromFuture(Future.value(_birth));
} }
return Observable.fromFuture(spUtil.getIntKv("birthday")); return Observable.fromFuture(spUtil.getDoubleKv("birthday"));
} }
String _countryId; String _countryId;
......
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
* @author lsy * @author lsy
* @date 2019-10-12 * @date 2019-10-12
**/ **/
class UserResultBean { class UserResultBean {
int error; int error;
String message; String message;
...@@ -47,7 +46,7 @@ class Data { ...@@ -47,7 +46,7 @@ class Data {
int gender; int gender;
Null age; Null age;
Null cityId; Null cityId;
int birth; double birth;
double registerTime; double registerTime;
bool isBind; bool isBind;
bool logined; bool logined;
......
/*
* @author lsy
* @date 2019-10-14
**/
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:gmalpha_flutter/res/anim/Anim.dart';
import 'package:gmalpha_flutter/userModel/page/comment/CommentSuggestPage.dart';
void jumpToComment(BuildContext context, String refer) {
Navigator.push(context, new CustomRoute(CommentSuggestPage(refer)));
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment