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

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

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