提交 87a1166a authored 作者: yueweilu's avatar yueweilu

add

上级 875ca608
......@@ -132,7 +132,8 @@ class ChapterModel {
this.sort,
this.seen,
this.children,
this.selected = false
this.selected = false,
this.currentRead = false
});
ChapterModel.fromJson(dynamic json) {
......@@ -150,6 +151,7 @@ class ChapterModel {
});
}
selected = false;
currentRead = false;
}
num? id;
String? name;
......@@ -159,6 +161,7 @@ class ChapterModel {
num? sort;
num? seen;
late bool selected;
late bool currentRead;
List<ChapterModel>? children;
ChapterModel copyWith({ num? id,
String? name,
......@@ -589,3 +592,12 @@ class SearchAllModel {
}
class PopBackModel {
PopBackModel({
required this.chapterId,
required this.back
});
String chapterId;
bool back;
}
......@@ -114,6 +114,7 @@ class _BuildItemState extends State<BuildItem> {
onTap: (){
if(chapterModel.children!.isEmpty){
widget.onTap(chapterModel);
chapterModel.currentRead= true;
}
else{
setState(() {
......
......@@ -14,6 +14,8 @@ class BookDetailController extends GetxController with GetSingleTickerProviderSt
const Tab(text: '本书信息',),
];
num currentChapterId = 0;
// 目录
List <ChapterModel> chapters = [];
// 图书
......@@ -48,6 +50,25 @@ class BookDetailController extends GetxController with GetSingleTickerProviderSt
}
}
/// 设置当前读的章节id
void setCurrentReadChapterId(){
for(ChapterModel chapterModel in chapters){
writeCurrentReadChapterIdToData(chapterModel);
}
}
void writeCurrentReadChapterIdToData(ChapterModel chapterModel){
for(ChapterModel cModel in chapterModel.children!){
cModel.currentRead = false;
if(cModel.id == currentChapterId){
cModel.currentRead = true;
cModel.selected = true;
chapterModel.selected = true;
}
writeCurrentReadChapterIdToData(chapterModel);
}
}
/// 写入特定数据
......@@ -68,6 +89,7 @@ class BookDetailController extends GetxController with GetSingleTickerProviderSt
writeData(chapters, result);
chapters = result;
setCurrentReadChapterId();
update();
}
......
......@@ -113,9 +113,11 @@ class _BookDetailPageState extends State<BookDetailPage> with SingleTickerProvid
controller.getBookDetails();
}
}else{
final result = await context.pushNamed(Routes.web,queryParameters: {'book_id': controller.bookDetails.bookId.toString(),'chapter_id': chapterModel.id.toString(),'chapter_name':chapterModel.name.toString(),'note_id':'0'},extra: controller.bookDetails);
if (result == true){
final PopBackModel? backModel = await context.pushNamed(Routes.web,queryParameters: {'book_id': controller.bookDetails.bookId.toString(),'chapter_id': chapterModel.id.toString(),'chapter_name':chapterModel.name.toString(),'note_id':'0'},extra: controller.bookDetails);
if (backModel!.back == true){
controller.getChapters();
// controller.setCurrentReadChapterId(backModel!.chapterId);
controller.currentChapterId = int.parse(backModel!.chapterId);
}
}
},
......@@ -211,9 +213,11 @@ class _BookDetailPageState extends State<BookDetailPage> with SingleTickerProvid
if(controller.bookDetails.isFree == 1){
final String chapterId = await controller.getCurrentChapterId();
final String chapterName = await controller.getCurrentChapterName();
final result = await context.pushNamed(Routes.web,queryParameters: {'book_id': controller.bookDetails.bookId.toString(),'chapter_id': chapterId,'chapter_name':chapterName,'note_id':'0'},extra: controller.bookDetails);
if (result == true){
final PopBackModel? backModel = await context.pushNamed(Routes.web,queryParameters: {'book_id': controller.bookDetails.bookId.toString(),'chapter_id': chapterId,'chapter_name':chapterName,'note_id':'0'},extra: controller.bookDetails);
if (backModel!.back == true){
controller.getChapters();
controller.currentChapterId = int.parse(backModel!.chapterId);
// controller.setCurrentReadChapterId(backModel!.chapterId);
}
}
else {
......@@ -242,9 +246,11 @@ class _BookDetailPageState extends State<BookDetailPage> with SingleTickerProvid
else{
final String chapterId = await controller.getCurrentChapterId();
final String chapterName = await controller.getCurrentChapterName();
final result = await context.pushNamed(Routes.web,queryParameters: {'book_id': controller.bookDetails.bookId.toString(),'chapter_id': chapterId,'chapter_name':chapterName,'note_id':'0'},extra: controller.bookDetails);
if (result == true){
final PopBackModel? backModel = await context.pushNamed(Routes.web,queryParameters: {'book_id': controller.bookDetails.bookId.toString(),'chapter_id': chapterId,'chapter_name':chapterName,'note_id':'0'},extra: controller.bookDetails);
if (backModel!.back == true){
controller.getChapters();
controller.currentChapterId = int.parse(backModel!.chapterId);
// controller.setCurrentReadChapterId(backModel!.chapterId);
}
}
}
......@@ -253,9 +259,11 @@ class _BookDetailPageState extends State<BookDetailPage> with SingleTickerProvid
final String chapterId = await controller.getCurrentChapterId();
final String chapterName = await controller.getCurrentChapterName();
final result = await context.pushNamed(Routes.web,queryParameters: {'book_id': controller.bookDetails.bookId.toString(),'chapter_id': chapterId,'chapter_name':chapterName,'note_id':'0'},extra: controller.bookDetails);
if (result == true){
final PopBackModel? backModel = await context.pushNamed(Routes.web,queryParameters: {'book_id': controller.bookDetails.bookId.toString(),'chapter_id': chapterId,'chapter_name':chapterName,'note_id':'0'},extra: controller.bookDetails);
if (backModel!.back == true){
controller.getChapters();
controller.currentChapterId = int.parse(backModel!.chapterId);
// controller.setCurrentReadChapterId(backModel!.chapterId);
}
}
......
......@@ -12,7 +12,7 @@ abstract class Routes {
static const web = 'read_web';
static const answer = 'answer';
static const readInfo = 'read_info';
// 支付界面
static const bookPay = 'book_pay';
......@@ -703,7 +703,18 @@ abstract class Routes {
)
)
),
GoRoute( // 知识测评
GoRoute( // 画廊 扩展阅读
path: '/$readInfo',
name: readInfo,
pageBuilder: (context, state) =>CupertinoPage(
name: state.uri.toString(),
key: state.pageKey,
child: ReadInfoPage(
params: state.uri.queryParameters,
)
)
),
GoRoute( // 图片预览
path: '/$imageView',
name: imageView,
pageBuilder: (context, state) =>BottomToTopTransitionPage(
......
......@@ -245,6 +245,7 @@ class _RequestInterceptor extends Interceptor {
Console.log('----------403---------access_token-------------------------${UserStore.to.accessToken}--------------------');
msg = '$statusCode - Unauthorized';
final newToken = await refreshToken();
Console.log('newToken----------$newToken');
if (newToken != null && newToken.isNotEmpty) {
final RequestOptions requestOptions = err.requestOptions;
final headers = requestOptions.headers;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论