From 2deb30bbee1ed9dcf682942faee3619381a07e08 Mon Sep 17 00:00:00 2001 From: fmk Date: Fri, 8 Oct 2021 14:43:22 +0800 Subject: [PATCH 1/7] safety --- lib/qr/qr_code_scan.dart | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/lib/qr/qr_code_scan.dart b/lib/qr/qr_code_scan.dart index 3fae8dfd..bda77c54 100644 --- a/lib/qr/qr_code_scan.dart +++ b/lib/qr/qr_code_scan.dart @@ -122,27 +122,28 @@ class _QrCodeScanPage extends State { } } - startCameraResult(String data, List offset) async { + void _startCameraResult(String data, List offset) { showData(data); this.viewController.stopCamera(); } Future onScan(QrReaderViewController viewController) async { this.viewController = viewController; - await this.viewController.startCamera(startCameraResult); + await this.viewController.startCamera(_startCameraResult); } showData(String data) { SmartDialog.show( - widget: Tips( - () {}, - text: "$data", - ), - onDismiss: () { - Future.delayed(Duration(seconds: 1), () { - this.viewController.startCamera(startCameraResult); - }); + widget: Tips( + () {}, + text: "$data", + ), + onDismiss: () { + Future.delayed(Duration(seconds: 1), () { + this.viewController.startCamera(_startCameraResult); }); + }, + ); } @override From b8a4f6b8ba5a21ef7ae75c5ff576147e31034f1e Mon Sep 17 00:00:00 2001 From: fmk Date: Fri, 8 Oct 2021 15:06:51 +0800 Subject: [PATCH 2/7] safety --- lib/generated/l10n.dart | 50 ----------------------------------------- 1 file changed, 50 deletions(-) diff --git a/lib/generated/l10n.dart b/lib/generated/l10n.dart index 6e43f88b..77c2cc76 100644 --- a/lib/generated/l10n.dart +++ b/lib/generated/l10n.dart @@ -5085,56 +5085,6 @@ class S { ); } - /// `订单结算` - String get dingdanjiesuan { - return Intl.message( - '订单结算', - name: 'dingdanjiesuan', - desc: '', - args: [], - ); - } - - /// `到店自取` - String get daodianziqu { - return Intl.message( - '到店自取', - name: 'daodianziqu', - desc: '', - args: [], - ); - } - - /// `外卖配送` - String get waimaipeisong { - return Intl.message( - '外卖配送', - name: 'waimaipeisong', - desc: '', - args: [], - ); - } - - /// `快递物流` - String get kuaidiwuliu { - return Intl.message( - '快递物流', - name: 'kuaidiwuliu', - desc: '', - args: [], - ); - } - - /// `预留电话` - String get yuliudianhua { - return Intl.message( - '预留电话', - name: 'yuliudianhua', - desc: '', - args: [], - ); - } - /// `并使用本机号码登录` String get privacy_policy4 { return Intl.message( From 87bd021e235073d0a9e86612c5a5318bc97fb0ab Mon Sep 17 00:00:00 2001 From: fmk Date: Fri, 8 Oct 2021 15:56:37 +0800 Subject: [PATCH 3/7] safety --- lib/main.dart | 1 + lib/web/web_page.dart | 4 +-- lib/web/web_view/comment_list.dart | 43 +++++++++++++----------------- lib/web/web_view/web_content.dart | 6 +++++ lib/web/web_view/web_header.dart | 43 +++++++++++++----------------- 5 files changed, 46 insertions(+), 51 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index 98e47eed..da62d3d6 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -54,6 +54,7 @@ import 'package:huixiang/setting/setting_page.dart'; import 'package:huixiang/setting/treaty_page.dart'; // import 'package:huixiang/store/settlement.dart'; import 'package:huixiang/store/store_order.dart'; +import 'package:huixiang/store/store_view/settlement.dart'; import 'package:huixiang/union/location_map_page.dart'; import 'package:huixiang/web/web_page.dart'; diff --git a/lib/web/web_page.dart b/lib/web/web_page.dart index 34a5b6a3..c4ecde42 100644 --- a/lib/web/web_page.dart +++ b/lib/web/web_page.dart @@ -219,7 +219,7 @@ class _WebPage extends State with WidgetsBindingObserver { ), ), ), - background: Color(0xFFF7F7F7), + background: Color(0xFFFFFFFFF), leadingColor: Colors.black, title: activity != null ? activity.mainTitle @@ -262,7 +262,7 @@ class _WebPage extends State with WidgetsBindingObserver { isKeyBoardShow, _reply, _delCommentTips, - 12 + 12.sp ), ], ), diff --git a/lib/web/web_view/comment_list.dart b/lib/web/web_view/comment_list.dart index 4f438915..13a791cf 100644 --- a/lib/web/web_view/comment_list.dart +++ b/lib/web/web_view/comment_list.dart @@ -25,16 +25,9 @@ class CommentList extends StatefulWidget { final Function delCommentTips; final double fontSize; - CommentList( - Key key, - this.arguments, - this.activity, - this.article, - this.isKeyBoardShow, - this.reply, - this.delCommentTips, - this.fontSize - ) : super(key: key); + CommentList(Key key, this.arguments, this.activity, this.article, + this.isKeyBoardShow, this.reply, this.delCommentTips, this.fontSize) + : super(key: key); @override State createState() { @@ -104,7 +97,7 @@ class _CommentList extends State { Text( S.of(context).pinglun_(commentTotal.toString()), style: TextStyle( - fontSize:widget.fontSize+4, + fontSize: widget.fontSize + 4, fontWeight: FontWeight.bold, color: Color(0xff1A1A1A), ), @@ -116,7 +109,7 @@ class _CommentList extends State { S.of(context).xihuan_( "${widget.article?.likes ?? widget.activity?.likes ?? "0"}"), style: TextStyle( - fontSize:widget.fontSize+4, + fontSize: widget.fontSize + 4, fontWeight: FontWeight.bold, color: Color(0xff1A1A1A), ), @@ -163,7 +156,7 @@ class _CommentList extends State { child: Text( S.of(context).yixiansquanbupinglun, style: TextStyle( - fontSize:widget.fontSize+2, + fontSize: widget.fontSize + 2, color: Color(0xff353535), ), ), @@ -171,17 +164,15 @@ class _CommentList extends State { if (memberList == null || memberList.length == 0) Container( width: double.infinity, - height: MediaQuery.of(context).size.height - - kToolbarHeight - - MediaQuery.of(context).padding.top - - 160.h, + height: MediaQuery.of(context).size.height - kToolbarHeight + - MediaQuery.of(context).padding.top - 160.h, alignment: Alignment.topCenter, color: Color(0xFFF2F2F2), padding: EdgeInsets.only(top: 22.h), child: Text( S.of(context).zanwupinglun, style: TextStyle( - fontSize:widget.fontSize+2, + fontSize: widget.fontSize + 2, fontWeight: FontWeight.bold, color: Color(0xFFA0A0A0), ), @@ -216,10 +207,12 @@ class _CommentList extends State { token: sharedPreferences.getString("token"), showLoading: false, ); - BaseData> baseData = await apiService.memberCommentList({ + BaseData> baseData = + await apiService.memberCommentList({ "pageNum": 1, "pageSize": 100, - "relationalId": widget.arguments["activityId"] ?? widget.arguments["articleId"], + "relationalId": + widget.arguments["activityId"] ?? widget.arguments["articleId"], "relationalType": 1, }).catchError((error) {}); if (baseData != null && baseData.isSuccess) { @@ -292,7 +285,7 @@ class _CommentList extends State { text: memberList.username, style: TextStyle( fontWeight: FontWeight.bold, - fontSize:widget.fontSize+2, + fontSize: widget.fontSize + 2, color: Colors.black, ), ), @@ -308,7 +301,7 @@ class _CommentList extends State { overflow: TextOverflow.ellipsis, maxLines: 2, style: TextStyle( - fontSize:widget.fontSize, + fontSize: widget.fontSize, color: Color(0xff808080), ), ), @@ -359,7 +352,7 @@ class _CommentList extends State { text, style: TextStyle( color: Color(0xFF1A1A1A), - fontSize:widget.fontSize, + fontSize: widget.fontSize, ), ); }, @@ -381,7 +374,7 @@ class _CommentList extends State { child: Text( memberList.content, style: TextStyle( - fontSize:widget.fontSize+2, + fontSize: widget.fontSize + 2, color: Color(0xff1A1A1A), ), ), @@ -415,7 +408,7 @@ class _CommentList extends State { child: Text( memberList.parentContent ?? "", style: TextStyle( - fontSize:widget.fontSize, + fontSize: widget.fontSize, color: Color(0xff808080), ), ), diff --git a/lib/web/web_view/web_content.dart b/lib/web/web_view/web_content.dart index b9bf54b5..65d1b5ab 100644 --- a/lib/web/web_view/web_content.dart +++ b/lib/web/web_view/web_content.dart @@ -7,6 +7,7 @@ import 'package:flutter_html/image_render.dart'; import 'package:chewie/src/chewie_progress_colors.dart' as chewie; import 'package:flutter/material.dart'; import 'package:flutter_html/src/replaced_element.dart'; +import 'package:flutter_html/style.dart'; import 'package:huixiang/retrofit/data/activity.dart'; import 'package:huixiang/retrofit/data/article.dart'; import 'package:video_player/video_player.dart'; @@ -38,6 +39,11 @@ class _WebContent extends State { : widget.article != null ? widget.article.content : "", + style: { + "html": Style( + backgroundColor: Colors.white + ) + }, customImageRenders: { base64DataUriMatcher(): base64ImageRender(), assetUriMatcher(): assetImageRender(), diff --git a/lib/web/web_view/web_header.dart b/lib/web/web_view/web_header.dart index a88ff5e0..aa7a5807 100644 --- a/lib/web/web_view/web_header.dart +++ b/lib/web/web_view/web_header.dart @@ -1,23 +1,20 @@ - import 'package:flutter/material.dart'; import 'package:huixiang/retrofit/data/activity.dart'; import 'package:huixiang/retrofit/data/article.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; class WebHeader extends StatefulWidget { - final Map arguments; final Activity activity; final Article article; final double fontSize; - WebHeader(this.arguments, this.activity, this.article,this.fontSize); + WebHeader(this.arguments, this.activity, this.article, this.fontSize); @override State createState() { return _WebHeader(); } - } class _WebHeader extends State { @@ -26,15 +23,15 @@ class _WebHeader extends State { return Column( children: [ Container( - color: Color(0xFFF7F7F7), + color: Color(0xFFFFFFFF), padding: EdgeInsets.all(12), alignment: Alignment.centerLeft, child: Text( widget.activity != null ? widget.activity.mainTitle : widget.article != null - ? widget.article.mainTitle - : "", + ? widget.article.mainTitle + : "", style: TextStyle( fontSize: widget.fontSize, fontWeight: FontWeight.bold, @@ -43,32 +40,34 @@ class _WebHeader extends State { ), ), Container( + color: Color(0xFFFFFFFF), padding: EdgeInsets.symmetric(horizontal: 12.w), child: Row( children: [ InkWell( child: Text( - "${widget.activity != null ? (widget.activity.storeName ?? "") : (widget.article != null && widget.article.author != null) ? (widget.article.author.name ?? "") : ""}", + "${widget.activity != null ? (widget.activity.storeName ?? "") + : (widget.article != null && widget.article.author != null) + ? (widget.article.author.name ?? "") : ""}", style: TextStyle( fontWeight: FontWeight.normal, - fontSize:widget.fontSize-2, + fontSize: widget.fontSize - 2, color: Colors.blue, ), ), onTap: () { if (widget.activity != null) { if (widget.arguments["source"] != null && - widget.arguments["source"] == - widget.activity.storeId) { + widget.arguments["source"] == widget.activity.storeId) { Navigator.of(context).pop(); } else { Navigator.of(context).pushNamed( - '/router/union_detail_page', - arguments: { - "id": widget.activity.storeId, - "source": - widget.arguments["activityId"] - }); + '/router/union_detail_page', + arguments: { + "id": widget.activity.storeId, + "source": widget.arguments["activityId"] + }, + ); } } }, @@ -80,11 +79,11 @@ class _WebHeader extends State { widget.activity != null ? widget.activity.createTime : widget.article != null - ? widget.article.createTime - : "", + ? widget.article.createTime + : "", style: TextStyle( fontWeight: FontWeight.normal, - fontSize: widget.fontSize-4, + fontSize: widget.fontSize - 4, color: Colors.grey, ), ), @@ -94,8 +93,4 @@ class _WebHeader extends State { ], ); } - } - - - From 49889246fa9c902a61a1239a9cd1fbc0e3fd444e Mon Sep 17 00:00:00 2001 From: fmk Date: Fri, 8 Oct 2021 16:54:58 +0800 Subject: [PATCH 4/7] safety --- lib/store/store_order.dart | 318 +++++++++++++- lib/store/store_view/settlement.dart | 1 - lib/store/store_view/store_activity.dart | 160 +++++++ ..._order_page.dart => store_order_list.dart} | 400 +----------------- lib/web/web_view/web_header.dart | 4 +- 5 files changed, 465 insertions(+), 418 deletions(-) create mode 100644 lib/store/store_view/store_activity.dart rename lib/store/store_view/{store_order_page.dart => store_order_list.dart} (54%) diff --git a/lib/store/store_order.dart b/lib/store/store_order.dart index 388d8120..4858be50 100644 --- a/lib/store/store_order.dart +++ b/lib/store/store_order.dart @@ -9,8 +9,9 @@ import 'package:huixiang/retrofit/data/activity.dart'; import 'package:huixiang/retrofit/data/base_data.dart'; import 'package:huixiang/retrofit/data/store_info.dart'; import 'package:huixiang/retrofit/retrofit_api.dart'; +import 'package:huixiang/store/store_view/store_activity.dart'; import 'package:huixiang/store/store_view/store_info.dart'; -import 'package:huixiang/store/store_view/store_order_page.dart'; +import 'package:huixiang/store/store_view/store_order_list.dart'; import 'package:huixiang/union/union_view/union_coupon.dart'; import 'package:huixiang/union/union_view/vip.dart'; import 'package:huixiang/utils/font_weight.dart'; @@ -40,11 +41,24 @@ class _StoreOrderPage extends State ApiService apiService; StoreInfo storeInfo; RefreshController refreshController; - + List _widgetOptions; @override void initState() { super.initState(); + if (tabcontroller == null) + tabcontroller = TabController( + length: 2, + vsync: this, + ); + + _widgetOptions = [ + StoreOrderListPage(widget.arguments, widget.activitys, + storeInfo, controller), + ///星店活动, + StoreActivity(widget.arguments, widget.activitys,), + ]; + queryStoreInfo(); } @@ -78,7 +92,11 @@ class _StoreOrderPage extends State Widget build(BuildContext context) { return Stack( children: [ - Expanded( + Positioned( + left: 0, + right: 0, + top: 0, + bottom: 54.h, child: DefaultTabController( length: 2, child: SmartRefresher( @@ -94,10 +112,12 @@ class _StoreOrderPage extends State child: NestedScrollView( controller: controller, dragStartBehavior: DragStartBehavior.start, - headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) { + headerSliverBuilder: + (BuildContext context, bool innerBoxIsScrolled) { return [ SliverOverlapAbsorber( - handle: NestedScrollView.sliverOverlapAbsorberHandleFor(context), + handle: NestedScrollView.sliverOverlapAbsorberHandleFor( + context), sliver: SliverAppBar( title: Text( widget.storeInfo != null @@ -202,10 +222,7 @@ class _StoreOrderPage extends State padding: EdgeInsets.symmetric(horizontal: 10.w), width: MediaQuery.of(context).size.width, child: TabBar( - controller: tabcontroller = TabController( - length: 2, - vsync: this, - ), + controller: tabcontroller, automaticIndicatorColorAdjustment: true, isScrollable: true, indicatorWeight: 1, @@ -236,13 +253,7 @@ class _StoreOrderPage extends State }, body: TabBarView( physics: BouncingScrollPhysics(), - children: [ - StoreOrderListPage(widget.arguments, widget.activitys, storeInfo, controller), - Container( - color: Colors.black, - width: MediaQuery.of(context).size.width, - ), - ], + children: _widgetOptions, controller: tabcontroller, ), ), @@ -293,6 +304,7 @@ class _StoreOrderPage extends State textColor: Colors.white, fontWeight: MyFontWeight.regular, backgroup: Color(0xFF32A060), + radius: 0, fontSize: 16.sp, padding: EdgeInsets.symmetric(vertical: 5.h), ), @@ -305,11 +317,11 @@ class _StoreOrderPage extends State InkWell( onTap: () { setState(() { - // showShoppingCart(); + showShoppingCart(); }); }, child: Image.asset( - "assets/image/icon_shop.png", + "assets/image/shopp.png", width: 88, height: 88, fit: BoxFit.fitWidth, @@ -327,7 +339,6 @@ class _StoreOrderPage extends State backgroup: Color(0xFF32A060), fontSize: 12.sp, radius: 100, - // padding: EdgeInsets.symmetric(vertical: 5.h), ), ) ], @@ -339,6 +350,275 @@ class _StoreOrderPage extends State ); } + ///购物车弹窗 + showShoppingCart() { + showModalBottomSheet( + context: context, + backgroundColor: Colors.transparent, + builder: (context) { + return StatefulBuilder(builder: (context1, state) { + return Container( + alignment: Alignment.topCenter, + width: double.infinity, + height: MediaQuery.of(context).size.height / 2, + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.only( + topLeft: Radius.circular(8), + topRight: Radius.circular(8), + ), + ), + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + padding: EdgeInsets.only( + top: 16, + left: 16, + right: 16, + bottom: 8, + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + "已选商品", + style: TextStyle( + color: Colors.black, + fontSize: 14.sp, + fontWeight: MyFontWeight.medium, + ), + ), + InkWell( + onTap: () {}, + child: Image.asset( + "assets/image/delete.png", + width: 22, + height: 22, + ), + ), + ], + ), + ), + Expanded( + child: Container( + padding: EdgeInsets.only( + top: 8, + left: 16, + right: 16, + ), + child: ListView.builder( + itemCount: 2, + physics: BouncingScrollPhysics(), + itemBuilder: (context, position) { + return shoppGoodsItem(); + }, + ), + ), + ), + Stack( + alignment: Alignment.bottomLeft, + children: [ + Container( + height: 54.h, + decoration: BoxDecoration( + color: Color(0xFFFAFAFA), + boxShadow: [ + BoxShadow( + color: Colors.black.withAlpha(8), + offset: Offset(0, -1), + blurRadius: 3, + spreadRadius: 0, + ), + ], + ), + child: Row( + children: [ + Spacer(), + Text( + S.of(context).heji, + style: TextStyle( + fontSize: 12.sp, + fontWeight: MyFontWeight.regular, + color: Colors.black, + ), + ), + Text( + "¥19.00", + style: TextStyle( + fontSize: 20.sp, + fontWeight: MyFontWeight.medium, + color: Color(0xFF32A060), + ), + ), + Spacer(), + RoundButton( + width: 103.w, + height: 54.h, + text: S.current.jiesuan, + textColor: Colors.white, + fontWeight: MyFontWeight.regular, + backgroup: Color(0xFF32A060), + radius: 0, + fontSize: 16.sp, + padding: EdgeInsets.symmetric(vertical: 5.h), + ) + ], + ), + ), + Stack( + children: [ + InkWell( + onTap: () { + Navigator.of(context).pop(); + }, + child: Image.asset( + "assets/image/shopp.png", + width: 88, + height: 88, + ), + ), + Positioned( + right: 15, + top: 14, + child: RoundButton( + width: 17, + height: 17, + text: "1", + textColor: Colors.white, + fontWeight: MyFontWeight.regular, + backgroup: Color(0xFF32A060), + fontSize: 12.sp, + radius: 100, + ), + ), + ], + ), + ], + ), + ], + ), + ); + }); + }, + ); + } + + Widget shoppGoodsItem() { + return Container( + padding: EdgeInsets.only(bottom: 10), + child: Row( + children: [ + Image.asset( + "assets/image/default_1.png", + width: 60, + height: 60, + fit: BoxFit.cover, + ), + SizedBox(width: 10), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + "手工啵啵奶茶", + style: TextStyle( + color: Colors.black, + fontSize: 12.sp, + fontWeight: MyFontWeight.medium, + ), + ), + SizedBox(height: 2), + Row( + children: [ + Text( + "无香精", + style: TextStyle( + color: Color(0xFF4C4C4C), + fontSize: 11.sp, + fontWeight: MyFontWeight.regular, + ), + ), + SizedBox(width: 10), + Text( + "无香精", + style: TextStyle( + color: Color(0xFF4C4C4C), + fontSize: 11.sp, + fontWeight: MyFontWeight.regular, + ), + ) + ], + ), + SizedBox(height: 6), + Row( + children: [ + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + children: [ + Text( + "会员价", + style: TextStyle( + color: Color(0xFFFF7A1A), + fontSize: 13.sp, + fontWeight: MyFontWeight.medium, + ), + ), + Text( + "¥19.00", + style: TextStyle( + color: Color(0xFFFF7A1A), + fontSize: 14.sp, + fontWeight: MyFontWeight.medium, + ), + ) + ], + ), + ], + ), + Spacer(), + InkWell( + onTap: () {}, + child: Image.asset( + "assets/image/reduce.png", + width: 22, + height: 22, + ), + ), + Padding( + padding: EdgeInsets.only(left: 8, right: 8), + child: Text( + "1", + style: TextStyle( + color: Colors.black, + fontSize: 14.sp, + fontWeight: MyFontWeight.medium, + ), + ), + ), + InkWell( + onTap: () {}, + child: Image.asset( + "assets/image/add.png", + width: 22, + height: 22, + ), + ), + ], + ), + ], + ), + flex: 1, + ), + ], + ), + ); + } + // @override // bool get wantKeepAlive => true; } diff --git a/lib/store/store_view/settlement.dart b/lib/store/store_view/settlement.dart index 611230ee..573262e8 100644 --- a/lib/store/store_view/settlement.dart +++ b/lib/store/store_view/settlement.dart @@ -3,7 +3,6 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:huixiang/generated/l10n.dart'; import 'package:huixiang/order/order_view/order_commodity.dart'; -import 'package:huixiang/order/order_view/order_info.dart'; import 'package:huixiang/retrofit/data/base_data.dart'; import 'package:huixiang/retrofit/data/order_info.dart'; import 'package:huixiang/retrofit/retrofit_api.dart'; diff --git a/lib/store/store_view/store_activity.dart b/lib/store/store_view/store_activity.dart new file mode 100644 index 00000000..ac200a78 --- /dev/null +++ b/lib/store/store_view/store_activity.dart @@ -0,0 +1,160 @@ + + + +import 'package:flutter/material.dart'; +import 'package:flutter_swiper/flutter_swiper.dart'; +import 'package:huixiang/retrofit/data/activity.dart'; +import 'package:huixiang/utils/font_weight.dart'; +import 'package:huixiang/view_widget/custom_image.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; + +class StoreActivity extends StatefulWidget { + + final Map arguments; + final List activitys; + + StoreActivity(this.arguments, this.activitys); + + @override + State createState() { + return _StoreActivity(); + } + +} + +class _StoreActivity extends State { + @override + Widget build(BuildContext context) { + return Container( + width: MediaQuery.of(context).size.width, + height: MediaQuery.of(context).size.height, + color: Colors.white, + child: Swiper( + viewportFraction: 0.95, + loop: false, + itemBuilder: (context, position) { + return InkWell( + onTap: () { + if (widget.arguments["source"] != null && + widget.arguments["source"] == widget.activitys[position].id) { + Navigator.of(context).pop(); + } else { + Navigator.of(context).pushNamed('/router/web_page', arguments: { + "activityId": widget.activitys[position].id, + "source": widget.arguments["id"] + }); + } + }, + child: Container( + margin: EdgeInsets.symmetric(horizontal: 5.w), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(8), + boxShadow: [ + BoxShadow( + color: Color(0x0D000000), + offset: Offset(0, 3), + blurRadius: 14, + spreadRadius: 0, + ), + ], + ), + child: Stack( + children: [ + Container( + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.max, + children: [ + MImage( + (widget.activitys != null && + widget.activitys.length > position) + ? widget.activitys[position].coverImg + : "", + aspectRatio: 2.2, + radius: BorderRadius.vertical( + top: Radius.circular(8), + ), + fit: BoxFit.cover, + errorSrc: "assets/image/default_2_1.png", + fadeSrc: "assets/image/default_2_1.png", + ), + Container( + padding: EdgeInsets.all(8), + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + (widget.activitys != null && + widget.activitys.length > position) + ? widget.activitys[position].storeName + : "", + style: TextStyle( + fontSize: 14.sp, + fontWeight: MyFontWeight.semi_bold, + color: Color(0xFF000000), + ), + ), + SizedBox( + height: 4.h, + ), + Text( + (widget.activitys != null && + widget.activitys.length > position) + ? widget.activitys[position].mainTitle + : "", + style: TextStyle( + fontSize: 12.sp, + fontWeight: MyFontWeight.semi_bold, + color: Color(0xFF727272), + ), + ), + ], + ), + ), + ], + ), + ), + Positioned( + top: 0, + right: 0, + child: Container( + padding: EdgeInsets.symmetric( + vertical: 4.h, + horizontal: 8.w, + ), + decoration: BoxDecoration( + color: Colors.black.withAlpha(76), + borderRadius: BorderRadius.only( + bottomLeft: Radius.circular(8), + topRight: Radius.circular(8), + ), + ), + child: Text( + (widget.activitys != null && + widget.activitys.length > position) + ? widget.activitys[position].startTime.split(" ")[0] + : "", + style: TextStyle( + fontWeight: MyFontWeight.semi_bold, + fontSize: 12.sp, + color: Color(0xD9FFFFFF), + ), + ), + ), + ), + ], + ), + ), + ); + }, + itemCount: (widget.activitys != null && widget.activitys.length > 0) + ? widget.activitys.length + : 0, + ), + ); + } + +} \ No newline at end of file diff --git a/lib/store/store_view/store_order_page.dart b/lib/store/store_view/store_order_list.dart similarity index 54% rename from lib/store/store_view/store_order_page.dart rename to lib/store/store_view/store_order_list.dart index d6c27bae..6f5e134d 100644 --- a/lib/store/store_view/store_order_page.dart +++ b/lib/store/store_view/store_order_list.dart @@ -66,6 +66,7 @@ class _StoreOrderListPage extends State { height: MediaQuery.of(context).size.height, child: ListView.builder( itemCount: 28, + padding: EdgeInsets.only(top: 25, bottom: 50), controller: widget.controller, itemBuilder: (context, position) { return orderItem(position); @@ -130,8 +131,6 @@ class _StoreOrderListPage extends State { color: Colors.white, padding: EdgeInsets.only(right: 16.w, bottom: 10, top: 10), child: Row( - // mainAxisAlignment: MainAxisAlignment.spaceAround, - // crossAxisAlignment: CrossAxisAlignment.center, children: [ SizedBox(width: 12.w), Image.asset( @@ -198,7 +197,7 @@ class _StoreOrderListPage extends State { fontSize: 11.sp, fontWeight: MyFontWeight.medium, ), - ) + ), ], ), Row( @@ -219,7 +218,7 @@ class _StoreOrderListPage extends State { fontSize: 10.sp, fontWeight: MyFontWeight.regular, ), - ) + ), ], ), ], @@ -228,9 +227,7 @@ class _StoreOrderListPage extends State { true ? GestureDetector( onTap: () { - setState(() { - showStoreSelector(); - }); + showStoreSelector(); }, child: RoundButton( width: 49.w, @@ -282,137 +279,6 @@ class _StoreOrderListPage extends State { ); } - ///星店活动 - Widget starGoodsItem() { - return Container( - child: Swiper( - viewportFraction: 0.95, - loop: false, - itemBuilder: (context, position) { - return InkWell( - onTap: () { - if (widget.arguments["source"] != null && - widget.arguments["source"] == widget.activitys[position].id) { - Navigator.of(context).pop(); - } else { - Navigator.of(context).pushNamed('/router/web_page', arguments: { - "activityId": widget.activitys[position].id, - "source": widget.arguments["id"] - }); - } - }, - child: Container( - margin: EdgeInsets.symmetric(horizontal: 5.w), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(8), - boxShadow: [ - BoxShadow( - color: Color(0x0D000000), - offset: Offset(0, 3), - blurRadius: 14, - spreadRadius: 0, - ) - ], - ), - child: Stack( - children: [ - Container( - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisSize: MainAxisSize.max, - children: [ - MImage( - (widget.activitys != null && - widget.activitys.length > position) - ? widget.activitys[position].coverImg - : "", - aspectRatio: 2.2, - radius: BorderRadius.vertical( - top: Radius.circular(8), - ), - fit: BoxFit.cover, - errorSrc: "assets/image/default_2_1.png", - fadeSrc: "assets/image/default_2_1.png", - ), - Container( - padding: EdgeInsets.all(8), - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - (widget.activitys != null && - widget.activitys.length > position) - ? widget.activitys[position].storeName - : "", - style: TextStyle( - fontSize: 14.sp, - fontWeight: MyFontWeight.semi_bold, - color: Color(0xFF000000), - ), - ), - SizedBox( - height: 4.h, - ), - Text( - (widget.activitys != null && - widget.activitys.length > position) - ? widget.activitys[position].mainTitle - : "", - style: TextStyle( - fontSize: 12.sp, - fontWeight: MyFontWeight.semi_bold, - color: Color(0xFF727272), - ), - ), - ], - ), - ), - ], - ), - ), - Positioned( - top: 0, - right: 0, - child: Container( - padding: EdgeInsets.symmetric( - vertical: 4.h, - horizontal: 8.w, - ), - decoration: BoxDecoration( - color: Colors.black.withAlpha(76), - borderRadius: BorderRadius.only( - bottomLeft: Radius.circular(8), - topRight: Radius.circular(8), - ), - ), - child: Text( - (widget.activitys != null && - widget.activitys.length > position) - ? widget.activitys[position].startTime.split(" ")[0] - : "", - style: TextStyle( - fontWeight: MyFontWeight.semi_bold, - fontSize: 12.sp, - color: Color(0xD9FFFFFF), - ), - ), - ), - ), - ], - ), - ), - ); - }, - itemCount: (widget.activitys != null && widget.activitys.length > 0) - ? widget.activitys.length - : 0, - ), - ); - } - ///选规格弹窗 showStoreSelector() { showModalBottomSheet( @@ -666,262 +532,4 @@ class _StoreOrderListPage extends State { ); } - ///购物车弹窗 - showShoppingCart() { - showModalBottomSheet( - context: context, - backgroundColor: Colors.transparent, - builder: (context) { - return StatefulBuilder(builder: (context1, state) { - return Container( - alignment: Alignment.topCenter, - width: double.infinity, - decoration: BoxDecoration( - color: Color(0xFFFAFAFA), - borderRadius: BorderRadius.only( - topLeft: Radius.circular(8), topRight: Radius.circular(8)), - ), - child: Stack( - children: [ - Container( - padding: EdgeInsets.only(top: 16, left: 16, right: 16), - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - "已选商品", - style: TextStyle( - color: Colors.black, - fontSize: 14.sp, - fontWeight: MyFontWeight.medium, - ), - ), - InkWell( - onTap: () {}, - child: Image.asset( - "assets/image/delete.png", - width: 22, - height: 22, - ), - ), - ], - ), - SizedBox(height: 24.h), - Expanded( - child: Container( - child: ListView.builder( - itemCount: 10, - shrinkWrap: true, - // physics:NeverScrollableScrollPhysics(), - itemBuilder: (context, position) { - return shoppGoodsItem(); - }), - ), - ) - ], - ), - ), - Positioned( - bottom: 0, - left: 0, - right: 0, - child: Stack( - alignment: Alignment.bottomLeft, - children: [ - Container( - height: 54.h, - color: Color(0xFFFAFAFA), - child: Row( - // mainAxisAlignment: MainAxisAlignment.end, - // crossAxisAlignment: CrossAxisAlignment.end, - children: [ - Spacer(), - Text( - S.of(context).heji, - style: TextStyle( - fontSize: 12.sp, - fontWeight: MyFontWeight.regular, - color: Colors.black, - ), - ), - Text( - "¥19.00", - style: TextStyle( - fontSize: 20.sp, - fontWeight: MyFontWeight.medium, - color: Color(0xFF32A060), - ), - ), - Spacer(), - RoundButton( - width: 103.w, - height: 54.h, - text: S.current.jiesuan, - textColor: Colors.white, - fontWeight: MyFontWeight.regular, - backgroup: Color(0xFF32A060), - fontSize: 16.sp, - padding: EdgeInsets.symmetric(vertical: 5.h), - ) - ], - ), - ), - Stack( - children: [ - InkWell( - onTap: () { - setState(() { - Navigator.of(context).pop(); - }); - }, - child: Image.asset( - "assets/image/shop.png", - width: 88, - height: 88, - ), - ), - Positioned( - right: 15, - top: 14, - child: RoundButton( - width: 17, - height: 17, - text: "1", - textColor: Colors.white, - fontWeight: MyFontWeight.regular, - backgroup: Color(0xFF32A060), - fontSize: 12.sp, - radius: 100, - // padding: EdgeInsets.symmetric(vertical: 5.h), - ), - ) - ], - ), - ], - ), - ) - ], - ), - ); - }); - }, - ); - } - - Widget shoppGoodsItem() { - return Container( - padding: EdgeInsets.only(bottom: 10), - child: Row( - children: [ - Image.asset( - "assets/image/default_1.png", - width: 60, - height: 60, - fit: BoxFit.cover, - ), - SizedBox(width: 10), - Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - "手工啵啵奶茶", - style: TextStyle( - color: Colors.black, - fontSize: 12.sp, - fontWeight: MyFontWeight.medium, - ), - ), - SizedBox(height: 2), - Row( - children: [ - Text( - "无香精", - style: TextStyle( - color: Color(0xFF4C4C4C), - fontSize: 11.sp, - fontWeight: MyFontWeight.regular, - ), - ), - SizedBox(width: 10), - Text( - "无香精", - style: TextStyle( - color: Color(0xFF4C4C4C), - fontSize: 11.sp, - fontWeight: MyFontWeight.regular, - ), - ) - ], - ), - SizedBox(height: 6), - Row( - children: [ - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - children: [ - Text( - "会员价", - style: TextStyle( - color: Color(0xFFFF7A1A), - fontSize: 13.sp, - fontWeight: MyFontWeight.medium, - ), - ), - Text( - "¥19.00", - style: TextStyle( - color: Color(0xFFFF7A1A), - fontSize: 14.sp, - fontWeight: MyFontWeight.medium, - ), - ) - ], - ), - ], - ), - Spacer(), - InkWell( - onTap: () {}, - child: Image.asset( - "assets/image/reduce.png", - width: 22, - height: 22, - ), - ), - Padding( - padding: EdgeInsets.only(left: 8, right: 8), - child: Text( - "1", - style: TextStyle( - color: Colors.black, - fontSize: 14.sp, - fontWeight: MyFontWeight.medium, - ), - ), - ), - InkWell( - onTap: () {}, - child: Image.asset( - "assets/image/add.png", - width: 22, - height: 22, - ), - ), - ], - ), - ], - ), - ) - ], - ), - ); - } } diff --git a/lib/web/web_view/web_header.dart b/lib/web/web_view/web_header.dart index aa7a5807..a4e355de 100644 --- a/lib/web/web_view/web_header.dart +++ b/lib/web/web_view/web_header.dart @@ -23,7 +23,7 @@ class _WebHeader extends State { return Column( children: [ Container( - color: Color(0xFFFFFFFF), + color: Colors.white, padding: EdgeInsets.all(12), alignment: Alignment.centerLeft, child: Text( @@ -40,7 +40,7 @@ class _WebHeader extends State { ), ), Container( - color: Color(0xFFFFFFFF), + color: Colors.white, padding: EdgeInsets.symmetric(horizontal: 12.w), child: Row( children: [ From 9088465f2edc025efe4afe4ef95030f57a44c540 Mon Sep 17 00:00:00 2001 From: fmk Date: Fri, 8 Oct 2021 17:06:36 +0800 Subject: [PATCH 5/7] safety --- lib/store/store_view/store_activity.dart | 242 ++++++++++++----------- 1 file changed, 125 insertions(+), 117 deletions(-) diff --git a/lib/store/store_view/store_activity.dart b/lib/store/store_view/store_activity.dart index ac200a78..c79863a1 100644 --- a/lib/store/store_view/store_activity.dart +++ b/lib/store/store_view/store_activity.dart @@ -1,15 +1,12 @@ - - - import 'package:flutter/material.dart'; import 'package:flutter_swiper/flutter_swiper.dart'; import 'package:huixiang/retrofit/data/activity.dart'; import 'package:huixiang/utils/font_weight.dart'; import 'package:huixiang/view_widget/custom_image.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:huixiang/view_widget/no_data_view.dart'; class StoreActivity extends StatefulWidget { - final Map arguments; final List activitys; @@ -19,142 +16,153 @@ class StoreActivity extends StatefulWidget { State createState() { return _StoreActivity(); } - } class _StoreActivity extends State { @override Widget build(BuildContext context) { - return Container( - width: MediaQuery.of(context).size.width, - height: MediaQuery.of(context).size.height, - color: Colors.white, - child: Swiper( - viewportFraction: 0.95, - loop: false, - itemBuilder: (context, position) { - return InkWell( - onTap: () { - if (widget.arguments["source"] != null && - widget.arguments["source"] == widget.activitys[position].id) { - Navigator.of(context).pop(); - } else { - Navigator.of(context).pushNamed('/router/web_page', arguments: { - "activityId": widget.activitys[position].id, - "source": widget.arguments["id"] - }); - } - }, - child: Container( - margin: EdgeInsets.symmetric(horizontal: 5.w), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(8), - boxShadow: [ - BoxShadow( - color: Color(0x0D000000), - offset: Offset(0, 3), - blurRadius: 14, - spreadRadius: 0, - ), - ], - ), - child: Stack( - children: [ - Container( - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisSize: MainAxisSize.max, - children: [ - MImage( - (widget.activitys != null && - widget.activitys.length > position) - ? widget.activitys[position].coverImg - : "", - aspectRatio: 2.2, - radius: BorderRadius.vertical( - top: Radius.circular(8), - ), - fit: BoxFit.cover, - errorSrc: "assets/image/default_2_1.png", - fadeSrc: "assets/image/default_2_1.png", + return (widget.activitys == null || widget.activitys.length == 0) + ? NoDataView( + isShowBtn: false, + text: "还没有活动~", + fontSize: 16.sp, + margin: EdgeInsets.only(top: 180.h), + ) + : Container( + width: MediaQuery.of(context).size.width, + height: MediaQuery.of(context).size.height, + color: Colors.white, + child: Swiper( + viewportFraction: 0.95, + loop: false, + itemBuilder: (context, position) { + return InkWell( + onTap: () { + if (widget.arguments["source"] != null && + widget.arguments["source"] == + widget.activitys[position].id) { + Navigator.of(context).pop(); + } else { + Navigator.of(context).pushNamed('/router/web_page', + arguments: { + "activityId": widget.activitys[position].id, + "source": widget.arguments["id"] + }); + } + }, + child: Container( + margin: EdgeInsets.symmetric(horizontal: 5.w), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(8), + boxShadow: [ + BoxShadow( + color: Color(0x0D000000), + offset: Offset(0, 3), + blurRadius: 14, + spreadRadius: 0, ), + ], + ), + child: Stack( + children: [ Container( - padding: EdgeInsets.all(8), child: Column( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.max, children: [ - Text( + MImage( (widget.activitys != null && - widget.activitys.length > position) - ? widget.activitys[position].storeName + widget.activitys.length > position) + ? widget.activitys[position].coverImg : "", - style: TextStyle( - fontSize: 14.sp, - fontWeight: MyFontWeight.semi_bold, - color: Color(0xFF000000), + aspectRatio: 2.2, + radius: BorderRadius.vertical( + top: Radius.circular(8), ), + fit: BoxFit.cover, + errorSrc: "assets/image/default_2_1.png", + fadeSrc: "assets/image/default_2_1.png", ), - SizedBox( - height: 4.h, - ), - Text( - (widget.activitys != null && - widget.activitys.length > position) - ? widget.activitys[position].mainTitle - : "", - style: TextStyle( - fontSize: 12.sp, - fontWeight: MyFontWeight.semi_bold, - color: Color(0xFF727272), + Container( + padding: EdgeInsets.all(8), + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + (widget.activitys != null && + widget.activitys.length > + position) + ? widget.activitys[position].storeName + : "", + style: TextStyle( + fontSize: 14.sp, + fontWeight: MyFontWeight.semi_bold, + color: Color(0xFF000000), + ), + ), + SizedBox( + height: 4.h, + ), + Text( + (widget.activitys != null && + widget.activitys.length > + position) + ? widget.activitys[position].mainTitle + : "", + style: TextStyle( + fontSize: 12.sp, + fontWeight: MyFontWeight.semi_bold, + color: Color(0xFF727272), + ), + ), + ], ), ), ], ), ), - ], - ), - ), - Positioned( - top: 0, - right: 0, - child: Container( - padding: EdgeInsets.symmetric( - vertical: 4.h, - horizontal: 8.w, - ), - decoration: BoxDecoration( - color: Colors.black.withAlpha(76), - borderRadius: BorderRadius.only( - bottomLeft: Radius.circular(8), - topRight: Radius.circular(8), - ), - ), - child: Text( - (widget.activitys != null && - widget.activitys.length > position) - ? widget.activitys[position].startTime.split(" ")[0] - : "", - style: TextStyle( - fontWeight: MyFontWeight.semi_bold, - fontSize: 12.sp, - color: Color(0xD9FFFFFF), + Positioned( + top: 0, + right: 0, + child: Container( + padding: EdgeInsets.symmetric( + vertical: 4.h, + horizontal: 8.w, + ), + decoration: BoxDecoration( + color: Colors.black.withAlpha(76), + borderRadius: BorderRadius.only( + bottomLeft: Radius.circular(8), + topRight: Radius.circular(8), + ), + ), + child: Text( + (widget.activitys != null && + widget.activitys.length > position) + ? widget.activitys[position].startTime + .split(" ")[0] + : "", + style: TextStyle( + fontWeight: MyFontWeight.semi_bold, + fontSize: 12.sp, + color: Color(0xD9FFFFFF), + ), + ), + ), ), - ), + ], ), ), - ], - ), + ); + }, + itemCount: + (widget.activitys != null && widget.activitys.length > 0) + ? widget.activitys.length + : 0, ), ); - }, - itemCount: (widget.activitys != null && widget.activitys.length > 0) - ? widget.activitys.length - : 0, - ), - ); } - -} \ No newline at end of file +} From 51853739812785d340d44612a1c4c4bf071e322e Mon Sep 17 00:00:00 2001 From: fmk Date: Fri, 8 Oct 2021 18:56:17 +0800 Subject: [PATCH 6/7] 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; + +} From c008a9b903de16d5d701b0498c3d6690d983b6ac Mon Sep 17 00:00:00 2001 From: fmk Date: Fri, 8 Oct 2021 18:56:32 +0800 Subject: [PATCH 7/7] safety --- lib/store/store_order.dart | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/store/store_order.dart b/lib/store/store_order.dart index 18991906..975305de 100644 --- a/lib/store/store_order.dart +++ b/lib/store/store_order.dart @@ -16,7 +16,6 @@ import 'package:huixiang/union/union_view/union_coupon.dart'; import 'package:huixiang/union/union_view/vip.dart'; import 'package:huixiang/utils/font_weight.dart'; import 'package:huixiang/view_widget/classic_header.dart'; -import 'package:huixiang/view_widget/custom_image.dart'; import 'package:huixiang/view_widget/my_tab.dart'; import 'package:huixiang/view_widget/round_button.dart'; import 'package:pull_to_refresh/pull_to_refresh.dart';