提交 b1a3e7e4 authored 作者: yueweilu's avatar yueweilu

1、笔记列表

2、错题列表
上级 6dc2c36c
...@@ -31,5 +31,42 @@ abstract class MineAPI { ...@@ -31,5 +31,42 @@ abstract class MineAPI {
}); });
} }
/// 3、笔记
///
static Future <List<CourseModel>> note({
int page = 1,
int limit = 10,
}) async {
final result = await HttpService.to.post(
'/v1/members/Information/myNotes',
params: {
'page': page,
'pageSize': limit,
},
);
if (result.data is! Map && result.data['list'] is! List) return [];
return List.generate(result.data['list'].length, (index){
return CourseModel.fromJson(result.data['list'][index]);
});
}
static Future <List<CourseModel>> wrong({
int page = 1,
int limit = 10,
}) async {
final result = await HttpService.to.post(
'/v1/members/Information/myWrongQuestion',
params: {
'page': page,
'pageSize': limit,
},
);
if (result.data is! Map && result.data['list'] is! List) return [];
return List.generate(result.data['list'].length, (index){
return CourseModel.fromJson(result.data['list'][index]);
});
}
} }
\ No newline at end of file
...@@ -30,7 +30,11 @@ class CourseModel { ...@@ -30,7 +30,11 @@ class CourseModel {
this.vipPrice, this.vipPrice,
this.status, this.status,
this.cartId, this.cartId,
this.selected = false this.selected = false,
///
/// 笔记
this.notesNum,
/// ///
}); });
...@@ -55,6 +59,11 @@ class CourseModel { ...@@ -55,6 +59,11 @@ class CourseModel {
cartId = json['cart_id']; cartId = json['cart_id'];
selected = false; selected = false;
/// ///
/// 笔记
notesNum = json['notes_num'];
///
} }
num? bookId; num? bookId;
String? bookName; String? bookName;
...@@ -78,6 +87,10 @@ class CourseModel { ...@@ -78,6 +87,10 @@ class CourseModel {
late bool selected; late bool selected;
/// ///
/// 笔记
num? notesNum;
///
...@@ -122,6 +135,10 @@ class CourseModel { ...@@ -122,6 +135,10 @@ class CourseModel {
num? cartId, num? cartId,
/// ///
/// 笔记
num? notesNum,
///
}) => CourseModel( bookId: bookId ?? this.bookId, }) => CourseModel( bookId: bookId ?? this.bookId,
bookName: bookName ?? this.bookName, bookName: bookName ?? this.bookName,
authors: authors ?? this.authors, authors: authors ?? this.authors,
...@@ -140,6 +157,11 @@ class CourseModel { ...@@ -140,6 +157,11 @@ class CourseModel {
status: status ?? this.status, status: status ?? this.status,
cartId: cartId ?? this.cartId, cartId: cartId ?? this.cartId,
/// ///
/// 笔记
notesNum: notesNum ?? this.notesNum,
///
); );
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
...@@ -160,6 +182,7 @@ class CourseModel { ...@@ -160,6 +182,7 @@ class CourseModel {
map['vip_price'] = vipPrice; map['vip_price'] = vipPrice;
map['status'] = status; map['status'] = status;
map['cart_id'] = cartId; map['cart_id'] = cartId;
map['notes_num'] = notesNum;
return map; return map;
} }
......
...@@ -42,7 +42,6 @@ class BookshopController extends GetxController { ...@@ -42,7 +42,6 @@ class BookshopController extends GetxController {
// 如果是刷新 清理数据 // 如果是刷新 清理数据
if (isRefresh) carts.clear(); if (isRefresh) carts.clear();
carts.addAll(result); carts.addAll(result);
carts.addAll(_test());
_page ++; _page ++;
_noMore = result.length < _limit; _noMore = result.length < _limit;
update(); update();
......
...@@ -40,11 +40,13 @@ class BuildCounter extends StatelessWidget { ...@@ -40,11 +40,13 @@ class BuildCounter extends StatelessWidget {
child: Container( child: Container(
margin: const EdgeInsets.symmetric(vertical: 9), margin: const EdgeInsets.symmetric(vertical: 9),
decoration: BoxDecoration( decoration: BoxDecoration(
color: AppTheme.primary, borderRadius: BorderRadius.circular(17.5),
borderRadius: BorderRadius.circular(15), color: AppTheme.primary
), ),
padding: const EdgeInsets.symmetric(vertical: 5,horizontal: 18), // height: 35,
child: const Text('结算(2)',style: TextStyle(color: Colors.white,fontSize: 12,fontWeight: FontWeight.w500),), alignment: Alignment.center,
padding: const EdgeInsets.symmetric(vertical: 8,horizontal: 20),
child: Text('结算(2)',style: TextStyle(fontSize: 14,color: Colors.white,height: 1.1,fontWeight: Fonts.medium),),
), ),
) )
], ],
......
...@@ -42,9 +42,9 @@ class MineController extends GetxController { ...@@ -42,9 +42,9 @@ class MineController extends GetxController {
void getInfo() async { void getInfo() async {
userInfo = await MineAPI.userInfo(); userInfo = await MineAPI.userInfo();
reads = [ reads = [
ReadModel(name: '笔记',value: userInfo['note_nums'].toString(),), ReadModel(name: '笔记',value: userInfo['note_nums'].toString(),link: Routes.note),
ReadModel(name: '讨论',value: userInfo['comment_nums'].toString()), ReadModel(name: '讨论',value: userInfo['comment_nums'].toString()),
ReadModel(name: '错题',value: userInfo['wrong_nums'].toString()), ReadModel(name: '错题',value: userInfo['wrong_nums'].toString(),link: Routes.wrong),
ReadModel(name: '收藏',value: userInfo['collect_nums'].toString(),link: Routes.love) ReadModel(name: '收藏',value: userInfo['collect_nums'].toString(),link: Routes.love)
]; ];
accounts = [ accounts = [
......
part of user_notes;
class UserNoteController extends GetxController {
final EasyRefreshController refreshController = EasyRefreshController(
controlFinishLoad: true,
controlFinishRefresh: true,
);
List<CourseModel> notes = [];
final int _limit = 10;
int _page = 1;
bool _noMore = false;
@override
void onClose() {
refreshController.dispose();
super.onClose();
}
/// 获取课程内图书列表
Future<void> _getNotes([bool isRefresh = false]) async {
if (isRefresh) _page = 1;
// 网路请求
final result = await MineAPI.note(
page: _page,
limit: _limit
);
// 如果是刷新 清理数据
if (isRefresh) notes.clear();
notes.addAll(_test());
notes.addAll(result);
_page ++;
_noMore = result.length < _limit;
update();
}
void onRefresh() async {
try {
await _getNotes(true);
refreshController.finishRefresh(IndicatorResult.success);
refreshController.resetFooter();
} catch (error) {
refreshController.finishRefresh(IndicatorResult.fail);
}
}
void onLoading() async {
if (_noMore) {
refreshController.finishLoad(IndicatorResult.noMore);
return;
}
try {
await _getNotes();
refreshController.finishLoad();
} catch (error) {
refreshController.finishLoad(IndicatorResult.fail);
}
}
List<CourseModel> _test(){
return [
CourseModel(),
CourseModel(),
CourseModel(),
];
}
}
\ No newline at end of file
library user_notes;
import 'package:easy_refresh/easy_refresh.dart';
import 'package:flutter/material.dart';
import 'package:flutter_book/apis/index.dart';
import 'package:flutter_book/theme.dart';
import 'package:flutter_book/widgets/index.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import '../../models/index.dart';
import '../../utils/index.dart';
part 'view.dart';
part 'controller.dart';
part 'widgets/item.dart';
\ No newline at end of file
part of user_notes;
class UserNotePage extends StatefulWidget {
const UserNotePage({Key? key}) : super(key: key);
@override
State<UserNotePage> createState() => _UserNotePageState();
}
class _UserNotePageState extends State<UserNotePage> {
@override
Widget build(BuildContext context) {
return GetBuilder<UserNoteController>(
init: UserNoteController(),
builder:(controller)=> Scaffold(
appBar: AppBar(
centerTitle: true,
title: const Text('笔记'),
),
body: Container(
margin: const EdgeInsets.all(10),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8),
// color: Colors.yellow,
boxShadow: [
BoxShadow(
color: const Color(0xFFC7C7C7).withOpacity(0.5),
offset: const Offset(3, 0),
blurRadius: 10.w,
spreadRadius: 0.w,
),
],
),
child: CustomPullScrollView(
controller: controller.refreshController,
onRefresh: controller.onRefresh,
onLoading: controller.onLoading,
child: SingleChildScrollView(
child: Column(
children: [
Container(
padding: const EdgeInsets.only(left: 10),
height: 32,
width: double.infinity,
decoration: const BoxDecoration(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(8),
topRight: Radius.circular(8),
),
color: Colors.white,
),
alignment: Alignment.centerLeft,
child: Text('共${controller.notes.length}本书',style: const TextStyle(fontSize: 13,height: 1.5,color: Colours.c6),),
),
ListView.builder(
physics: const NeverScrollableScrollPhysics(),
shrinkWrap: true,
itemBuilder: (BuildContext context, int index){
return BuildItem(model: controller.notes[index],);
},
itemCount: controller.notes.length,
)
],
),
),
),
),
),
);
}
}
part of user_notes;
class BuildItem extends StatelessWidget {
final CourseModel model;
const BuildItem({
Key? key,
required this.model
}) : super(key: key);
@override
Widget build(BuildContext context) {
return Container(
margin: const EdgeInsets.symmetric(horizontal: 10),
child: Column(
children: [
Container(
height: 0.5,
color: Colours.cF0,
),
Container(
padding: const EdgeInsets.only(top: 12,bottom: 15),
color: Colors.red,
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
height: 87,
width: 73,
color: Colors.cyan,
),
Container(
height: 87,
margin: const EdgeInsets.only(left: 13),
color: Colors.green,
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(model.bookName??'',style: const TextStyle(fontSize: 14,height: 1.5,fontWeight: Fonts.medium,color: Colours.c3),),
Text(model.authors??'',style: const TextStyle(fontSize: 12,height: 1.5,color: Colours.c6),),
],
),
Text(model.notesNum.toString(),style: const TextStyle(fontSize: 11,height: 1.5,color: AppTheme.primary)),
],
),
)
],
),
)
],
),
);
}
}
part of user_wrong;
class UserWrongController extends GetxController {
final EasyRefreshController refreshController = EasyRefreshController(
controlFinishLoad: true,
controlFinishRefresh: true,
);
List<CourseModel> wrongs = [];
final int _limit = 10;
int _page = 1;
bool _noMore = false;
@override
void onClose() {
refreshController.dispose();
super.onClose();
}
/// 获取课程内图书列表
Future<void> _getWrongs([bool isRefresh = false]) async {
if (isRefresh) _page = 1;
// 网路请求
final result = await MineAPI.wrong(
page: _page,
limit: _limit
);
// 如果是刷新 清理数据
if (isRefresh) wrongs.clear();
wrongs.addAll(result);
_page ++;
_noMore = result.length < _limit;
update();
}
void onRefresh() async {
try {
await _getWrongs(true);
refreshController.finishRefresh(IndicatorResult.success);
refreshController.resetFooter();
} catch (error) {
refreshController.finishRefresh(IndicatorResult.fail);
}
}
void onLoading() async {
if (_noMore) {
refreshController.finishLoad(IndicatorResult.noMore);
return;
}
try {
await _getWrongs();
refreshController.finishLoad();
} catch (error) {
refreshController.finishLoad(IndicatorResult.fail);
}
}
}
\ No newline at end of file
library user_wrong;
import 'package:easy_refresh/easy_refresh.dart';
import 'package:flutter/material.dart';
import 'package:flutter_book/apis/index.dart';
import 'package:flutter_book/theme.dart';
import 'package:flutter_book/widgets/index.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import '../../models/index.dart';
import '../../utils/index.dart';
part 'view.dart';
part 'controller.dart';
part 'widgets/item.dart';
\ No newline at end of file
part of user_wrong;
class UserWrongPage extends StatefulWidget {
const UserWrongPage({Key? key}) : super(key: key);
@override
State<UserWrongPage> createState() => _UserWrongPageState();
}
class _UserWrongPageState extends State<UserWrongPage> {
@override
Widget build(BuildContext context) {
return GetBuilder<UserWrongController>(
init: UserWrongController(),
builder:(controller)=> Scaffold(
appBar: AppBar(
centerTitle: true,
title: const Text('错题'),
),
body: Container(
margin: const EdgeInsets.all(10),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8),
// color: Colors.yellow,
boxShadow: [
BoxShadow(
color: const Color(0xFFC7C7C7).withOpacity(0.5),
offset: const Offset(3, 0),
blurRadius: 10.w,
spreadRadius: 0.w,
),
],
),
child: CustomPullScrollView(
controller: controller.refreshController,
onRefresh: controller.onRefresh,
onLoading: controller.onLoading,
child: SingleChildScrollView(
child: Column(
children: [
Container(
padding: const EdgeInsets.only(left: 10),
height: 32,
width: double.infinity,
decoration: const BoxDecoration(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(8),
topRight: Radius.circular(8),
),
color: Colors.white,
),
alignment: Alignment.centerLeft,
child: Text('共${controller.wrongs.length}本书',style: const TextStyle(fontSize: 13,height: 1.5,color: Colours.c6),),
),
ListView.builder(
physics: const NeverScrollableScrollPhysics(),
shrinkWrap: true,
itemBuilder: (BuildContext context, int index){
return BuildItem(model: controller.wrongs[index],);
},
itemCount: controller.wrongs.length,
)
],
),
),
),
),
),
);
}
}
part of user_wrong;
class BuildItem extends StatelessWidget {
final CourseModel model;
const BuildItem({
Key? key,
required this.model
}) : super(key: key);
@override
Widget build(BuildContext context) {
return Container(
margin: const EdgeInsets.symmetric(horizontal: 10),
child: Column(
children: [
Container(
height: 0.5,
color: Colours.cF0,
),
Container(
padding: const EdgeInsets.only(top: 12,bottom: 15),
color: Colors.red,
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
height: 87,
width: 73,
color: Colors.cyan,
),
Container(
height: 87,
margin: const EdgeInsets.only(left: 13),
color: Colors.green,
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(model.bookName??'',style: const TextStyle(fontSize: 14,height: 1.5,fontWeight: Fonts.medium,color: Colours.c3),),
Text(model.authors??'',style: const TextStyle(fontSize: 12,height: 1.5,color: Colours.c6),),
],
),
Text(model.notesNum.toString(),style: const TextStyle(fontSize: 11,height: 1.5,color: AppTheme.primary)),
],
),
)
],
),
)
],
),
);
}
}
...@@ -22,6 +22,8 @@ import 'package:flutter_book/pages/user_info/index.dart'; ...@@ -22,6 +22,8 @@ import 'package:flutter_book/pages/user_info/index.dart';
import 'package:flutter_book/pages/user_love/index.dart'; import 'package:flutter_book/pages/user_love/index.dart';
import 'package:flutter_book/pages/user_msg/index.dart'; import 'package:flutter_book/pages/user_msg/index.dart';
import 'package:flutter_book/pages/user_nick/index.dart'; import 'package:flutter_book/pages/user_nick/index.dart';
import 'package:flutter_book/pages/user_notes/index.dart';
import 'package:flutter_book/pages/user_wrong/index.dart';
import 'package:flutter_book/pages/web/index.dart'; import 'package:flutter_book/pages/web/index.dart';
import 'package:go_router/go_router.dart'; import 'package:go_router/go_router.dart';
......
...@@ -70,6 +70,10 @@ abstract class Routes { ...@@ -70,6 +70,10 @@ abstract class Routes {
static const studyHistory = 'study_history'; static const studyHistory = 'study_history';
// 我的收藏 // 我的收藏
static const love = 'love'; static const love = 'love';
// 笔记
static const note = 'note';
// 错题
static const wrong = 'wrong';
static final GoRouter config = GoRouter( static final GoRouter config = GoRouter(
...@@ -284,6 +288,24 @@ abstract class Routes { ...@@ -284,6 +288,24 @@ abstract class Routes {
child: const BookShopPage() child: const BookShopPage()
) )
), ),
GoRoute(
path: '/$note',
name: note,
pageBuilder: (context, state) =>CupertinoPage(
name: state.uri.toString(),
key: state.pageKey,
child: const UserNotePage()
)
),
GoRoute(
path: '/$wrong',
name: wrong,
pageBuilder: (context, state) =>CupertinoPage(
name: state.uri.toString(),
key: state.pageKey,
child: const UserWrongPage()
)
),
] ]
); );
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论