import 'dart:convert'; import 'package:flutter/material.dart'; import 'package:huixiang/retrofit/data/activity_pos.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'custom_image.dart'; class ActivityPoster extends StatefulWidget { final ActivityPos activityPos; ActivityPoster(this.activityPos); @override State createState() { return _ActivityPoster(); } } class _ActivityPoster extends State { @override Widget build(BuildContext context) { return 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(); }, child: Image.asset( "assets/image/yq_qx.webp", width: 40, height: 40, fit: BoxFit.cover, color: Colors.white, ) ) ) ], ), ); } /// contentType 跳转类型(0:不跳转,1:积分商品,2:活动,3:文章,4:页面跳转,5:课程) jumpClick(ActivityPos activityPos) async { switch (activityPos.jumpType) { case 1: Navigator.of(context).pushNamed('/router/integral_store_page', arguments: {"goodsId": widget.activityPos.jumpUrl}); break; case 2: Navigator.of(context) .pushNamed('/router/web_page', arguments: { "activityId": widget.activityPos.jumpUrl, }); break; case 3: Navigator.of(context) .pushNamed('/router/web_page', arguments: { "articleId": widget.activityPos.jumpUrl, }); break; case 4: String router = widget.activityPos.jumpUrl; if (router.contains("?")) { String params = router.substring(router.indexOf("?")); params = params.replaceAll("?", ""); Map map = jsonDecode(params); Navigator.of(context).pushNamed(router, arguments: map); } else { Navigator.of(context).pushNamed(router); } break; case 5: Navigator.of(context) .pushNamed('/router/class_details', arguments: { "id": widget.activityPos.jumpUrl, }); break; } } }