w-R
3 years ago
11 changed files with 243 additions and 62 deletions
@ -0,0 +1,50 @@
|
||||
/// enabled : true |
||||
/// code : "1111" |
||||
/// showImage : "https://pos.upload.gznl.top/0000/2022/03/4ca95160-aa19-46e5-ad07-8a16ca11c697.jpg" |
||||
/// jumpType : 1 |
||||
/// jumpUrl : "1417675188681572352" |
||||
|
||||
class ActivityPos { |
||||
ActivityPos({ |
||||
bool enabled, |
||||
String code, |
||||
String showImage, |
||||
int jumpType, |
||||
String jumpUrl,}){ |
||||
_enabled = enabled; |
||||
_code = code; |
||||
_showImage = showImage; |
||||
_jumpType = jumpType; |
||||
_jumpUrl = jumpUrl; |
||||
} |
||||
|
||||
ActivityPos.fromJson(dynamic json) { |
||||
_enabled = json['enabled']; |
||||
_code = json['code']; |
||||
_showImage = json['showImage']; |
||||
_jumpType = json['jumpType']; |
||||
_jumpUrl = json['jumpUrl']; |
||||
} |
||||
bool _enabled; |
||||
String _code; |
||||
String _showImage; |
||||
int _jumpType; |
||||
String _jumpUrl; |
||||
|
||||
bool get enabled => _enabled; |
||||
String get code => _code; |
||||
String get showImage => _showImage; |
||||
int get jumpType => _jumpType; |
||||
String get jumpUrl => _jumpUrl; |
||||
|
||||
Map<String, dynamic> toJson() { |
||||
final map = <String, dynamic>{}; |
||||
map['enabled'] = _enabled; |
||||
map['code'] = _code; |
||||
map['showImage'] = _showImage; |
||||
map['jumpType'] = _jumpType; |
||||
map['jumpUrl'] = _jumpUrl; |
||||
return map; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,113 @@
|
||||
|
||||
|
||||
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<StatefulWidget> createState() { |
||||
return _ActivityPoster(); |
||||
} |
||||
} |
||||
|
||||
class _ActivityPoster extends State<ActivityPoster> { |
||||
@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.png", |
||||
fadeSrc: "assets/image/default_1.png", |
||||
),), |
||||
), |
||||
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.png", |
||||
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; |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue