From ee6e0f9724652b25168f253bb18eb4f5efed9824 Mon Sep 17 00:00:00 2001 From: wurong <953969641@qq.com> Date: Wed, 8 Mar 2023 11:35:51 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E9=A6=96=E9=A1=B5=E6=B4=BB?= =?UTF-8?q?=E5=8A=A8=E6=B5=B7=E6=8A=A5=E5=BC=B9=E7=AA=97-=E6=96=B0?= =?UTF-8?q?=E4=BA=BA=E5=BC=B9=E7=AA=97=E9=A1=BA=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/home/home_page.dart | 33 +++--- lib/retrofit/min_api.dart | 2 +- lib/retrofit/retrofit_api.dart | 2 +- lib/view_widget/activity_poster.dart | 139 ++++++++++++++----------- lib/view_widget/new_people_reward.dart | 2 +- 5 files changed, 95 insertions(+), 83 deletions(-) diff --git a/lib/home/home_page.dart b/lib/home/home_page.dart index 8973c95c..a984a42e 100644 --- a/lib/home/home_page.dart +++ b/lib/home/home_page.dart @@ -81,9 +81,9 @@ class HomePageState extends State with AutomaticKeepAliveClientMixin { widget.interviewCouponList != null && widget.interviewCouponList.length > 0) showInvite = true; - if (widget.firstLoginCouponList != null && widget.firstLoginCouponList.length > 0) - showNew = true; - + //判断新人弹窗 + // if (widget.firstLoginCouponList != null && widget.firstLoginCouponList.length > 0) + // showNew = true; } @@ -98,19 +98,8 @@ class HomePageState extends State with AutomaticKeepAliveClientMixin { ); } - ///新用户奖励弹窗 - newShowAlertDialog(newUserCouponList) { - //显示对话框 - showDialog( - context: context, - builder: (BuildContext context) { - return NewPeopleReward(newUserCouponList); - }, - ); - } - ///活动海报弹窗 - posterShowAlertDialog(ActivityPos activityPos) { + posterShowAlertDialog(ActivityPos activityPos,firstLoginCouponList) { var today = DateTime.now().day; SharedPreferences.getInstance().then((value) { if(value.getInt("today")==today && (value.getString("ActivityPosCode") ?? "").contains("${activityPos.code}_${value.getString("userId")};")) @@ -121,7 +110,7 @@ class HomePageState extends State with AutomaticKeepAliveClientMixin { showDialog( context: context, builder: (BuildContext context) { - return ActivityPoster(activityPos); + return ActivityPoster(activityPos,firstLoginCouponList); }, ); }); @@ -283,10 +272,12 @@ class HomePageState extends State with AutomaticKeepAliveClientMixin { inviteShowAlertDialog(widget.invite, widget.interviewCouponList[0]); showInvite = false; } - if (showNew) { - newShowAlertDialog(widget.firstLoginCouponList); - showNew = false; - } + + //判断新人弹窗 + // if (showNew) { + // newShowAlertDialog(widget.firstLoginCouponList); + // showNew = false; + // } } queryUserBalance() async { @@ -337,7 +328,7 @@ class HomePageState extends State with AutomaticKeepAliveClientMixin { }); if (baseData != null && baseData.isSuccess) { if(baseData.data?.enabled ?? true) - posterShowAlertDialog(baseData.data); + posterShowAlertDialog(baseData.data,widget.firstLoginCouponList); } } diff --git a/lib/retrofit/min_api.dart b/lib/retrofit/min_api.dart index 1308a39d..f7e60731 100644 --- a/lib/retrofit/min_api.dart +++ b/lib/retrofit/min_api.dart @@ -26,7 +26,7 @@ import 'data/shopping_home_config.dart'; part 'min_api.g.dart'; -const localBaseUrl = "https://pos.api.lotus-wallet.com/app/";///本地 +const localBaseUrl = "http://192.168.10.78:8765/app/";///本地 // const localBaseUrl = "https://2946-27-19-77-115.jp.ngrok.io/app/";///本地 const serviceBaseUrl = "https://pos.api.lotus-wallet.com/app/";///线上 diff --git a/lib/retrofit/retrofit_api.dart b/lib/retrofit/retrofit_api.dart index 57d5221c..7b1581b7 100644 --- a/lib/retrofit/retrofit_api.dart +++ b/lib/retrofit/retrofit_api.dart @@ -64,7 +64,7 @@ import 'data/wx_pay.dart'; part 'retrofit_api.g.dart'; -const localBaseUrl = "https://pos.platform.lotus-wallet.com/app/";///本地 +const localBaseUrl = "http://192.168.10.78:8766/app/";///本地 // const localBaseUrl = "https://2946-27-19-77-115.jp.ngrok.io/app/";///本地 const serviceBaseUrl = "https://pos.platform.lotus-wallet.com/app/";///线上 diff --git a/lib/view_widget/activity_poster.dart b/lib/view_widget/activity_poster.dart index 45b0b334..9500d023 100644 --- a/lib/view_widget/activity_poster.dart +++ b/lib/view_widget/activity_poster.dart @@ -1,17 +1,18 @@ - - import 'dart:convert'; import 'package:flutter/material.dart'; import 'package:huixiang/retrofit/data/activity_pos.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; +import '../retrofit/data/login_info.dart'; import 'custom_image.dart'; +import 'new_people_reward.dart'; class ActivityPoster extends StatefulWidget { final ActivityPos activityPos; + final List firstLoginCouponList; - ActivityPoster(this.activityPos); + ActivityPoster(this.activityPos, this.firstLoginCouponList); @override State createState() { @@ -20,58 +21,81 @@ class ActivityPoster extends StatefulWidget { } class _ActivityPoster extends State { + bool showNew = false; + + @override + void initState() { + super.initState(); + if (widget.firstLoginCouponList != null && + widget.firstLoginCouponList.length > 0) showNew = true; + } + @override Widget build(BuildContext context) { - return WillPopScope( + return WillPopScope( onWillPop: () async => false, - child:Container( - width: double.infinity, - alignment: Alignment.center, - margin: EdgeInsets.only( - left:27.w, - right:27.w, - ), - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - GestureDetector( - onTap: (){ - jumpClick(widget.activityPos); - }, - child: - Container( - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(12), - ), - child:MImage( - widget?.activityPos?.showImage ?? "", - aspectRatio: 0.75, - fit: BoxFit.cover, - noCompress: true, - radius: BorderRadius.all(Radius.circular(12)), - errorSrc: "assets/image/default_1.webp", - fadeSrc: "assets/image/default_1.webp", - ),), + child: Container( + width: double.infinity, + alignment: Alignment.center, + margin: EdgeInsets.only( + left: 27.w, + right: 27.w, ), - Container( - margin: EdgeInsets.only(top:35.h,right: 8.w,bottom:8.w), - child:GestureDetector( - behavior: HitTestBehavior.opaque, - onTap: (){ - Navigator.of(context).pop(); + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + GestureDetector( + onTap: () { + jumpClick(widget.activityPos); }, - child: Image.asset( - "assets/image/yq_qx.webp", - width: 40, - height: 40, - fit: BoxFit.cover, - color: Colors.white, - ) - ) ) - ], - ), - )); + child: Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(12), + ), + child: MImage( + widget?.activityPos?.showImage ?? "", + aspectRatio: 0.75, + fit: BoxFit.cover, + noCompress: true, + radius: BorderRadius.all(Radius.circular(12)), + errorSrc: "assets/image/default_1.webp", + fadeSrc: "assets/image/default_1.webp", + ), + ), + ), + Container( + margin: EdgeInsets.only(top: 35.h, right: 8.w, bottom: 8.w), + child: GestureDetector( + behavior: HitTestBehavior.opaque, + onTap: () { + Navigator.of(context).pop(); + if (showNew) { + newShowAlertDialog(widget.firstLoginCouponList); + showNew = false; + } + }, + child: Image.asset( + "assets/image/yq_qx.webp", + width: 40, + height: 40, + fit: BoxFit.cover, + color: Colors.white, + ))) + ], + ), + )); + } + + ///新用户奖励弹窗 + newShowAlertDialog(newUserCouponList) { + //显示对话框 + showDialog( + context: context, + builder: (BuildContext context) { + return NewPeopleReward(newUserCouponList); + }, + ); } /// contentType 跳转类型(0:不跳转,1:积分商品,2:活动,3:文章,4:页面跳转,5:课程) @@ -82,31 +106,28 @@ class _ActivityPoster extends State { arguments: {"goodsId": widget.activityPos.jumpUrl}); break; case 2: - Navigator.of(context) - .pushNamed('/router/web_page', arguments: { + Navigator.of(context).pushNamed('/router/web_page', arguments: { "activityId": widget.activityPos.jumpUrl, }); break; case 3: - Navigator.of(context) - .pushNamed('/router/web_page', arguments: { + Navigator.of(context).pushNamed('/router/web_page', arguments: { "articleId": widget.activityPos.jumpUrl, }); break; case 4: String router = widget.activityPos.jumpUrl; + // String router = "/router/store_order?{\"id\":\"1333246101343436800\",\"tenant\":\"1175\",\"storeName\":\"海峡姐妹茶(汉街店)\"}"; if (router.contains("?")) { - String params = router.substring(router.indexOf("?")); - params = params.replaceAll("?", ""); + String params = router.substring(router.indexOf("?")+1); Map map = jsonDecode(params); - Navigator.of(context).pushNamed(router, arguments: map); + Navigator.of(context).pushNamed(router.substring(0,router.indexOf("?")), arguments: map); } else { Navigator.of(context).pushNamed(router); } break; case 5: - Navigator.of(context) - .pushNamed('/router/class_details', arguments: { + Navigator.of(context).pushNamed('/router/class_details', arguments: { "id": widget.activityPos.jumpUrl, }); break; diff --git a/lib/view_widget/new_people_reward.dart b/lib/view_widget/new_people_reward.dart index 7acf376d..ad29fd59 100644 --- a/lib/view_widget/new_people_reward.dart +++ b/lib/view_widget/new_people_reward.dart @@ -42,7 +42,7 @@ class _NewPeopleReward extends State { GestureDetector( onTap: () { Navigator.of(context).pop(); - SmartDialog.showToast("领取成功"); + SmartDialog.showToast("领取成功",alignment: Alignment.center); }, child: Container( margin: EdgeInsets.only(