Browse Source

新增发票详情页面;

pdf显示处理,新增依赖(flutter_pdfview);
新增发票详情接口;
wr_2024_invoice
wurong 5 months ago
parent
commit
dfabb8f4df
  1. 4
      android/app/build.gradle
  2. 3
      lib/main.dart
  3. 820
      lib/order/invoices_manage/invoices_detail_page.dart
  4. 10
      lib/order/invoices_manage/invoices_history.dart
  5. 1
      lib/order/invoices_manage/invoices_title_info.dart
  6. 179
      lib/order/invoices_manage/pdf_screen.dart
  7. 1515
      lib/retrofit/data/invoices_detail_info.dart
  8. 5
      lib/retrofit/retrofit_api.dart
  9. 22
      lib/retrofit/retrofit_api.g.dart
  10. 28
      pubspec.lock
  11. 4
      pubspec.yaml

4
android/app/build.gradle

@ -168,6 +168,10 @@ android {
exclude 'assets/main_icon_zoomin.png'
exclude 'assets/cfg/a/mode_1/reduct.sty'
exclude 'assets/SDK_Default_Traffic_Texture_SevereCongestion.png'
pickFirst 'lib/x86/libc++_shared.so'
pickFirst 'lib/x86_64/libc++_shared.so'
pickFirst 'lib/armeabi-v7a/libc++_shared.so'
pickFirst 'lib/arm64-v8a/libc++_shared.so'
}
aaptOptions {
additionalParameters '--auto-add-overlay'

3
lib/main.dart

@ -171,6 +171,7 @@ import 'mine/release_page.dart';
import 'mine/roll_center_page.dart';
import 'order/invoices_manage/add_invoices_title.dart';
import 'order/invoices_manage/edit_invoices_info.dart';
import 'order/invoices_manage/invoices_detail_page.dart';
import 'order/invoices_manage/invoices_history.dart';
import 'order/invoices_manage/invoices_manage_page.dart';
import 'order/invoices_manage/invoices_title_info.dart';
@ -593,5 +594,7 @@ Map<String, WidgetBuilder> routers = <String, WidgetBuilder>{
InvoicesHistory(),
'/router/edit_invoices_info': (context, {arguments}) =>
EditInvoicesInfo(arguments:arguments),
'/router/invoices_detail_page': (context, {arguments}) =>
InvoicesDetailPage(arguments:arguments),
};

820
lib/order/invoices_manage/invoices_detail_page.dart

@ -0,0 +1,820 @@
import 'dart:async';
import 'dart:io';
import 'package:dio/dio.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/services.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:huixiang/order/invoices_manage/pdf_screen.dart';
import 'package:path_provider/path_provider.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:shimmer/shimmer.dart';
import 'package:url_launcher/url_launcher.dart';
import '../../community/photo_view_gallery_screen.dart';
import '../../retrofit/data/base_data.dart';
import '../../retrofit/data/invoices_detail_info.dart';
import '../../retrofit/retrofit_api.dart';
import '../../utils/flutter_utils.dart';
import '../../utils/font_weight.dart';
import '../../view_widget/classic_header.dart';
import '../../view_widget/my_appbar.dart';
import '../../view_widget/my_footer.dart';
class InvoicesDetailPage extends StatefulWidget {
final Map<String, dynamic> arguments;
InvoicesDetailPage({this.arguments});
@override
State<StatefulWidget> createState() {
return _InvoicesDetailPage();
}
}
class _InvoicesDetailPage extends State<InvoicesDetailPage> {
ApiService apiService;
InvoicesDetailInfo invoicesDetailInfo;
String remotePDFpath = "";
String networkError = "";
int networkStatus = 0;
final RefreshController refreshController = RefreshController();
@override
void initState() {
super.initState();
SharedPreferences.getInstance().then((value) => {
apiService = ApiService(
Dio(),
context: context,
token: value.getString('token'),
),
queryInvoices(widget?.arguments["id"] ?? ""),
});
}
///
@override
void dispose() {
super.dispose();
refreshController.dispose();
}
///
queryInvoices(id) async {
if (apiService == null) {
SharedPreferences value = await SharedPreferences.getInstance();
apiService = ApiService(
Dio(),
context: context,
token: value.getString("token"),
);
}
BaseData<InvoicesDetailInfo> baseData =
await apiService.invoiceDetail(id).catchError((error) {
networkError = AppUtils.dioErrorTypeToString(error.type);
networkStatus = -1;
setState(() {});
refreshController.refreshFailed();
refreshController.loadFailed();
});
if (baseData != null && baseData.isSuccess) {
invoicesDetailInfo = baseData.data;
createFileOfPdfUrl().then((f) {
setState(() {
remotePDFpath = f.path;
});
});
refreshController.refreshCompleted();
networkStatus = 1;
setState(() {});
} else {
refreshController.refreshFailed();
refreshController.loadFailed();
SmartDialog.showToast(baseData.msg, alignment: Alignment.center);
}
}
/// PDF
Future<File> createFileOfPdfUrl() async {
Completer<File> completer = Completer();
print("Start download file from internet!");
try {
final url = invoicesDetailInfo?.ossUrl ?? "";
final filename = url.substring(url.lastIndexOf("/") + 1);
var request = await HttpClient().getUrl(Uri.parse(url));
var response = await request.close();
var bytes = await consolidateHttpClientResponseBytes(response);
var dir = await getApplicationDocumentsDirectory();
print("Download files");
print("${dir.path}/$filename");
File file = File("${dir.path}/$filename");
await file.writeAsBytes(bytes, flush: true);
completer.complete(file);
} catch (e) {
throw Exception('Error parsing asset file!');
}
return completer.future;
}
@override
Widget build(BuildContext context) {
return Scaffold(
resizeToAvoidBottomInset: false,
appBar: MyAppBar(
title: "发票详情",
titleColor: Colors.black,
background: Colors.white,
leadingColor: Colors.black,
),
body: networkStatus == -1
? noNetwork()
: (networkStatus == 0
? invoicesSm()
: SmartRefresher(
controller: refreshController,
enablePullDown: true,
header: MyHeader(),
footer: CustomFooter(
builder: (context, mode) {
return MyFooter(mode);
},
),
onRefresh: () {
queryInvoices(widget?.arguments["id"] ?? "");
},
physics: BouncingScrollPhysics(),
scrollController: ScrollController(),
child: Container(
margin: EdgeInsets.only(top: 12.h),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
child: Container(
padding: EdgeInsets.symmetric(horizontal: 17.w),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
padding: EdgeInsets.symmetric(
vertical: 16.h, horizontal: 18.w),
margin: EdgeInsets.symmetric(vertical: 12.h),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(6),
boxShadow: [
BoxShadow(
color: Color(0x0F06152E),
offset: Offset(0, 2),
blurRadius: 4,
spreadRadius: 0,
)
],
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
"电子发票资讯",
style: TextStyle(
color: Color(0xFF1A1A1A),
fontSize: 15.sp,
fontWeight: MyFontWeight.bold,
),
),
Padding(
padding: EdgeInsets.only(
top: 16.h, bottom: 18.h),
child: Row(
children: [
Expanded(
child: Text(
"发票状态",
style: TextStyle(
color: Color(0xFF1A1A1A),
fontSize: 14.sp,
fontWeight: MyFontWeight.regular,
),
)),
Text(
invoicesState(
invoicesDetailInfo?.state ??
""),
style: TextStyle(
color: Color(0xFF32A060),
fontSize: 14.sp,
fontWeight: MyFontWeight.regular,
),
),
],
),
),
Padding(
padding: EdgeInsets.only(bottom: 18.h),
child: Row(
children: [
Expanded(
child: Text(
"发票抬头",
style: TextStyle(
color: Color(0xFF1A1A1A),
fontSize: 14.sp,
fontWeight: MyFontWeight.regular,
),
)),
Expanded(
child: Text(
invoicesDetailInfo
?.invoiceHeaderName ??
"",
maxLines: 1,
overflow: TextOverflow.ellipsis,
textAlign: TextAlign.end,
style: TextStyle(
color: Color(0xFF1A1A1A),
fontSize: 14.sp,
fontWeight: MyFontWeight.regular,
),
)),
],
),
),
Padding(
padding: EdgeInsets.only(bottom: 18.h),
child: Row(
children: [
Expanded(
child: Text(
"申请时间",
style: TextStyle(
color: Color(0xFF1A1A1A),
fontSize: 14.sp,
fontWeight: MyFontWeight.regular,
),
)),
Text(
invoicesDetailInfo?.reviewerTime ??
"",
style: TextStyle(
color: Color(0xFF1A1A1A),
fontSize: 14.sp,
fontWeight: MyFontWeight.regular,
),
),
],
),
),
Row(
children: [
Expanded(
child: Text(
"开票金额",
style: TextStyle(
color: Color(0xFF1A1A1A),
fontSize: 14.sp,
fontWeight: MyFontWeight.regular,
),
)),
Text(
invoicesDetailInfo?.money ?? "",
style: TextStyle(
color: Color(0xFF1A1A1A),
fontSize: 14.sp,
fontWeight: MyFontWeight.regular,
),
),
],
)
],
),
),
GestureDetector(
onTap: () {
if ((invoicesDetailInfo?.ossUrl ?? "")
.endsWith("pdf")) {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => PDFScreen(
path: remotePDFpath,
inlet: 0,
),
),
);
} else {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) =>
PhotoViewGalleryScreen(
images: [
invoicesDetailInfo?.ossUrl ?? ""
], //list
index: 0, //index
),
));
}
},
child: Container(
padding: EdgeInsets.symmetric(
vertical: 16.h, horizontal: 17.w),
margin: EdgeInsets.symmetric(vertical: 12.h),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(6),
boxShadow: [
BoxShadow(
color: Color(0x0F06152E),
offset: Offset(0, 2),
blurRadius: 4,
spreadRadius: 0,
)
],
),
child: Row(
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Expanded(
child: Text(
"1张发票,含${invoicesDetailInfo?.orderList?.length ?? 0}个订单",
style: TextStyle(
color: Color(0xFF1A1A1A),
fontSize: 14.sp,
fontWeight: MyFontWeight.regular,
),
)),
Padding(
padding: EdgeInsets.only(right: 6.w),
child: Text(
"查看",
style: TextStyle(
color: Color(0xFF1A1A1A),
fontSize: 14.sp,
fontWeight: MyFontWeight.regular,
),
),
),
Icon(Icons.arrow_forward_ios,
color: Color(0xFF181818), size: 14.sp)
],
),
),
),
],
),
)),
Row(
children: [
Expanded(
child: GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () {
if ((invoicesDetailInfo?.ossUrl ?? "")
.endsWith("pdf")) {
showPdfAlertDialog();
} else {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) =>
PhotoViewGalleryScreen(
images: [
invoicesDetailInfo?.ossUrl ?? ""
], //list
index: 0, //index
),
));
}
},
child: Container(
padding: EdgeInsets.symmetric(vertical: 16.h),
margin: EdgeInsets.only(
bottom: 34.h, right: 9.5.w, left: 14.w),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(45),
border: Border.all(
color: Color(0xff32A060),
width: 1.w,
),
),
width: double.infinity,
alignment: Alignment.center,
child: Text(
"查看电子发票",
style: TextStyle(
color: Color(0xff32A060),
fontSize: 16.sp,
fontWeight: MyFontWeight.medium,
),
),
),
)),
Expanded(
child: GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () {
launchBrowser();
},
child: Container(
padding: EdgeInsets.symmetric(vertical: 16.h),
margin: EdgeInsets.only(
bottom: 34.h, left: 9.5.w, right: 14.w),
decoration: BoxDecoration(
color: Color(0xff32A060),
borderRadius: BorderRadius.circular(45),
),
width: double.infinity,
alignment: Alignment.center,
child: Text(
"下载电子发票",
style: TextStyle(
color: Colors.white,
fontSize: 16.sp,
fontWeight: MyFontWeight.medium,
),
),
),
)),
],
)
],
),
),
)),
);
}
///
String invoicesState(state) {
if (state == "UN_AUDIT") {
return "待审核";
} else if (state == "AUDIT_PASS") {
return "开票成功";
} else if (state == "AUDIT_VOID") {
return "已作废";
} else if (state == "AUDIT_FAIL") {
return "开票失败";
} else {
return "";
}
}
///
showPdfAlertDialog() {
//
showDialog(
context: context,
builder: (BuildContext context) {
return PDFScreen(path: remotePDFpath, inlet: 1);
},
);
}
///
launchBrowser() async {
String url = invoicesDetailInfo?.ossUrl ?? "";
if (await canLaunch(url)) {
await launch(url);
} else {
throw 'Could not launch $url';
}
}
Widget invoicesSm() {
return Container(
margin: EdgeInsets.only(top: 12.h),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
child: Container(
padding: EdgeInsets.symmetric(horizontal: 17.w),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
padding:
EdgeInsets.symmetric(vertical: 16.h, horizontal: 18.w),
margin: EdgeInsets.symmetric(vertical: 12.h),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(6),
boxShadow: [
BoxShadow(
color: Color(0x0F06152E),
offset: Offset(0, 2),
blurRadius: 4,
spreadRadius: 0,
)
],
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Shimmer.fromColors(
baseColor: Color(0XFFD8D8D8),
highlightColor: Color(0XFFD8D8D8),
child: Container(
margin: EdgeInsets.only(right: 10),
decoration: BoxDecoration(
color: Color(0XFFD8D8D8),
borderRadius: BorderRadius.circular(2),
),
width: 90.w,
height: 20.h,
),
),
Padding(
padding: EdgeInsets.only(top: 16.h, bottom: 18.h),
child: Row(
children: [
Shimmer.fromColors(
baseColor: Color(0XFFD8D8D8),
highlightColor: Color(0XFFD8D8D8),
child: Container(
margin: EdgeInsets.only(right: 10),
decoration: BoxDecoration(
color: Color(0XFFD8D8D8),
borderRadius: BorderRadius.circular(2),
),
width: 58.w,
height: 20.h,
),
),
Spacer(),
Shimmer.fromColors(
baseColor: Color(0XFFD8D8D8),
highlightColor: Color(0XFFD8D8D8),
child: Container(
margin: EdgeInsets.only(right: 10),
decoration: BoxDecoration(
color: Color(0XFFD8D8D8),
borderRadius: BorderRadius.circular(2),
),
width: 58.w,
height: 20.h,
),
),
],
),
),
Padding(
padding: EdgeInsets.only(bottom: 18.h),
child: Row(
children: [
Shimmer.fromColors(
baseColor: Color(0XFFD8D8D8),
highlightColor: Color(0XFFD8D8D8),
child: Container(
margin: EdgeInsets.only(right: 10),
decoration: BoxDecoration(
color: Color(0XFFD8D8D8),
borderRadius: BorderRadius.circular(2),
),
width: 58.w,
height: 20.h,
),
),
Spacer(),
Shimmer.fromColors(
baseColor: Color(0XFFD8D8D8),
highlightColor: Color(0XFFD8D8D8),
child: Container(
margin: EdgeInsets.only(right: 10),
decoration: BoxDecoration(
color: Color(0XFFD8D8D8),
borderRadius: BorderRadius.circular(2),
),
width: 58.w,
height: 20.h,
),
),
],
),
),
Padding(
padding: EdgeInsets.only(bottom: 18.h),
child: Row(
children: [
Shimmer.fromColors(
baseColor: Color(0XFFD8D8D8),
highlightColor: Color(0XFFD8D8D8),
child: Container(
margin: EdgeInsets.only(right: 10),
decoration: BoxDecoration(
color: Color(0XFFD8D8D8),
borderRadius: BorderRadius.circular(2),
),
width: 58.w,
height: 20.h,
),
),
Spacer(),
Shimmer.fromColors(
baseColor: Color(0XFFD8D8D8),
highlightColor: Color(0XFFD8D8D8),
child: Container(
margin: EdgeInsets.only(right: 10),
decoration: BoxDecoration(
color: Color(0XFFD8D8D8),
borderRadius: BorderRadius.circular(2),
),
width: 58.w,
height: 20.h,
),
),
],
),
),
Row(
children: [
Shimmer.fromColors(
baseColor: Color(0XFFD8D8D8),
highlightColor: Color(0XFFD8D8D8),
child: Container(
margin: EdgeInsets.only(right: 10),
decoration: BoxDecoration(
color: Color(0XFFD8D8D8),
borderRadius: BorderRadius.circular(2),
),
width: 58.w,
height: 20.h,
),
),
Spacer(),
Shimmer.fromColors(
baseColor: Color(0XFFD8D8D8),
highlightColor: Color(0XFFD8D8D8),
child: Container(
margin: EdgeInsets.only(right: 10),
decoration: BoxDecoration(
color: Color(0XFFD8D8D8),
borderRadius: BorderRadius.circular(2),
),
width: 58.w,
height: 20.h,
),
),
],
)
],
),
),
Container(
padding:
EdgeInsets.symmetric(vertical: 16.h, horizontal: 17.w),
margin: EdgeInsets.symmetric(vertical: 12.h),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(6),
boxShadow: [
BoxShadow(
color: Color(0x0F06152E),
offset: Offset(0, 2),
blurRadius: 4,
spreadRadius: 0,
)
],
),
child: Row(
children: [
Shimmer.fromColors(
baseColor: Color(0XFFD8D8D8),
highlightColor: Color(0XFFD8D8D8),
child: Container(
margin: EdgeInsets.only(right: 10),
decoration: BoxDecoration(
color: Color(0XFFD8D8D8),
borderRadius: BorderRadius.circular(2),
),
width: 124.w,
height: 20.h,
),
),
Spacer(),
Shimmer.fromColors(
baseColor: Color(0XFFD8D8D8),
highlightColor: Color(0XFFD8D8D8),
child: Container(
margin: EdgeInsets.only(right: 10),
decoration: BoxDecoration(
color: Color(0XFFD8D8D8),
borderRadius: BorderRadius.circular(2),
),
width: 28.w,
height: 20.h,
),
),
Shimmer.fromColors(
baseColor: Color(0XFFD8D8D8),
highlightColor: Color(0XFFD8D8D8),
child: Container(
decoration: BoxDecoration(
color: Color(0XFFD8D8D8),
borderRadius: BorderRadius.circular(2),
),
width: 18.w,
height: 20.h,
),
),
],
),
),
],
),
)),
Row(
children: [
Shimmer.fromColors(
baseColor: Color(0XFFD8D8D8),
highlightColor: Color(0XFFD8D8D8),
child: Container(
// padding: EdgeInsets.symmetric(vertical: 16.h),
margin:
EdgeInsets.only(bottom: 34.h, right: 9.5.w, left: 14.w),
decoration: BoxDecoration(
color: Color(0XFFD8D8D8),
borderRadius: BorderRadius.circular(45),
),
width: 164.w,
height: 48.h,
),
),
Shimmer.fromColors(
baseColor: Color(0XFFD8D8D8),
highlightColor: Color(0XFFD8D8D8),
child: Container(
// padding: EdgeInsets.symmetric(vertical: 16.h),
margin:
EdgeInsets.only(bottom: 34.h, right: 9.5.w, left: 14.w),
decoration: BoxDecoration(
color: Color(0XFFD8D8D8),
borderRadius: BorderRadius.circular(45),
),
width: 164.w,
height: 48.h,
),
),
],
),
],
),
);
}
Widget noNetwork() {
return Container(
width: double.infinity,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
// "无法连接到网络",
networkError.substring(0, networkError.indexOf(",")),
style: TextStyle(
fontSize: 14.sp,
color: Color(0xFF0D0D0D),
fontWeight: MyFontWeight.bold),
),
Padding(
padding: EdgeInsets.symmetric(vertical: 10.h),
child: Text(
"请检查网络设置或稍后重试",
style: TextStyle(
fontSize: 12.sp,
color: Color(0xFF7A797F),
fontWeight: MyFontWeight.regular),
),
),
GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () {
queryInvoices(widget?.arguments["id"] ?? "");
},
child: Container(
decoration: BoxDecoration(
color: Color(0xff32A060),
borderRadius: BorderRadius.circular(15),
),
padding: EdgeInsets.symmetric(horizontal: 12.w, vertical: 3.h),
child: Text(
"重试",
style: TextStyle(
fontSize: 14.sp,
color: Colors.white,
fontWeight: MyFontWeight.regular),
)),
)
],
),
);
}
}

