提交 1550099f authored 作者: yueweilu's avatar yueweilu

1、消息跳转

2、消息已读状态
上级 11406f8d
...@@ -34,7 +34,6 @@ abstract class CommonAPI { ...@@ -34,7 +34,6 @@ abstract class CommonAPI {
); );
if (result.data is! Map && result.data['list'] is! List) return []; if (result.data is! Map && result.data['list'] is! List) return [];
return List.generate(result.data['list'].length, (index){ return List.generate(result.data['list'].length, (index){
print(result.data['list'][index]);
return MsgModel.fromJson(result.data['list'][index]); return MsgModel.fromJson(result.data['list'][index]);
}); });
} }
......
...@@ -23,7 +23,7 @@ class MsgModel { ...@@ -23,7 +23,7 @@ class MsgModel {
title = json['title']; title = json['title'];
content = json['content']; content = json['content'];
status = json['status']; status = json['status'];
urlId = json['url_id']; urlId = json['url_id'] != null ? UrlIdModel.fromJson(json['url_id']) : null;
createTime = json['create_time']; createTime = json['create_time'];
} }
num? id; num? id;
...@@ -31,7 +31,7 @@ class MsgModel { ...@@ -31,7 +31,7 @@ class MsgModel {
String? title; String? title;
String? content; String? content;
num? status; num? status;
num? urlId; UrlIdModel? urlId;
String? createTime; String? createTime;
MsgModel copyWith({ MsgModel copyWith({
num? id, num? id,
...@@ -39,7 +39,7 @@ class MsgModel { ...@@ -39,7 +39,7 @@ class MsgModel {
String? title, String? title,
String? content, String? content,
num? status, num? status,
num? urlId, UrlIdModel? urlId,
String? createTime, String? createTime,
}) => MsgModel( }) => MsgModel(
id: id ?? this.id, id: id ?? this.id,
...@@ -57,9 +57,36 @@ class MsgModel { ...@@ -57,9 +57,36 @@ class MsgModel {
map['title'] = title; map['title'] = title;
map['content'] = content; map['content'] = content;
map['status'] = status; map['status'] = status;
map['url_id'] = urlId; if (urlId != null) {
map['url_id'] = urlId?.toJson();
}
map['create_time'] = createTime; map['create_time'] = createTime;
return map; return map;
} }
} }
class UrlIdModel {
UrlIdModel({
this.bookId,
this.chapterId,});
UrlIdModel.fromJson(dynamic json) {
bookId = json['book_id'];
chapterId = json['chapter_id'];
}
num? bookId;
num? chapterId;
UrlIdModel copyWith({ num? bookId,
num? chapterId,
}) => UrlIdModel( bookId: bookId ?? this.bookId,
chapterId: chapterId ?? this.chapterId,
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['book_id'] = bookId;
map['chapter_id'] = chapterId;
return map;
}
}
\ No newline at end of file
...@@ -20,7 +20,7 @@ class MineController extends GetxController { ...@@ -20,7 +20,7 @@ class MineController extends GetxController {
@override @override
void onReady() { void onReady() {
_getAds(); _getAds();
_getNums(); getNums();
getInfo(); getInfo();
super.onReady(); super.onReady();
} }
...@@ -33,7 +33,7 @@ class MineController extends GetxController { ...@@ -33,7 +33,7 @@ class MineController extends GetxController {
} }
/// 消息未读数 /// 消息未读数
void _getNums() async { void getNums() async {
num = await CommonAPI.num(); num = await CommonAPI.num();
update(); update();
} }
......
...@@ -42,9 +42,13 @@ class _MinePageState extends State<MinePage> { ...@@ -42,9 +42,13 @@ class _MinePageState extends State<MinePage> {
onPressed: () => context.pushNamed(Routes.set), onPressed: () => context.pushNamed(Routes.set),
), ),
GestureDetector( GestureDetector(
onTap: (){ onTap: () async{
context.pushNamed(Routes.msgs); final result = await context.pushNamed(Routes.msgs);
// controller.logout(context);
print('---------------------------------1111$result');
if (result == true){
controller.getNums();
}
}, },
child: badges.Badge( child: badges.Badge(
position: badges.BadgePosition.topEnd(top: -5, end: 0), position: badges.BadgePosition.topEnd(top: -5, end: 0),
......
...@@ -8,6 +8,7 @@ import 'package:flutter_book/utils/index.dart'; ...@@ -8,6 +8,7 @@ import 'package:flutter_book/utils/index.dart';
import 'package:flutter_book/widgets/index.dart'; import 'package:flutter_book/widgets/index.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:go_router/go_router.dart';
import '../../models/index.dart'; import '../../models/index.dart';
......
...@@ -11,7 +11,12 @@ class UserCouponPage extends StatefulWidget { ...@@ -11,7 +11,12 @@ class UserCouponPage extends StatefulWidget {
class _UserCouponPageState extends State<UserCouponPage> { class _UserCouponPageState extends State<UserCouponPage> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return GetBuilder<UserCouponController>( return WillPopScope(
onWillPop: () async {
context.pop(true);
return false;
},
child: GetBuilder<UserCouponController>(
init: UserCouponController(), init: UserCouponController(),
builder:(controller) => Scaffold( builder:(controller) => Scaffold(
appBar: AppBar( appBar: AppBar(
...@@ -44,6 +49,7 @@ class _UserCouponPageState extends State<UserCouponPage> { ...@@ -44,6 +49,7 @@ class _UserCouponPageState extends State<UserCouponPage> {
), ),
), ),
), ),
),
); );
} }
} }
...@@ -27,14 +27,36 @@ class MsgPage extends StatelessWidget { ...@@ -27,14 +27,36 @@ class MsgPage extends StatelessWidget {
onLoading: controller.onLoading, onLoading: controller.onLoading,
child: ListView.builder( child: ListView.builder(
itemBuilder: (BuildContext context, int index){ itemBuilder: (BuildContext context, int index){
MsgModel model = controller.msgs[index];
return GestureDetector( return GestureDetector(
child: BuildItem(model: controller.msgs[index],), child: BuildItem(model:model,),
onTap: () async{ onTap: () async{
controller.read(controller.msgs[index].id.toString()); controller.read(model.id.toString());
final result = await context.pushNamed(Routes.coin);
if(model.type == 1){
// 1订单支付快要超时(跳转订单详情)
///TODO:
}else if (model.type == 2){
// 2 购买完成三天未评价(跳转订单列表--已完成)
///TODO:
}else if (model.type == 3){
// 3 讨论有人回复的时候 (跳转对应书籍的讨论页面)
}
else if (model.type == 4){
// 4 订单完成后有新的积分增加(跳转用户积分记录页)
final result = await context.pushNamed(Routes.point);
if (result == true){
controller.onRefresh();
}
}else if (model.type == 5){
// 5后台直接发放给指定用户优惠券(跳转到用户优惠券页)
final result = await context.pushNamed(Routes.coupon);
if (result == true){ if (result == true){
controller.onRefresh(); controller.onRefresh();
} }
}
}, },
); );
}, },
......
...@@ -7,6 +7,7 @@ import 'package:flutter_book/utils/index.dart'; ...@@ -7,6 +7,7 @@ import 'package:flutter_book/utils/index.dart';
import 'package:flutter_book/widgets/index.dart'; import 'package:flutter_book/widgets/index.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:go_router/go_router.dart';
import '../../apis/index.dart'; import '../../apis/index.dart';
import '../../models/index.dart'; import '../../models/index.dart';
......
...@@ -10,7 +10,12 @@ class UserPointPage extends StatefulWidget { ...@@ -10,7 +10,12 @@ class UserPointPage extends StatefulWidget {
class _UserPointPageState extends State<UserPointPage> { class _UserPointPageState extends State<UserPointPage> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return GetBuilder<UserPointController>( return WillPopScope(
onWillPop: () async {
context.pop(true);
return false;
},
child: GetBuilder<UserPointController>(
init: UserPointController(), init: UserPointController(),
builder: (controller) => Scaffold( builder: (controller) => Scaffold(
appBar: AppBar( appBar: AppBar(
...@@ -43,6 +48,7 @@ class _UserPointPageState extends State<UserPointPage> { ...@@ -43,6 +48,7 @@ class _UserPointPageState extends State<UserPointPage> {
), ),
), ),
), ),
),
); );
} }
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论