Browse Source

safety

master
fmk 3 years ago
parent
commit
5185373981
  1. 37
      lib/retrofit/data/base_data.g.dart
  2. 41
      lib/retrofit/data/page.g.dart
  3. 112
      lib/retrofit/min_api.dart
  4. 8
      lib/retrofit/retrofit_api.dart
  5. 1208
      lib/retrofit/retrofit_api.g.dart
  6. 43
      lib/store/store_order.dart
  7. 85
      lib/store/store_view/store_header.dart

37
lib/retrofit/data/base_data.g.dart

@ -1,37 +0,0 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'base_data.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
BaseData<T> _$BaseDataFromJson<T>(
Map<String, dynamic> json,
T Function(Object json) fromJsonT,
) {
return BaseData<T>()
..code = json['code'] as int
..data = fromJsonT(json['data'])
..extra = json['extra']
..isError = json['isError'] as bool
..isSuccess = json['isSuccess'] as bool
..msg = json['msg'] as String
..path = json['path'] as String
..timestamp = json['timestamp'] as String;
}
Map<String, dynamic> _$BaseDataToJson<T>(
BaseData<T> instance,
Object Function(T value) toJsonT,
) =>
<String, dynamic>{
'code': instance.code,
'data': toJsonT(instance.data),
'extra': instance.extra,
'isError': instance.isError,
'isSuccess': instance.isSuccess,
'msg': instance.msg,
'path': instance.path,
'timestamp': instance.timestamp,
};

41
lib/retrofit/data/page.g.dart

@ -1,41 +0,0 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'page.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
PageInfo<D> _$PageInfoFromJson<D>(
Map<String, dynamic> json,
D Function(Object json) fromJsonD,
) {
return PageInfo<D>()
..pageNum = json['pageNum'] as int
..current = json['current']
..pageSize = json['pageSize'] as int
..size = json['size']
..pages = json['pages']
..hasPreviousPage = json['hasPreviousPage'] as bool
..hasNextPage = json['hasNextPage'] as bool
..total = json['total'] as String
..list = (json['list'] as List)?.map(fromJsonD)?.toList()
..records = (json['records'] as List)?.map(fromJsonD)?.toList();
}
Map<String, dynamic> _$PageInfoToJson<D>(
PageInfo<D> instance,
Object Function(D value) toJsonD,
) =>
<String, dynamic>{
'pageNum': instance.pageNum,
'current': instance.current,
'pageSize': instance.pageSize,
'size': instance.size,
'pages': instance.pages,
'hasPreviousPage': instance.hasPreviousPage,
'hasNextPage': instance.hasNextPage,
'total': instance.total,
'list': instance.list?.map(toJsonD)?.toList(),
'records': instance.records?.map(toJsonD)?.toList(),
};

112
lib/retrofit/min_api.dart

@ -0,0 +1,112 @@
import 'dart:convert';
import 'package:dio/dio.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:huixiang/generated/l10n.dart';
import 'package:huixiang/view_widget/login_tips_dialog.dart';
import 'package:retrofit/retrofit.dart';
part 'min_api.g.dart';
const base_url = "https://pos.platform.lotus-wallet.com/app/"; ///
const baseUrl = "https://pos.platform.lotus-wallet.com/app/"; ///
// const base_url = "http://192.168.10.236:8766/app/"; ///
// const baseUrl = "http://192.168.10.236:8766/app/"; ///
// const base_url = "http://192.168.10.37:8766/app/";
// const baseUrl = "http://192.168.10.37:8766/app/";
///
@RestApi(baseUrl: baseUrl)
abstract class MinApiService {
factory MinApiService(Dio dio, {
String baseUrl,
BuildContext context,
String token,
bool showLoading = true,
bool pay = false,
}) {
Map<String, dynamic> headers =
(token == null || token == "") ? {} : {'token': "Bearer $token"};
if (pay) {
headers["Environment"] = "app";
}
dio.options = BaseOptions(
connectTimeout: 60000,
receiveTimeout: 60000,
headers: headers,
responseType: ResponseType.json,
);
dio.interceptors.add(
InterceptorsWrapper(onRequest: (RequestOptions options) {
debugPrint("\n======================= Min_请求数据 =======================");
debugPrint("method = ${options.method.toString()}");
debugPrint("url = ${options.uri.toString()}");
debugPrint("headers = ${options.headers}");
if (showLoading && !EasyLoading.isShow) {
//loading
EasyLoading.show(status: S.of(context).zhengzaijiazai);
}
if (options.data is FormData) {
debugPrint("params data = FormData");
} else {
debugPrint("params data = ${jsonEncode(options.data)}");
}
debugPrint("params queryParameters = ${options.queryParameters}");
}, onResponse: (Response response) {
debugPrint("\n======================= Min_响应数据开始 =======================");
if (showLoading && EasyLoading.isShow) {
EasyLoading.dismiss();
}
debugPrint("code = ${response.statusCode}");
p(jsonEncode(response.data));
Map map = response.data;
if (map["code"] != 0) {
EasyLoading.dismiss();
}
if (map["code"] == 40005 || map["code"] == 40001) {
if (!LoginTipsDialog().isShow) {
print("show: ${LoginTipsDialog().isShow}");
LoginTipsDialog().show(context);
}
} else if (map["code"] != 0 && response.request.baseUrl == baseUrl) {
///poi服务请求不需要toast
SmartDialog.showToast(map["msg"], alignment: Alignment.center);
}
debugPrint("======================= Min_响应数据结束 =======================\n");
}, onError: (DioError e) {
if (EasyLoading.isShow) {
EasyLoading.dismiss();
}
debugPrint("\n======================= Min_错误响应数据 =======================");
debugPrint("type = ${e.type}");
debugPrint("message = ${e.message}");
debugPrint("\n");
}),
);
if (kReleaseMode) {
baseUrl = base_url;
}
return _MinApiService(dio, baseUrl: baseUrl);
}
static void p(String msg) {
//String的length是字符数量不是字节数量所以为了防止中文字符过多
// 4*1024MAX字节打印长度改为1000字符数
int maxStrLength = 900;
//1000
while (msg.length > maxStrLength) {
debugPrint(msg.substring(0, maxStrLength));
msg = msg.substring(maxStrLength);
}
//
print(msg);
}
}

