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

阅读页 跳转 知识测评

上级 d40fb606
library answer;
import 'package:flutter/material.dart';
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
import '../../utils/index.dart';
part 'view.dart';
\ No newline at end of file
part of answer;
class AnswerPage extends StatefulWidget {
final Map<String,String> params;
const AnswerPage({
Key? key,
required this.params
}) : super(key: key);
@override
State<AnswerPage> createState() => _AnswerPageState();
}
class _AnswerPageState extends State<AnswerPage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('知识测评'),
),
body: InAppWebView(
initialUrlRequest: URLRequest(
url: Uri.parse(widget.params['url']??''),
),
onLoadStop: (controller, url) {
String str = '${widget.params['book_id']},${widget.params['chapter_id']},${widget.params['token']},${widget.params['position']}';
Console.log('知识测评--------传给前端的参数--------------------------------$str');
controller.evaluateJavascript(source: 'callbackInFlutterComponent("$str");');
},
onConsoleMessage: (controller, consoleMessage) {
// 接收从 WebView 发送的消息
Console.log("知识测评-------Received message from WebView-----------------------------: ${consoleMessage.message}");
},
)
);
}
}
...@@ -729,6 +729,9 @@ class ReadController extends FullLifeCycleController with GetSingleTickerProvide ...@@ -729,6 +729,9 @@ class ReadController extends FullLifeCycleController with GetSingleTickerProvide
update(); update();
} }
/// 搜索全文
/// 添加阅读时长 /// 添加阅读时长
void _addReadTime({required type}) async{ void _addReadTime({required type}) async{
final result = await LibraryAPI.addReadTime(bookId: bookId, readTypes: type); final result = await LibraryAPI.addReadTime(bookId: bookId, readTypes: type);
......
...@@ -151,13 +151,31 @@ class _ReadPageState extends State<ReadPage> { ...@@ -151,13 +151,31 @@ class _ReadPageState extends State<ReadPage> {
readController.titleInput.text = args.first.toString(); readController.titleInput.text = args.first.toString();
}); });
controller.addJavaScriptHandler(handlerName: 'answerCallBack', callback: (args){ controller.addJavaScriptHandler(handlerName: 'answerResultCallBack', callback: (args){
Console.log('监听答题回调------------------------------------------------$args'); Console.log('监听答题回调------------------------------------------------$args');
}); String chapterId = args.first[0].toString();
String position = args.first[1].toString();
String type = args.first[2].toString();
String url = '';
// 未答题
if(type == '0'){
url = kAnswer;
}
else {
url = kAnswerResult;
}
Map<String,String> params = {
'chapter_id':chapterId,
'position':position,
'url':url,
'book_id':readController.bookId,
'token':UserStore.to.token
};
Console.log('监听答题回调---------------给页面传参---------------------------------$params');
context.pushNamed(Routes.answer,queryParameters: params);
controller.addJavaScriptHandler(handlerName: 'answerResultCallBack', callback: (args){ // 跳转知识测评界面
Console.log('监听答题结果回调------------------------------------------------$args');
}); });
......
...@@ -3,6 +3,7 @@ library routes; ...@@ -3,6 +3,7 @@ library routes;
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter_book/pages/ad/index.dart'; import 'package:flutter_book/pages/ad/index.dart';
import 'package:flutter_book/pages/answer/index.dart';
import 'package:flutter_book/pages/book_detail/index.dart'; import 'package:flutter_book/pages/book_detail/index.dart';
import 'package:flutter_book/pages/book_pay/index.dart'; import 'package:flutter_book/pages/book_pay/index.dart';
import 'package:flutter_book/pages/book_score/index.dart'; import 'package:flutter_book/pages/book_score/index.dart';
......
...@@ -9,7 +9,10 @@ abstract class Routes { ...@@ -9,7 +9,10 @@ abstract class Routes {
static const ad = 'ad'; static const ad = 'ad';
static const adDetail = 'ad_detail'; static const adDetail = 'ad_detail';
static const web = 'read_web'; static const web = 'read_web';
static const answer = 'answer';
// 支付界面 // 支付界面
static const bookPay = 'book_pay'; static const bookPay = 'book_pay';
...@@ -639,6 +642,17 @@ abstract class Routes { ...@@ -639,6 +642,17 @@ abstract class Routes {
) )
) )
), ),
GoRoute( // 知识测评
path: '/$answer',
name: answer,
pageBuilder: (context, state) =>CupertinoPage(
name: state.uri.toString(),
key: state.pageKey,
child: AnswerPage(
params: state.uri.queryParameters,
)
)
),
] ]
); );
......
...@@ -23,6 +23,8 @@ const String kUserWrongDes = 'http://150.158.138.40:9200/evaluating_wrong.html'; ...@@ -23,6 +23,8 @@ const String kUserWrongDes = 'http://150.158.138.40:9200/evaluating_wrong.html';
const String kReadBook = 'http://150.158.138.40:9200/read.html'; const String kReadBook = 'http://150.158.138.40:9200/read.html';
// 答题页 // 答题页
const String kAnswer = 'http://150.158.138.40:9200/evaluating.html'; const String kAnswer = 'http://150.158.138.40:9200/evaluating.html';
// 答题结果页
const String kAnswerResult = 'http://150.158.138.40:9200/evaluating_result.html';
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论