import 'dart:convert'; import 'package:flutter/material.dart'; import 'package:huixiang/retrofit/data/activity_pos.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, height: 289, alignment: Alignment.center, margin: EdgeInsets.only( left:37, right:37, ), child: Stack( children: [ GestureDetector( onTap: (){ jumpClick(widget.activityPos); }, child: Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(12), ), child:MImage( widget?.activityPos?.showImage ?? "", width: double.infinity, height: MediaQuery.of(context).size.height / 2, fit: BoxFit.cover, radius: BorderRadius.all(Radius.circular(12)), errorSrc: "assets/image/default_1.webp", fadeSrc: "assets/image/default_1.webp", ),), ), Container( padding: EdgeInsets.only(top: 8,right: 8,bottom:8), child:GestureDetector( behavior: HitTestBehavior.opaque, onTap: (){ Navigator.of(context).pop(); }, child: Row(children: [ Spacer(), Image.asset( "assets/image/cancel.webp", width: 24, height: 24, 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; } } }