10
lib/order/invoices_manage/invoices_history.dart

@ -200,7 +200,13 @@ class _InvoicesHistory extends State<InvoicesHistory> {
itemBuilder: (context, position) {
return GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () {},
onTap: () {
if(records[position].state == "AUDIT_PASS")
Navigator.of(context)
.pushNamed('/router/invoices_detail_page',arguments: {
"id":records[position].id ?? ""
});
},
child: invoicesHistoryList(records[position]),
);
},
@ -302,6 +308,8 @@ class _InvoicesHistory extends State<InvoicesHistory> {
return "已作废";
}else if (state =="AUDIT_FAIL") {
return "开票失败";
}else {
return "";
}
}

1
lib/order/invoices_manage/invoices_title_info.dart

@ -130,6 +130,7 @@ class _InvoicesTitleInfo extends State<InvoicesTitleInfo> {
Future.delayed(Duration(milliseconds: 500), () {
SmartDialog.showToast("删除信息成功", alignment: Alignment.center);
});
networkStatus = 1;
} else {
SmartDialog.showToast(baseData.msg, alignment: Alignment.center);
}

179
lib/order/invoices_manage/pdf_screen.dart

@ -0,0 +1,179 @@
import 'dart:async';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_pdfview/flutter_pdfview.dart';
class PDFScreen extends StatefulWidget {
final String path;
final int inlet;
PDFScreen({Key key, this.path,this.inlet}) : super(key: key);
_PDFScreenState createState() => _PDFScreenState();
}
class _PDFScreenState extends State<PDFScreen> with WidgetsBindingObserver {
final Completer<PDFViewController> _controller = Completer<PDFViewController>();
int pages = 0;
int currentPage = 0;
int pageTotal =0;
bool isReady = false;
String errorMessage = '';
@override
Widget build(BuildContext context) {
return widget.inlet == 1 ?Material(
type: MaterialType.transparency,
child: Stack(
children: <Widget>[
Center(
child: Container(
height:250,
decoration: BoxDecoration(
color: Colors.transparent,
),
child: PDFView(
filePath: widget.path,
enableSwipe: true,
swipeHorizontal: true,
autoSpacing: false,
pageFling: true,
pageSnap: true,
defaultPage: currentPage,
fitPolicy: FitPolicy.BOTH,
preventLinkNavigation:
false, // if set to true the link is handled in flutter
onRender: (_pages) {
setState(() {
pages = _pages;
isReady = true;
});
},
onError: (error) {
setState(() {
errorMessage = error.toString();
});
print(error.toString());
},
onPageError: (page, error) {
setState(() {
errorMessage = '$page: ${error.toString()}';
});
print('$page: ${error.toString()}');
},
onViewCreated: (PDFViewController pdfViewController) {
_controller.complete(pdfViewController);
},
onLinkHandler: (String uri) {
print('goto uri: $uri');
},
onPageChanged: (int page, int total) {
print('page change: $page/$total');
setState(() {
currentPage = page;
pageTotal = total;
});
},
),
),
),
errorMessage.isEmpty
? !isReady
? Center(
child: CircularProgressIndicator(),
)
: Container()
: Center(
child: Text(errorMessage),
),
//pdfindex显示
Positioned(
width: MediaQuery.of(context).size.width,
bottom:45,
child: Center(
child: Text("${currentPage+1}/${pageTotal}",style: TextStyle(color: Colors.white,fontSize: 16)),
),
),
],
),
):Scaffold(
body: Stack(
children: <Widget>[
PDFView(
filePath: widget.path,
enableSwipe: true,
swipeHorizontal: true,
autoSpacing: false,
pageFling: true,
pageSnap: true,
defaultPage: currentPage,
fitPolicy: FitPolicy.BOTH,
preventLinkNavigation:
false, // if set to true the link is handled in flutter
onRender: (_pages) {
setState(() {
pages = _pages;
isReady = true;
});
},
onError: (error) {
setState(() {
errorMessage = error.toString();
});
print(error.toString());
},
onPageError: (page, error) {
setState(() {
errorMessage = '$page: ${error.toString()}';
});
print('$page: ${error.toString()}');
},
onViewCreated: (PDFViewController pdfViewController) {
_controller.complete(pdfViewController);
},
onLinkHandler: (String uri) {
print('goto uri: $uri');
},
onPageChanged: (int page, int total) {
print('page change: $page/$total');
setState(() {
currentPage = page;
pageTotal = total;
});
},
),
errorMessage.isEmpty
? !isReady
? Center(
child: CircularProgressIndicator(),
)
: Container()
: Center(
child: Text(errorMessage),
),
//pdfindex显示
Positioned(
bottom: 45,
width: MediaQuery.of(context).size.width,
child: Center(
child: Text("${currentPage+1}/${pageTotal}",style: TextStyle(color: Colors.black,fontSize: 16)),
),
),
Positioned(//
right: 10,
top: MediaQuery.of(context).padding.top,
child: IconButton(
icon: Icon(Icons.close,size: 30,color: Colors.black,),
onPressed: (){
Navigator.of(context).pop();
},
),
),
],
),
);
}
}

