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

1、消息跳转

2、消息已读状态
上级 11406f8d
......@@ -34,7 +34,6 @@ abstract class CommonAPI {
);
if (result.data is! Map && result.data['list'] is! List) return [];
return List.generate(result.data['list'].length, (index){
print(result.data['list'][index]);
return MsgModel.fromJson(result.data['list'][index]);
});
}
......
......@@ -23,7 +23,7 @@ class MsgModel {
title = json['title'];
content = json['content'];
status = json['status'];
urlId = json['url_id'];
urlId = json['url_id'] != null ? UrlIdModel.fromJson(json['url_id']) : null;
createTime = json['create_time'];
}
num? id;
......@@ -31,7 +31,7 @@ class MsgModel {
String? title;
String? content;
num? status;
num? urlId;
UrlIdModel? urlId;
String? createTime;
MsgModel copyWith({
num? id,
......@@ -39,7 +39,7 @@ class MsgModel {
String? title,
String? content,
num? status,
num? urlId,
UrlIdModel? urlId,
String? createTime,
}) => MsgModel(
id: id ?? this.id,
......@@ -57,9 +57,36 @@ class MsgModel {
map['title'] = title;
map['content'] = content;
map['status'] = status;
map['url_id'] = urlId;
if (urlId != null) {
map['url_id'] = urlId?.toJson();
}
map['create_time'] = createTime;
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 {
@override
void onReady() {
_getAds();
_getNums();
getNums();
getInfo();
super.onReady();
}
......@@ -33,7 +33,7 @@ class MineController extends GetxController {
}
/// 消息未读数
void _getNums() async {
void getNums() async {
num = await CommonAPI.num();
update();
}
......
......@@ -42,9 +42,13 @@ class _MinePageState extends State<MinePage> {
onPressed: () => context.pushNamed(Routes.set),
),
GestureDetector(
onTap: (){
context.pushNamed(Routes.msgs);
// controller.logout(context);
onTap: () async{
final result = await context.pushNamed(Routes.msgs);
print('---------------------------------1111$result');
if (result == true){
controller.getNums();
}
},
child: badges.Badge(
position: badges.BadgePosition.topEnd(top: -5, end: 0),
......
......@@ -8,6 +8,7 @@ import 'package:flutter_book/utils/index.dart';
import 'package:flutter_book/widgets/index.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:go_router/go_router.dart';
import '../../models/index.dart';
......
......@@ -11,7 +11,12 @@ class UserCouponPage extends StatefulWidget {
class _UserCouponPageState extends State<UserCouponPage> {
@override
Widget build(BuildContext context) {
return GetBuilder<UserCouponController>(
return WillPopScope(
onWillPop: () async {
context.pop(true);
return false;
},
child: GetBuilder<UserCouponController>(
init: UserCouponController(),
builder:(controller) => Scaffold(
appBar: AppBar(
......@@ -44,6 +49,7 @@ class _UserCouponPageState extends State<UserCouponPage> {
),
),
),
),
);
}
}
......@@ -27,14 +27,36 @@ class MsgPage extends StatelessWidget {
onLoading: controller.onLoading,
child: ListView.builder(
itemBuilder: (BuildContext context, int index){
MsgModel model = controller.msgs[index];
return GestureDetector(
child: BuildItem(model: controller.msgs[index],),
child: BuildItem(model:model,),
onTap: () async{
controller.read(controller.msgs[index].id.toString());
final result = await context.pushNamed(Routes.coin);
controller.read(model.id.toString());
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){
controller.onRefresh();
}
}
},
);
},
......
......@@ -7,6 +7,7 @@ import 'package:flutter_book/utils/index.dart';
import 'package:flutter_book/widgets/index.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:go_router/go_router.dart';
import '../../apis/index.dart';
import '../../models/index.dart';
......
......@@ -10,7 +10,12 @@ class UserPointPage extends StatefulWidget {
class _UserPointPageState extends State<UserPointPage> {
@override
Widget build(BuildContext context) {
return GetBuilder<UserPointController>(
return WillPopScope(
onWillPop: () async {
context.pop(true);
return false;
},
child: GetBuilder<UserPointController>(
init: UserPointController(),
builder: (controller) => Scaffold(
appBar: AppBar(
......@@ -43,6 +48,7 @@ class _UserPointPageState extends State<UserPointPage> {
),
),
),
),
);
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论