fmk
3 years ago
7 changed files with 233 additions and 1301 deletions
@ -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, |
||||
}; |
@ -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(), |
||||
}; |
@ -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*1024的MAX字节打印长度改为1000字符数 |
||||
int maxStrLength = 900; |
||||
//大于1000时 |
||||
while (msg.length > maxStrLength) { |
||||
debugPrint(msg.substring(0, maxStrLength)); |
||||
msg = msg.substring(maxStrLength); |
||||
} |
||||
//剩余部分 |
||||
print(msg); |
||||
} |
||||
|
||||
|
||||
} |
File diff suppressed because it is too large
Load Diff
@ -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…
Reference in new issue