1515
lib/retrofit/data/invoices_detail_info.dart

File diff suppressed because it is too large Load Diff

5
lib/retrofit/retrofit_api.dart

@ -41,6 +41,7 @@ import 'data/headlines_list_details.dart';
import 'data/home_rank.dart';
import 'data/invitation_list.dart';
import 'data/invoice_list.dart';
import 'data/invoices_detail_info.dart';
import 'data/invoices_history_list.dart';
import 'data/ip_data.dart';
import 'data/logistics.dart';
@ -641,4 +642,8 @@ abstract class ApiService {
///
@POST("invoice/page")
Future<BaseData<InvoicesHistoryList>> invoicePage(@Body() Map<String, dynamic> param);
///
@GET("invoice/detail{id}")
Future<BaseData<InvoicesDetailInfo>> invoiceDetail(@Path("id") String id);
}

22
lib/retrofit/retrofit_api.g.dart

@ -2464,4 +2464,26 @@ class _ApiService implements ApiService {
);
return value;
}
@override
Future<BaseData<InvoicesDetailInfo>> invoiceDetail(id) async {
ArgumentError.checkNotNull(id, 'id');
const _extra = <String, dynamic>{};
final queryParameters = <String, dynamic>{};
final _data = <String, dynamic>{};
final _result = await _dio.request<Map<String, dynamic>>(
'invoice/detail/$id',
queryParameters: queryParameters,
options: RequestOptions(
method: 'GET',
headers: <String, dynamic>{},
extra: _extra,
baseUrl: baseUrl),
data: _data);
final value = BaseData<InvoicesDetailInfo>.fromJson(
_result.data,
(json) => InvoicesDetailInfo.fromJson(json),
);
return value;
}
}

