Commit 09da21c9 authored by 郑智刚's avatar 郑智刚

解决冲突

parents 90b5b8f5 d58738cd
...@@ -63,7 +63,7 @@ class MainActivity : FlutterActivity() { ...@@ -63,7 +63,7 @@ class MainActivity : FlutterActivity() {
result.success("wifi") result.success("wifi")
} else if (call.method == "INIT_PARAMS") { } else if (call.method == "INIT_PARAMS") {
val map = HashMap<String, String>() val map = HashMap<String, String>()
map.put("buildConfig", "release") 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)
......
...@@ -9,6 +9,6 @@ import 'package:gmalpha_flutter/ActivityReportModel/page/ActivityReportPage.dart ...@@ -9,6 +9,6 @@ import 'package:gmalpha_flutter/ActivityReportModel/page/ActivityReportPage.dart
class ActivityReportRouterImpl implements ActivityReportRouter { class ActivityReportRouterImpl implements ActivityReportRouter {
@override @override
Widget getActivityReportPage(int id, int type,String fromPage) { Widget getActivityReportPage(int id, int type,String fromPage) {
return ActivityReportPage(id, type,fromPage); return new ActivityReportPage(id, type,fromPage);
} }
} }
...@@ -5,7 +5,6 @@ import 'package:gmalpha_flutter/NewMessageModel/NewMessageRouterImpl.dart'; ...@@ -5,7 +5,6 @@ import 'package:gmalpha_flutter/NewMessageModel/NewMessageRouterImpl.dart';
@Router("NewMessageModel", NewMessageRouterImpl, true) @Router("NewMessageModel", NewMessageRouterImpl, true)
abstract class NewMessageRouter implements RouterBaser { abstract class NewMessageRouter implements RouterBaser {
Widget getMessagePage();
Widget getAttentionPage(String fromPage); Widget getAttentionPage(String fromPage);
Widget getMessagePage(String fromPage);
} }
\ No newline at end of file
...@@ -6,8 +6,8 @@ import 'package:gmalpha_flutter/NewMessageModel/page/AttentionPage.dart'; ...@@ -6,8 +6,8 @@ import 'package:gmalpha_flutter/NewMessageModel/page/AttentionPage.dart';
class NewMessageRouterImpl implements NewMessageRouter { class NewMessageRouterImpl implements NewMessageRouter {
@override @override
Widget getMessagePage() { Widget getMessagePage(String fromPage) {
return MessagePage(); return MessagePage(fromPage);
} }
@override @override
......
...@@ -24,6 +24,7 @@ class MessageModel extends BaseModel { ...@@ -24,6 +24,7 @@ class MessageModel extends BaseModel {
getLatestMessage(); getLatestMessage();
} }
getMyMessage(page, count){ getMyMessage(page, count){
MessageRepository.getInstance() MessageRepository.getInstance()
.getMyMessage(page, count) .getMyMessage(page, count)
......
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:gmalpha_flutter/NewMessageModel/page/MessageModel.dart'; import 'package:gmalpha_flutter/NewMessageModel/page/MessageModel.dart';
import 'package:gmalpha_flutter/NewMessageModel/service/remote/entity/LatestMessageEntity.dart';
import 'package:gmalpha_flutter/NewMessageModel/service/remote/entity/MyMessageEntity.dart';
import 'package:gmalpha_flutter/NewMessageModel/service/remote/entity/UnreadMessageEntity.dart';
import 'package:gmalpha_flutter/commonModel/ui/ALColors.dart'; import 'package:gmalpha_flutter/commonModel/ui/ALColors.dart';
import 'common.dart'; import 'common.dart';
...@@ -17,7 +20,7 @@ enum LoadingStatus { ...@@ -17,7 +20,7 @@ enum LoadingStatus {
class MessagePage extends StatefulWidget { class MessagePage extends StatefulWidget {
MessageModel _messageModel; MessageModel _messageModel;
MessagePage() { MessagePage(String fromPage) {
_messageModel = new MessageModel(1, 10); _messageModel = new MessageModel(1, 10);
} }
@override @override
...@@ -79,7 +82,6 @@ class _MessagePageState extends State<MessagePage> { ...@@ -79,7 +82,6 @@ class _MessagePageState extends State<MessagePage> {
void initState() { void initState() {
super.initState(); super.initState();
_messageModel.init(context); _messageModel.init(context);
list.insertAll(0, [1]);
//在初始化状态的方法里 设置ListView的监听 //在初始化状态的方法里 设置ListView的监听
_scrollController.addListener(() { _scrollController.addListener(() {
//判断 当滑动到最底部的时候,去加载更多的数据 //判断 当滑动到最底部的时候,去加载更多的数据
...@@ -100,49 +102,81 @@ class _MessagePageState extends State<MessagePage> { ...@@ -100,49 +102,81 @@ class _MessagePageState extends State<MessagePage> {
title: messageTitle('消息'), title: messageTitle('消息'),
elevation: 0, elevation: 0,
), ),
body: ListView.builder( body: SingleChildScrollView(
itemCount: list.length + 1, child: Center(
itemBuilder: (BuildContext context, int index) { child: Column(
if (index == list.length) { children: <Widget>[
if(list.length == 1) { topCard(),
return Container( Container(
color: ALColors.ColorFFFFFF, color: ALColors.ColorFFFFFF,
height: ScreenUtil().setHeight(430), child: StreamBuilder<MyMessageEntity>(
child: Center(child: Text('暂无相关内容', style: TextStyle(color: ALColors.Color999999, fontSize: ScreenUtil().setSp(16)))) stream: _messageModel.myMessageLive.stream,
); initialData: _messageModel.myMessageLive.data ,
} else { builder: (BuildContext context, data){
return _loadingView(); var dataList = data.data?.data;
} if(dataList == null) {
} else { return Container(
if(index == 0) { color: ALColors.ColorFFFFFF,
return topCard(_messageModel.latestMessageLive); height: ScreenUtil().setHeight(430),
} else { child: Center(child: Text('暂无相关内容', style: TextStyle(color: ALColors.Color999999, fontSize: ScreenUtil().setSp(16))))
return Container( );
color: ALColors.ColorFFFFFF, }
child: Column( print('++++++====================${dataList.length}=================');
children: <Widget>[ return ListView.builder(
Center( itemCount: dataList.length + 1,
child: messageList(_messageModel.myMessageLive), itemExtent: 50,
) itemBuilder: (BuildContext context, int index) {
], print('============${index}++++++++${dataList.length}=============');
), if (index == dataList.length) {
); return _loadingView();
} } else {
} return messageList(dataList[index]);
}, }
controller: _scrollController, },
controller: _scrollController,
);
},
)
)
]
),
),
) )
); );
} }
topCard(latestMessageLive){ topCard(){
return Container( return Container(
color: ALColors.ColorFFFFFF, color: ALColors.ColorFFFFFF,
child: Column( child: Column(
children: <Widget>[ children: <Widget>[
messageTop('images/message_noti.png', '通知', '', 0), StreamBuilder<LatestMessageEntity>(
messageTop('images/message_like.png', 'Like!', '还没有人给你Like!哦~', 0), stream: _messageModel.latestMessageLive.stream,
messageTop('images/message_att.png', '关注', '还没有人给你关注哦~', 0), initialData: _messageModel.latestMessageLive.data ,
builder: (BuildContext context, data){
var content = data.data?.data?.content ?? '没有新的通知';
print('-====================${data.data.data.content}=================');
return messageTop('images/message_noti.png', '通知', content == '' ? '没有新的通知' : content, 0);
},
),
StreamBuilder<UnreadMessageEntity>(
stream: _messageModel.likeUnreadMessageLive.stream,
initialData: _messageModel.likeUnreadMessageLive.data ,
builder: (BuildContext context, data){
var voteCount = data.data?.data?.voteCount ?? 0;
print('-====================${voteCount}=================');
return messageTop('images/message_like.png', 'Like!', voteCount == 0 ? '还没有人给你Like!哦~' : '有$voteCount个人Like!了你', voteCount);
},
),
StreamBuilder<UnreadMessageEntity>(
stream: _messageModel.followUnreadMessageLive.stream,
initialData: _messageModel.followUnreadMessageLive.data ,
builder: (BuildContext context, data){
var count = data.data?.data?.count ?? 0;
print('-====================${count}=================');
return messageTop('images/message_att.png', '关注', count == 0 ? '还没有人给你关注哦~' : '有$count个人关注了你', count);
},
),
Container( Container(
margin: EdgeInsets.only(left: ScreenUtil().setWidth(16), right: ScreenUtil().setWidth(16), bottom: ScreenUtil().setHeight(24)), margin: EdgeInsets.only(left: ScreenUtil().setWidth(16), right: ScreenUtil().setWidth(16), bottom: ScreenUtil().setHeight(24)),
height: ScreenUtil().setHeight(12), height: ScreenUtil().setHeight(12),
......
import 'package:common_utils/common_utils.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:gmalpha_flutter/commonModel/ui/ALColors.dart'; import 'package:gmalpha_flutter/commonModel/ui/ALColors.dart';
messageTitle(String text) { messageTitle(String text) {
return Text( return Text(
text, text,
...@@ -101,6 +103,7 @@ getNum([int count]) { ...@@ -101,6 +103,7 @@ getNum([int count]) {
} }
messageList(list) { messageList(list) {
var contentText = {1: '评论了你', 2: '评论了你的评论', 3: '评论了你', 4: '评论了你的评论', 5: '关注了你的问题'};
return Container( return Container(
padding: EdgeInsets.only(left: width, right: width), padding: EdgeInsets.only(left: width, right: width),
margin: EdgeInsets.only(bottom: ScreenUtil().setHeight(25)), margin: EdgeInsets.only(bottom: ScreenUtil().setHeight(25)),
...@@ -118,7 +121,7 @@ messageList(list) { ...@@ -118,7 +121,7 @@ messageList(list) {
decoration: BoxDecoration( decoration: BoxDecoration(
shape: BoxShape.circle, shape: BoxShape.circle,
image: DecorationImage( image: DecorationImage(
image: NetworkImage('http://alpha-s.gmeiapp.com/2018/12/23/c909726bc2-w') image: NetworkImage(list.icon)
), ),
), ),
), ),
...@@ -131,7 +134,7 @@ messageList(list) { ...@@ -131,7 +134,7 @@ messageList(list) {
Row( Row(
children: <Widget>[ children: <Widget>[
Text( Text(
'参白', list.name,
style: TextStyle( style: TextStyle(
color: ALColors.Color323232, color: ALColors.Color323232,
fontSize: ScreenUtil().setSp(13), fontSize: ScreenUtil().setSp(13),
...@@ -140,7 +143,7 @@ messageList(list) { ...@@ -140,7 +143,7 @@ messageList(list) {
), ),
SizedBox(width: ScreenUtil().setWidth(10)), SizedBox(width: ScreenUtil().setWidth(10)),
Text( Text(
'评论了你', contentText[list.repliedContent?.type],
style: TextStyle( style: TextStyle(
color: ALColors.Color323232, color: ALColors.Color323232,
fontSize: ScreenUtil().setSp(13) fontSize: ScreenUtil().setSp(13)
...@@ -149,7 +152,7 @@ messageList(list) { ...@@ -149,7 +152,7 @@ messageList(list) {
], ],
), ),
Text( Text(
'半框眼镜真的很搭配', list.content,
style: TextStyle( style: TextStyle(
color: ALColors.Color323232, color: ALColors.Color323232,
fontSize: ScreenUtil().setSp(13) fontSize: ScreenUtil().setSp(13)
...@@ -158,7 +161,11 @@ messageList(list) { ...@@ -158,7 +161,11 @@ messageList(list) {
overflow: TextOverflow.ellipsis overflow: TextOverflow.ellipsis
), ),
Text( Text(
'12小时', // TimelineUtil.format(list.time,
// locTimeMillis: DateTime.now().millisecondsSinceEpoch,
// locale: 'zh',
// dayFormat: DayFormat.Full),
list.time.toString(),
style: TextStyle( style: TextStyle(
color: Color(0xfff8e8e8e), color: Color(0xfff8e8e8e),
fontSize: ScreenUtil().setSp(10) fontSize: ScreenUtil().setSp(10)
...@@ -170,7 +177,7 @@ messageList(list) { ...@@ -170,7 +177,7 @@ messageList(list) {
], ],
), ),
Image.network( Image.network(
'http://alpha-s.gmeiapp.com/2018/12/24/2b9fca0930-w', list.repliedContent.content,
width: ScreenUtil().setWidth(48), width: ScreenUtil().setWidth(48),
fit: BoxFit.fill, fit: BoxFit.fill,
) )
......
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:gmalpha_flutter/NewMessageModel/page/MessagePage.dart';
void jumpToMs(BuildContext context){
Navigator.push(
context,
new MaterialPageRoute(
builder: (context) => MessagePage('') ,
));
}
\ No newline at end of file
...@@ -12,14 +12,19 @@ import 'package:gmalpha_flutter/commonModel/net/DioUtil.dart'; ...@@ -12,14 +12,19 @@ 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();
print("lsy -->INIT!!!");
}
init(BuildContext context) { init(BuildContext context) {
titleLive.notifyView(userName); titleLive.notifyView(userName);
...@@ -37,5 +42,6 @@ class ReputationsModel extends BaseModel { ...@@ -37,5 +42,6 @@ class ReputationsModel extends BaseModel {
void dispose() { void dispose() {
prestigeLive.dispost(); prestigeLive.dispost();
titleLive.dispost(); titleLive.dispost();
print("lsy -->DISPOST!!!");
} }
} }
...@@ -16,6 +16,7 @@ class ReputationsPage extends StatefulWidget { ...@@ -16,6 +16,7 @@ class ReputationsPage extends StatefulWidget {
ReputationsModel _model; ReputationsModel _model;
ReputationsPage(int userId, String userName, String fromPage) { ReputationsPage(int userId, String userName, String fromPage) {
print("lsy --> ONEN PAGE");
_model = new ReputationsModel(userId, userName, fromPage); _model = new ReputationsModel(userId, userName, fromPage);
} }
...@@ -60,7 +61,7 @@ class ReputationsState extends BasePage<ReputationsPage> { ...@@ -60,7 +61,7 @@ class ReputationsState extends BasePage<ReputationsPage> {
RouterCenterImpl() RouterCenterImpl()
.findBuriedRouter() .findBuriedRouter()
?.onClick(pageName(), "return"); ?.onClick(pageName(), "return");
Navigator.pop(context,""); Navigator.pop(context, "");
}, },
// child: Image.asset("images/nav_back.png"), // child: Image.asset("images/nav_back.png"),
child: Center( child: Center(
...@@ -232,8 +233,8 @@ class ReputationsState extends BasePage<ReputationsPage> { ...@@ -232,8 +233,8 @@ class ReputationsState extends BasePage<ReputationsPage> {
@override @override
void dispose() { void dispose() {
super.dispose();
_model.dispose(); _model.dispose();
super.dispose();
} }
@override @override
......
...@@ -7,12 +7,13 @@ import 'package:flutter/material.dart'; ...@@ -7,12 +7,13 @@ 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() {
Api.getInstance().setDioCookie({ Api.getInstance().setDioCookie({
'Cookie': 'Cookie':
'sessionid=iro2ke6i7rc9qselm7yogjf5xvgwzn1p; _gtid=203c91f8ebd811e981aa525400e82fab6765; _gm_token=2927681570850359' 'sessionid=k96qdzwb3bquf87g32kdfbn676jkfnmk; _gtid=6bcbb61eebf411e9bfa4525400e82fab7541; _gm_token=e0fc1c1570864112'
}); });
} }
...@@ -27,62 +28,69 @@ class TestPage extends StatelessWidget { ...@@ -27,62 +28,69 @@ class TestPage extends StatelessWidget {
presigePage(context), presigePage(context),
albumPage(context), albumPage(context),
userSettingPage(context), userSettingPage(context),
attentionPage(context) attentionPage(context),
testMessagePage(context),
], ],
), ),
)); ));
} }
base(BuildContext context, Widget page, String itemName) { base(BuildContext context, VoidCallback callback, String itemName) {
return Container( return Container(
margin: EdgeInsets.fromLTRB(16, 16, 16, 0), margin: EdgeInsets.fromLTRB(16, 16, 16, 0),
child: OutlineButton( child: OutlineButton(
onPressed: () { onPressed: callback,
Navigator.push(
context,
new MaterialPageRoute(
builder: (context) => page,
));
},
child: Text(itemName), child: Text(itemName),
), ),
); );
} }
testReportPage(BuildContext context) { testMessagePage(BuildContext context) {
return base( return base(
context, context,
RouterCenterImpl() RouterCenterImpl()
.findActivityReportRouter() .findNewMessageRouter()
?.getActivityReportPage(2, 1, ''), ?.getMessagePage(''),
"报告页面"); "消息页面");
}
testReportPage(BuildContext context) {
return base(context, () {
Navigator.push(
context,
new CustomRoute(RouterCenterImpl()
.findActivityReportRouter()
?.getActivityReportPage(300, 1, '')));
}, "报告页面");
} }
presigePage(BuildContext context) { presigePage(BuildContext context) {
return base( return base(context, () {
context, Navigator.push(
RouterCenterImpl() context,
.findPrestigeRouter() new CustomRoute(RouterCenterImpl()
?.getReputationsPage(1, "ww", "ww"), .findPrestigeRouter()
"专家声望页面"); ?.getReputationsPage(1, "ww", "ww")));
}, "专家声望页面");
} }
albumPage(BuildContext context) { albumPage(BuildContext context) {
return base( return base(context, () {
context, Navigator.push(
RouterCenterImpl().findAlbumRouter()?.getAlbumPage( context,
"com.example.gengmei_flutter_plugin_example", true, 1, null), new CustomRoute(RouterCenterImpl().findAlbumRouter()?.getAlbumPage(
"相册页面"); "com.example.gengmei_flutter_plugin_example", true, 1, null)));
}, "相册页面");
} }
userSettingPage(BuildContext context) { userSettingPage(BuildContext context) {
return base( return base(context, () {
context, Navigator.push(
RouterCenterImpl() context,
.findUserRouter() new CustomRoute(RouterCenterImpl()
?.getUserSettingPage("241765327", "NULL"), .findUserRouter()
"设置页面"); ?.getUserSettingPage("241765462", "NULL")));
}, "设置页面");
} }
attentionPage(BuildContext context) { attentionPage(BuildContext context) {
......
/*
* @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;
})));
}
...@@ -9,6 +9,7 @@ class LiveData<T> { ...@@ -9,6 +9,7 @@ class LiveData<T> {
T data; T data;
LiveData() { LiveData() {
print("!!!! ${_controller == null}");
this._controller = new StreamController<T>(); this._controller = new StreamController<T>();
} }
...@@ -22,6 +23,7 @@ class LiveData<T> { ...@@ -22,6 +23,7 @@ class LiveData<T> {
} }
void dispost() { void dispost() {
data = null;
_controller.close(); _controller.close();
} }
} }
...@@ -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,6 @@ class _MyAppState extends State<MyApp> { ...@@ -28,7 +27,6 @@ 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),
'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) {
Toast.show(context, "提交成功");
Navigator.pop(context);
}).onError((error) {
Toast.show(context, "提交失败");
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; class CommentSuggestPage extends StatefulWidget {
CommentSuggest(this.params); var _model;
Widget build(BuildContext context) { CommentSuggestPage(String refer) {
_model = CommentModel(refer);
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 @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(
...@@ -114,7 +77,7 @@ class _CommentSuggestPageState extends State<CommentSuggestPage> { ...@@ -114,7 +77,7 @@ class _CommentSuggestPageState extends State<CommentSuggestPage> {
margin: EdgeInsets.only(left: 30, right: 30, top: 40), margin: EdgeInsets.only(left: 30, right: 30, top: 40),
// padding: EdgeInsets.only(bottom: 10), // padding: EdgeInsets.only(bottom: 10),
decoration: BoxDecoration( decoration: BoxDecoration(
border: Border( border: Border(
bottom: BorderSide(color: ALColors.ColorC4C4C4), bottom: BorderSide(color: ALColors.ColorC4C4C4),
)), )),
alignment: Alignment.centerLeft, alignment: Alignment.centerLeft,
...@@ -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:
...@@ -157,44 +124,20 @@ class _CommentSuggestPageState extends State<CommentSuggestPage> { ...@@ -157,44 +124,20 @@ 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() { @override
// NativeFlutterTransferPlugin.track('click_comment_suggest', {'comment_id': '10086'}); String pageName() {
confimSuggestInfo(); return "comment_arguement";
} }
void confimSuggestInfo() { @override
BaseOptions options = DioUtil.getDefOptions(); String referrer() {
final cookie = new Map<String, dynamic>.from(widget.nativeCookie); return _model.refer;
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);
}
});
} }
} }
...@@ -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");
UserRepository.getInstance().getUserInfo(userid).listen((data) { if (value == null || value != userid) {
print(data); UserRepository.getInstance().getUserInfo(userid).listen((data) {
}).onError((error) { print(data);
print(error); nameLive.notifyView(data?.data?.nickName);
Toast.show(context, "error"); cityLive.notifyView(data?.data?.countryInfo?.name);
}); headImgLive.notifyView(data?.data?.profilePic);
} else { }).onError((error) {
UserEntityImpl().getnickName().listen((data) { print(error);
nameLive.notifyView(data); Toast.show(context, error);
}).onError((error) { });
print(error); } else {
Toast.debugShow(context, error); UserEntityImpl().getnickName().listen((data) {
}); print("NICK $data");
UserEntityImpl().getcountryInfoName().listen((data) { nameLive.notifyView(data);
cityLive.notifyView(data); }).onError((error) {
}).onError((error) { print(error);
print(error); Toast.debugShow(context, error);
Toast.debugShow(context, error); });
}); UserEntityImpl().getcountryInfoName().listen((data) {
UserEntityImpl().getprofilePic().listen((value) { print("con $data");
headImgLive.notifyView(value); cityLive.notifyView(data);
}).onError((error) { }).onError((error) {
print(error); print(error);
Toast.debugShow(context, error); Toast.debugShow(context, error);
}); });
} UserEntityImpl().getprofilePic().listen((value) {
print("head $value");
headImgLive.notifyView(value);
}).onError((error) {
print(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,88 +24,93 @@ class UserEntity { ...@@ -24,88 +24,93 @@ 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;
UserEntity( UserEntity(
{this.userId, {this.userId,
this.nickName, this.nickName,
this.profilePic, this.profilePic,
this.hasAnswered, this.hasAnswered,
this.hasScanFace, this.hasScanFace,
this.id, this.id,
this.gender, this.gender,
this.cityId, this.cityId,
this.birth, this.birth,
this.countryId, this.countryId,
this.logined, this.logined,
this.detailSetted, this.detailSetted,
this.tagSetted, this.tagSetted,
this.questionUrl, this.questionUrl,
this.isBind, this.isBind,
this.countryInfoName, this.countryInfoName,
this.countryInfoId, this.countryInfoId,
this.countryInfoLanguage, this.countryInfoLanguage,
this.insBindId, this.insBindId,
this.registerTime}); this.registerTime});
UserEntity.fromJson(Map<String, dynamic> json) { UserEntity.fromJson(Map<String, dynamic> json) {
userId = json['user_id']; userId = json['user_id'];
...@@ -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)));
}
...@@ -113,6 +113,13 @@ packages: ...@@ -113,6 +113,13 @@ packages:
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.14.11" version: "1.14.11"
common_utils:
dependency: "direct main"
description:
name: common_utils
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.1.3"
convert: convert:
dependency: transitive dependency: transitive
description: description:
...@@ -155,6 +162,13 @@ packages: ...@@ -155,6 +162,13 @@ packages:
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.2.7" version: "1.2.7"
decimal:
dependency: transitive
description:
name: decimal
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.3.5"
dio: dio:
dependency: "direct main" dependency: "direct main"
description: description:
...@@ -447,6 +461,13 @@ packages: ...@@ -447,6 +461,13 @@ packages:
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "2.0.3" version: "2.0.3"
rational:
dependency: transitive
description:
name: rational
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.3.6"
rxdart: rxdart:
dependency: "direct main" dependency: "direct main"
description: description:
......
...@@ -31,6 +31,7 @@ dependencies: ...@@ -31,6 +31,7 @@ dependencies:
# gengmei_flutter_plugin: ^0.0.731 # gengmei_flutter_plugin: ^0.0.731
cached_network_image: ^1.1.1 cached_network_image: ^1.1.1
flutter_screenutil: ^0.5.3 flutter_screenutil: ^0.5.3
common_utils: ^1.1.3
gengmei_flutter_plugin: gengmei_flutter_plugin:
git: git:
url: 'git@git.wanmeizhensuo.com:linshengyu/flutter_plugin.git' url: 'git@git.wanmeizhensuo.com:linshengyu/flutter_plugin.git'
......
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