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, this.firstLoginCouponList); @override State createState() { return _ActivityPoster(); } } 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( 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", ), ), ), 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:课程,7:门店跳转) jumpClick(ActivityPos activityPos) async { switch (activityPos.jumpType) { case 1: Navigator.of(context).popAndPushNamed('/router/integral_store_page', arguments: {"goodsId": widget.activityPos.jumpUrl}); break; case 2: Navigator.of(context).popAndPushNamed('/router/web_page', arguments: { "activityId": widget.activityPos.jumpUrl, }); break; case 3: Navigator.of(context).popAndPushNamed('/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("?")+1); Map map = jsonDecode(params); Navigator.of(context).popAndPushNamed(router.substring(0,router.indexOf("?")), arguments: map); } else { Navigator.of(context).popAndPushNamed(router); } break; case 5: Navigator.of(context).popAndPushNamed('/router/class_details', arguments: { "id": widget.activityPos.jumpUrl, }); break; case 7: String params = widget.activityPos.jumpUrl.substring(widget.activityPos.jumpUrl.indexOf("?")+1); Map map = jsonDecode(params); Navigator.of(context).popAndPushNamed(widget.activityPos.jumpUrl.substring(0,widget.activityPos.jumpUrl.indexOf("?")), arguments: map); break; } } }