28
pubspec.lock

@ -229,10 +229,10 @@ packages:
dependency: transitive
description:
name: ffi
sha256: ed5337a5660c506388a9f012be0288fb38b49020ce2b45fe1f8b8323fe429f99
sha256: "13a6ccf6a459a125b3fcdb6ec73bd5ff90822e071207c663bfd1f70062d51d18"
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.0.2"
version: "1.2.1"
file:
dependency: transitive
description:
@ -315,6 +315,14 @@ packages:
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.0.3"
flutter_pdfview:
dependency: "direct main"
description:
name: flutter_pdfview
sha256: a9055bf920c7095bf08c2781db431ba23577aa5da5a056a7152dc89a18fbec6f
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.3.2"
flutter_screenutil:
dependency: "direct main"
description:
@ -481,10 +489,10 @@ packages:
dependency: "direct main"
description:
name: image_gallery_saver
sha256: be812580c7a320d3bf583af89cac6b376f170d48000aca75215a73285a3223a0
sha256: "0aba74216a4d9b0561510cb968015d56b701ba1bd94aace26aacdd8ae5761816"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.7.1"
version: "2.0.3"
image_pickers:
dependency: "direct main"
description:
@ -689,10 +697,10 @@ packages:
dependency: transitive
description:
name: path_provider_windows
sha256: d3f80b32e83ec208ac95253e0cd4d298e104fbc63cb29c5c69edaed43b0c69d6
sha256: a34ecd7fb548f8e57321fd8e50d865d266941b54e6c3b7758cf8f37c24116905
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.1.6"
version: "2.0.7"
permission_handler:
dependency: "direct main"
description:
@ -1215,10 +1223,10 @@ packages:
dependency: transitive
description:
name: wakelock_windows
sha256: "857f77b3fe6ae82dd045455baa626bc4b93cb9bb6c86bf3f27c182167c3a5567"
sha256: "108b1b73711f1664ee462e73af34a9286ff496e27d4d8371e2fb4da8fde4cdac"
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.2.1"
version: "0.2.0"
webview_flutter:
dependency: transitive
description:
@ -1239,10 +1247,10 @@ packages:
dependency: transitive
description:
name: win32
sha256: a6f0236dbda0f63aa9a25ad1ff9a9d8a4eaaa5012da0dc59d21afdb1dc361ca4
sha256: c0e3a4f7be7dae51d8f152230b86627e3397c1ba8c3fa58e63d44a9f3edc9cef
url: "https://pub.flutter-io.cn"
source: hosted
version: "3.1.4"
version: "2.6.1"
xdg_directories:
dependency: transitive
description:

4
pubspec.yaml

@ -17,6 +17,8 @@ dependencies:
tobias: 2.4.1
#pdf展示
flutter_pdfview: ^1.3.2
gradient_widgets: ^0.6.0
@ -81,7 +83,7 @@ dependencies:
path_provider: ^2.0.4
network_to_file_image: ^4.0.1
image_gallery_saver: ^1.7.0
image_gallery_saver: ^2.0.3
flutter_html: ^2.1.5 #2.1.0
chewie_audio: ^1.1.2

Loading…
Cancel
Save