8
lib/retrofit/retrofit_api.dart

@ -37,12 +37,8 @@ import 'data/wx_pay.dart';
part 'retrofit_api.g.dart';
const base_url = "https://pos.platform.lotus-wallet.com/app/";
///
const baseUrl = "https://pos.platform.lotus-wallet.com/app/";
///
const base_url = "https://pos.platform.lotus-wallet.com/app/"; ///
const baseUrl = "https://pos.platform.lotus-wallet.com/app/"; ///
// const base_url = "http://192.168.10.236:8766/app/"; ///
// const baseUrl = "http://192.168.10.236:8766/app/"; ///

1208
lib/retrofit/retrofit_api.g.dart

File diff suppressed because it is too large Load Diff

43
lib/store/store_order.dart

@ -42,6 +42,7 @@ class _StoreOrderPage extends State<StoreOrderPage>
StoreInfo storeInfo;
RefreshController refreshController;
List<Widget> _widgetOptions;
@override
void initState() {
super.initState();
@ -53,10 +54,14 @@ class _StoreOrderPage extends State<StoreOrderPage>
);
_widgetOptions = [
StoreOrderListPage(widget.arguments, widget.activitys,
storeInfo, controller),
StoreOrderListPage(
widget.arguments, widget.activitys, storeInfo, controller),
///,
StoreActivity(widget.arguments, widget.activitys,),
StoreActivity(
widget.arguments,
widget.activitys,
),
];
queryStoreInfo();
@ -116,13 +121,12 @@ class _StoreOrderPage extends State<StoreOrderPage>
(BuildContext context, bool innerBoxIsScrolled) {
return [
SliverOverlapAbsorber(
handle: NestedScrollView.sliverOverlapAbsorberHandleFor(
context),
handle: NestedScrollView.sliverOverlapAbsorberHandleFor(context),
sliver: SliverAppBar(
title: Text(
widget.storeInfo != null
? widget.storeInfo.storeName
: "",
storeInfo != null
? storeInfo.storeName
: '',
style: TextStyle(
color: Colors.black,
fontWeight: FontWeight.bold,
@ -136,6 +140,11 @@ class _StoreOrderPage extends State<StoreOrderPage>
floating: false,
snap: false,
pinned: true,
stretch: false,
onStretchTrigger: () {
return Future.sync((){});
},
stretchTriggerOffset: 100,
leading: GestureDetector(
onTap: () {
Navigator.of(context).pop();
@ -152,6 +161,23 @@ class _StoreOrderPage extends State<StoreOrderPage>
),
),
flexibleSpace: FlexibleSpaceBar(
// title: Container(
// margin: EdgeInsets.only(bottom: 40),
// child: Text(
// 'Expanded Title',
// style: TextStyle(
// color: Colors.black,
// fontWeight: FontWeight.bold,
// fontSize: 18.sp,
// ),
// ),
// ),
collapseMode: CollapseMode.pin,
stretchModes: [
StretchMode.zoomBackground,
StretchMode.fadeTitle,
StretchMode.blurBackground,
],
background: Stack(
children: [
Positioned(
@ -208,7 +234,6 @@ class _StoreOrderPage extends State<StoreOrderPage>
),
],
),
collapseMode: CollapseMode.pin,
),
backgroundColor: Color(0xFFFAFAFA),
centerTitle: false,

85
lib/store/store_view/store_header.dart

@ -0,0 +1,85 @@
import 'package:flutter/material.dart';
import 'package:huixiang/retrofit/data/store_info.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:huixiang/store/store_view/store_info.dart';
import 'package:huixiang/union/union_view/union_coupon.dart';
import 'package:huixiang/union/union_view/vip.dart';
class StoreHeader extends SliverPersistentHeaderDelegate {
final StoreInfo storeInfo;
final double minHeight;
StoreHeader(this.storeInfo, this.minHeight);
@override
Widget build(BuildContext context, double shrinkOffset, bool overlapsContent) {
print("overlapsContent: $overlapsContent");
return Stack(
children: [
Positioned(
child: Column(
children: [
Image.asset(
"assets/image/share_image_bg.png",
fit: BoxFit.cover,
width: MediaQuery.of(context).size.width,
height: 180.h,
),
Expanded(
child: Container(
color: Colors.transparent,
),
flex: 1,
),
],
),
top: 0,
bottom: 0,
left: 0,
right: 0,
),
Positioned(
child: Container(
child: Column(
children: [
///
StoreInfoView(storeInfo),
///
if (storeInfo != null && storeInfo.couponVOList != null)
UnionCoupon(
storeInfo,
(a) {},
coupon: true,
),
SizedBox(
height: 8,
),
///VIP信息
Vip(storeInfo, () {}, false),
],
),
),
top: 110.h,
bottom: 0,
left: 0,
right: 0,
),
],
);
} //
@override
double get maxExtent => (storeInfo != null && storeInfo.couponVOList != null)
? 425.h
: 365.h; //
@override
double get minExtent => kToolbarHeight + minHeight; //
@override
bool shouldRebuild(SliverPersistentHeaderDelegate oldDelegate) => false;
}
Loading…
Cancel
Save