|
|
|
@ -3,6 +3,7 @@ import 'dart:convert';
|
|
|
|
|
import 'package:flutter/material.dart'; |
|
|
|
|
import 'package:flutter_swiper/flutter_swiper.dart'; |
|
|
|
|
import 'package:huixiang/retrofit/data/banner.dart'; |
|
|
|
|
import 'package:huixiang/retrofit/data/home_rank.dart'; |
|
|
|
|
import 'package:huixiang/retrofit/data/shopping_home_config.dart'; |
|
|
|
|
import 'package:huixiang/retrofit/retrofit_api.dart'; |
|
|
|
|
import 'package:huixiang/view_widget/custom_image.dart'; |
|
|
|
@ -11,6 +12,8 @@ import 'package:huixiang/utils/font_weight.dart';
|
|
|
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart'; |
|
|
|
|
|
|
|
|
|
class TopSellingList extends StatefulWidget { |
|
|
|
|
final HomeRank homeRank; |
|
|
|
|
TopSellingList(this.homeRank); |
|
|
|
|
@override |
|
|
|
|
State<StatefulWidget> createState() { |
|
|
|
|
return _TopSellingList(); |
|
|
|
@ -34,8 +37,10 @@ class _TopSellingList extends State<TopSellingList> {
|
|
|
|
|
decoration: BoxDecoration( |
|
|
|
|
borderRadius: BorderRadius.circular(6), |
|
|
|
|
image: DecorationImage( |
|
|
|
|
fit: BoxFit.fill, |
|
|
|
|
image: AssetImage("assets/image/hot_list.webp"), |
|
|
|
|
image: NetworkImage( |
|
|
|
|
widget?.homeRank?.commodityListImg ?? "" |
|
|
|
|
), |
|
|
|
|
fit: BoxFit.cover, |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
margin: EdgeInsets.only(left: 14.w,right: 14.w,top: 12.h,bottom: 23.h), |
|
|
|
@ -63,11 +68,12 @@ class _TopSellingList extends State<TopSellingList> {
|
|
|
|
|
child: ListView.builder( |
|
|
|
|
scrollDirection: Axis.horizontal, |
|
|
|
|
physics: BouncingScrollPhysics(), |
|
|
|
|
itemCount:3, |
|
|
|
|
itemCount:widget.homeRank.commodityList.length ?? 0, |
|
|
|
|
itemBuilder: (context, position) { |
|
|
|
|
return GestureDetector( |
|
|
|
|
onTap: () {}, |
|
|
|
|
child: hotSaleItem(), |
|
|
|
|
onTap: () { |
|
|
|
|
}, |
|
|
|
|
child: hotSaleItem(widget.homeRank.commodityList[position],position), |
|
|
|
|
); |
|
|
|
|
}, |
|
|
|
|
), |
|
|
|
@ -77,7 +83,7 @@ class _TopSellingList extends State<TopSellingList> {
|
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Widget hotSaleItem() { |
|
|
|
|
Widget hotSaleItem(CommodityList commodityList,index) { |
|
|
|
|
return Container( |
|
|
|
|
width: 290.w, |
|
|
|
|
decoration: BoxDecoration( |
|
|
|
@ -91,7 +97,7 @@ class _TopSellingList extends State<TopSellingList> {
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start, |
|
|
|
|
children: [ |
|
|
|
|
Text( |
|
|
|
|
"好喝榜", |
|
|
|
|
commodityList?.typeName ?? "", |
|
|
|
|
style: TextStyle( |
|
|
|
|
fontSize: 14.sp, |
|
|
|
|
fontWeight: MyFontWeight.bold, |
|
|
|
@ -102,15 +108,23 @@ class _TopSellingList extends State<TopSellingList> {
|
|
|
|
|
), |
|
|
|
|
Expanded(child: ListView.builder( |
|
|
|
|
padding: EdgeInsets.zero, |
|
|
|
|
itemCount:6, |
|
|
|
|
itemCount:widget.homeRank.commodityList[index].goodList.length>3?3:widget.homeRank.commodityList[index].goodList.length, |
|
|
|
|
scrollDirection: Axis.vertical, |
|
|
|
|
shrinkWrap: true, |
|
|
|
|
physics: BouncingScrollPhysics(), |
|
|
|
|
itemBuilder: (context, position) { |
|
|
|
|
return GestureDetector( |
|
|
|
|
onTap: () { |
|
|
|
|
Navigator.of(context).pushNamed( |
|
|
|
|
'/router/store_order', |
|
|
|
|
arguments: { |
|
|
|
|
"id": widget.homeRank.commodityList[index].goodList[position].storeId, |
|
|
|
|
"tenant": widget.homeRank.commodityList[index].goodList[position].tenantCode, |
|
|
|
|
"storeName": "" |
|
|
|
|
}, |
|
|
|
|
); |
|
|
|
|
}, |
|
|
|
|
child: rankingItem(), |
|
|
|
|
child: rankingItem(widget.homeRank.commodityList[index].goodList[position],position), |
|
|
|
|
); |
|
|
|
|
}, |
|
|
|
|
),) |
|
|
|
@ -119,7 +133,7 @@ class _TopSellingList extends State<TopSellingList> {
|
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Widget rankingItem() { |
|
|
|
|
Widget rankingItem(GoodList goodList,index) { |
|
|
|
|
return Container( |
|
|
|
|
margin: EdgeInsets.only(right:14.w,top: 12.h,bottom: 12.h), |
|
|
|
|
child: Row( |
|
|
|
@ -128,14 +142,18 @@ class _TopSellingList extends State<TopSellingList> {
|
|
|
|
|
children: [ |
|
|
|
|
Stack( |
|
|
|
|
children: [ |
|
|
|
|
Image.asset( |
|
|
|
|
"assets/image/icon_story_td.webp", |
|
|
|
|
width: 54.w, |
|
|
|
|
height: 54, |
|
|
|
|
MImage( |
|
|
|
|
goodList.productImg ?? "", |
|
|
|
|
fit: BoxFit.cover, |
|
|
|
|
), Image.asset( |
|
|
|
|
"assets/image/ranking1.webp", |
|
|
|
|
width: 25.w, |
|
|
|
|
radius: BorderRadius.circular(4), |
|
|
|
|
width: 54, |
|
|
|
|
height: 54, |
|
|
|
|
errorSrc: "assets/image/default_2_1.webp", |
|
|
|
|
fadeSrc: "assets/image/default_2_1.webp", |
|
|
|
|
), |
|
|
|
|
Image.asset( |
|
|
|
|
index == 0 ? "assets/image/ranking1.webp" :(index == 1 ? "assets/image/ranking2.webp": "assets/image/ranking3.webp"), |
|
|
|
|
width: 25, |
|
|
|
|
height: 25, |
|
|
|
|
fit: BoxFit.cover, |
|
|
|
|
), |
|
|
|
@ -151,7 +169,7 @@ class _TopSellingList extends State<TopSellingList> {
|
|
|
|
|
children: [ |
|
|
|
|
Padding(padding:EdgeInsets.only(top: 5.h,bottom: 8.h), |
|
|
|
|
child: Text( |
|
|
|
|
"暴打柠檬茶", |
|
|
|
|
goodList?.productName ?? "", |
|
|
|
|
style: TextStyle( |
|
|
|
|
fontSize: 13.sp, |
|
|
|
|
fontWeight: MyFontWeight.regular, |
|
|
|
@ -162,7 +180,7 @@ class _TopSellingList extends State<TopSellingList> {
|
|
|
|
|
TextSpan( |
|
|
|
|
children: [ |
|
|
|
|
TextSpan( |
|
|
|
|
text: "¥22.00", |
|
|
|
|
text: goodList?.price ?? "", |
|
|
|
|
style: TextStyle( |
|
|
|
|
fontSize: 12.sp, |
|
|
|
|
fontWeight: MyFontWeight.semi_bold, |
|
|
|
@ -170,7 +188,7 @@ class _TopSellingList extends State<TopSellingList> {
|
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
TextSpan( |
|
|
|
|
text: "¥22.00", |
|
|
|
|
text: goodList?.applyPrice ?? "", |
|
|
|
|
style: TextStyle( |
|
|
|
|
fontSize:10.sp, |
|
|
|
|
decoration: TextDecoration.lineThrough, |
|
|
|
|