From 51853739812785d340d44612a1c4c4bf071e322e Mon Sep 17 00:00:00 2001 From: fmk Date: Fri, 8 Oct 2021 18:56:17 +0800 Subject: [PATCH] safety --- lib/retrofit/data/base_data.g.dart | 37 - lib/retrofit/data/page.g.dart | 41 - lib/retrofit/min_api.dart | 112 +++ lib/retrofit/retrofit_api.dart | 8 +- lib/retrofit/retrofit_api.g.dart | 1208 ------------------------ lib/store/store_order.dart | 43 +- lib/store/store_view/store_header.dart | 85 ++ 7 files changed, 233 insertions(+), 1301 deletions(-) delete mode 100644 lib/retrofit/data/base_data.g.dart delete mode 100644 lib/retrofit/data/page.g.dart create mode 100644 lib/retrofit/min_api.dart delete mode 100644 lib/retrofit/retrofit_api.g.dart create mode 100644 lib/store/store_view/store_header.dart diff --git a/lib/retrofit/data/base_data.g.dart b/lib/retrofit/data/base_data.g.dart deleted file mode 100644 index 3a4ba372..00000000 --- a/lib/retrofit/data/base_data.g.dart +++ /dev/null @@ -1,37 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'base_data.dart'; - -// ************************************************************************** -// JsonSerializableGenerator -// ************************************************************************** - -BaseData _$BaseDataFromJson( - Map json, - T Function(Object json) fromJsonT, -) { - return BaseData() - ..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 _$BaseDataToJson( - BaseData instance, - Object Function(T value) toJsonT, -) => - { - '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, - }; diff --git a/lib/retrofit/data/page.g.dart b/lib/retrofit/data/page.g.dart deleted file mode 100644 index e40a14ae..00000000 --- a/lib/retrofit/data/page.g.dart +++ /dev/null @@ -1,41 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'page.dart'; - -// ************************************************************************** -// JsonSerializableGenerator -// ************************************************************************** - -PageInfo _$PageInfoFromJson( - Map json, - D Function(Object json) fromJsonD, -) { - return PageInfo() - ..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 _$PageInfoToJson( - PageInfo instance, - Object Function(D value) toJsonD, -) => - { - '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(), - }; diff --git a/lib/retrofit/min_api.dart b/lib/retrofit/min_api.dart new file mode 100644 index 00000000..b6ad97de --- /dev/null +++ b/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 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); + } + + +} \ No newline at end of file diff --git a/lib/retrofit/retrofit_api.dart b/lib/retrofit/retrofit_api.dart index c6b0b692..a3fe779f 100644 --- a/lib/retrofit/retrofit_api.dart +++ b/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/"; ///费韬 diff --git a/lib/retrofit/retrofit_api.g.dart b/lib/retrofit/retrofit_api.g.dart deleted file mode 100644 index f75cf97d..00000000 --- a/lib/retrofit/retrofit_api.g.dart +++ /dev/null @@ -1,1208 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'retrofit_api.dart'; - -// ************************************************************************** -// RetrofitGenerator -// ************************************************************************** - -class _ApiService implements ApiService { - _ApiService(this._dio, {this.baseUrl}) { - ArgumentError.checkNotNull(_dio, '_dio'); - baseUrl ??= 'https://pos.platform.lotus-wallet.com/app/'; - } - - final Dio _dio; - - String baseUrl; - - @override - Future> upload(data, folderId) async { - ArgumentError.checkNotNull(data, 'data'); - ArgumentError.checkNotNull(folderId, 'folderId'); - const _extra = {}; - final queryParameters = {}; - final _data = FormData(); - _data.files.add(MapEntry( - 'file', - MultipartFile.fromFileSync(data.path, - filename: data.path.split(Platform.pathSeparator).last))); - if (folderId != null) { - _data.fields.add(MapEntry('folderId', folderId.toString())); - } - final _result = await _dio.request>('/file/upload', - queryParameters: queryParameters, - options: RequestOptions( - method: 'POST', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson( - _result.data, - (json) => UploadResult.fromJson(json), - ); - return value; - } - - @override - Future searchPoi(lat, lng, keywords, size, page) async { - ArgumentError.checkNotNull(lat, 'lat'); - ArgumentError.checkNotNull(lng, 'lng'); - ArgumentError.checkNotNull(keywords, 'keywords'); - ArgumentError.checkNotNull(size, 'size'); - ArgumentError.checkNotNull(page, 'page'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - final _result = await _dio.request( - 'https://restapi.amap.com/v3/place/around?key=542b46afa8e4b88fe1eb3c4d0ba0872f&location=$lat,$lng&keywords=$keywords&offset={size}&page={page}&extensions=all', - queryParameters: queryParameters, - options: RequestOptions( - method: 'GET', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = _result.data; - return value; - } - - @override - Future> memberLogin(param) async { - ArgumentError.checkNotNull(param, 'param'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - _data.addAll(param ?? {}); - final _result = await _dio.request>( - '/auth/platform/memberLogin', - queryParameters: queryParameters, - options: RequestOptions( - method: 'POST', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson( - _result.data, - (json) => json as dynamic, - ); - return value; - } - - @override - Future> sendVerify(mobile) async { - ArgumentError.checkNotNull(mobile, 'mobile'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - final _result = await _dio.request>( - '/auth/sendVerify/$mobile', - queryParameters: queryParameters, - options: RequestOptions( - method: 'GET', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson( - _result.data, - (json) => json as dynamic, - ); - return value; - } - - @override - Future>> creditGoods(param) async { - ArgumentError.checkNotNull(param, 'param'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - _data.addAll(param ?? {}); - final _result = await _dio.request>( - '/creditGoods/list', - queryParameters: queryParameters, - options: RequestOptions( - method: 'POST', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData>.fromJson( - _result.data, - (json) => PageInfo.fromJson( - json, - (json) => Goods.fromJson(json), - ), - ); - return value; - } - - @override - Future>> goodsCategory(param) async { - ArgumentError.checkNotNull(param, 'param'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - _data.addAll(param ?? {}); - final _result = await _dio.request>( - '/creditGoodsCategory/page', - queryParameters: queryParameters, - options: RequestOptions( - method: 'POST', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData>.fromJson( - _result.data, - (json) => PageInfo.fromJson( - json, - (json) => GoodsCategory.fromJson(json), - ), - ); - return value; - } - - @override - Future> creditGoodsById(id) async { - ArgumentError.checkNotNull(id, 'id'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - final _result = await _dio.request>('/creditGoods/$id', - queryParameters: queryParameters, - options: RequestOptions( - method: 'GET', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson( - _result.data, - (json) => Goods.fromJson(json), - ); - return value; - } - - @override - Future> queryInfo() async { - const _extra = {}; - final queryParameters = {}; - final _data = {}; - final _result = await _dio.request>('/member/info', - queryParameters: queryParameters, - options: RequestOptions( - method: 'GET', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson( - _result.data, - (json) => UserInfo.fromJson(json), - ); - return value; - } - - @override - Future> editInfo(param) async { - ArgumentError.checkNotNull(param, 'param'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - _data.addAll(param ?? {}); - final _result = await _dio.request>( - '/member/editMemberInfo', - queryParameters: queryParameters, - options: RequestOptions( - method: 'POST', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson( - _result.data, - (json) => json as dynamic, - ); - return value; - } - - @override - Future> signInInfo() async { - const _extra = {}; - final queryParameters = {}; - final _data = {}; - final _result = await _dio.request>( - '/member/signInInfo', - queryParameters: queryParameters, - options: RequestOptions( - method: 'GET', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson( - _result.data, - (json) => SignInfo.fromJson(json), - ); - return value; - } - - @override - Future> signIn() async { - const _extra = {}; - final queryParameters = {}; - final _data = {}; - final _result = await _dio.request>('/member/signIn', - queryParameters: queryParameters, - options: RequestOptions( - method: 'GET', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson( - _result.data, - (json) => json as dynamic, - ); - return value; - } - - @override - Future> recharge(param) async { - ArgumentError.checkNotNull(param, 'param'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - _data.addAll(param ?? {}); - final _result = await _dio.request>('/wallet/recharge', - queryParameters: queryParameters, - options: RequestOptions( - method: 'POST', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson( - _result.data, - (json) => WxPay.fromJson(json), - ); - return value; - } - - @override - Future> receiveCoupon(couponId) async { - ArgumentError.checkNotNull(couponId, 'couponId'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - final _result = await _dio.request>( - '/coupon/receive?couponId=$couponId', - queryParameters: queryParameters, - options: RequestOptions( - method: 'GET', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson( - _result.data, - (json) => json as dynamic, - ); - return value; - } - - @override - Future>> creditOrderList(param) async { - ArgumentError.checkNotNull(param, 'param'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - _data.addAll(param ?? {}); - final _result = await _dio.request>( - '/creditOrder/list', - queryParameters: queryParameters, - options: RequestOptions( - method: 'POST', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData>.fromJson( - _result.data, - (json) => PageInfo.fromJson( - json, - (json) => ExchangeOrder.fromJson(json), - ), - ); - return value; - } - - @override - Future> creditOrder(param) async { - ArgumentError.checkNotNull(param, 'param'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - _data.addAll(param ?? {}); - final _result = await _dio.request>( - '/creditOrder/create', - queryParameters: queryParameters, - options: RequestOptions( - method: 'POST', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson( - _result.data, - (json) => json as dynamic, - ); - return value; - } - - @override - Future> addAddress(param) async { - ArgumentError.checkNotNull(param, 'param'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - _data.addAll(param ?? {}); - final _result = await _dio.request>('/address/add', - queryParameters: queryParameters, - options: RequestOptions( - method: 'POST', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson( - _result.data, - (json) => json as dynamic, - ); - return value; - } - - @override - Future> deleteAddress(param) async { - ArgumentError.checkNotNull(param, 'param'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - _data.addAll(param ?? {}); - final _result = await _dio.request>('/address/delete', - queryParameters: queryParameters, - options: RequestOptions( - method: 'POST', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson( - _result.data, - (json) => json as dynamic, - ); - return value; - } - - @override - Future> queryAddress(id) async { - ArgumentError.checkNotNull(id, 'id'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - final _result = await _dio.request>( - '/address/detail/$id', - queryParameters: queryParameters, - options: RequestOptions( - method: 'GET', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson( - _result.data, - (json) => json as dynamic, - ); - return value; - } - - @override - Future>> queryMemberAddress() async { - const _extra = {}; - final queryParameters = {}; - final _data = {}; - final _result = await _dio.request>( - '/address/queryMemberAddress', - queryParameters: queryParameters, - options: RequestOptions( - method: 'GET', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData>.fromJson( - _result.data, - (json) => (json as List) - .map
((i) => Address.fromJson(i as Map)) - .toList()); - return value; - } - - @override - Future> updateAddress(param) async { - ArgumentError.checkNotNull(param, 'param'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - _data.addAll(param ?? {}); - final _result = await _dio.request>('/address/update', - queryParameters: queryParameters, - options: RequestOptions( - method: 'POST', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson( - _result.data, - (json) => json as dynamic, - ); - return value; - } - - @override - Future>> queryCoupon(param) async { - ArgumentError.checkNotNull(param, 'param'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - _data.addAll(param ?? {}); - final _result = await _dio.request>( - '/coupon/centreList', - queryParameters: queryParameters, - options: RequestOptions( - method: 'POST', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData>.fromJson( - _result.data, - (json) => PageInfo.fromJson( - json, - (json) => Coupon.fromJson(json), - ), - ); - return value; - } - - @override - Future>> queryCard(param) async { - ArgumentError.checkNotNull(param, 'param'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - _data.addAll(param ?? {}); - final _result = await _dio.request>( - '/coupon/packageList', - queryParameters: queryParameters, - options: RequestOptions( - method: 'POST', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData>.fromJson( - _result.data, - (json) => PageInfo.fromJson( - json, - (json) => Coupon.fromJson(json), - ), - ); - return value; - } - - @override - Future>> queryStore(param) async { - ArgumentError.checkNotNull(param, 'param'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - _data.addAll(param ?? {}); - final _result = await _dio.request>('/store/list', - queryParameters: queryParameters, - options: RequestOptions( - method: 'POST', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData>.fromJson( - _result.data, - (json) => (json as List) - .map((i) => Store.fromJson(i as Map)) - .toList()); - return value; - } - - @override - Future>> informationList(param) async { - ArgumentError.checkNotNull(param, 'param'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - _data.addAll(param ?? {}); - final _result = await _dio.request>( - '/information/list', - queryParameters: queryParameters, - options: RequestOptions( - method: 'POST', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData>.fromJson( - _result.data, - (json) => PageInfo.fromJson( - json, - (json) => Activity.fromJson(json), - ), - ); - return value; - } - - @override - Future> informationInfo(id) async { - ArgumentError.checkNotNull(id, 'id'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - final _result = await _dio.request>('/information/$id', - queryParameters: queryParameters, - options: RequestOptions( - method: 'GET', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData
.fromJson( - _result.data, - (json) => Article.fromJson(json), - ); - return value; - } - - @override - Future> activityInfo(id) async { - ArgumentError.checkNotNull(id, 'id'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - final _result = await _dio.request>('/information/$id', - queryParameters: queryParameters, - options: RequestOptions( - method: 'GET', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson( - _result.data, - (json) => Activity.fromJson(json), - ); - return value; - } - - @override - Future> creditOrderReceive(id) async { - ArgumentError.checkNotNull(id, 'id'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - final _result = await _dio.request>( - '/creditOrder/receive/$id', - queryParameters: queryParameters, - options: RequestOptions( - method: 'GET', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson( - _result.data, - (json) => json as dynamic, - ); - return value; - } - - @override - Future> queryHome() async { - const _extra = {}; - final queryParameters = {}; - final _data = {}; - final _result = await _dio.request>('/home/home', - queryParameters: queryParameters, - options: RequestOptions( - method: 'GET', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson( - _result.data, - (json) => BrandData.fromJson(json), - ); - return value; - } - - @override - Future> queryStoreInfo(id) async { - ArgumentError.checkNotNull(id, 'id'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - final _result = await _dio.request>('/store/$id', - queryParameters: queryParameters, - options: RequestOptions( - method: 'GET', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson( - _result.data, - (json) => json as dynamic, - ); - return value; - } - - @override - Future>> queryArticle(param) async { - ArgumentError.checkNotNull(param, 'param'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - _data.addAll(param ?? {}); - final _result = await _dio.request>( - '/information/list', - queryParameters: queryParameters, - options: RequestOptions( - method: 'POST', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData>.fromJson( - _result.data, - (json) => PageInfo
.fromJson( - json, - (json) => Article.fromJson(json), - ), - ); - return value; - } - - @override - Future>> queryBanner(param) async { - ArgumentError.checkNotNull(param, 'param'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - _data.addAll(param ?? {}); - final _result = await _dio.request>('/banner/page', - queryParameters: queryParameters, - options: RequestOptions( - method: 'POST', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData>.fromJson( - _result.data, - (json) => PageInfo.fromJson( - json, - (json) => BannerData.fromJson(json), - ), - ); - return value; - } - - @override - Future> queryHomeBrand() async { - const _extra = {}; - final queryParameters = {}; - final _data = {}; - final _result = await _dio.request>('/home/brand', - queryParameters: queryParameters, - options: RequestOptions( - method: 'GET', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson( - _result.data, - (json) => json as dynamic, - ); - return value; - } - - @override - Future> minLogin(storeId) async { - ArgumentError.checkNotNull(storeId, 'storeId'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - final _result = await _dio.request>( - '/auth/mini/login/$storeId', - queryParameters: queryParameters, - options: RequestOptions( - method: 'GET', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson( - _result.data, - (json) => json as dynamic, - ); - return value; - } - - @override - Future>> queryBillInfo(param) async { - ArgumentError.checkNotNull(param, 'param'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - _data.addAll(param ?? {}); - final _result = await _dio.request>('/member/listBill', - queryParameters: queryParameters, - options: RequestOptions( - method: 'POST', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData>.fromJson( - _result.data, - (json) => PageInfo.fromJson( - json, - (json) => UserBill.fromJson(json), - ), - ); - return value; - } - - @override - Future>> rankList() async { - const _extra = {}; - final queryParameters = {}; - final _data = {}; - final _result = await _dio.request>('/member/rankList', - queryParameters: queryParameters, - options: RequestOptions( - method: 'GET', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData>.fromJson( - _result.data, - (json) => (json as List) - .map((i) => Rank.fromJson(i as Map)) - .toList()); - return value; - } - - @override - Future>> orderList(param) async { - ArgumentError.checkNotNull(param, 'param'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - _data.addAll(param ?? {}); - final _result = await _dio.request>('/order/list', - queryParameters: queryParameters, - options: RequestOptions( - method: 'POST', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData>.fromJson( - _result.data, - (json) => PageInfo.fromJson( - json, - (json) => OrderInfo.fromJson(json), - ), - ); - return value; - } - - @override - Future> orderDetail(id) async { - ArgumentError.checkNotNull(id, 'id'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - final _result = await _dio.request>( - '/order/orderDetail?id=$id', - queryParameters: queryParameters, - options: RequestOptions( - method: 'GET', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson( - _result.data, - (json) => OrderInfo.fromJson(json), - ); - return value; - } - - @override - Future> continuePay(param) async { - ArgumentError.checkNotNull(param, 'param'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - _data.addAll(param ?? {}); - final _result = await _dio.request>( - '/order/continuePay', - queryParameters: queryParameters, - options: RequestOptions( - method: 'POST', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson( - _result.data, - (json) => json as dynamic, - ); - return value; - } - - @override - Future> receiveToCard(id) async { - ArgumentError.checkNotNull(id, 'id'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - final _result = await _dio.request>( - '/creditOrder/receive/$id', - queryParameters: queryParameters, - options: RequestOptions( - method: 'GET', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson( - _result.data, - (json) => json as dynamic, - ); - return value; - } - - @override - Future>> vipList(param) async { - ArgumentError.checkNotNull(param, 'param'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - _data.addAll(param ?? {}); - final _result = await _dio.request>('/member/vipList', - queryParameters: queryParameters, - options: RequestOptions( - method: 'POST', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData>.fromJson( - _result.data, - (json) => (json as List) - .map((i) => VipCard.fromJson(i as Map)) - .toList()); - return value; - } - - @override - Future> vipDetail(param) async { - ArgumentError.checkNotNull(param, 'param'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - _data.addAll(param ?? {}); - final _result = await _dio.request>( - '/member/vipDetail', - queryParameters: queryParameters, - options: RequestOptions( - method: 'POST', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson( - _result.data, - (json) => VipCard.fromJson(json), - ); - return value; - } - - @override - Future>> msgList(param) async { - ArgumentError.checkNotNull(param, 'param'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - _data.addAll(param ?? {}); - final _result = await _dio.request>('/app-msg/list', - queryParameters: queryParameters, - options: RequestOptions( - method: 'POST', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData>.fromJson( - _result.data, - (json) => PageInfo.fromJson( - json, - (json) => Message.fromJson(json), - ), - ); - return value; - } - - @override - Future> queryMsg(id) async { - ArgumentError.checkNotNull(id, 'id'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - final _result = await _dio.request>('/app-msg/$id', - queryParameters: queryParameters, - options: RequestOptions( - method: 'GET', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson( - _result.data, - (json) => json as dynamic, - ); - return value; - } - - @override - Future> informationLikes(id) async { - ArgumentError.checkNotNull(id, 'id'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - final _result = await _dio.request>( - '/information/likes/$id', - queryParameters: queryParameters, - options: RequestOptions( - method: 'GET', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson( - _result.data, - (json) => json as dynamic, - ); - return value; - } - - @override - Future> memberComment(param) async { - ArgumentError.checkNotNull(param, 'param'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - _data.addAll(param ?? {}); - final _result = await _dio.request>('/memberComment', - queryParameters: queryParameters, - options: RequestOptions( - method: 'POST', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson( - _result.data, - (json) => json as dynamic, - ); - return value; - } - - @override - Future>> memberCommentList(param) async { - ArgumentError.checkNotNull(param, 'param'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - _data.addAll(param ?? {}); - final _result = await _dio.request>( - '/memberComment/list', - queryParameters: queryParameters, - options: RequestOptions( - method: 'POST', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData>.fromJson( - _result.data, - (json) => PageInfo.fromJson( - json, - (json) => MemberCommentList.fromJson(json), - ), - ); - return value; - } - - @override - Future> commentLike(id) async { - ArgumentError.checkNotNull(id, 'id'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - final _result = await _dio.request>( - '/memberComment/likes/$id', - queryParameters: queryParameters, - options: RequestOptions( - method: 'GET', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson( - _result.data, - (json) => json as dynamic, - ); - return value; - } - - @override - Future> delComment(id) async { - ArgumentError.checkNotNull(id, 'id'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - final _result = await _dio.request>( - '/memberComment/delete/$id', - queryParameters: queryParameters, - options: RequestOptions( - method: 'GET', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson( - _result.data, - (json) => json as dynamic, - ); - return value; - } - - @override - Future> shippingTrace(shipperCode, logisticCode) async { - ArgumentError.checkNotNull(shipperCode, 'shipperCode'); - ArgumentError.checkNotNull(logisticCode, 'logisticCode'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - final _result = await _dio.request>( - '/order/getShippingTrace/$shipperCode/$logisticCode', - queryParameters: queryParameters, - options: RequestOptions( - method: 'GET', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson( - _result.data, - (json) => Logistics.fromJson(json), - ); - return value; - } - - @override - Future> report(map) async { - ArgumentError.checkNotNull(map, 'map'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - _data.addAll(map ?? {}); - final _result = await _dio.request>('/other/report', - queryParameters: queryParameters, - options: RequestOptions( - method: 'POST', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson( - _result.data, - (json) => json as bool, - ); - return value; - } - - @override - Future> orderCancel(id) async { - ArgumentError.checkNotNull(id, 'id'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - final _result = await _dio.request>( - '/order/orderCancel?id=$id', - queryParameters: queryParameters, - options: RequestOptions( - method: 'GET', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson( - _result.data, - (json) => json as bool, - ); - return value; - } - - @override - Future> settlement(map) async { - ArgumentError.checkNotNull(map, 'map'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - _data.addAll(map ?? {}); - final _result = await _dio.request>( - '/order/settlement', - queryParameters: queryParameters, - options: RequestOptions( - method: 'POST', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson( - _result.data, - (json) => json as String, - ); - return value; - } -} diff --git a/lib/store/store_order.dart b/lib/store/store_order.dart index 4858be50..18991906 100644 --- a/lib/store/store_order.dart +++ b/lib/store/store_order.dart @@ -42,6 +42,7 @@ class _StoreOrderPage extends State StoreInfo storeInfo; RefreshController refreshController; List _widgetOptions; + @override void initState() { super.initState(); @@ -53,10 +54,14 @@ class _StoreOrderPage extends State ); _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 (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 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 ), ), 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 ), ], ), - collapseMode: CollapseMode.pin, ), backgroundColor: Color(0xFFFAFAFA), centerTitle: false, diff --git a/lib/store/store_view/store_header.dart b/lib/store/store_view/store_header.dart new file mode 100644 index 00000000..964ea4e3 --- /dev/null +++ b/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; + +}