Browse Source

我的页面,推广banner更改;

dev
huixiang_app 1 year ago
parent
commit
a47fd28cbe
  1. 28
      lib/home/home_page.dart
  2. 110
      lib/mine/mine_page.dart

28
lib/home/home_page.dart

@ -656,7 +656,7 @@ class HomePageState extends State<HomePage> with AutomaticKeepAliveClientMixin {
width: double.infinity,
// margin: EdgeInsets.symmetric(horizontal:14.w),
height: 85.h,
child: bannerData != null && bannerData.isNotEmpty
child: activityBannerData != null && activityBannerData.isNotEmpty
? Swiper(
pagination: SwiperPagination(
alignment: Alignment.bottomCenter,
@ -688,27 +688,6 @@ class HomePageState extends State<HomePage> with AutomaticKeepAliveClientMixin {
),
),
);
// GestureDetector(
// onTap: () {
// if (position == 0) {
// Navigator.of(context).pushNamed('/router/invite_friends');
// } else if (position == 1) {
// Navigator.of(context).pushNamed('/router/trading_card_page');
// }
// },
// child: Container(
// margin: EdgeInsets.symmetric(horizontal: 14.w),
// child: ClipRRect(
// child: Image.asset(
// spreadItem[position],
// width: double.infinity,
// fit: BoxFit.fill,
// height: double.infinity,
// ),
// borderRadius: BorderRadius.circular(6.w),
// ),
// ),
// );
},
itemCount: activityBannerData.length,
)
@ -766,11 +745,6 @@ class HomePageState extends State<HomePage> with AutomaticKeepAliveClientMixin {
}
}
final List<String> spreadItem = [
"assets/image/welfare_spread.webp",
"assets/image/welfare_yz.webp",
];
///
toScan() async {
if (await Permission.camera.isPermanentlyDenied) {

110
lib/mine/mine_page.dart

@ -26,9 +26,11 @@ import 'package:shared_preferences/shared_preferences.dart';
import 'package:dio/dio.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import '../retrofit/data/banner.dart';
import '../retrofit/data/coupon.dart';
import '../retrofit/data/page.dart';
import '../utils/flutter_utils.dart';
import '../view_widget/custom_image.dart';
import 'mine_view/mine_item.dart';
import 'mine_view/mine_view.dart';
@ -49,6 +51,7 @@ class MinePageState extends State<MinePage> with AutomaticKeepAliveClientMixin {
final RefreshController _refreshController = RefreshController();
int totalMsg = 0;
String couponNum;
List<BannerData> activityBannerData = [];
_toUserInfo() async {
SharedPreferences shared = await SharedPreferences.getInstance();
@ -78,6 +81,7 @@ class MinePageState extends State<MinePage> with AutomaticKeepAliveClientMixin {
querySocialInfo();
queryMsgStats();
queryCoupon();
queryActivityBanner();
// queryCard();
eventBus.on<EventType>().listen((event) {
@ -136,6 +140,23 @@ class MinePageState extends State<MinePage> with AutomaticKeepAliveClientMixin {
// EasyLoading.dismiss();
}
///banner
queryActivityBanner() async {
SharedPreferences value = await SharedPreferences.getInstance();
apiService = ApiService(
Dio(),
context: context,
token: value.getString("token"),
showLoading: false,
);
BaseData<PageInfo<BannerData>> baseData = await apiService.queryBanner({
"model": {"type": "HOME_STORE_PAGE"},
}).catchError((onError) {});
if (baseData != null && baseData.isSuccess) {
activityBannerData = baseData.data.records;
}
}
queryCoupon() async {
SharedPreferences value = await SharedPreferences.getInstance();
apiService = ApiService(
@ -166,6 +187,7 @@ class MinePageState extends State<MinePage> with AutomaticKeepAliveClientMixin {
queryCoupon();
querySocialInfo();
queryMsgStats();
queryActivityBanner();
}
///(//)
@ -427,10 +449,11 @@ class MinePageState extends State<MinePage> with AutomaticKeepAliveClientMixin {
///广
Widget spreadImage() {
return Container(
margin: EdgeInsets.only(bottom: 30.h,),
width: double.infinity,
// margin: EdgeInsets.symmetric(horizontal:14.w),
height: 85.h,
child: Swiper(
child: activityBannerData != null && activityBannerData.isNotEmpty
? Swiper(
pagination: SwiperPagination(
alignment: Alignment.bottomCenter,
margin: EdgeInsets.only(top: 5.h),
@ -442,37 +465,82 @@ class MinePageState extends State<MinePage> with AutomaticKeepAliveClientMixin {
color: Colors.white.withAlpha(76),
),
),
autoplay:true,
autoplay: true,
duration: 1000,
autoplayDelay: 2000,
itemBuilder: (context, position) {
return GestureDetector(
onTap: (){
if(position == 0){
Navigator.of(context).pushNamed('/router/invite_friends');
}else if(position == 1){
Navigator.of(context).pushNamed('/router/trading_card_page');
}
return InkWell(
onTap: () {
spreadBannerClick(activityBannerData[position]);
},
child:Container(
margin: EdgeInsets.symmetric(horizontal:14.w),
child: ClipRRect(
child:Image.asset(
spreadItem[position],
width:double.infinity,
fit: BoxFit.fill,
height:double.infinity,
),
borderRadius: BorderRadius.circular(6.w),
child: Container(
margin: EdgeInsets.symmetric(horizontal: 14.w),
child: MImage(
activityBannerData[position].imgUrl,
fit: BoxFit.cover,
radius: BorderRadius.circular(6),
errorSrc: "assets/image/default_2_1.webp",
fadeSrc: "assets/image/default_2_1.webp",
),
),
);
},
itemCount:2,
itemCount: activityBannerData.length,
)
: Image.asset(
"assets/image/default_2_1.webp",
fit: BoxFit.cover,
),
);
}
/// contentType 0123,4:,5:7
spreadBannerClick(BannerData activityBannerData) async {
switch (activityBannerData.contentType) {
case 1:
Navigator.of(context).pushNamed('/router/integral_store_page',
arguments: {"goodsId": activityBannerData.content});
break;
case 2:
Navigator.of(context).pushNamed('/router/web_page', arguments: {
"activityId": activityBannerData.content,
});
break;
case 3:
Navigator.of(context).pushNamed('/router/web_page', arguments: {
"articleId": activityBannerData.content,
});
break;
case 4:
String router = activityBannerData.content;
// String router = "/router/store_order?{\"id\":\"1512378184161558528\",\"tenant\":\"1188\",\"storeName\":\"农场煮意\"}";
if (router.contains("?")) {
String params = router.substring(router.indexOf("?") + 1);
Map map = jsonDecode(params);
Navigator.of(context).pushNamed(
router.substring(0, router.indexOf("?")),
arguments: map);
} else {
Navigator.of(context).pushNamed(router);
}
break;
case 5:
Navigator.of(context).pushNamed('/router/class_details', arguments: {
"id": activityBannerData.content,
});
break;
case 7:
String params = activityBannerData.content
.substring(activityBannerData.content.indexOf("?") + 1);
Map map = jsonDecode(params);
Navigator.of(context).pushNamed(
activityBannerData.content
.substring(0, activityBannerData.content.indexOf("?")),
arguments: map);
break;
}
}
final List<String> spreadItem = [
"assets/image/welfare_spread.webp",
"assets/image/welfare_yz.webp",

Loading…
Cancel
Save