diff --git a/lib/community/community_page.dart b/lib/community/community_page.dart index c9b76326..49e6fdf8 100644 --- a/lib/community/community_page.dart +++ b/lib/community/community_page.dart @@ -17,7 +17,7 @@ class CommunityPage extends StatefulWidget { } class _CommunityPage extends State - with SingleTickerProviderStateMixin { + with SingleTickerProviderStateMixin,AutomaticKeepAliveClientMixin { TabController tabcontroller; CommunityChildPage guanzhu,tuijian ; @@ -83,7 +83,12 @@ class _CommunityPage extends State MediaQuery.of(context).size.width - 60.w, 38.h, ), - child: TabBar( + child: Theme( + data: ThemeData( + splashColor: Colors.transparent, // 点击时的水波纹颜色设置为透明 + highlightColor: Colors.transparent, // 点击时的背景高亮颜色设置为透明 + ), + child: TabBar( controller: tabcontroller, automaticIndicatorColorAdjustment: true, isScrollable: true, @@ -102,7 +107,7 @@ class _CommunityPage extends State ), labelColor: Colors.black, tabs: lables.map((e) => MyTab(text: e)).toList(), - ), + )), ), // onTap: () { // _toRelease(); @@ -148,4 +153,7 @@ class _CommunityPage extends State ), ); } + + @override + bool get wantKeepAlive => true; } diff --git a/lib/community/community_view/class_list_view.dart b/lib/community/community_view/class_list_view.dart index 92f45945..c1c2a21f 100644 --- a/lib/community/community_view/class_list_view.dart +++ b/lib/community/community_view/class_list_view.dart @@ -168,7 +168,7 @@ class _ClassListView extends State { Text( classList.subject, overflow: TextOverflow.ellipsis, - maxLines: 2, + maxLines: 1, style: TextStyle( fontSize: 14.sp, fontWeight: MyFontWeight.semi_bold, diff --git a/lib/community/community_view/class_title_tab.dart b/lib/community/community_view/class_title_tab.dart index 44f47df3..7394b1f9 100644 --- a/lib/community/community_view/class_title_tab.dart +++ b/lib/community/community_view/class_title_tab.dart @@ -19,7 +19,7 @@ class ClassTitleTab extends StatefulWidget { } class _ClassTitleTab extends State - with SingleTickerProviderStateMixin { + with SingleTickerProviderStateMixin,AutomaticKeepAliveClientMixin { TabController tabController; @override @@ -68,4 +68,6 @@ class _ClassTitleTab extends State ); } + @override + bool get wantKeepAlive => true; } diff --git a/lib/community/community_view/home_class.dart b/lib/community/community_view/home_class.dart index add55a71..2649c8ab 100644 --- a/lib/community/community_view/home_class.dart +++ b/lib/community/community_view/home_class.dart @@ -48,8 +48,6 @@ class _HomeClass extends State { Widget collectItem(CollectClassList collectList) { return Container( - width: 168.w, - // height: 250, margin: EdgeInsets.symmetric( horizontal: 6.w, vertical: 10.h, @@ -106,7 +104,6 @@ class _HomeClass extends State { Widget classItem(CourseList collect) { return Container( width: 168.w, - height: 195.h, decoration: BoxDecoration( borderRadius: BorderRadius.vertical( bottom: Radius.circular(4), @@ -258,7 +255,7 @@ class _HomeClass extends State { child: Text( collect.subject, overflow: TextOverflow.ellipsis, - maxLines: 2, + maxLines: 1, style: TextStyle( fontSize: 14.sp, fontWeight: MyFontWeight.semi_bold, diff --git a/lib/community/order_page.dart b/lib/community/order_page.dart index 862426ea..caddd2ac 100644 --- a/lib/community/order_page.dart +++ b/lib/community/order_page.dart @@ -16,7 +16,7 @@ class OrderPage extends StatefulWidget { } class _OrderPage extends State - with SingleTickerProviderStateMixin { + with SingleTickerProviderStateMixin,AutomaticKeepAliveClientMixin { TabController tabcontroller; List lables = [ @@ -42,7 +42,12 @@ class _OrderPage extends State appBar: MyAppBar( title: "", leading: false, - bottom: TabBar( + bottom: Theme( + data: ThemeData( + splashColor: Colors.transparent, // 点击时的水波纹颜色设置为透明 + highlightColor: Colors.transparent, // 点击时的背景高亮颜色设置为透明 + ), + child: TabBar( // isScrollable: true, //可滚动 indicatorColor: Color(0xff39B54A), labelColor: Colors.black, @@ -65,7 +70,7 @@ class _OrderPage extends State MyTab(text: S.of(context).weiwancheng), MyTab(text: S.of(context).yiwancheng), ], - ), + )), ), body: TabBarView( children: [OrderHistoryList(0),OrderHistoryList(1),OrderHistoryList(2),OrderHistoryList(3), ], @@ -73,4 +78,7 @@ class _OrderPage extends State ), ); } + + @override + bool get wantKeepAlive => true; } \ No newline at end of file diff --git a/lib/home/points_mall_view/points_goods_title.dart b/lib/home/points_mall_view/points_goods_title.dart index b09e70f0..7ff78430 100644 --- a/lib/home/points_mall_view/points_goods_title.dart +++ b/lib/home/points_mall_view/points_goods_title.dart @@ -23,7 +23,8 @@ class PointsGoodsTitle extends StatefulWidget { } } -class _PointsGoodsTitle extends State { +class _PointsGoodsTitle extends State + with SingleTickerProviderStateMixin, AutomaticKeepAliveClientMixin{ var _itemText = S.current.morenpaixu; List sortString = [ S.current.morenpaixu, @@ -162,4 +163,7 @@ class _PointsGoodsTitle extends State { _itemText = item; }); } + + @override + bool get wantKeepAlive => true; } diff --git a/lib/home/welfare_exchange.dart b/lib/home/welfare_exchange.dart index 80202a46..ede6a0d7 100644 --- a/lib/home/welfare_exchange.dart +++ b/lib/home/welfare_exchange.dart @@ -31,7 +31,7 @@ class WelfareExchange extends StatefulWidget { } } -class _WelfareExchange extends State { +class _WelfareExchange extends State with SingleTickerProviderStateMixin, AutomaticKeepAliveClientMixin{ ApiService apiService; final ScrollController scrollController = ScrollController(); final RefreshController refreshController = RefreshController(); @@ -582,4 +582,7 @@ class _WelfareExchange extends State { return "${AppUtils.calculateDouble(double.tryParse(goods.oneMoney) ?? 0)}元"; } } + + @override + bool get wantKeepAlive => true; } diff --git a/lib/integral/integral_detailed_page.dart b/lib/integral/integral_detailed_page.dart index 2032affc..0f6e7990 100644 --- a/lib/integral/integral_detailed_page.dart +++ b/lib/integral/integral_detailed_page.dart @@ -25,7 +25,7 @@ class IntegralDetailedPage extends StatefulWidget { } class _IntegralDetailedPage extends State - with SingleTickerProviderStateMixin { + with SingleTickerProviderStateMixin, AutomaticKeepAliveClientMixin { List _tabs; TabController tabController; @@ -64,7 +64,8 @@ class _IntegralDetailedPage extends State void initState() { super.initState(); SharedPreferences.getInstance().then((value) => { - apiService = ApiService(Dio(), context: context, token: value.getString("token")), + apiService = ApiService(Dio(), + context: context, token: value.getString("token")), userInfo = UserInfo.fromJson(jsonDecode(value.getString('user'))), queryDetail("bill_cate_point_get"), }); @@ -155,47 +156,52 @@ class _IntegralDetailedPage extends State leadingWidth: 56, flexibleSpace: FlexibleSpaceBar( background: Container( - alignment: Alignment.center, - margin: EdgeInsets.only(top: 56.h), - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Text( - userInfo != null ? userInfo.points : "0", - style: TextStyle( - color: Colors.white, - fontWeight: MyFontWeight.medium, - fontSize: 48.sp), - ), - Text( - S.of(context).wodejifenzhi, - style: TextStyle( - color: Color(0xFFF2F2F2), - fontSize: 12.sp, - fontWeight: MyFontWeight.regular), - ), - ], + alignment: Alignment.center, + margin: EdgeInsets.only(top: 56.h), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Text( + userInfo != null ? userInfo.points : "0", + style: TextStyle( + color: Colors.white, + fontWeight: MyFontWeight.medium, + fontSize: 48.sp), + ), + Text( + S.of(context).wodejifenzhi, + style: TextStyle( + color: Color(0xFFF2F2F2), + fontSize: 12.sp, + fontWeight: MyFontWeight.regular), + ), + ], + ), ), ), - ), expandedHeight: 228, bottom: PreferredSize( - preferredSize: Size(double.infinity, 38), - child: TabBar( - tabs: _tabs, - controller: tabController, - isScrollable: false, - indicatorSize: TabBarIndicatorSize.label, - labelColor: Colors.white, - labelStyle: - TextStyle(fontSize: 16.sp, fontWeight: MyFontWeight.medium), - unselectedLabelStyle: - TextStyle(fontSize: 16.sp,fontWeight: MyFontWeight.medium), - indicatorColor: Colors.white, - unselectedLabelColor: Color(0xFFE6E6E6), - ), - ), + preferredSize: Size(double.infinity, 38), + child: Theme( + data: ThemeData( + splashColor: Colors.transparent, // 点击时的水波纹颜色设置为透明 + highlightColor: Colors.transparent, // 点击时的背景高亮颜色设置为透明 + ), + child: TabBar( + tabs: _tabs, + controller: tabController, + isScrollable: false, + indicatorSize: TabBarIndicatorSize.label, + labelColor: Colors.white, + labelStyle: TextStyle( + fontSize: 16.sp, fontWeight: MyFontWeight.medium), + unselectedLabelStyle: TextStyle( + fontSize: 16.sp, fontWeight: MyFontWeight.medium), + indicatorColor: Colors.white, + unselectedLabelColor: Color(0xFFE6E6E6), + ), + )), ), ]; }, @@ -289,4 +295,7 @@ class _IntegralDetailedPage extends State ), ); } + + @override + bool get wantKeepAlive => true; } diff --git a/lib/main.dart b/lib/main.dart index 60d542f1..028734a4 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -132,7 +132,7 @@ void main() async { SharedPreferences sharedPreferences = await SharedPreferences.getInstance(); Locale locale; if (sharedPreferences.containsKey("language") && - sharedPreferences.getString("language") == "zh") { + sharedPreferences.getString("language") == "tw") { locale = Locale.fromSubtags(languageCode: 'zh', countryCode: 'TW'); } else { locale = Locale.fromSubtags(languageCode: 'zh', countryCode: 'CH'); diff --git a/lib/mine/fans_page.dart b/lib/mine/fans_page.dart index 9b769753..76181c8f 100644 --- a/lib/mine/fans_page.dart +++ b/lib/mine/fans_page.dart @@ -29,7 +29,8 @@ class FansPage extends StatefulWidget { } } -class _FansPage extends State { +class _FansPage extends State + with SingleTickerProviderStateMixin, AutomaticKeepAliveClientMixin { RefreshController _refreshController; int pageNum = 1; List list = []; @@ -208,4 +209,7 @@ class _FansPage extends State { ), ); } + + @override + bool get wantKeepAlive => true; } diff --git a/lib/mine/follow_page.dart b/lib/mine/follow_page.dart index 63ab8c60..2a5718ad 100644 --- a/lib/mine/follow_page.dart +++ b/lib/mine/follow_page.dart @@ -30,7 +30,7 @@ class FollowPage extends StatefulWidget { } } -class _FollowPage extends State { +class _FollowPage extends State with SingleTickerProviderStateMixin, AutomaticKeepAliveClientMixin{ RefreshController _refreshController; ApiService apiService; int pageNum = 1; @@ -201,4 +201,7 @@ class _FollowPage extends State { ), ); } + + @override + bool get wantKeepAlive => true; } diff --git a/lib/mine/mine_card_page.dart b/lib/mine/mine_card_page.dart index 8317d904..0b09bd31 100644 --- a/lib/mine/mine_card_page.dart +++ b/lib/mine/mine_card_page.dart @@ -16,7 +16,7 @@ class MineCardPage extends StatefulWidget { } class _MineCardPage extends State - with SingleTickerProviderStateMixin { + with SingleTickerProviderStateMixin,AutomaticKeepAliveClientMixin { @override Widget build(BuildContext context) { return DefaultTabController( @@ -57,4 +57,7 @@ class _MineCardPage extends State ), ); } + + @override + bool get wantKeepAlive => true; } diff --git a/lib/mine/mine_view/community_follow.dart b/lib/mine/mine_view/community_follow.dart index 5b56f089..c5a15b18 100644 --- a/lib/mine/mine_view/community_follow.dart +++ b/lib/mine/mine_view/community_follow.dart @@ -21,7 +21,7 @@ class CommunityFollow extends StatefulWidget { } class _CommunityFollow extends State - with SingleTickerProviderStateMixin { + with SingleTickerProviderStateMixin, AutomaticKeepAliveClientMixin { ApiService apiService; SocialInfo infoNumber; @@ -34,15 +34,11 @@ class _CommunityFollow extends State ///个人社交信息(粉丝/关注数量/成就数量) querySocialInfo() async { SharedPreferences value = await SharedPreferences.getInstance(); - apiService = ApiService( - Dio(), - context: context, - token: value.getString("token"), - showLoading: true - ); + apiService = ApiService(Dio(), + context: context, token: value.getString("token"), showLoading: true); BaseData baseData = - await apiService.socialInfo().catchError((onError) {}); + await apiService.socialInfo().catchError((onError) {}); if (baseData != null && baseData.isSuccess) { setState(() { infoNumber = baseData.data; @@ -51,7 +47,6 @@ class _CommunityFollow extends State EasyLoading.dismiss(); } - @override Widget build(BuildContext context) { return DefaultTabController( @@ -81,15 +76,27 @@ class _CommunityFollow extends State indicatorSize: TabBarIndicatorSize.label, //指示器与文字等宽 tabs: [ - MyTab(text:"关注${infoNumber?.follow??"0"}",), - MyTab(text: "粉丝${infoNumber?.fans??"0"}"), + MyTab( + text: "关注${infoNumber?.follow ?? "0"}", + ), + MyTab(text: "粉丝${infoNumber?.fans ?? "0"}"), ], ), ), body: TabBarView( - children: [FollowPage((){querySocialInfo();}),FansPage((){querySocialInfo();})], + children: [ + FollowPage(() { + querySocialInfo(); + }), + FansPage(() { + querySocialInfo(); + }) + ], ), ), ); } + + @override + bool get wantKeepAlive => true; } diff --git a/lib/mine/mine_view/mine_view.dart b/lib/mine/mine_view/mine_view.dart index a27c8241..f8248f56 100644 --- a/lib/mine/mine_view/mine_view.dart +++ b/lib/mine/mine_view/mine_view.dart @@ -328,7 +328,7 @@ class _MineView extends State { : Row( children: [ Text( - "${S.of(context).guanzhu} ${widget?.infoNumber?.follow.toString() ?? "0"}", + "${S.of(context).guanzhu} ${widget?.infoNumber?.follow ?? "0"}", style: TextStyle( fontSize: 12.sp, fontWeight: MyFontWeight.regular, @@ -342,7 +342,7 @@ class _MineView extends State { color: Color(0xFFFFFFFF), ), Text( - "${S.of(context).fensi} ${widget?.infoNumber?.fans.toString() ?? "0"}", + "${S.of(context).fensi} ${widget?.infoNumber?.fans ?? "0"}", style: TextStyle( fontSize: 12.sp, fontWeight: MyFontWeight.regular, diff --git a/lib/order/bargain_group_order.dart b/lib/order/bargain_group_order.dart index c49b47a1..068167bf 100644 --- a/lib/order/bargain_group_order.dart +++ b/lib/order/bargain_group_order.dart @@ -125,7 +125,7 @@ class ExchangeHistoryList extends StatefulWidget { } } -class _ExchangeHistoryList extends State { +class _ExchangeHistoryList extends State with AutomaticKeepAliveClientMixin{ MinApiService minService; List activityOrderList = []; RefreshController _refreshController = RefreshController(initialRefresh: false); @@ -473,4 +473,7 @@ class _ExchangeHistoryList extends State { ), ); } + + @override + bool get wantKeepAlive => true; } diff --git a/lib/order/exchange_history_page.dart b/lib/order/exchange_history_page.dart index ebf56a16..51eec9aa 100644 --- a/lib/order/exchange_history_page.dart +++ b/lib/order/exchange_history_page.dart @@ -78,7 +78,12 @@ class _ExchangeHistoryPage extends State toolbarHeight: kToolbarHeight + MediaQuery.of(context).padding.top, bottom: PreferredSize( preferredSize: Size(double.infinity, 38.h), - child: TabBar( + child: Theme( + data: ThemeData( + splashColor: Colors.transparent, // 点击时的水波纹颜色设置为透明 + highlightColor: Colors.transparent, // 点击时的背景高亮颜色设置为透明 + ), + child: TabBar( controller: tabcontroller, indicatorWeight: 2, indicatorColor: Color(0xFF39B54A), @@ -94,7 +99,7 @@ class _ExchangeHistoryPage extends State fontWeight: MyFontWeight.semi_bold), labelColor: Colors.black, tabs: tabs, - ), + )), ), ), body: TabBarView( @@ -117,7 +122,8 @@ class ExchangeHistoryList extends StatefulWidget { } } -class _ExchangeHistoryList extends State { +class _ExchangeHistoryList extends State + with AutomaticKeepAliveClientMixin{ ApiService apiService; RefreshController _refreshController = @@ -563,4 +569,7 @@ class _ExchangeHistoryList extends State { // ); } } + + @override + bool get wantKeepAlive => true; } diff --git a/lib/order/order_history_page.dart b/lib/order/order_history_page.dart index c8a9fc6c..eb5ddd9e 100644 --- a/lib/order/order_history_page.dart +++ b/lib/order/order_history_page.dart @@ -69,7 +69,12 @@ class _OrderHistoryPage extends State toolbarHeight: kToolbarHeight + MediaQuery.of(context).padding.top, bottom: PreferredSize( preferredSize: Size(double.infinity, 38.h), - child: TabBar( + child: Theme( + data: ThemeData( + splashColor: Colors.transparent, // 点击时的水波纹颜色设置为透明 + highlightColor: Colors.transparent, // 点击时的背景高亮颜色设置为透明 + ), + child: TabBar( controller: tabController, isScrollable: false, indicatorWeight: 2.w, @@ -100,7 +105,7 @@ class _OrderHistoryPage extends State text: S.of(context).yiwancheng, ) ], - ), + )), ), ), body: TabBarView( diff --git a/lib/retrofit/data/min_order_info.dart b/lib/retrofit/data/min_order_info.dart index d2370a0a..04bd3f90 100644 --- a/lib/retrofit/data/min_order_info.dart +++ b/lib/retrofit/data/min_order_info.dart @@ -49,7 +49,8 @@ class MinOrderInfo { int payChannel, dynamic payNum, String promotionId, - String couponId, + String couponId, + String couponName, int isDelete, int isTakeOut, int batch, @@ -131,6 +132,7 @@ class MinOrderInfo { this.payNum = payNum; this.promotionId = promotionId; this.couponId = couponId; + this.couponName = couponName; this.isDelete = isDelete; this.isTakeOut = isTakeOut; this.batch = batch; @@ -215,6 +217,7 @@ class MinOrderInfo { this.payNum = json['payNum']; this.promotionId = json['promotionId']; this.couponId = json['couponId']; + this.couponName = json['couponName']; this.isDelete = json['isDelete']; this.isTakeOut = json['isTakeOut']; this.batch = json['batch']; @@ -302,6 +305,7 @@ class MinOrderInfo { dynamic payNum; String promotionId; String couponId; + String couponName; int isDelete; int isTakeOut; int batch; @@ -386,6 +390,7 @@ class MinOrderInfo { map['payNum'] = this.payNum; map['promotionId'] = this.promotionId; map['couponId'] = this.couponId; + map['couponName'] = this.couponName; map['isDelete'] = this.isDelete; map['isTakeOut'] = this.isTakeOut; map['batch'] = this.batch; diff --git a/lib/retrofit/min_api.dart b/lib/retrofit/min_api.dart index 72a86318..f37552cb 100644 --- a/lib/retrofit/min_api.dart +++ b/lib/retrofit/min_api.dart @@ -4,11 +4,9 @@ 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/retrofit/data/address.dart'; import 'package:huixiang/retrofit/data/base_data.dart'; -import 'package:huixiang/retrofit/data/down_order.dart'; import 'package:huixiang/retrofit/data/min_order_info.dart'; import 'package:huixiang/retrofit/data/wx_pay.dart'; import 'package:huixiang/view_widget/login_tips_dialog.dart'; @@ -247,4 +245,12 @@ abstract class MinApiService { @GET("actTemplate/showOneAct?actRecordId={actRecordId}") Future> showOneAct(@Path("actRecordId") String actRecordId); + /// 小程序取消优惠券 + @GET("promotion/cancelMemberCoupon?orderId={orderId}") + Future cancelMemberCoupon(@Path("orderId") String orderId); + + /// 小程序使用该优惠券 + @POST("promotion/useMemberCoupon") + Future useMemberCoupon(@Body() Map param); + } diff --git a/lib/retrofit/min_api.g.dart b/lib/retrofit/min_api.g.dart index b2d36ae5..563bfbf2 100644 --- a/lib/retrofit/min_api.g.dart +++ b/lib/retrofit/min_api.g.dart @@ -218,7 +218,7 @@ class _MinApiService implements MinApiService { data: _data); final value = BaseData.fromJson( _result.data, - (json) => SettleOrderInfo.fromJson(json), + (json) => json == "" ? null :SettleOrderInfo.fromJson(json), ); return value; } @@ -605,4 +605,49 @@ class _MinApiService implements MinApiService { ); return value; } + + @override + Future> cancelMemberCoupon(orderId) async { + ArgumentError.checkNotNull(orderId, 'orderId'); + const _extra = {}; + final queryParameters = {}; + final _data = {}; + final _result = await _dio.request>( + 'promotion/cancelMemberCoupon?orderId=$orderId', + 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> useMemberCoupon(param) async { + ArgumentError.checkNotNull(param, 'param'); + const _extra = {}; + final queryParameters = {}; + final _data = {}; + _data.addAll(param ?? {}); + final _result = await _dio.request>( + 'promotion/useMemberCoupon', + 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; + } } diff --git a/lib/setting/setting_page.dart b/lib/setting/setting_page.dart index d6864c9f..68a308bf 100644 --- a/lib/setting/setting_page.dart +++ b/lib/setting/setting_page.dart @@ -144,9 +144,9 @@ class _SettingPage extends State { }, child: settingItem( S.of(context).yuyan, - locale == "zh" - ? S.of(context).zhongwenjianti - : S.of(context).fantizhongwen), + locale == "tw" + ? S.of(context).fantizhongwen + : S.of(context).zhongwenjianti), ), GestureDetector( child: settingSingleItem(S.of(context).quanxian), diff --git a/lib/settlement/settlement.dart b/lib/settlement/settlement.dart index 38839c73..a18fcc2b 100644 --- a/lib/settlement/settlement.dart +++ b/lib/settlement/settlement.dart @@ -164,8 +164,18 @@ class _Settlement extends State { } ///订单结算信息 - queryOrderInfo(addressId, isTake, memberCouponId, orderId, promotionId, - productSkuId, actProductId, actProductSkuId, buyNum, payChannel,tableId) async { + queryOrderInfo( + addressId, + isTake, + memberCouponId, + orderId, + promotionId, + productSkuId, + actProductId, + actProductSkuId, + buyNum, + payChannel, + tableId) async { BaseData baseData = await minService.getOrderInfo({ "addressId": addressId, "isTake": isTake, @@ -177,7 +187,7 @@ class _Settlement extends State { "actProductSkuId": actProductSkuId, "buyNum": buyNum, "payChannel": payChannel, - "tableId":tableId + "tableId": tableId }).catchError((error) {}); this.promotion = null; promotions = ""; @@ -186,17 +196,17 @@ class _Settlement extends State { if (baseData != null && baseData.isSuccess) { setState(() { settleOrderInfo = baseData.data; - if((settleOrderInfo?.promotionId??"")!=""){ + if ((settleOrderInfo?.promotionId ?? "") != "") { settleOrderInfo.promotionInfoList.forEach((element) { - if(element.id == settleOrderInfo.promotionId){ + if (element.id == settleOrderInfo.promotionId) { this.promotion = element; promotions = promotion?.name ?? ""; } }); } - if((settleOrderInfo?.memberCouponId??"")!=""){ + if ((settleOrderInfo?.memberCouponId ?? "") != "") { settleOrderInfo.couponList.forEach((element) { - if(element.id == settleOrderInfo.memberCouponId){ + if (element.id == settleOrderInfo.memberCouponId) { this.couponListBean = element; coupons = couponListBean?.promotionName ?? ""; } @@ -209,21 +219,50 @@ class _Settlement extends State { pageType != null ? widget.arguments["orderId"] : parentId); } }); + } else { + SmartDialog.showToast(baseData?.msg ?? "", alignment: Alignment.center); } } ///查看订单详情 queryOrderDetails(id) async { - BaseData baseData = await minService.getOrderDetails({ - "id": pageType != null ? widget.arguments["orderId"] : id??parentId, - }).catchError((error) {}); - if (baseData != null && baseData.isSuccess) { - setState(() { - minOrderInfo = baseData.data; - }); - } else { - SmartDialog.showToast(baseData.msg ?? "", alignment: Alignment.center); - } + BaseData baseData = await minService.getOrderDetails({ + "id": pageType != null ? widget.arguments["orderId"] : id ?? parentId, + }).catchError((error) {}); + if (baseData != null && baseData.isSuccess) { + setState(() { + minOrderInfo = baseData.data; + coupons = minOrderInfo?.couponName ?? ""; + }); + } else { + SmartDialog.showToast(baseData.msg ?? "", alignment: Alignment.center); + } + } + + ///取消优惠券 + queryCancelMemberCoupon(orderId) async { + BaseData baseData = + await minService.cancelMemberCoupon(orderId).catchError((error) {}); + if (baseData != null && baseData.isSuccess) { + queryOrderDetails(parentId); + // SmartDialog.showToast(baseData.data, alignment: Alignment.center); + } else { + SmartDialog.showToast(baseData.msg ?? "", alignment: Alignment.center); + } + } + + ///使用该优惠券 + queryUseMemberCoupon(memberCouponId) async { + BaseData baseData = await minService.useMemberCoupon({ + "memberCouponId": memberCouponId, + "orderId": parentId, + "phone": minOrderInfo.orderInfoVo.memberVO.phone + }).catchError((error) {}); + if (baseData != null && baseData.isSuccess) { + queryOrderDetails(parentId); + } else { + SmartDialog.showToast(baseData.msg ?? "", alignment: Alignment.center); + } } queryAddress(int selectedBtn) async { @@ -438,7 +477,6 @@ class _Settlement extends State { .catchError((error) { print("error: $error"); }); - // orderButton =false; if (baseData != null && baseData.isSuccess) { placeOrder = true; this.downOrder = DownOrder.fromJson(baseData.data); @@ -470,11 +508,11 @@ class _Settlement extends State { }); } } - orderButton =false; + orderButton = false; if (baseData != null && baseData.isSuccess) { placeOrder = true; this.downOrder = DownOrder.fromJson(baseData.data); - parentId = this.downOrder.id??this.downOrder.parentId; + parentId = this.downOrder.id ?? this.downOrder.parentId; queryOrderDetails(parentId); setState(() {}); } else { @@ -503,7 +541,7 @@ class _Settlement extends State { .catchError((error) { print(error); }); - orderButton =false; + orderButton = false; if (baseData != null && baseData.isSuccess) { WxPay wxPay = baseData.data; await registerWxApi( @@ -527,7 +565,7 @@ class _Settlement extends State { .catchError((error) { print(error); }); - orderButton =false; + orderButton = false; if (baseData != null && baseData.isSuccess) { SmartDialog.showToast(baseData.data, alignment: Alignment.center); toOrderDetails(placeOrderFirst.id); @@ -704,6 +742,7 @@ class _Settlement extends State { couponCart, activityCart, settleOrderInfo, + minOrderInfo, coupons, promotions, couponCount(), @@ -760,7 +799,7 @@ class _Settlement extends State { ), Text( (minOrderInfo != null - ? "¥${minOrderInfo.orderSumPrice}" + ? "¥${minOrderInfo.finalPayPrice}" : "¥${settleOrderInfo == null ? "0" : settleOrderInfo.price}"), style: TextStyle( fontSize: 20.sp, @@ -786,11 +825,11 @@ class _Settlement extends State { vertical: 5.h, ), callback: () { - if(orderButton){ - SmartDialog.showToast("订单正在提交中...",alignment: Alignment.center); + if (orderButton) { + SmartDialog.showToast("订单正在提交中...", + alignment: Alignment.center); return; - } - else + } else orderButton = true; pageType != null ? bargainOrderId != null @@ -857,7 +896,8 @@ class _Settlement extends State { context: context, backgroundColor: Colors.transparent, builder: (context) { - return SettlementCoupon(settleOrderInfo, storeInfo, + return SettlementCoupon( + settleOrderInfo, minOrderInfo, tableId, storeInfo, couponBean: couponListBean); }, ); @@ -866,6 +906,12 @@ class _Settlement extends State { // coupons = couponListBean?.promotionName ?? ""; // promotions = ""; // this.promotion = null; + if (tableId > 0) { + if(couponBean == null) + queryCancelMemberCoupon(parentId); + if (couponBean.id != null) + queryUseMemberCoupon(couponBean.id); + } else { queryOrderInfo( address?.id, selectedBtn, @@ -878,6 +924,8 @@ class _Settlement extends State { count1, payChannel, tableId); + } + // } } @@ -896,18 +944,18 @@ class _Settlement extends State { // promotions = promotion?.name ?? ""; // coupons = ""; // this.couponListBean = null; - queryOrderInfo( - address?.id, - selectedBtn, - null, - 0, - promotion != null ? pro.id : (productId ?? null), - productSkuId ?? "", - actProductId ?? "", - actProductSkuId ?? "", - count1, - payChannel, - tableId); - } - // } + queryOrderInfo( + address?.id, + selectedBtn, + null, + 0, + promotion != null ? pro.id : (productId ?? null), + productSkuId ?? "", + actProductId ?? "", + actProductSkuId ?? "", + count1, + payChannel, + tableId); + } +// } } diff --git a/lib/settlement/settlement_view/activity_coupon_remarks.dart b/lib/settlement/settlement_view/activity_coupon_remarks.dart index 345b7649..ce610134 100644 --- a/lib/settlement/settlement_view/activity_coupon_remarks.dart +++ b/lib/settlement/settlement_view/activity_coupon_remarks.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:huixiang/generated/l10n.dart'; +import 'package:huixiang/retrofit/data/min_order_info.dart'; import 'package:huixiang/retrofit/data/settleOrderInfo.dart'; import 'package:huixiang/retrofit/data/store_info.dart'; import 'package:huixiang/utils/font_weight.dart'; @@ -13,6 +14,7 @@ class ActivityCouponRemarks extends StatefulWidget { final String coupons; final String promotions; final SettleOrderInfo settleOrderInfo; + final MinOrderInfo minOrderInfo; final int couponCount; final bool placeOrder; final String remark; @@ -22,6 +24,7 @@ class ActivityCouponRemarks extends StatefulWidget { this.couponCart, this.activityCart, this.settleOrderInfo, + this.minOrderInfo, this.coupons, this.promotions, this.couponCount, @@ -136,11 +139,11 @@ class _ActivityCouponRemarks extends State { ], ), ), - if (widget.placeOrder && widget.tableId <=0) + if (widget.placeOrder) SizedBox( height: 13, ), - if (widget.placeOrder && widget.tableId <=0) + if (widget.placeOrder) InkWell( onTap: () { widget.couponCart(); @@ -242,6 +245,13 @@ class _ActivityCouponRemarks extends State { String coupon = ""; if (widget.coupons == null || widget.coupons == "") { coupon = "未选择任何优惠券"; + if(widget.placeOrder) + if(widget.minOrderInfo == null || + widget.minOrderInfo.orderInfoVo.couponList == null) + {coupon = "暂无可选优惠券";} + else if(widget.promotions != null && widget.promotions != ""){ + coupon = "优惠券与活动不可同享"; + } if (widget.settleOrderInfo == null || widget.settleOrderInfo.couponList == null) { coupon = "暂无可选优惠券"; diff --git a/lib/settlement/settlement_view/settlement_coupon.dart b/lib/settlement/settlement_view/settlement_coupon.dart index 427e277e..23b6a090 100644 --- a/lib/settlement/settlement_view/settlement_coupon.dart +++ b/lib/settlement/settlement_view/settlement_coupon.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:huixiang/retrofit/data/min_order_info.dart'; import 'package:huixiang/retrofit/data/settleOrderInfo.dart'; import 'package:huixiang/retrofit/data/store_info.dart'; import 'package:huixiang/settlement/settlement_view/coupon.dart'; @@ -7,11 +8,15 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; class SettlementCoupon extends StatefulWidget { final StoreInfo storeInfo; + final MinOrderInfo minOrderInfo; + final int tableId; final SettleOrderInfo settleOrderInfo; final CouponListBean couponBean; SettlementCoupon( this.settleOrderInfo, + this.minOrderInfo, + this.tableId, this.storeInfo, { this.couponBean, }); @@ -33,18 +38,36 @@ class _SettlementCoupon extends State { couponCan.clear(); couponNo.clear(); - if (widget.settleOrderInfo != null && - widget.settleOrderInfo.couponList != null && - widget.settleOrderInfo.couponList.length > 0) { - widget.settleOrderInfo.couponList.forEach((element) { - if (element.usable) { - couponCan.add(element); - } else { - couponNo.add(element); - } - }); - setState(() {}); + if(widget.tableId > 0){ + if (widget.minOrderInfo != null && + widget.minOrderInfo.orderInfoVo.couponList != null && + widget.minOrderInfo.orderInfoVo.couponList.length > 0) { + widget.minOrderInfo.orderInfoVo.couponList.forEach((element) { + if (element["usable"]) { + couponCan.add(CouponListBean.fromJson(element)); + } else { + couponNo.add(CouponListBean.fromJson(element)); + } + }); + setState(() {}); + } + }else{ + if (widget.settleOrderInfo != null && + widget.settleOrderInfo.couponList != null && + widget.settleOrderInfo.couponList.length > 0) { + widget.settleOrderInfo.couponList.forEach((element) { + if (element.usable) { + couponCan.add(element); + } else { + couponNo.add(element); + } + }); + setState(() {}); + } } + + + } @override diff --git a/lib/settlement/settlement_view/settlement_order_commodity.dart b/lib/settlement/settlement_view/settlement_order_commodity.dart index 0516a33f..68845e7c 100644 --- a/lib/settlement/settlement_view/settlement_order_commodity.dart +++ b/lib/settlement/settlement_view/settlement_order_commodity.dart @@ -398,7 +398,7 @@ class _SettlementOrderCommodity extends State { String discountPrice(){ if(widget.minOrderInfo != null){ - return AppUtils.calculateDouble(double.tryParse(widget.minOrderInfo?.discountAmount ?? "0") + double.tryParse(widget.settleOrderInfo?.benefitDiscountAmount ?? "0")); + return AppUtils.calculateDouble(double.tryParse(widget.minOrderInfo?.couponSubPrice ?? "0") + double.tryParse(widget.settleOrderInfo?.benefitDiscountAmount ?? "0")); }else if(widget.tableId < 0){ return "0"; }else { @@ -409,7 +409,7 @@ class _SettlementOrderCommodity extends State { String totalPrice() { if (widget.minOrderInfo != null && widget.minOrderInfo.orderProductVOList != null) { - return "${widget.minOrderInfo.orderSumPrice}"; + return "${widget.minOrderInfo.finalPayPrice}"; } if (widget.settleOrderInfo.orderProductList == null) return ""; return "${widget.settleOrderInfo.price}"; diff --git a/lib/store/shopping/shopping_home/shopping_title_tab.dart b/lib/store/shopping/shopping_home/shopping_title_tab.dart index a9f931af..930d4a01 100644 --- a/lib/store/shopping/shopping_home/shopping_title_tab.dart +++ b/lib/store/shopping/shopping_home/shopping_title_tab.dart @@ -17,7 +17,7 @@ class ShoppingTitleTab extends StatefulWidget { } class _ClassTitleTab extends State - with SingleTickerProviderStateMixin { + with SingleTickerProviderStateMixin,AutomaticKeepAliveClientMixin { TabController tabController; @override @@ -62,4 +62,6 @@ class _ClassTitleTab extends State ); } + @override + bool get wantKeepAlive => true; } diff --git a/lib/store/store_order.dart b/lib/store/store_order.dart index e9993e9f..5da2e79d 100644 --- a/lib/store/store_order.dart +++ b/lib/store/store_order.dart @@ -362,7 +362,12 @@ class _StoreOrderPage extends State padding: EdgeInsets.symmetric(horizontal: 10.w), width: MediaQuery.of(context).size.width, - child: TabBar( + child: Theme( + data: ThemeData( + splashColor: Colors.transparent, // 点击时的水波纹颜色设置为透明 + highlightColor: Colors.transparent, // 点击时的背景高亮颜色设置为透明 + ), + child: TabBar( controller: tabcontroller, automaticIndicatorColorAdjustment: true, isScrollable: true, @@ -387,7 +392,7 @@ class _StoreOrderPage extends State MyTab(text: S.of(context).diandan), // MyTab(text: ""), ], - ), + )), ), ), ), diff --git a/lib/union/union_page.dart b/lib/union/union_page.dart index c9be6c29..d6360820 100644 --- a/lib/union/union_page.dart +++ b/lib/union/union_page.dart @@ -32,7 +32,8 @@ import 'package:flutter_baidu_mapapi_base/flutter_baidu_mapapi_base.dart'; class UnionPage extends StatefulWidget { final int initialIndex; - UnionPage(Key key,this.initialIndex): super(key: key); + + UnionPage(Key key, this.initialIndex) : super(key: key); @override State createState() { @@ -57,7 +58,7 @@ class UnionPageState extends State bool isKeyBoardShow = false; BMFCoordinate latLng; - jumpIndex(jpIndex){ + jumpIndex(jpIndex) { tabController.index = jpIndex; } @@ -98,7 +99,8 @@ class UnionPageState extends State void initState() { super.initState(); if (tabController == null) - tabController = TabController(length: 4, vsync: this,initialIndex: widget.initialIndex); + tabController = TabController( + length: 4, vsync: this, initialIndex: widget.initialIndex); // tabController?.addListener(() { // startLocation(); // }); @@ -114,18 +116,20 @@ class UnionPageState extends State startLocation(false); } - RefreshController tabRefresh(){ + RefreshController tabRefresh() { RefreshController tempRef; - if (tabController.index == 0) tempRef = refreshController; - else if (tabController.index == 1) tempRef = refreshController1; - else if (tabController.index == 2) tempRef = refreshController2; + if (tabController.index == 0) + tempRef = refreshController; + else if (tabController.index == 1) + tempRef = refreshController1; + else if (tabController.index == 2) + tempRef = refreshController2; else if (tabController.index == 3) tempRef = refreshController3; return tempRef; } startLocation(bool isOnRefresh) async { - if(!isOnRefresh) - EasyLoading.show(status: S.current.zhengzaijiazai); + if (!isOnRefresh) EasyLoading.show(status: S.current.zhengzaijiazai); Location.getInstance() .aMapFlutterLocation .onResultCallback() @@ -141,9 +145,9 @@ class UnionPageState extends State latLng = BMFCoordinate(event["latitude"], event["longitude"]); } BMFCalculateUtils.coordConvert( - coordinate: latLng, - fromType: BMF_COORD_TYPE.BD09LL, - toType: BMF_COORD_TYPE.COMMON) + coordinate: latLng, + fromType: BMF_COORD_TYPE.BD09LL, + toType: BMF_COORD_TYPE.COMMON) .then((value) { this.latLng = value; saveLatLng( @@ -157,21 +161,20 @@ class UnionPageState extends State event["province"], event["city"], event["district"], - editingController.text,-1); + editingController.text, + -1); if (_mapController != null) _mapController.updateMapOptions(BMFMapOptions( center: value, zoomLevel: 15, )); }); - } - else { + } else { getLatLng(); // EasyLoading.dismiss(); } }); - Location.getInstance().prepareLoc(); Location.getInstance().startLocation(context).then((value) { if (!value) { @@ -211,7 +214,8 @@ class UnionPageState extends State value.getString("province"), value.getString("city"), value.getString("district"), - editingController.text,-1), + editingController.text, + -1), setState(() { if (_mapController != null) { _mapController.updateMapOptions(BMFMapOptions( @@ -223,7 +227,7 @@ class UnionPageState extends State } else { - queryStore("", "", "", "", "", editingController.text,-1), + queryStore("", "", "", "", "", editingController.text, -1), } }, ); @@ -234,7 +238,8 @@ class UnionPageState extends State List storeList2; List storeList3; - queryStore(latitude, longitude, province, city, district, searchKey,int index) async { + queryStore(latitude, longitude, province, city, district, searchKey, + int index) async { if (apiService == null) { SharedPreferences value = await SharedPreferences.getInstance(); apiService = ApiService( @@ -254,31 +259,38 @@ class UnionPageState extends State ? "" : ((tabController.index == 1 && index == -1) || index == 1 ? "EATSTORE" - : ((tabController.index == 2 && index == -1) || index == 2 ? "DRINKSTORE" : "HAPPYSTORE")), + : ((tabController.index == 2 && index == -1) || index == 2 + ? "DRINKSTORE" + : "HAPPYSTORE")), }).catchError((error) { - if(index == -1) - tabRefresh().refreshFailed(); + if (index == -1) tabRefresh().refreshFailed(); }); if (baseData != null && baseData.isSuccess) { - if(index == -1 && storeList == null){ + if (index == -1 && storeList == null) { if (tabController.index != 0) - queryStore(latitude, longitude, province, city, district, searchKey,0); + queryStore( + latitude, longitude, province, city, district, searchKey, 0); if (tabController.index != 1) - queryStore(latitude, longitude, province, city, district, searchKey,1); + queryStore( + latitude, longitude, province, city, district, searchKey, 1); if (tabController.index != 2) - queryStore(latitude, longitude, province, city, district, searchKey,2); + queryStore( + latitude, longitude, province, city, district, searchKey, 2); if (tabController.index != 3) - queryStore(latitude, longitude, province, city, district, searchKey,3); + queryStore( + latitude, longitude, province, city, district, searchKey, 3); } - if ((tabController.index == 0 && index == -1) || index == 0) storeList = baseData.data; - else if ((tabController.index == 1 && index == -1) || index == 1) storeList1 = baseData.data; - else if ((tabController.index == 2 && index == -1) || index == 2) storeList2 = baseData.data; - else if ((tabController.index == 3 && index == -1) || index == 3) storeList3 = baseData.data; - if(index == -1) - tabRefresh().refreshCompleted(); + if ((tabController.index == 0 && index == -1) || index == 0) + storeList = baseData.data; + else if ((tabController.index == 1 && index == -1) || index == 1) + storeList1 = baseData.data; + else if ((tabController.index == 2 && index == -1) || index == 2) + storeList2 = baseData.data; + else if ((tabController.index == 3 && index == -1) || index == 3) + storeList3 = baseData.data; + if (index == -1) tabRefresh().refreshCompleted(); } else { - if(index == -1) - tabRefresh().refreshFailed(); + if (index == -1) tabRefresh().refreshFailed(); } EasyLoading.dismiss(); setState(() {}); @@ -291,54 +303,67 @@ class UnionPageState extends State super.build(context); return GestureDetector( behavior: HitTestBehavior.translucent, - onTap: (){ - FocusScope.of(context).requestFocus(FocusNode()); - }, - child:Scaffold( - resizeToAvoidBottomInset: false, - appBar: MyAppBar( - title: "", - leading: false, - brightness: Brightness.light, - titleChild: PreferredSize( - preferredSize: Size(double.infinity, 38.h), - child: TabBar( - controller: tabController, - isScrollable: true, - //可滚动 - indicatorColor: Color(0xff39B54A), - labelColor: Colors.black, - labelStyle: TextStyle( - fontSize: 18.sp, - fontWeight: FontWeight.bold, - ), - unselectedLabelStyle: TextStyle( - fontSize: 15.sp, - fontWeight: FontWeight.normal, - ), - // controller: tabController, - //未选中文字颜色 - unselectedLabelColor: Color(0xffA29E9E), - indicatorSize: TabBarIndicatorSize.label, - //指示器与文字等宽 - tabs: [ - MyTab(text: S.of(context).quanbu), - MyTab(text: "吃"), - MyTab(text: "喝"), - MyTab(text: "玩"), - ], - ), - )), - body: TabBarView( - controller: tabController, - children: [ - UnionList(refreshController, storeList,(){startLocation(true);}), - UnionList(refreshController1, storeList1,(){startLocation(true);}), - UnionList(refreshController2, storeList2,(){startLocation(true);}), - UnionList(refreshController3, storeList3,(){startLocation(true);}), - ], - ), - )); + onTap: () { + FocusScope.of(context).requestFocus(FocusNode()); + }, + child: Scaffold( + resizeToAvoidBottomInset: false, + appBar: MyAppBar( + title: "", + leading: false, + brightness: Brightness.light, + titleChild: PreferredSize( + preferredSize: Size(double.infinity, 38.h), + child: Theme( + data: ThemeData( + splashColor: Colors.transparent, // 点击时的水波纹颜色设置为透明 + highlightColor: Colors.transparent, // 点击时的背景高亮颜色设置为透明 + ), + child: TabBar( + controller: tabController, + isScrollable: true, + //可滚动 + indicatorColor: Color(0xff39B54A), + labelColor: Colors.black, + labelStyle: TextStyle( + fontSize: 18.sp, + fontWeight: FontWeight.bold, + ), + unselectedLabelStyle: TextStyle( + fontSize: 15.sp, + fontWeight: FontWeight.normal, + ), + // controller: tabController, + //未选中文字颜色 + unselectedLabelColor: Color(0xffA29E9E), + indicatorSize: TabBarIndicatorSize.label, + //指示器与文字等宽 + tabs: [ + MyTab(text: S.of(context).quanbu), + MyTab(text: "吃"), + MyTab(text: "喝"), + MyTab(text: "玩"), + ], + )), + )), + body: TabBarView( + controller: tabController, + children: [ + UnionList(refreshController, storeList, () { + startLocation(true); + }), + UnionList(refreshController1, storeList1, () { + startLocation(true); + }), + UnionList(refreshController2, storeList2, () { + startLocation(true); + }), + UnionList(refreshController3, storeList3, () { + startLocation(true); + }), + ], + ), + )); // GestureDetector( // onTap: () { // FocusScope.of(context).requestFocus(FocusNode()); diff --git a/pubspec.yaml b/pubspec.yaml index c6ce3987..5f383d3b 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -3,7 +3,7 @@ description: 一心回乡. publish_to: 'none' # Remove this line if you wish to publish to pub.dev -version: 2.0.24+12 +version: 2.0.25+13 environment: sdk: ">=2.7.0 <3.0.0"