You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

151 lines
4.9 KiB

import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:huixiang/data/activity_pos.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import '../data/login_info.dart';
import 'custom_image.dart';
import 'new_people_reward.dart';
class ActivityPoster extends StatefulWidget {
final ActivityPos? activityPos;
final List<FirstLoginCouponList>? firstLoginCouponList;
ActivityPoster(this.activityPos, this.firstLoginCouponList);
@override
State<StatefulWidget> createState() {
return _ActivityPoster();
}
}
class _ActivityPoster extends State<ActivityPoster> {
bool showNew = false;
@override
void initState() {
super.initState();
if ((widget.firstLoginCouponList?.length ?? 0) > 0) showNew = true;
}
@override
Widget build(BuildContext context) {
return PopScope(
canPop: false,
onPopInvoked: (isPop) {},
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;
if (router?.isEmpty ?? true) {
return;
}
// 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? router = widget.activityPos?.jumpUrl;
if (router?.isEmpty ?? true) {
return;
}
String params = router!.substring(router.indexOf("?")+1);
Map map = jsonDecode(params);
Navigator.of(context).popAndPushNamed(router.substring(0,router.indexOf("?")), arguments: map);
break;
}
}
}