parent
bd432292fb
commit
57bd25f384
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
@ -0,0 +1,59 @@
|
|||||||
|
class MarketSwiperModel {
|
||||||
|
int? id;
|
||||||
|
int? jcookGoodsId;
|
||||||
|
int? skuId;
|
||||||
|
List<ImgList>? imgList;
|
||||||
|
|
||||||
|
MarketSwiperModel({this.id, this.jcookGoodsId, this.skuId, this.imgList});
|
||||||
|
|
||||||
|
MarketSwiperModel.fromJson(Map<String, dynamic> json) {
|
||||||
|
id = json['id'];
|
||||||
|
jcookGoodsId = json['jcookGoodsId'];
|
||||||
|
skuId = json['skuId'];
|
||||||
|
if (json['imgList'] != null) {
|
||||||
|
imgList = [];
|
||||||
|
json['imgList'].forEach((v) {
|
||||||
|
imgList!.add(new ImgList.fromJson(v));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||||
|
data['id'] = this.id;
|
||||||
|
data['jcookGoodsId'] = this.jcookGoodsId;
|
||||||
|
data['skuId'] = this.skuId;
|
||||||
|
if (this.imgList != null) {
|
||||||
|
data['imgList'] = this.imgList!.map((v) => v.toJson()).toList();
|
||||||
|
}
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class ImgList {
|
||||||
|
String? url;
|
||||||
|
String? size;
|
||||||
|
int? longs;
|
||||||
|
int? paragraph;
|
||||||
|
int? sort;
|
||||||
|
|
||||||
|
ImgList({this.url, this.size, this.longs, this.paragraph, this.sort});
|
||||||
|
|
||||||
|
ImgList.fromJson(Map<String, dynamic> json) {
|
||||||
|
url = json['url'];
|
||||||
|
size = json['size'];
|
||||||
|
longs = json['longs'];
|
||||||
|
paragraph = json['paragraph'];
|
||||||
|
sort = json['sort'];
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||||
|
data['url'] = this.url;
|
||||||
|
data['size'] = this.size;
|
||||||
|
data['longs'] = this.longs;
|
||||||
|
data['paragraph'] = this.paragraph;
|
||||||
|
data['sort'] = this.sort;
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
@ -1,301 +1,301 @@
|
|||||||
// import 'package:aku_community/base/base_style.dart';
|
// // import 'package:aku_community/base/base_style.dart';
|
||||||
|
//
|
||||||
import 'package:flutter/cupertino.dart';
|
// import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
// import 'package:flutter/material.dart';
|
||||||
|
//
|
||||||
import 'package:bot_toast/bot_toast.dart';
|
// import 'package:bot_toast/bot_toast.dart';
|
||||||
import 'package:flutter_easyrefresh/easy_refresh.dart';
|
// import 'package:flutter_easyrefresh/easy_refresh.dart';
|
||||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
// import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||||
import 'package:get/get.dart';
|
// import 'package:get/get.dart';
|
||||||
import 'package:waterfall_flow/waterfall_flow.dart';
|
// import 'package:waterfall_flow/waterfall_flow.dart';
|
||||||
|
//
|
||||||
import 'package:aku_community/constants/api.dart';
|
// import 'package:aku_community/constants/api.dart';
|
||||||
import 'package:aku_community/models/market/display_category_model.dart';
|
// import 'package:aku_community/models/market/display_category_model.dart';
|
||||||
import 'package:aku_community/models/market/goods_item.dart';
|
// import 'package:aku_community/models/market/goods_item.dart';
|
||||||
import 'package:aku_community/models/market/market_category_model.dart';
|
// import 'package:aku_community/models/market/market_category_model.dart';
|
||||||
import 'package:aku_community/ui/market/category/category_card.dart';
|
// import 'package:aku_community/ui/market/category/category_card.dart';
|
||||||
import 'package:aku_community/ui/market/category/category_page.dart';
|
// import 'package:aku_community/ui/market/category/category_page.dart';
|
||||||
import 'package:aku_community/ui/market/goods/goods_card.dart';
|
// import 'package:aku_community/ui/market/goods/goods_card.dart';
|
||||||
import 'package:aku_community/ui/market/order/my_order_page.dart';
|
// import 'package:aku_community/ui/market/order/my_order_page.dart';
|
||||||
import 'package:aku_community/ui/market/search/search_goods_page.dart';
|
// import 'package:aku_community/ui/market/search/search_goods_page.dart';
|
||||||
import 'package:aku_community/utils/headers.dart';
|
// import 'package:aku_community/utils/headers.dart';
|
||||||
import 'package:aku_community/utils/network/base_list_model.dart';
|
// import 'package:aku_community/utils/network/base_list_model.dart';
|
||||||
import 'package:aku_community/utils/network/net_util.dart';
|
// import 'package:aku_community/utils/network/net_util.dart';
|
||||||
import 'package:aku_community/widget/bee_scaffold.dart';
|
// import 'package:aku_community/widget/bee_scaffold.dart';
|
||||||
|
//
|
||||||
// import 'package:aku_community/ui/market/goods/goods_detail_page.dart';
|
// // import 'package:aku_community/ui/market/goods/goods_detail_page.dart';
|
||||||
|
//
|
||||||
// import 'package:aku_community/widget/tab_bar/bee_tab_bar.dart';
|
// // import 'package:aku_community/widget/tab_bar/bee_tab_bar.dart';
|
||||||
|
//
|
||||||
class MarketPage111 extends StatefulWidget {
|
// class MarketPage111 extends StatefulWidget {
|
||||||
MarketPage111({Key? key}) : super(key: key);
|
// MarketPage111({Key? key}) : super(key: key);
|
||||||
|
//
|
||||||
@override
|
// @override
|
||||||
_MarketPageState createState() => _MarketPageState();
|
// _MarketPageState createState() => _MarketPageState();
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
class _MarketPageState extends State<MarketPage111>
|
// class _MarketPageState extends State<MarketPage111>
|
||||||
with AutomaticKeepAliveClientMixin {
|
// with AutomaticKeepAliveClientMixin {
|
||||||
List<MarketCategoryModel> _marketModels = [];
|
// List<MarketCategoryModel> _marketModels = [];
|
||||||
List<GoodsItem> _hotItems = [];
|
// List<GoodsItem> _hotItems = [];
|
||||||
late EasyRefreshController _refreshController;
|
// late EasyRefreshController _refreshController;
|
||||||
int _pageNum = 1;
|
// int _pageNum = 1;
|
||||||
int _size = 4;
|
// int _size = 4;
|
||||||
int _pageCount = 0;
|
// int _pageCount = 0;
|
||||||
|
//
|
||||||
Future updateMarketInfo() async {
|
// Future updateMarketInfo() async {
|
||||||
BaseListModel baseListModel =
|
// BaseListModel baseListModel =
|
||||||
await NetUtil().getList(API.market.hotTop, params: {
|
// await NetUtil().getList(API.market.hotTop, params: {
|
||||||
"pageNum": _pageNum,
|
// "pageNum": _pageNum,
|
||||||
"size": _size,
|
// "size": _size,
|
||||||
});
|
// });
|
||||||
if (baseListModel.tableList!.isNotEmpty) {
|
// if (baseListModel.tableList!.isNotEmpty) {
|
||||||
_hotItems = (baseListModel.tableList as List)
|
// _hotItems = (baseListModel.tableList as List)
|
||||||
.map((e) => GoodsItem.fromJson(e))
|
// .map((e) => GoodsItem.fromJson(e))
|
||||||
.toList();
|
// .toList();
|
||||||
}
|
// }
|
||||||
_pageCount = baseListModel.pageCount!;
|
// _pageCount = baseListModel.pageCount!;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
Future loadMarketInfo() async {
|
// Future loadMarketInfo() async {
|
||||||
BaseListModel baseListModel =
|
// BaseListModel baseListModel =
|
||||||
await NetUtil().getList(API.market.hotTop, params: {
|
// await NetUtil().getList(API.market.hotTop, params: {
|
||||||
"pageNum": _pageNum,
|
// "pageNum": _pageNum,
|
||||||
"size": _size,
|
// "size": _size,
|
||||||
});
|
// });
|
||||||
if (baseListModel.tableList!.isNotEmpty) {
|
// if (baseListModel.tableList!.isNotEmpty) {
|
||||||
_hotItems.addAll((baseListModel.tableList as List)
|
// _hotItems.addAll((baseListModel.tableList as List)
|
||||||
.map((e) => GoodsItem.fromJson(e))
|
// .map((e) => GoodsItem.fromJson(e))
|
||||||
.toList());
|
// .toList());
|
||||||
}
|
// }
|
||||||
_pageCount = baseListModel.pageCount!;
|
// _pageCount = baseListModel.pageCount!;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@override
|
// @override
|
||||||
void initState() {
|
// void initState() {
|
||||||
super.initState();
|
// super.initState();
|
||||||
_refreshController = EasyRefreshController();
|
// _refreshController = EasyRefreshController();
|
||||||
Future.delayed(Duration(milliseconds: 0), () async {
|
// Future.delayed(Duration(milliseconds: 0), () async {
|
||||||
_marketModels = await DisplayCategoryModel.top8;
|
// _marketModels = await DisplayCategoryModel.top8;
|
||||||
await updateMarketInfo();
|
// await updateMarketInfo();
|
||||||
setState(() {});
|
// setState(() {});
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@override
|
// @override
|
||||||
void dispose() {
|
// void dispose() {
|
||||||
_refreshController.dispose();
|
// _refreshController.dispose();
|
||||||
super.dispose();
|
// super.dispose();
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@override
|
// @override
|
||||||
Widget build(BuildContext context) {
|
// Widget build(BuildContext context) {
|
||||||
super.build(context);
|
// super.build(context);
|
||||||
final mediaWidth = MediaQuery.of(context).size.width;
|
// final mediaWidth = MediaQuery.of(context).size.width;
|
||||||
return BeeScaffold(
|
// return BeeScaffold(
|
||||||
leading: IconButton(
|
// leading: IconButton(
|
||||||
icon: Icon(CupertinoIcons.search),
|
// icon: Icon(CupertinoIcons.search),
|
||||||
onPressed: () {
|
// onPressed: () {
|
||||||
Get.to(() => SearchGoodsPage());
|
// Get.to(() => SearchGoodsPage());
|
||||||
},
|
// },
|
||||||
),
|
// ),
|
||||||
title: '商城',
|
// title: '商城',
|
||||||
actions: [
|
// actions: [
|
||||||
MaterialButton(
|
// MaterialButton(
|
||||||
minWidth: 108.w,
|
// minWidth: 108.w,
|
||||||
padding: EdgeInsets.zero,
|
// padding: EdgeInsets.zero,
|
||||||
onPressed: () async {
|
// onPressed: () async {
|
||||||
// Get.to(() => SecondHandPage());
|
// // Get.to(() => SecondHandPage());
|
||||||
Get.to(() => MyOrderPage());
|
// Get.to(() => MyOrderPage());
|
||||||
},
|
// },
|
||||||
child: Column(
|
// child: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
// mainAxisAlignment: MainAxisAlignment.center,
|
||||||
mainAxisSize: MainAxisSize.max,
|
// mainAxisSize: MainAxisSize.max,
|
||||||
children: [
|
// children: [
|
||||||
Image.asset(
|
// Image.asset(
|
||||||
R.ASSETS_ICONS_SECOND_HAND_PNG,
|
// R.ASSETS_ICONS_SECOND_HAND_PNG,
|
||||||
width: 48.w,
|
// width: 48.w,
|
||||||
height: 48.w,
|
// height: 48.w,
|
||||||
),
|
// ),
|
||||||
4.hb,
|
// 4.hb,
|
||||||
// '二手'.text.size(20.sp).black.make(),
|
// // '二手'.text.size(20.sp).black.make(),
|
||||||
'订单'.text.size(20.sp).black.make(),
|
// '订单'.text.size(20.sp).black.make(),
|
||||||
],
|
// ],
|
||||||
),
|
// ),
|
||||||
),
|
// ),
|
||||||
MaterialButton(
|
// MaterialButton(
|
||||||
minWidth: 108.w,
|
// minWidth: 108.w,
|
||||||
padding: EdgeInsets.zero,
|
// padding: EdgeInsets.zero,
|
||||||
onPressed: () async {
|
// onPressed: () async {
|
||||||
final cancel = BotToast.showLoading();
|
// final cancel = BotToast.showLoading();
|
||||||
List<MarketCategoryModel> models =
|
// List<MarketCategoryModel> models =
|
||||||
await DisplayCategoryModel.fetchCategory(0);
|
// await DisplayCategoryModel.fetchCategory(0);
|
||||||
cancel();
|
// cancel();
|
||||||
Get.to(() => CategoryPage(models: models));
|
// Get.to(() => CategoryPage(models: models));
|
||||||
},
|
// },
|
||||||
child: Column(
|
// child: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
// mainAxisAlignment: MainAxisAlignment.center,
|
||||||
mainAxisSize: MainAxisSize.max,
|
// mainAxisSize: MainAxisSize.max,
|
||||||
children: [
|
// children: [
|
||||||
Image.asset(
|
// Image.asset(
|
||||||
R.ASSETS_ICONS_CATEGORY_PNG,
|
// R.ASSETS_ICONS_CATEGORY_PNG,
|
||||||
width: 48.w,
|
// width: 48.w,
|
||||||
height: 48.w,
|
// height: 48.w,
|
||||||
),
|
// ),
|
||||||
4.hb,
|
// 4.hb,
|
||||||
'分类'.text.size(20.sp).black.make(),
|
// '分类'.text.size(20.sp).black.make(),
|
||||||
],
|
// ],
|
||||||
),
|
// ),
|
||||||
),
|
// ),
|
||||||
],
|
// ],
|
||||||
body:
|
// body:
|
||||||
NestedScrollView(
|
// NestedScrollView(
|
||||||
headerSliverBuilder: (context, value) {
|
// headerSliverBuilder: (context, value) {
|
||||||
var gridItems = Material(
|
// var gridItems = Material(
|
||||||
color: Colors.white,
|
// color: Colors.white,
|
||||||
clipBehavior: Clip.antiAlias,
|
// clipBehavior: Clip.antiAlias,
|
||||||
borderRadius: BorderRadius.circular(8.w),
|
// borderRadius: BorderRadius.circular(8.w),
|
||||||
child: GridView(
|
// child: GridView(
|
||||||
physics: NeverScrollableScrollPhysics(),
|
// physics: NeverScrollableScrollPhysics(),
|
||||||
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
// gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
||||||
crossAxisCount: 4,
|
// crossAxisCount: 4,
|
||||||
childAspectRatio: 1,
|
// childAspectRatio: 1,
|
||||||
),
|
// ),
|
||||||
shrinkWrap: true,
|
// shrinkWrap: true,
|
||||||
children:
|
// children:
|
||||||
_marketModels.map((e) => CategoryCard(model: e)).toList(),
|
// _marketModels.map((e) => CategoryCard(model: e)).toList(),
|
||||||
),
|
// ),
|
||||||
);
|
// );
|
||||||
return [
|
// return [
|
||||||
SliverAppBar(
|
// SliverAppBar(
|
||||||
//AppBar top Widget height
|
// //AppBar top Widget height
|
||||||
//bottom height: 48
|
// //bottom height: 48
|
||||||
// flexibleSpace的高为 (设备宽 - 边距)/4*2 + 外边距 + bottom高 + top热搜栏
|
// // flexibleSpace的高为 (设备宽 - 边距)/4*2 + 外边距 + bottom高 + top热搜栏
|
||||||
// * 热搜栏
|
// // * 热搜栏
|
||||||
//expandedHeight:
|
// //expandedHeight:
|
||||||
//(mediaWidth - 32.w * 2) / 4 * 2 + 16.w * 2 + 48 + 68.w,
|
// //(mediaWidth - 32.w * 2) / 4 * 2 + 16.w * 2 + 48 + 68.w,
|
||||||
//
|
// //
|
||||||
expandedHeight: (mediaWidth - 32.w * 2) / 4 * 2 + 16.w * 2,
|
// expandedHeight: (mediaWidth - 32.w * 2) / 4 * 2 + 16.w * 2,
|
||||||
backgroundColor: Colors.transparent,
|
// backgroundColor: Colors.transparent,
|
||||||
elevation: 0,
|
// elevation: 0,
|
||||||
flexibleSpace: FlexibleSpaceBar(
|
// flexibleSpace: FlexibleSpaceBar(
|
||||||
background: Container(
|
// background: Container(
|
||||||
color: Color(0xFFF9F9F9),
|
// color: Color(0xFFF9F9F9),
|
||||||
padding: EdgeInsets.only(
|
// padding: EdgeInsets.only(
|
||||||
top: 16.w,
|
// top: 16.w,
|
||||||
left: 32.w,
|
// left: 32.w,
|
||||||
right: 32.w,
|
// right: 32.w,
|
||||||
bottom: 16.w, //底部边距需要加上bottom高
|
// bottom: 16.w, //底部边距需要加上bottom高
|
||||||
),
|
// ),
|
||||||
child: Column(
|
// child: Column(
|
||||||
children: [
|
// children: [
|
||||||
// SizedBox(
|
// // SizedBox(
|
||||||
// height: 58.w,
|
// // height: 58.w,
|
||||||
// child: Row(
|
// // child: Row(
|
||||||
// children: [
|
// // children: [
|
||||||
// Text(
|
// // Text(
|
||||||
// '热搜:',
|
// // '热搜:',
|
||||||
// style: TextStyle(
|
// // style: TextStyle(
|
||||||
// fontSize: 20.sp,
|
// // fontSize: 20.sp,
|
||||||
// ),
|
// // ),
|
||||||
// ),
|
// // ),
|
||||||
// 20.wb,
|
// // 20.wb,
|
||||||
// ListView.separated(
|
// // ListView.separated(
|
||||||
// scrollDirection: Axis.horizontal,
|
// // scrollDirection: Axis.horizontal,
|
||||||
// separatorBuilder: (_, __) => 20.wb,
|
// // separatorBuilder: (_, __) => 20.wb,
|
||||||
// itemBuilder: (context, index) {
|
// // itemBuilder: (context, index) {
|
||||||
// final item = _hotItems[index];
|
// // final item = _hotItems[index];
|
||||||
// return MaterialButton(
|
// // return MaterialButton(
|
||||||
// padding:
|
// // padding:
|
||||||
// EdgeInsets.symmetric(horizontal: 40.w),
|
// // EdgeInsets.symmetric(horizontal: 40.w),
|
||||||
// minWidth: 0,
|
// // minWidth: 0,
|
||||||
// shape: StadiumBorder(
|
// // shape: StadiumBorder(
|
||||||
// side: BorderSide(
|
// // side: BorderSide(
|
||||||
// color: ktextSubColor,
|
// // color: ktextSubColor,
|
||||||
// width: 1,
|
// // width: 1,
|
||||||
// ),
|
// // ),
|
||||||
// ),
|
// // ),
|
||||||
// materialTapTargetSize:
|
// // materialTapTargetSize:
|
||||||
// MaterialTapTargetSize.shrinkWrap,
|
// // MaterialTapTargetSize.shrinkWrap,
|
||||||
// onPressed: () {
|
// // onPressed: () {
|
||||||
// Get.to(() => GoodsDetailPage(id: item.id));
|
// // Get.to(() => GoodsDetailPage(id: item.id));
|
||||||
// },
|
// // },
|
||||||
// child: Text(
|
// // child: Text(
|
||||||
// item.title,
|
// // item.title,
|
||||||
// style: TextStyle(
|
// // style: TextStyle(
|
||||||
// color: ktextSubColor,
|
// // color: ktextSubColor,
|
||||||
// ),
|
// // ),
|
||||||
// ),
|
// // ),
|
||||||
// );
|
// // );
|
||||||
// },
|
// // },
|
||||||
// itemCount: _hotItems.length,
|
// // itemCount: _hotItems.length,
|
||||||
// ).expand(),
|
// // ).expand(),
|
||||||
// ],
|
// // ],
|
||||||
// ),
|
// // ),
|
||||||
// ),
|
// // ),
|
||||||
// 10.hb,
|
// // 10.hb,
|
||||||
gridItems.expand(),
|
// gridItems.expand(),
|
||||||
],
|
// ],
|
||||||
),
|
// ),
|
||||||
),
|
// ),
|
||||||
),
|
// ),
|
||||||
pinned: true,
|
// pinned: true,
|
||||||
toolbarHeight: 0,
|
// toolbarHeight: 0,
|
||||||
// bottom: PreferredSize(
|
// // bottom: PreferredSize(
|
||||||
// child: Material(
|
// // child: Material(
|
||||||
// color: Color(0xFFF9F9F9),
|
// // color: Color(0xFFF9F9F9),
|
||||||
// child: Align(
|
// // child: Align(
|
||||||
// alignment: Alignment.centerLeft,
|
// // alignment: Alignment.centerLeft,
|
||||||
// child: BeeTabBar(
|
// // child: BeeTabBar(
|
||||||
// scrollable: true,
|
// // scrollable: true,
|
||||||
// controller: _tabController,
|
// // controller: _tabController,
|
||||||
// tabs: ['社区商城', '二手市场'],
|
// // tabs: ['社区商城', '二手市场'],
|
||||||
// ),
|
// // ),
|
||||||
// ),
|
// // ),
|
||||||
// ),
|
// // ),
|
||||||
// preferredSize: Size.fromHeight(48),
|
// // preferredSize: Size.fromHeight(48),
|
||||||
// ),
|
// // ),
|
||||||
),
|
// ),
|
||||||
];
|
// ];
|
||||||
},
|
// },
|
||||||
body: EasyRefresh(
|
// body: EasyRefresh(
|
||||||
firstRefresh: false,
|
// firstRefresh: false,
|
||||||
enableControlFinishLoad: false,
|
// enableControlFinishLoad: false,
|
||||||
header: MaterialHeader(),
|
// header: MaterialHeader(),
|
||||||
footer: MaterialFooter(),
|
// footer: MaterialFooter(),
|
||||||
controller: _refreshController,
|
// controller: _refreshController,
|
||||||
onRefresh: () async {
|
// onRefresh: () async {
|
||||||
_pageNum = 1;
|
// _pageNum = 1;
|
||||||
await updateMarketInfo();
|
// await updateMarketInfo();
|
||||||
setState(() {});
|
// setState(() {});
|
||||||
},
|
// },
|
||||||
onLoad: () async {
|
// onLoad: () async {
|
||||||
_pageNum++;
|
// _pageNum++;
|
||||||
await loadMarketInfo();
|
// await loadMarketInfo();
|
||||||
if (_pageCount <= _pageNum) {
|
// if (_pageCount <= _pageNum) {
|
||||||
_refreshController.finishLoad(noMore: false);
|
// _refreshController.finishLoad(noMore: false);
|
||||||
}
|
// }
|
||||||
setState(() {});
|
// setState(() {});
|
||||||
},
|
// },
|
||||||
child: WaterfallFlow.builder(
|
// child: WaterfallFlow.builder(
|
||||||
gridDelegate: SliverWaterfallFlowDelegateWithFixedCrossAxisCount(
|
// gridDelegate: SliverWaterfallFlowDelegateWithFixedCrossAxisCount(
|
||||||
crossAxisCount: 2,
|
// crossAxisCount: 2,
|
||||||
mainAxisSpacing: 20.w,
|
// mainAxisSpacing: 20.w,
|
||||||
crossAxisSpacing: 20.w,
|
// crossAxisSpacing: 20.w,
|
||||||
),
|
// ),
|
||||||
padding: EdgeInsets.all(32.w),
|
// padding: EdgeInsets.all(32.w),
|
||||||
itemBuilder: (context, index) {
|
// itemBuilder: (context, index) {
|
||||||
return SizedBox();
|
// return SizedBox();
|
||||||
//final item = _hotItems[index];
|
// //final item = _hotItems[index];
|
||||||
// return GoodsCard(item: item);
|
// // return GoodsCard(item: item);
|
||||||
},
|
// },
|
||||||
itemCount: _hotItems.length,
|
// itemCount: _hotItems.length,
|
||||||
),
|
// ),
|
||||||
),
|
// ),
|
||||||
),
|
// ),
|
||||||
);
|
// );
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@override
|
// @override
|
||||||
bool get wantKeepAlive => true;
|
// bool get wantKeepAlive => true;
|
||||||
}
|
// }
|
||||||
|
@ -0,0 +1,289 @@
|
|||||||
|
import 'package:aku_community/models/market/order/goods_home_model.dart';
|
||||||
|
import 'package:aku_community/models/search/search_goods_model.dart';
|
||||||
|
import 'package:aku_community/ui/market/search/good_detail_page.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_easyrefresh/easy_refresh.dart';
|
||||||
|
|
||||||
|
import 'package:get/get.dart';
|
||||||
|
|
||||||
|
import 'package:aku_community/base/base_style.dart';
|
||||||
|
import 'package:aku_community/constants/api.dart';
|
||||||
|
import 'package:aku_community/model/common/img_model.dart';
|
||||||
|
import 'package:aku_community/models/market/goods_item.dart';
|
||||||
|
import 'package:aku_community/ui/market/goods/goods_detail_page.dart';
|
||||||
|
import 'package:aku_community/utils/headers.dart';
|
||||||
|
|
||||||
|
import 'collection/collection_func.dart';
|
||||||
|
|
||||||
|
class SearchGoodsCard extends StatefulWidget {
|
||||||
|
final SearchGoodsModel item;
|
||||||
|
final EasyRefreshController? refreshController;
|
||||||
|
|
||||||
|
const SearchGoodsCard({Key? key, required this.item, this.refreshController,})
|
||||||
|
: super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
_SearchGoodsCardState createState() => _SearchGoodsCardState();
|
||||||
|
}
|
||||||
|
class _SearchGoodsCardState extends State<SearchGoodsCard> {
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return MaterialButton(
|
||||||
|
color: Colors.white,
|
||||||
|
elevation: 0,
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.circular(24.w),
|
||||||
|
),
|
||||||
|
padding: EdgeInsets.zero,
|
||||||
|
onPressed: () {
|
||||||
|
Get.to(
|
||||||
|
() => GoodDetailPage(goodId: widget.item.id!),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
clipBehavior: Clip.antiAlias,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
borderRadius: BorderRadius.all(Radius.circular(24.w)),
|
||||||
|
),
|
||||||
|
child: Stack(
|
||||||
|
children: [
|
||||||
|
FadeInImage.assetNetwork(
|
||||||
|
placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP,
|
||||||
|
image: widget.item.mainPhoto ?? '',
|
||||||
|
fit: BoxFit.fill,
|
||||||
|
imageErrorBuilder: (context, error, stackTrace) {
|
||||||
|
return Image.asset(R.ASSETS_IMAGES_PLACEHOLDER_WEBP);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
// Positioned(
|
||||||
|
// left: 0,
|
||||||
|
// right: 0,
|
||||||
|
// bottom: 0,
|
||||||
|
// child: Container(
|
||||||
|
// height: 38.w,
|
||||||
|
// color: Colors.black54,
|
||||||
|
// alignment: Alignment.centerLeft,
|
||||||
|
// padding: EdgeInsets.symmetric(horizontal: 12.w),
|
||||||
|
// child: Text(
|
||||||
|
// item.skuName??'',
|
||||||
|
// overflow: TextOverflow.ellipsis,
|
||||||
|
// style: TextStyle(
|
||||||
|
// color: Colors.white,
|
||||||
|
// fontSize: 18.sp,
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Container(
|
||||||
|
padding: EdgeInsets.only(
|
||||||
|
left: 16.w, right: 16.w,
|
||||||
|
top: 10.w,
|
||||||
|
),
|
||||||
|
child: Text(
|
||||||
|
widget.item.skuName ?? '',
|
||||||
|
maxLines: 2,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 28.sp,
|
||||||
|
color: ktextPrimary
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
|
||||||
|
Padding(
|
||||||
|
padding: EdgeInsets.only(
|
||||||
|
left: 16.w, right: 16.w,
|
||||||
|
top: 10.w,
|
||||||
|
),
|
||||||
|
child: Container(
|
||||||
|
child: _getIcon(widget.item.kind??0),
|
||||||
|
)
|
||||||
|
),
|
||||||
|
|
||||||
|
10.hb,
|
||||||
|
Padding(
|
||||||
|
padding: EdgeInsets.symmetric(
|
||||||
|
horizontal: 16.w,
|
||||||
|
),
|
||||||
|
child: RichText(
|
||||||
|
text: TextSpan(
|
||||||
|
children: [
|
||||||
|
TextSpan(
|
||||||
|
text: '¥',
|
||||||
|
style: TextStyle(
|
||||||
|
color: Colors.red,
|
||||||
|
fontSize: 28.sp,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
TextSpan(
|
||||||
|
text: '${widget.item.sellPrice ?? ''} ',
|
||||||
|
style: TextStyle(
|
||||||
|
color: Colors.red,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
fontSize: 40.sp,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Column(
|
||||||
|
children: [
|
||||||
|
Padding(
|
||||||
|
padding: EdgeInsets.symmetric(
|
||||||
|
horizontal: 16.w,
|
||||||
|
),
|
||||||
|
child: RichText(
|
||||||
|
text: TextSpan(
|
||||||
|
children: [
|
||||||
|
TextSpan(
|
||||||
|
text: '原价:',
|
||||||
|
style: TextStyle(
|
||||||
|
color: ktextSubColor,
|
||||||
|
fontSize: 20.sp,
|
||||||
|
|
||||||
|
),
|
||||||
|
),
|
||||||
|
TextSpan(
|
||||||
|
text: widget.item.discountPrice == null ? '' : '¥${widget.item
|
||||||
|
.discountPrice ?? ''}',
|
||||||
|
style: TextStyle(
|
||||||
|
color: ktextSubColor,
|
||||||
|
fontSize: 20.sp,
|
||||||
|
decoration: TextDecoration.lineThrough,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Padding(
|
||||||
|
padding: EdgeInsets.symmetric(
|
||||||
|
horizontal: 16.w,
|
||||||
|
),
|
||||||
|
child: RichText(
|
||||||
|
text: TextSpan(
|
||||||
|
children: [
|
||||||
|
TextSpan(
|
||||||
|
text: '折扣:',
|
||||||
|
style: TextStyle(
|
||||||
|
color: ktextSubColor,
|
||||||
|
fontSize: 20.sp,
|
||||||
|
|
||||||
|
),
|
||||||
|
),
|
||||||
|
TextSpan(
|
||||||
|
text: (widget.item.discountPrice ?? 0) > (widget.item.sellPrice ?? 0)
|
||||||
|
? _getDiscount(widget.item.sellPrice ?? -1,
|
||||||
|
widget.item.discountPrice ?? -1)
|
||||||
|
: '暂无折扣',
|
||||||
|
style: TextStyle(
|
||||||
|
color: ktextSubColor,
|
||||||
|
fontSize: 20.sp,
|
||||||
|
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
Spacer(),
|
||||||
|
GestureDetector(
|
||||||
|
onTap: () async {
|
||||||
|
await CollectionFunc.collection(widget.item.id!);
|
||||||
|
|
||||||
|
if (widget.refreshController != null) {
|
||||||
|
widget.refreshController!.callRefresh();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
child: (widget.item.isCollection ?? 0) != 0
|
||||||
|
? Image.asset(
|
||||||
|
R.ASSETS_ICONS_SHOP_FAVORFILL_PNG,
|
||||||
|
width: 42.w,
|
||||||
|
height: 42.w,
|
||||||
|
)
|
||||||
|
: Image.asset(
|
||||||
|
R.ASSETS_ICONS_ICON_FAVOR_CHOOSE_PNG,
|
||||||
|
width: 42.w,
|
||||||
|
height: 42.w,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
20.wb,
|
||||||
|
],
|
||||||
|
),
|
||||||
|
|
||||||
|
20.hb,
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
_getDiscount(double sellPrice, double discountPrice) {
|
||||||
|
String count = '';
|
||||||
|
count = ((sellPrice / discountPrice) * 10).toStringAsFixed(1);
|
||||||
|
|
||||||
|
return count + '折';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Widget _getIcon(int type) {
|
||||||
|
if (type == 1) {
|
||||||
|
return Container(
|
||||||
|
width: 86.w,
|
||||||
|
height: 26.w,
|
||||||
|
alignment: Alignment.center,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
borderRadius: BorderRadius.all(Radius.circular(4.w),),
|
||||||
|
gradient: LinearGradient(
|
||||||
|
begin: FractionalOffset.centerLeft,
|
||||||
|
end: FractionalOffset.centerRight,
|
||||||
|
colors: <Color>[Color(0xFFEC5329), Color(0xFFF58123)],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: Text(
|
||||||
|
'京东自营',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 18.sp,
|
||||||
|
color: kForeGroundColor
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else if (type == 2) {
|
||||||
|
return Container(
|
||||||
|
alignment: Alignment.center,
|
||||||
|
width: 86.w,
|
||||||
|
height: 30.w,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
borderRadius: BorderRadius.all(Radius.circular(4.w),),
|
||||||
|
gradient: LinearGradient(
|
||||||
|
begin: FractionalOffset.centerLeft,
|
||||||
|
end: FractionalOffset.centerRight,
|
||||||
|
colors: <Color>[Color(0xFFF59B1C), Color(0xFFF5AF16)],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: Text(
|
||||||
|
'京东POP',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 18.sp,
|
||||||
|
color: kForeGroundColor
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return SizedBox();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in new issue