提交 448adb05 authored 作者: maodou's avatar maodou

Merge remote-tracking branch 'origin/test' into test

...@@ -2,6 +2,8 @@ import 'package:flutter/cupertino.dart'; ...@@ -2,6 +2,8 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_book/services/index.dart'; import 'package:flutter_book/services/index.dart';
import 'package:flutter_book/store/index.dart'; import 'package:flutter_book/store/index.dart';
import 'package:flutter_book/utils/index.dart';
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
class Global { class Global {
static Future<void> init() async { static Future<void> init() async {
...@@ -9,6 +11,11 @@ class Global { ...@@ -9,6 +11,11 @@ class Global {
WidgetsFlutterBinding.ensureInitialized(); WidgetsFlutterBinding.ensureInitialized();
// 设置应用程序的首选屏幕方向 // 设置应用程序的首选屏幕方向
await SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]); await SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
// String documentRoot = await Tools.getDirectory();
// final InAppLocalhostServer localhostServer =
// InAppLocalhostServer(documentRoot: '$documentRoot/',shared: true);
// await localhostServer.start();
// print('本地服务器已成功启动,根目录为: $documentRoot');
await Future.wait([ await Future.wait([
// 配置存储 // 配置存储
......
...@@ -2,6 +2,7 @@ library models; ...@@ -2,6 +2,7 @@ library models;
import 'package:just_audio/just_audio.dart' as just_audio; import 'package:just_audio/just_audio.dart' as just_audio;
part 'response.dart'; part 'response.dart';
......
...@@ -88,6 +88,7 @@ class CouponModel { ...@@ -88,6 +88,7 @@ class CouponModel {
couponName = json['coupon_name']; couponName = json['coupon_name'];
normPrice = json['norm_price']; normPrice = json['norm_price'];
reducedPrice = json['reduced_price']; reducedPrice = json['reduced_price'];
type = json['use_status'];
} }
num? couponRecId; num? couponRecId;
...@@ -107,6 +108,7 @@ class CouponModel { ...@@ -107,6 +108,7 @@ class CouponModel {
String? couponName, String? couponName,
num? normPrice, num? normPrice,
String? reducedPrice, String? reducedPrice,
num? type,
}) => }) =>
CouponModel( CouponModel(
couponRecId: couponRecId ?? this.couponRecId, couponRecId: couponRecId ?? this.couponRecId,
...@@ -116,6 +118,7 @@ class CouponModel { ...@@ -116,6 +118,7 @@ class CouponModel {
couponName: couponName ?? this.couponName, couponName: couponName ?? this.couponName,
normPrice: normPrice ?? this.normPrice, normPrice: normPrice ?? this.normPrice,
reducedPrice: reducedPrice ?? this.reducedPrice, reducedPrice: reducedPrice ?? this.reducedPrice,
type: type ?? this.type
); );
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
...@@ -127,6 +130,7 @@ class CouponModel { ...@@ -127,6 +130,7 @@ class CouponModel {
map['coupon_name'] = couponName; map['coupon_name'] = couponName;
map['norm_price'] = normPrice; map['norm_price'] = normPrice;
map['reduced_price'] = reducedPrice; map['reduced_price'] = reducedPrice;
map['use_status'] = type;
return map; return map;
} }
} }
......
...@@ -69,23 +69,32 @@ class MsgModel { ...@@ -69,23 +69,32 @@ class MsgModel {
class UrlIdModel { class UrlIdModel {
UrlIdModel({ UrlIdModel({
this.bookId, this.bookId,
this.chapterId,}); this.chapterId,
this.orderNum
});
UrlIdModel.fromJson(dynamic json) { UrlIdModel.fromJson(dynamic json) {
bookId = json['book_id']; bookId = json['book_id'];
chapterId = json['chapter_id']; chapterId = json['chapter_id'];
orderNum = json['ordersnum'];
} }
num? bookId; num? bookId;
num? chapterId; num? chapterId;
UrlIdModel copyWith({ num? bookId, String? orderNum;
UrlIdModel copyWith({
num? bookId,
num? chapterId, num? chapterId,
}) => UrlIdModel( bookId: bookId ?? this.bookId, String? orderNum,
}) => UrlIdModel(
bookId: bookId ?? this.bookId,
chapterId: chapterId ?? this.chapterId, chapterId: chapterId ?? this.chapterId,
orderNum: orderNum ?? this.orderNum
); );
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
final map = <String, dynamic>{}; final map = <String, dynamic>{};
map['book_id'] = bookId; map['book_id'] = bookId;
map['chapter_id'] = chapterId; map['chapter_id'] = chapterId;
map['ordersnum'] = orderNum;
return map; return map;
} }
......
...@@ -52,8 +52,10 @@ class ReadController extends FullLifeCycleController with GetSingleTickerProvide ...@@ -52,8 +52,10 @@ class ReadController extends FullLifeCycleController with GetSingleTickerProvide
// 录音开始 // 录音开始
bool startRecording = false; bool startRecording = false;
// 是否存在离线文件 // 是否存在离线文件
bool isExistFile = false; bool existDownFile= false;
// 网络状态
bool netStatus = false;
///------------------------------------------ 页面 生命周期-------------------------------------------------------- ///------------------------------------------ 页面 生命周期--------------------------------------------------------
@override @override
...@@ -69,20 +71,20 @@ class ReadController extends FullLifeCycleController with GetSingleTickerProvide ...@@ -69,20 +71,20 @@ class ReadController extends FullLifeCycleController with GetSingleTickerProvide
// 上报开始阅读时间 // 上报开始阅读时间
_addReadTime(type: 'open'); _addReadTime(type: 'open');
_getChapters(); _getChapters();
final netStatus = await Tools.checkCurrentNetStatus(); netStatus = await Tools.checkCurrentNetStatus();
// 判断是否有离线文件 如果有使用离线阅读 // // 判断是否有离线文件 如果有使用离线阅读
final exist = await _isExistFile(bookId); // final exist = await _isExistFile(bookId);
// 没有网并且有离线文件 离线阅读 // // 没有网并且有离线文件 离线阅读
if (netStatus && exist){ // String path = await _getDirectory();
// webViewController.loadUrl(urlRequest: Uri.parse(urlRequest)) // String finalPath = '$path/174/0-318.html';
} // final content = await readHtmlFileContent(finalPath);
// Console.log('原始内容-----------------$content');
String path = await _getDirectory(); // String htmlStr = EncryptUtil.aesDecrypt(content!);
String finalPath = '$path/175/333.html'; // Console.log('解密-----------------$htmlStr');
final content = await readHtmlFileContent(finalPath); // if (netStatus && exist){
// EncryptUtil.aesDecrypt(content); // Console.log('-------------使用本地文件-------------------');
Console.log('原始内容-----------------$content'); // webViewController.loadData(data: htmlStr??'');
Console.log('解密-----------------${EncryptUtil.aesDecrypt(content!)}'); // }
super.onReady(); super.onReady();
...@@ -112,6 +114,25 @@ class ReadController extends FullLifeCycleController with GetSingleTickerProvide ...@@ -112,6 +114,25 @@ class ReadController extends FullLifeCycleController with GetSingleTickerProvide
update(); update();
} }
// 读取那个章节
void readLocalHtml(String chapterId) async {
// 判断是否有离线文件 如果有使用离线阅读
final exist = await _isExistFile(bookId);
if (netStatus && exist){
// 没有网并且有离线文件 离线阅读
String path = await _getDirectory();
String finalPath = '$path/$bookId/0-318.html';
final content = await readHtmlFileContent(finalPath);
Console.log('原始内容-----------------$content');
String htmlStr = EncryptUtil.aesDecrypt(content!);
Console.log('解密-----------------$htmlStr');
Console.log('-------------使用本地文件-------------------');
webViewController.loadData(data: htmlStr??'');
}
}
// 初始化录音组件 // 初始化录音组件
Future<void> openTheRecorder() async { Future<void> openTheRecorder() async {
// 获取权限 // 获取权限
...@@ -460,12 +481,15 @@ class ReadController extends FullLifeCycleController with GetSingleTickerProvide ...@@ -460,12 +481,15 @@ class ReadController extends FullLifeCycleController with GetSingleTickerProvide
bool directoryExists = await directory.exists(); bool directoryExists = await directory.exists();
if (directoryExists) { if (directoryExists) {
print('存在名为 "$bookId" 的文件夹'); print('存在名为 "$bookId" 的文件夹');
return await Directory('${directory.path}/$bookId').exists(); existDownFile = await Directory('${directory.path}/$bookId').exists();
} }
isExistFile = directoryExists; else {
print('不存在名为 "$bookId" 的文件夹'); print('不存在名为 "$bookId" 的文件夹');
return false; existDownFile = false;
}
update();
return existDownFile;
} }
......
...@@ -42,7 +42,7 @@ class _ReadPageState extends State<ReadPage> { ...@@ -42,7 +42,7 @@ class _ReadPageState extends State<ReadPage> {
readController.getBookDown(); readController.getBookDown();
}, },
child: Text( child: Text(
readController.isExistFile?'':'离线阅读', readController.existDownFile == true?'':'离线阅读',
style: TextStyle( style: TextStyle(
fontSize: 14.w, color: Colours.c3), fontSize: 14.w, color: Colours.c3),
)) ))
...@@ -64,7 +64,8 @@ class _ReadPageState extends State<ReadPage> { ...@@ -64,7 +64,8 @@ class _ReadPageState extends State<ReadPage> {
children: [ children: [
InAppWebView( InAppWebView(
initialUrlRequest: URLRequest( initialUrlRequest: URLRequest(
url: Uri.parse('http://150.158.138.40:9200/read.html'), // url: Uri.parse('http://150.158.138.40:9200/read.html'),
url: Uri.parse("/storage/emulated/0/Android/data/com.zijin.book.flutter_book/files/174/7-325.html"),
), ),
contextMenu: ContextMenu( contextMenu: ContextMenu(
options: ContextMenuOptions(hideDefaultSystemContextMenuItems: true), options: ContextMenuOptions(hideDefaultSystemContextMenuItems: true),
...@@ -301,6 +302,7 @@ class _ReadPageState extends State<ReadPage> { ...@@ -301,6 +302,7 @@ class _ReadPageState extends State<ReadPage> {
return const SizedBox(); return const SizedBox();
} }
} }
......
...@@ -10,7 +10,7 @@ class UserCouponController extends GetxController { ...@@ -10,7 +10,7 @@ class UserCouponController extends GetxController {
// 优惠券 // 优惠券
List <CouponModel> coupons = []; List <CouponModel> coupons = [];
late int type = 2; // late int type = 0;
final int _limit = 10; final int _limit = 10;
int _page = 1; int _page = 1;
...@@ -23,13 +23,13 @@ class UserCouponController extends GetxController { ...@@ -23,13 +23,13 @@ class UserCouponController extends GetxController {
} }
//
void getOverCoupons() { // void getOverCoupons() {
_noMore = true; // _noMore = true;
_page = 1; // _page = 1;
type = 1; // type = 0;
_getCoupon(); // _getCoupon();
} // }
/// 获取我的优惠券 /// 获取我的优惠券
Future<void> _getCoupon([bool isRefresh = false]) async { Future<void> _getCoupon([bool isRefresh = false]) async {
...@@ -38,15 +38,15 @@ class UserCouponController extends GetxController { ...@@ -38,15 +38,15 @@ class UserCouponController extends GetxController {
final result = await MineAPI.coupon( final result = await MineAPI.coupon(
page: _page, page: _page,
limit: _limit, limit: _limit,
type: type, type: 0,
); );
// 如果是刷新 清理数据 // 如果是刷新 清理数据
if (isRefresh) coupons.clear(); if (isRefresh) coupons.clear();
for(CouponModel model in result){ // for(CouponModel model in result){
model.type=type; // model.type=type;
coupons.add(model); // coupons.add(model);
} // }
// coupons.addAll(result); coupons.addAll(result);
_page ++; _page ++;
_noMore = result.length < _limit; _noMore = result.length < _limit;
update(); update();
......
...@@ -29,24 +29,26 @@ class _UserCouponPageState extends State<UserCouponPage> { ...@@ -29,24 +29,26 @@ class _UserCouponPageState extends State<UserCouponPage> {
onLoading: controller.onLoading, onLoading: controller.onLoading,
child: ListView.builder( child: ListView.builder(
itemBuilder: (BuildContext context, int index){ itemBuilder: (BuildContext context, int index){
if (index == controller.coupons.length){
return GestureDetector(
onTap: (){
controller.getOverCoupons();
},
child: Container(
alignment: Alignment.center,
height: 40.w,
// color: Colors.cyan,
child: Text('过期优惠券'),
),
);
}
else {
return BuildItem(model: controller.coupons[index],); return BuildItem(model: controller.coupons[index],);
} // if (index == controller.coupons.length){
// return GestureDetector(
// onTap: (){
// // controller.getOverCoupons();
// },
// child: Container(
// alignment: Alignment.center,
// height: 40.w,
// // color: Colors.cyan,
// child: Text('过期优惠券'),
// ),
// );
// }
// else {
// return BuildItem(model: controller.coupons[index],);
// }
}, },
itemCount: controller.coupons.length +1, // itemCount: controller.coupons.length +1,
itemCount: controller.coupons.length,
), ),
), ),
), ),
......
...@@ -14,7 +14,7 @@ class BuildItem extends StatelessWidget { ...@@ -14,7 +14,7 @@ class BuildItem extends StatelessWidget {
child: Stack( child: Stack(
children: [ children: [
Image.asset( Image.asset(
model.type == 2 model.type == 0
? 'assets/images/coupon_bg.png' ? 'assets/images/coupon_bg.png'
: 'assets/images/coupon_bg_expired.png', : 'assets/images/coupon_bg_expired.png',
fit: BoxFit.contain, fit: BoxFit.contain,
...@@ -44,7 +44,7 @@ class BuildItem extends StatelessWidget { ...@@ -44,7 +44,7 @@ class BuildItem extends StatelessWidget {
fontSize: 15.w, fontSize: 15.w,
fontWeight: Fonts.boldSemi, fontWeight: Fonts.boldSemi,
height: 1.5, height: 1.5,
color: model.type == 2 color: model.type == 0
? Colors.white ? Colors.white
: Colours.cC8)), : Colours.cC8)),
TextSpan( TextSpan(
...@@ -53,7 +53,7 @@ class BuildItem extends StatelessWidget { ...@@ -53,7 +53,7 @@ class BuildItem extends StatelessWidget {
fontSize: 40.w, fontSize: 40.w,
fontWeight: Fonts.boldSemi, fontWeight: Fonts.boldSemi,
height: 1.5, height: 1.5,
color: model.type == 2 color: model.type == 0
? Colors.white ? Colors.white
: Colours.cC8)), : Colours.cC8)),
]), ]),
...@@ -61,7 +61,7 @@ class BuildItem extends StatelessWidget { ...@@ -61,7 +61,7 @@ class BuildItem extends StatelessWidget {
Text( Text(
'满${model.normPrice}可用', '满${model.normPrice}可用',
style: TextStyle( style: TextStyle(
fontSize: 11.w, height: 1.5, color: model.type == 2 fontSize: 11.w, height: 1.5, color: model.type == 0
? Colors.white ? Colors.white
: Colours.cC8), : Colours.cC8),
) )
...@@ -87,7 +87,7 @@ class BuildItem extends StatelessWidget { ...@@ -87,7 +87,7 @@ class BuildItem extends StatelessWidget {
fontSize: 16.w, fontSize: 16.w,
fontWeight: Fonts.medium, fontWeight: Fonts.medium,
height: 1.5, height: 1.5,
color: model.type == 2 color: model.type == 0
? Colours.c3 ? Colours.c3
: Colours.c9), : Colours.c9),
maxLines: 1, maxLines: 1,
...@@ -116,7 +116,7 @@ class BuildItem extends StatelessWidget { ...@@ -116,7 +116,7 @@ class BuildItem extends StatelessWidget {
], ],
), ),
), ),
model.type == 2 model.type == 0
? Stack( ? Stack(
children: [ children: [
//TODO 暂时隐藏 立即使用 按钮 //TODO 暂时隐藏 立即使用 按钮
......
...@@ -26,6 +26,11 @@ class MsgController extends GetxController { ...@@ -26,6 +26,11 @@ class MsgController extends GetxController {
return result; return result;
} }
/// 获取订单详细
Future<OrderInfoModel> getOrderInfo(String orderNum) async {
return await MineAPI.getOrderInfo(orderNum: orderNum);
}
/// 获取课程内图书列表 /// 获取课程内图书列表
Future<void> _getMsgs([bool isRefresh = false]) async { Future<void> _getMsgs([bool isRefresh = false]) async {
if (isRefresh) _page = 1; if (isRefresh) _page = 1;
......
...@@ -34,11 +34,40 @@ class MsgPage extends StatelessWidget { ...@@ -34,11 +34,40 @@ class MsgPage extends StatelessWidget {
controller.read(model.id.toString()); controller.read(model.id.toString());
if(model.type == 1){ if(model.type == 1){
// 1订单支付快要超时(跳转订单详情)
final result = await context.pushNamed(Routes.order); final result = await context.pushNamed(Routes.order);
if (result == true){ if (result == true){
controller.onRefresh(); controller.onRefresh();
} }
// final orderInfo = await controller.getOrderInfo(model.urlId?.orderNum??'');
// // 待支付
// if (orderInfo.status == 1){
// // 书籍订单
// if (orderInfo.types ==1){
// final result = await context.pushNamed(Routes.orderAwaiting,
// queryParameters: {'orderNum': model.urlId?.orderNum.toString()});
// if (result == true){
// controller.onRefresh();
// }
// }
// // 充值订单
// else {
// final result = await context.pushNamed(Routes.orderCoinAwaiting,
// queryParameters: {'orderNum': model.urlId?.orderNum.toString()});
// if (result == true){
// controller.onRefresh();
// }
// }
//
// }
// // 已支付
// else if (orderInfo.status ==3){
//
// }
// // 已退款
// else if (orderInfo.status == 4){
//
// }
///TODO: ///TODO:
}else if (model.type == 2){ }else if (model.type == 2){
// 2 购买完成三天未评价(跳转订单列表--已完成) // 2 购买完成三天未评价(跳转订单列表--已完成)
......
...@@ -14,7 +14,7 @@ abstract class AssetsPicker { ...@@ -14,7 +14,7 @@ abstract class AssetsPicker {
if (context.mounted) { if (context.mounted) {
CustomDialog.showAccess( CustomDialog.showAccess(
context: context, context: context,
content: const Text('Requires access to your photo gallery'), content: const Text('获取相册权限'),
); );
} }
return null; return null;
...@@ -36,7 +36,7 @@ abstract class AssetsPicker { ...@@ -36,7 +36,7 @@ abstract class AssetsPicker {
if (context.mounted) { if (context.mounted) {
CustomDialog.showAccess( CustomDialog.showAccess(
context: context, context: context,
content: const Text('Requires access to your photo gallery'), content: const Text('获取拍照权限'),
); );
} }
return null; return null;
......
...@@ -48,9 +48,9 @@ class CustomDialog extends StatelessWidget { ...@@ -48,9 +48,9 @@ class CustomDialog extends StatelessWidget {
await show( await show(
context: context, context: context,
builder: (context) => content, builder: (context) => content,
title: const Text('Permission'), title: const Text('权限申请'),
cancel: const Text('Cancel'), cancel: const Text('取消'),
confirm: const Text('Setting'), confirm: const Text('设置'),
onCancel: () => Navigator.of(context).pop(), onCancel: () => Navigator.of(context).pop(),
onConfirm: () => Access.setting(), onConfirm: () => Access.setting(),
); );
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论