After Width: | Height: | Size: 5.3 KiB |
After Width: | Height: | Size: 2.5 KiB |
After Width: | Height: | Size: 1.9 KiB |
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 1.8 KiB |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 1.8 KiB |
After Width: | Height: | Size: 4.0 KiB |
After Width: | Height: | Size: 5.0 KiB |
After Width: | Height: | Size: 473 B |
After Width: | Height: | Size: 7.1 KiB |
After Width: | Height: | Size: 3.4 KiB |
Before Width: | Height: | Size: 553 B After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 1.7 KiB |
@ -0,0 +1,44 @@
|
||||
class CollectionGoodsModel {
|
||||
int? id;
|
||||
String? skuName;
|
||||
String? mainPhoto;
|
||||
int? status;
|
||||
int? shopStatus;
|
||||
double? sellPrice;
|
||||
double? discountPrice;
|
||||
int? kind;
|
||||
|
||||
CollectionGoodsModel(
|
||||
{this.id,
|
||||
this.skuName,
|
||||
this.mainPhoto,
|
||||
this.status,
|
||||
this.shopStatus,
|
||||
this.sellPrice,
|
||||
this.discountPrice,
|
||||
this.kind});
|
||||
|
||||
CollectionGoodsModel.fromJson(Map<String, dynamic> json) {
|
||||
id = json['id'];
|
||||
skuName = json['skuName'];
|
||||
mainPhoto = json['mainPhoto'];
|
||||
status = json['status'];
|
||||
shopStatus = json['shopStatus'];
|
||||
sellPrice = json['sellPrice'];
|
||||
discountPrice = json['discountPrice'];
|
||||
kind = json['kind'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
data['id'] = this.id;
|
||||
data['skuName'] = this.skuName;
|
||||
data['mainPhoto'] = this.mainPhoto;
|
||||
data['status'] = this.status;
|
||||
data['shopStatus'] = this.shopStatus;
|
||||
data['sellPrice'] = this.sellPrice;
|
||||
data['discountPrice'] = this.discountPrice;
|
||||
data['kind'] = this.kind;
|
||||
return data;
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
class SearchGoodsModel {
|
||||
int? id;
|
||||
String? skuName;
|
||||
String? mainPhoto;
|
||||
double? sellPrice;
|
||||
double? discountPrice;
|
||||
int? kind;
|
||||
int? isCollection;
|
||||
|
||||
SearchGoodsModel(
|
||||
{this.id,
|
||||
this.skuName,
|
||||
this.mainPhoto,
|
||||
this.sellPrice,
|
||||
this.discountPrice,
|
||||
this.kind,
|
||||
this.isCollection});
|
||||
|
||||
SearchGoodsModel.fromJson(Map<String, dynamic> json) {
|
||||
id = json['id'];
|
||||
skuName = json['skuName'];
|
||||
mainPhoto = json['mainPhoto'];
|
||||
sellPrice = json['sellPrice'];
|
||||
discountPrice = json['discountPrice'];
|
||||
kind = json['kind'];
|
||||
isCollection = json['isCollection'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
data['id'] = this.id;
|
||||
data['skuName'] = this.skuName;
|
||||
data['mainPhoto'] = this.mainPhoto;
|
||||
data['sellPrice'] = this.sellPrice;
|
||||
data['discountPrice'] = this.discountPrice;
|
||||
data['kind'] = this.kind;
|
||||
data['isCollection'] = this.isCollection;
|
||||
return data;
|
||||
}
|
||||
}
|
@ -0,0 +1,90 @@
|
||||
import 'package:aku_community/constants/api.dart';
|
||||
import 'package:aku_community/models/collection/collection_goods_model.dart';
|
||||
import 'package:aku_community/models/market/goods_item.dart';
|
||||
import 'package:aku_community/models/market/order/order_detail_model.dart';
|
||||
import 'package:aku_community/utils/network/base_model.dart';
|
||||
import 'package:aku_community/utils/network/net_util.dart';
|
||||
|
||||
class CollectionFunc {
|
||||
///加入和取消收藏
|
||||
static Future collection(int jcookGoodsId) async {
|
||||
await NetUtil().get(API.market.addCollection,
|
||||
params: {"jcookGoodsId": jcookGoodsId}, showMessage: true);
|
||||
}
|
||||
|
||||
|
||||
/// 获取此供应商热度最高的商品
|
||||
static Future<List<CollectionGoodsModel>> getCollectionList() async {
|
||||
BaseModel baseModel =
|
||||
await NetUtil().get(API.market.collectionList);
|
||||
if (baseModel.status == true && baseModel.data != null) {
|
||||
return (baseModel.data as List)
|
||||
.map((e) => CollectionGoodsModel.fromJson(e))
|
||||
.toList();
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
|
||||
// ///确认收货
|
||||
// static Future confirmReceive(int goodsAppointmentId) async {
|
||||
// await NetUtil().get(API.market.confirmReceive,
|
||||
// params: {"goodsAppointmentId": goodsAppointmentId}, showMessage: true);
|
||||
// }
|
||||
//
|
||||
// ///申请退换
|
||||
// static Future refundOrder(
|
||||
// int goodsAppointmentId, String reson, int type) async {
|
||||
// BaseModel baseModel = await NetUtil().get(API.market.refundOrder,
|
||||
// params: {
|
||||
// "goodsAppointmentId": goodsAppointmentId,
|
||||
// "backReason": reson,
|
||||
// "backType": type
|
||||
// },
|
||||
// showMessage: true);
|
||||
// return baseModel;
|
||||
// }
|
||||
//
|
||||
// ///取消预约
|
||||
// static Future cancelOrder(int goodsAppointmentId) async {
|
||||
// BaseModel baseModel = await NetUtil().get(API.market.cancleOrder,
|
||||
// params: {"goodsAppointmentId": goodsAppointmentId}, showMessage: true);
|
||||
// return baseModel;
|
||||
// }
|
||||
//
|
||||
// ///商品评价
|
||||
// static Future goodsEvalution(
|
||||
// int goodsAppointmentId, int rating, String evaluationReason) async {
|
||||
// BaseModel baseModel = await NetUtil().get(API.market.goodsEvaluation,
|
||||
// params: {
|
||||
// "goodsAppointmentId": goodsAppointmentId,
|
||||
// "score": rating,
|
||||
// "evaluationReason": evaluationReason
|
||||
// },
|
||||
// showMessage: true);
|
||||
// return baseModel;
|
||||
// }
|
||||
//
|
||||
// /// 获取此供应商热度最高的商品
|
||||
// static Future<List<GoodsItem>> getHotTops(int supplierId) async {
|
||||
// BaseModel baseModel =
|
||||
// await NetUtil().get(API.market.suppliyerHotTop, params: {
|
||||
// "supplierId": supplierId,
|
||||
// });
|
||||
// if (baseModel.status == true && baseModel.data != null) {
|
||||
// return (baseModel.data as List)
|
||||
// .map((e) => GoodsItem.fromJson(e))
|
||||
// .toList();
|
||||
// }
|
||||
// return [];
|
||||
// }
|
||||
//
|
||||
// ///获取商品详情
|
||||
// static Future getOrderDetail(int goodsAppointmentId) async {
|
||||
// BaseModel baseModel = await NetUtil().get(API.market.orderDetail,
|
||||
// params: {"goodsAppointmentId": goodsAppointmentId});
|
||||
// if (baseModel.status! && baseModel.data != null) {
|
||||
// return OrderDetailModel.fromJson(baseModel.data);
|
||||
// }
|
||||
// }
|
||||
}
|
@ -0,0 +1,230 @@
|
||||
import 'package:aku_community/base/base_style.dart';
|
||||
import 'package:aku_community/models/collection/collection_goods_model.dart';
|
||||
import 'package:aku_community/models/search/search_goods_model.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:bot_toast/bot_toast.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import 'package:aku_community/constants/api.dart';
|
||||
|
||||
import 'package:aku_community/utils/headers.dart';
|
||||
|
||||
class CollectionListCard extends StatelessWidget {
|
||||
final CollectionGoodsModel model;
|
||||
const CollectionListCard({Key? key, required this.model}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return GestureDetector(
|
||||
child: Container(
|
||||
height: 280.w,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.all(
|
||||
Radius.circular(16.w),
|
||||
),
|
||||
color: Colors.white),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
ClipRRect(
|
||||
borderRadius: BorderRadius.all(
|
||||
Radius.circular(16.w),
|
||||
),
|
||||
child: FadeInImage.assetNetwork(
|
||||
image: model.mainPhoto ?? '',
|
||||
placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP,
|
||||
height: 280.w,
|
||||
width: 280.w,
|
||||
fit: BoxFit.fill,
|
||||
imageErrorBuilder: (context, error, stackTrace) {
|
||||
return Image.asset(
|
||||
R.ASSETS_IMAGES_PLACEHOLDER_WEBP,
|
||||
height: 280.w,
|
||||
width: 280.w,
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
16.wb,
|
||||
Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
8.hb,
|
||||
SizedBox(
|
||||
width: 400.w,
|
||||
child: Text(
|
||||
model.skuName ?? '',
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(
|
||||
fontSize: 28.sp,
|
||||
color: ktextPrimary,
|
||||
),
|
||||
),
|
||||
),
|
||||
5.hb,
|
||||
_getIcon(2),
|
||||
//_getIcon(model.kind??0),
|
||||
Spacer(),
|
||||
20.hb,
|
||||
RichText(
|
||||
text: TextSpan(
|
||||
children: [
|
||||
TextSpan(
|
||||
text: '¥',
|
||||
style: TextStyle(
|
||||
color: Colors.red,
|
||||
fontSize: 28.sp,
|
||||
),
|
||||
),
|
||||
TextSpan(
|
||||
text: '${model.sellPrice ?? 0} ',
|
||||
style: TextStyle(
|
||||
color: Colors.red,
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 40.sp,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
RichText(
|
||||
text: TextSpan(
|
||||
children: [
|
||||
TextSpan(
|
||||
text: '官方指导价:¥',
|
||||
style: TextStyle(
|
||||
color: ktextSubColor,
|
||||
fontSize: 20.sp,
|
||||
),
|
||||
),
|
||||
TextSpan(
|
||||
text: '${model.sellPrice ?? 0}',
|
||||
style: TextStyle(
|
||||
color: ktextSubColor,
|
||||
fontSize: 20.sp,
|
||||
decoration: TextDecoration.lineThrough,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
RichText(
|
||||
text: TextSpan(
|
||||
children: [
|
||||
TextSpan(
|
||||
text: '折扣:',
|
||||
style: TextStyle(
|
||||
color: ktextSubColor,
|
||||
fontSize: 20.sp,
|
||||
),
|
||||
),
|
||||
TextSpan(
|
||||
text: ((model.discountPrice ??
|
||||
1 / (model.sellPrice ?? 1)) *
|
||||
10) <
|
||||
1
|
||||
? _getDiscount(model.sellPrice ?? -1,
|
||||
model.discountPrice ?? -1)
|
||||
: '暂无折扣',
|
||||
style: TextStyle(
|
||||
color: ktextSubColor,
|
||||
fontSize: 20.sp,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Spacer(),
|
||||
Row(
|
||||
children: [
|
||||
GestureDetector(
|
||||
child: Image.asset(R.ASSETS_ICONS_COLLECTION_SHARE_PNG,width: 44.w,height: 44.w,),
|
||||
onTap: (){
|
||||
|
||||
},
|
||||
),
|
||||
24.wb,
|
||||
GestureDetector(
|
||||
child: Image.asset(R.ASSETS_ICONS_COLLECTION_SETTING_PNG,width: 44.w,height: 44.w,),
|
||||
onTap: (){
|
||||
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
44.wb,
|
||||
],
|
||||
),
|
||||
16.hb,
|
||||
],
|
||||
).expand(),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
_getDiscount(double sellPrice, double discountPrice) {
|
||||
String count = '';
|
||||
count = ((discountPrice / sellPrice) * 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();
|
||||
}
|
||||
}
|
@ -0,0 +1,117 @@
|
||||
import 'package:aku_community/model/common/img_model.dart';
|
||||
import 'package:aku_community/models/collection/collection_goods_model.dart';
|
||||
import 'package:aku_community/models/search/search_goods_model.dart';
|
||||
import 'package:aku_community/provider/user_provider.dart';
|
||||
import 'package:aku_community/ui/market/search/goods_list_card.dart';
|
||||
import 'package:aku_community/utils/hive_store.dart';
|
||||
import 'package:aku_community/widget/bee_back_button.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:flutter_easyrefresh/easy_refresh.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:waterfall_flow/waterfall_flow.dart';
|
||||
|
||||
import 'package:aku_community/base/base_style.dart';
|
||||
import 'package:aku_community/constants/api.dart';
|
||||
import 'package:aku_community/models/market/goods_item.dart';
|
||||
import 'package:aku_community/pages/things_page/widget/bee_list_view.dart';
|
||||
import 'package:aku_community/ui/market/goods/goods_card.dart';
|
||||
import 'package:aku_community/utils/headers.dart';
|
||||
import 'package:aku_community/widget/bee_scaffold.dart';
|
||||
|
||||
import 'collection_func.dart';
|
||||
import 'collection_list_card.dart';
|
||||
|
||||
|
||||
class MyCollectionPage extends StatefulWidget {
|
||||
MyCollectionPage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
MyCollectionPageState createState() => MyCollectionPageState();
|
||||
}
|
||||
|
||||
class MyCollectionPageState extends State<MyCollectionPage> {
|
||||
// TextEditingController _editingController = TextEditingController();
|
||||
EasyRefreshController _refreshController = EasyRefreshController();
|
||||
// List<String> _searchHistory = [];
|
||||
String _searchText = "";
|
||||
late List<CollectionGoodsModel> _models;
|
||||
bool _onload = true;
|
||||
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_refreshController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final userProvider = Provider.of<UserProvider>(context, listen: false);
|
||||
return BeeScaffold(
|
||||
titleSpacing: 0,
|
||||
bgColor: Color(0xFFF9F9F9),
|
||||
bodyColor: Color(0xFFF9F9F9),
|
||||
title: '收藏的商品',
|
||||
body:Container(
|
||||
color: Color(0xFFF2F3F4),
|
||||
child: EasyRefresh(
|
||||
firstRefresh: true,
|
||||
header: MaterialHeader(),
|
||||
controller: _refreshController,
|
||||
onRefresh: () async {
|
||||
_models = await CollectionFunc.getCollectionList();
|
||||
_onload = false;
|
||||
setState(() {});
|
||||
},
|
||||
child: _onload
|
||||
? Container()
|
||||
: ListView(
|
||||
children: [..._models.map((e) => CollectionListCard( model: e,)).toList()],
|
||||
),
|
||||
),
|
||||
|
||||
// BeeListView(
|
||||
// path: API.market.collectionList,
|
||||
// controller: _refreshController,
|
||||
// extraParams: {
|
||||
// "keyword":_searchText,
|
||||
// },
|
||||
// convert: (model) => model.tableList!
|
||||
// .map((e) => CollectionGoodsModel.fromJson(e))
|
||||
// .toList(),
|
||||
// builder: (items) {
|
||||
// return ListView.separated(
|
||||
// padding: EdgeInsets.only(top: 10.w,
|
||||
// left: 20.w, right: 20.w, bottom: 32.w),
|
||||
// // gridDelegate: SliverWaterfallFlowDelegateWithFixedCrossAxisCount(
|
||||
// // crossAxisCount: 2,
|
||||
// // mainAxisSpacing: 20.w,
|
||||
// // crossAxisSpacing: 20.w,
|
||||
// // ),
|
||||
// itemBuilder: (context, index) {
|
||||
// final item = items[index];
|
||||
// return Container(width: 100.w,height: 100.w,color: Colors.red,);
|
||||
// CollectionListCard(
|
||||
// model: item,); //GoodsCard(item: item);
|
||||
// },
|
||||
// separatorBuilder: (_, __) {
|
||||
// return 32.w.heightBox;
|
||||
// },
|
||||
// itemCount: items.length,
|
||||
// );
|
||||
// },
|
||||
// ),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,240 @@
|
||||
import 'package:flutter/material.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';
|
||||
|
||||
class GoodsCard extends StatelessWidget {
|
||||
final GoodsItem item;
|
||||
final bool? border;
|
||||
const GoodsCard({Key? key, required this.item, this.border})
|
||||
: super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialButton(
|
||||
color: Colors.white,
|
||||
elevation: 0,
|
||||
shape: !(border ?? false)
|
||||
? null
|
||||
: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(8.w),
|
||||
side: BorderSide(color: Color(0xFFC4C4C4))),
|
||||
padding: EdgeInsets.zero,
|
||||
onPressed: () => Get.to(
|
||||
() => GoodsDetailPage(id: item.id),
|
||||
preventDuplicates: false,
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Container(
|
||||
clipBehavior: Clip.antiAlias,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.all(Radius.circular(12.w)),
|
||||
),
|
||||
child: Stack(
|
||||
children: [
|
||||
FadeInImage.assetNetwork(
|
||||
placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP,
|
||||
image: API.image(ImgModel.first(item.imgList)),
|
||||
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.recommend,
|
||||
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(
|
||||
item.title,
|
||||
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(1),
|
||||
)
|
||||
),
|
||||
|
||||
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: '${item.sellingPrice} ',
|
||||
style: TextStyle(
|
||||
color: Colors.red,
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 40.sp,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
Padding(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 16.w,
|
||||
),
|
||||
child: RichText(
|
||||
text: TextSpan(
|
||||
children: [
|
||||
TextSpan(
|
||||
text: '原价:¥',
|
||||
style: TextStyle(
|
||||
color: ktextSubColor,
|
||||
fontSize: 20.sp,
|
||||
|
||||
),
|
||||
),
|
||||
TextSpan(
|
||||
text: '${item.markingPrice}',
|
||||
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: '9折',
|
||||
style: TextStyle(
|
||||
color: ktextSubColor,
|
||||
fontSize: 20.sp,
|
||||
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,245 @@
|
||||
import 'package:aku_community/base/base_style.dart';
|
||||
import 'package:aku_community/models/search/search_goods_model.dart';
|
||||
import 'package:aku_community/ui/market/collection/collection_func.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:bot_toast/bot_toast.dart';
|
||||
import 'package:flutter_easyrefresh/easy_refresh.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import 'package:aku_community/constants/api.dart';
|
||||
|
||||
import 'package:aku_community/utils/headers.dart';
|
||||
|
||||
class GoodsListCard extends StatefulWidget {
|
||||
final SearchGoodsModel model;
|
||||
final EasyRefreshController? refreshController;
|
||||
|
||||
GoodsListCard({Key? key, required this.model, this.refreshController})
|
||||
: super(key: key);
|
||||
|
||||
@override
|
||||
GoodsListCardState createState() => GoodsListCardState();
|
||||
}
|
||||
|
||||
class GoodsListCardState extends State<GoodsListCard> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return GestureDetector(
|
||||
child: Container(
|
||||
height: 280.w,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.all(
|
||||
Radius.circular(16.w),
|
||||
),
|
||||
color: Colors.white),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
ClipRRect(
|
||||
borderRadius: BorderRadius.all(
|
||||
Radius.circular(16.w),
|
||||
),
|
||||
child: FadeInImage.assetNetwork(
|
||||
image: widget.model.mainPhoto ?? '',
|
||||
placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP,
|
||||
height: 280.w,
|
||||
width: 280.w,
|
||||
fit: BoxFit.fill,
|
||||
imageErrorBuilder: (context, error, stackTrace) {
|
||||
return Image.asset(
|
||||
R.ASSETS_IMAGES_PLACEHOLDER_WEBP,
|
||||
height: 280.w,
|
||||
width: 280.w,
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
16.wb,
|
||||
Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
8.hb,
|
||||
SizedBox(
|
||||
width: 400.w,
|
||||
child: Text(
|
||||
widget.model.skuName ?? '',
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(
|
||||
fontSize: 28.sp,
|
||||
color: ktextPrimary,
|
||||
),
|
||||
),
|
||||
),
|
||||
5.hb,
|
||||
_getIcon(2),
|
||||
//_getIcon(model.kind??0),
|
||||
Spacer(),
|
||||
20.hb,
|
||||
RichText(
|
||||
text: TextSpan(
|
||||
children: [
|
||||
TextSpan(
|
||||
text: '¥',
|
||||
style: TextStyle(
|
||||
color: Colors.red,
|
||||
fontSize: 28.sp,
|
||||
),
|
||||
),
|
||||
TextSpan(
|
||||
text: '${widget.model.sellPrice ?? 0} ',
|
||||
style: TextStyle(
|
||||
color: Colors.red,
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 40.sp,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
RichText(
|
||||
text: TextSpan(
|
||||
children: [
|
||||
TextSpan(
|
||||
text: '官方指导价:¥',
|
||||
style: TextStyle(
|
||||
color: ktextSubColor,
|
||||
fontSize: 20.sp,
|
||||
),
|
||||
),
|
||||
TextSpan(
|
||||
text: '${widget.model.sellPrice ?? 0}',
|
||||
style: TextStyle(
|
||||
color: ktextSubColor,
|
||||
fontSize: 20.sp,
|
||||
decoration: TextDecoration.lineThrough,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
RichText(
|
||||
text: TextSpan(
|
||||
children: [
|
||||
TextSpan(
|
||||
text: '折扣:',
|
||||
style: TextStyle(
|
||||
color: ktextSubColor,
|
||||
fontSize: 20.sp,
|
||||
),
|
||||
),
|
||||
TextSpan(
|
||||
text: ((widget.model.discountPrice ??
|
||||
1 / (widget.model.sellPrice ?? 1)) *
|
||||
10) <
|
||||
1
|
||||
? _getDiscount(widget.model.sellPrice ?? -1,
|
||||
widget.model.discountPrice ?? -1)
|
||||
: '暂无折扣',
|
||||
style: TextStyle(
|
||||
color: ktextSubColor,
|
||||
fontSize: 20.sp,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Spacer(),
|
||||
GestureDetector(
|
||||
onTap: () async {
|
||||
await CollectionFunc.collection(widget.model.id!);
|
||||
|
||||
if (widget.refreshController != null) {
|
||||
widget.refreshController!.callRefresh();
|
||||
}
|
||||
},
|
||||
child: (widget.model.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,
|
||||
),
|
||||
),
|
||||
24.wb,
|
||||
],
|
||||
),
|
||||
16.hb,
|
||||
],
|
||||
).expand(),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
_getDiscount(double sellPrice, double discountPrice) {
|
||||
String count = '';
|
||||
count = ((discountPrice / sellPrice) * 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();
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,467 @@
|
||||
import 'package:aku_community/model/common/img_model.dart';
|
||||
import 'package:aku_community/provider/user_provider.dart';
|
||||
import 'package:aku_community/utils/hive_store.dart';
|
||||
import 'package:aku_community/widget/bee_back_button.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:flutter_easyrefresh/easy_refresh.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:waterfall_flow/waterfall_flow.dart';
|
||||
|
||||
import 'package:aku_community/base/base_style.dart';
|
||||
import 'package:aku_community/constants/api.dart';
|
||||
import 'package:aku_community/models/market/goods_item.dart';
|
||||
import 'package:aku_community/pages/things_page/widget/bee_list_view.dart';
|
||||
import 'package:aku_community/ui/market/goods/goods_card.dart';
|
||||
import 'package:aku_community/utils/headers.dart';
|
||||
import 'package:aku_community/widget/bee_scaffold.dart';
|
||||
|
||||
enum OrderType {
|
||||
NORMAL,
|
||||
SALES,
|
||||
PRICE_HIGH,
|
||||
PRICE_LOW,
|
||||
}
|
||||
|
||||
class SearchDetailPage extends StatefulWidget {
|
||||
SearchDetailPage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
SearchDetailPageState createState() => SearchDetailPageState();
|
||||
}
|
||||
|
||||
class SearchDetailPageState extends State<SearchDetailPage> {
|
||||
TextEditingController _editingController = TextEditingController();
|
||||
OrderType _orderType = OrderType.NORMAL;
|
||||
IconData priceIcon = CupertinoIcons.chevron_up_chevron_down;
|
||||
EasyRefreshController _refreshController = EasyRefreshController();
|
||||
List<String> _searchHistory = [];
|
||||
String _searchText = "";
|
||||
FocusNode _contentFocusNode = FocusNode();
|
||||
bool _showList = true;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
getSearchListFromSharedPreferences();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_refreshController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final userProvider = Provider.of<UserProvider>(context, listen: false);
|
||||
final normalTypeButton = MaterialButton(
|
||||
onPressed: () {
|
||||
_orderType = OrderType.NORMAL;
|
||||
priceIcon = CupertinoIcons.chevron_up_chevron_down;
|
||||
setState(() {});
|
||||
},
|
||||
child: Text(
|
||||
'综合',
|
||||
style: TextStyle(
|
||||
color:
|
||||
_orderType == OrderType.NORMAL ? kDarkPrimaryColor : ktextPrimary,
|
||||
),
|
||||
),
|
||||
height: 80.w,
|
||||
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
||||
);
|
||||
final salesTypeButton = MaterialButton(
|
||||
onPressed: () {
|
||||
_orderType = OrderType.SALES;
|
||||
priceIcon = CupertinoIcons.chevron_up_chevron_down;
|
||||
setState(() {});
|
||||
},
|
||||
child: Text(
|
||||
'销量',
|
||||
style: TextStyle(
|
||||
color:
|
||||
_orderType == OrderType.SALES ? kDarkPrimaryColor : ktextPrimary,
|
||||
),
|
||||
),
|
||||
height: 80.w,
|
||||
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
||||
);
|
||||
|
||||
final priceButton = MaterialButton(
|
||||
onPressed: () {
|
||||
switch (_orderType) {
|
||||
case OrderType.NORMAL:
|
||||
case OrderType.SALES:
|
||||
_orderType = OrderType.PRICE_HIGH;
|
||||
priceIcon = CupertinoIcons.chevron_up;
|
||||
break;
|
||||
case OrderType.PRICE_HIGH:
|
||||
_orderType = OrderType.PRICE_LOW;
|
||||
priceIcon = CupertinoIcons.chevron_down;
|
||||
break;
|
||||
case OrderType.PRICE_LOW:
|
||||
_orderType = OrderType.PRICE_HIGH;
|
||||
priceIcon = CupertinoIcons.chevron_up;
|
||||
break;
|
||||
}
|
||||
setState(() {});
|
||||
},
|
||||
child: Row(
|
||||
children: [
|
||||
Text(
|
||||
'价格',
|
||||
style: TextStyle(
|
||||
color: _orderType == OrderType.PRICE_HIGH ||
|
||||
_orderType == OrderType.PRICE_LOW
|
||||
? kDarkPrimaryColor
|
||||
: ktextPrimary,
|
||||
),
|
||||
),
|
||||
Icon(
|
||||
priceIcon,
|
||||
size: 32.w,
|
||||
color: _orderType == OrderType.PRICE_HIGH ||
|
||||
_orderType == OrderType.PRICE_LOW
|
||||
? kDarkPrimaryColor
|
||||
: ktextPrimary,
|
||||
),
|
||||
],
|
||||
),
|
||||
height: 80.w,
|
||||
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
||||
);
|
||||
return BeeScaffold(
|
||||
titleSpacing: 0,
|
||||
bgColor: Color(0xFFF9F9F9),
|
||||
bodyColor: Color(0xFFF9F9F9),
|
||||
title: Row(
|
||||
children: [
|
||||
Container(
|
||||
width: 520.w,
|
||||
height: 68.w,
|
||||
child: TextField(
|
||||
keyboardType: TextInputType.text,
|
||||
onEditingComplete: () {
|
||||
setState(() {});
|
||||
// _refreshController.callRefresh();
|
||||
},
|
||||
focusNode: _contentFocusNode,
|
||||
onChanged: (text) {
|
||||
_searchText = text;
|
||||
setState(() {});
|
||||
},
|
||||
onSubmitted: (_submitted) async {
|
||||
_contentFocusNode.unfocus();
|
||||
if (_searchHistory.contains(_searchText)) {
|
||||
_searchHistory.remove(_searchText);
|
||||
List<String> list = [_searchText];
|
||||
list.addAll(_searchHistory);
|
||||
_searchHistory = list;
|
||||
} else {
|
||||
List<String> list = [_searchText];
|
||||
list.addAll(_searchHistory);
|
||||
_searchHistory = list;
|
||||
while (_searchHistory.length > 15) {
|
||||
_searchHistory.removeLast();
|
||||
}
|
||||
}
|
||||
saveSearchListToSharedPreferences(_searchHistory);
|
||||
setState(() {});
|
||||
},
|
||||
style: TextStyle(
|
||||
textBaseline: TextBaseline.ideographic,
|
||||
fontSize: 32.sp,
|
||||
color: Colors.black,
|
||||
),
|
||||
controller: _editingController,
|
||||
decoration: InputDecoration(
|
||||
contentPadding: EdgeInsets.only(left: 20.w),
|
||||
//filled: true,
|
||||
fillColor: Color(0xFFF3F3F3),
|
||||
hintText: "请输入想要搜索的内容...",
|
||||
hintStyle: TextStyle(
|
||||
color: Colors.grey.shade500,
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w300),
|
||||
|
||||
//isDense: true,
|
||||
// prefixIcon: Icon(CupertinoIcons.search),
|
||||
|
||||
enabledBorder: OutlineInputBorder(
|
||||
borderSide: BorderSide(color: ktextPrimary),
|
||||
borderRadius: BorderRadius.circular(40),
|
||||
),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderSide: BorderSide(color: Color(0xFFE52E2E)),
|
||||
borderRadius: BorderRadius.circular(40),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
20.wb,
|
||||
Image.asset(R.ASSETS_ICONS_ICON_CHANGE_LIST_PNG,width: 48.w,height: 48.w,),
|
||||
|
||||
Text(
|
||||
'搜索',
|
||||
style: TextStyle(color: ktextPrimary, fontSize: 28.sp),
|
||||
),
|
||||
],
|
||||
),
|
||||
body: Column(
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
normalTypeButton,
|
||||
salesTypeButton,
|
||||
priceButton,
|
||||
],
|
||||
),
|
||||
10.hb,
|
||||
10.hb,
|
||||
_showList
|
||||
? Container(
|
||||
color: Color(0xFFF2F3F4),
|
||||
child: BeeListView(
|
||||
path: API.market.search,
|
||||
controller: _refreshController,
|
||||
extraParams: {'searchName': ''},
|
||||
convert: (model) => model.tableList!
|
||||
.map((e) => GoodsItem.fromJson(e))
|
||||
.toList(),
|
||||
builder: (items) {
|
||||
return ListView.separated(
|
||||
padding: EdgeInsets.only(top: 10.w,
|
||||
left: 20.w, right: 20.w, bottom: 32.w),
|
||||
// gridDelegate: SliverWaterfallFlowDelegateWithFixedCrossAxisCount(
|
||||
// crossAxisCount: 2,
|
||||
// mainAxisSpacing: 20.w,
|
||||
// crossAxisSpacing: 20.w,
|
||||
// ),
|
||||
itemBuilder: (context, index) {
|
||||
final item = items[index];
|
||||
return _hotGoodsCard(
|
||||
item, index); //GoodsCard(item: item);
|
||||
},
|
||||
separatorBuilder: (_, __) {
|
||||
return 32.w.heightBox;
|
||||
},
|
||||
itemCount: items.length,
|
||||
);
|
||||
},
|
||||
),
|
||||
).expand()
|
||||
: SizedBox(),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
_hotGoodsCard(GoodsItem goodsItem, int index) {
|
||||
return Row(
|
||||
children: [
|
||||
Stack(
|
||||
children: [
|
||||
Material(
|
||||
color: Color(0xFFF5F5F5),
|
||||
borderRadius: BorderRadius.circular(16.w),
|
||||
clipBehavior: Clip.antiAlias,
|
||||
child: FadeInImage.assetNetwork(
|
||||
placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP,
|
||||
image: API.image(ImgModel.first(goodsItem.imgList)),
|
||||
fit: BoxFit.fill,
|
||||
width: 124.w,
|
||||
height: 124.w,
|
||||
imageErrorBuilder: (context, error, stackTrace) {
|
||||
return Image.asset(
|
||||
R.ASSETS_IMAGES_PLACEHOLDER_WEBP,
|
||||
width: 124.w,
|
||||
height: 124.w,
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
// Image.asset(
|
||||
// R.ASSETS_IMAGES_PLACEHOLDER_WEBP,
|
||||
// fit: BoxFit.fill,
|
||||
// width: 124.w,
|
||||
// height: 124.w,
|
||||
// ),
|
||||
Positioned(
|
||||
left: 0,
|
||||
top: 0,
|
||||
child: Container(
|
||||
alignment: Alignment.center,
|
||||
width: 32.w,
|
||||
height: 32.w,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.only(
|
||||
topLeft: Radius.circular(16.w),
|
||||
topRight: Radius.circular(16.w),
|
||||
bottomLeft: Radius.circular(16.w)),
|
||||
gradient: LinearGradient(
|
||||
begin: Alignment.topLeft,
|
||||
end: Alignment.bottomCenter,
|
||||
colors: index == 0
|
||||
? <Color>[
|
||||
Color(0xFFE52E2E),
|
||||
Color(0xFFF58123),
|
||||
]
|
||||
: index == 1
|
||||
? <Color>[
|
||||
Color(0xFFF58123),
|
||||
Color(0xFFF5AF16),
|
||||
]
|
||||
: index == 2
|
||||
? <Color>[
|
||||
Color(0xFFF5AF16),
|
||||
Color(0xFFF5AF16),
|
||||
]
|
||||
: <Color>[
|
||||
Color(0xFFBBBBBB),
|
||||
Color(0xFFBBBBBB),
|
||||
],
|
||||
),
|
||||
),
|
||||
child: Text(
|
||||
'${index + 1}',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 24.sp,
|
||||
),
|
||||
),
|
||||
)),
|
||||
],
|
||||
),
|
||||
32.wb,
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
SizedBox(
|
||||
width: 500.w,
|
||||
child: Text(
|
||||
goodsItem.title,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(color: ktextPrimary, fontSize: 28.sp),
|
||||
),
|
||||
),
|
||||
8.hb,
|
||||
Row(
|
||||
children: [
|
||||
Text(
|
||||
'人气值',
|
||||
style: TextStyle(color: ktextSubColor, fontSize: 24.sp),
|
||||
),
|
||||
10.wb,
|
||||
Text(
|
||||
'99251',
|
||||
style: TextStyle(color: Color(0xFFBBBBBB), fontSize: 24.sp),
|
||||
),
|
||||
],
|
||||
)
|
||||
],
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
_searchHistoryWidget() {
|
||||
List<Widget> choiceChipList = [];
|
||||
if (_searchHistory != null && _searchHistory.length > 0) {
|
||||
for (var text in _searchHistory) {
|
||||
choiceChipList.add(Padding(
|
||||
padding: EdgeInsets.only(right: 10, bottom: 5),
|
||||
child: ChoiceChip(
|
||||
backgroundColor: Colors.white,
|
||||
// disabledColor: Colors.blue,
|
||||
labelStyle: TextStyle(fontSize: 15 * 2.sp, color: Colors.black),
|
||||
labelPadding: EdgeInsets.only(left: 20, right: 20),
|
||||
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
||||
onSelected: (bool value) {
|
||||
_editingController.text = text;
|
||||
_searchText = text;
|
||||
FocusManager.instance.primaryFocus!.unfocus();
|
||||
setState(() {});
|
||||
},
|
||||
label: Text(text),
|
||||
selected: false,
|
||||
),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
return _searchHistory.length == 0
|
||||
? SizedBox()
|
||||
: Container(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
36.hb,
|
||||
Container(
|
||||
child: Container(
|
||||
margin: EdgeInsets.only(left: 15, bottom: 5),
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
Text(
|
||||
'历史搜索',
|
||||
style: TextStyle(
|
||||
color: Colors.black,
|
||||
fontSize: 16,
|
||||
),
|
||||
),
|
||||
Spacer(),
|
||||
(_searchHistory != null && _searchHistory.length > 0)
|
||||
? GestureDetector(
|
||||
onTap: () {
|
||||
_searchHistory = [];
|
||||
saveSearchListToSharedPreferences(
|
||||
_searchHistory);
|
||||
setState(() {});
|
||||
},
|
||||
child: Image.asset(
|
||||
R.ASSETS_ICONS_DELETE_PNG,
|
||||
width: 40.w,
|
||||
height: 40.w,
|
||||
),
|
||||
)
|
||||
: Container(),
|
||||
36.wb,
|
||||
],
|
||||
)),
|
||||
),
|
||||
Container(
|
||||
width: MediaQuery.of(context).size.width,
|
||||
padding: EdgeInsets.only(left: 10, right: 10),
|
||||
child: Wrap(
|
||||
children: choiceChipList,
|
||||
),
|
||||
),
|
||||
// Spacer()
|
||||
24.hb,
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
getSearchListFromSharedPreferences() async {
|
||||
final userProvider = Provider.of<UserProvider>(Get.context!, listen: false);
|
||||
_searchHistory = HiveStore.appBox!.get(
|
||||
userProvider.userInfoModel?.id.toString() ?? '' + "userSearhHistory")!;
|
||||
if (_searchHistory == null) {
|
||||
_searchHistory = [];
|
||||
}
|
||||
setState(() {});
|
||||
}
|
||||
|
||||
saveSearchListToSharedPreferences(List<String> value) async {
|
||||
final userProvider = Provider.of<UserProvider>(Get.context!, listen: false);
|
||||
|
||||
HiveStore.appBox!.put(
|
||||
userProvider.userInfoModel?.id.toString() ?? '' + "userSearhHistory",
|
||||
value);
|
||||
}
|
||||
}
|
@ -0,0 +1,97 @@
|
||||
import 'package:aku_community/constants/api.dart';
|
||||
import 'package:aku_community/models/market/goods_item.dart';
|
||||
import 'package:aku_community/models/market/order/order_detail_model.dart';
|
||||
import 'package:aku_community/models/search/search_goods_model.dart';
|
||||
import 'package:aku_community/utils/network/base_list_model.dart';
|
||||
import 'package:aku_community/utils/network/base_model.dart';
|
||||
import 'package:aku_community/utils/network/net_util.dart';
|
||||
import 'package:aku_community/utils/text_utils.dart';
|
||||
|
||||
class SearchFunc {
|
||||
/// 搜索商品 根据关键字
|
||||
static Future<List<SearchGoodsModel>> getGoodsList(int pageNum,int size
|
||||
,int orderBySalesVolume,int orderByPrice,String keyword, int brandId,double minPrice,double maxPrice) async {
|
||||
//orderBySalesVolume 1降序 2升序
|
||||
Map<String, dynamic> params = {
|
||||
"pageNum": pageNum,
|
||||
"size":size,
|
||||
};
|
||||
if(orderBySalesVolume!=-1){
|
||||
params.putIfAbsent("orderBySalesVolume", () => orderBySalesVolume);
|
||||
}
|
||||
if(orderByPrice!=-1){
|
||||
params.putIfAbsent("orderByPrice", () => orderByPrice);
|
||||
}
|
||||
if (!TextUtils.isEmpty(keyword)) {
|
||||
params.putIfAbsent("keyword", () => keyword);
|
||||
}
|
||||
if(brandId!=-1){
|
||||
params.putIfAbsent("brandId", () => brandId);
|
||||
}
|
||||
if(minPrice!=-1){
|
||||
params.putIfAbsent("minPrice", () => minPrice);
|
||||
}
|
||||
if(maxPrice!=-1){
|
||||
params.putIfAbsent("maxPrice", () => maxPrice);
|
||||
}
|
||||
|
||||
BaseListModel model = await NetUtil().getList(
|
||||
API.market.findGoodsList,
|
||||
params: params,
|
||||
);
|
||||
if (model.tableList!.length == 0) return [];
|
||||
return model.tableList!.map((e) => SearchGoodsModel.fromJson(e)).toList();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
///确认收货
|
||||
static Future confirmReceive(int goodsAppointmentId) async {
|
||||
await NetUtil().get(API.market.confirmReceive,
|
||||
params: {"goodsAppointmentId": goodsAppointmentId}, showMessage: true);
|
||||
}
|
||||
|
||||
///申请退换
|
||||
static Future refundOrder(
|
||||
int goodsAppointmentId, String reson, int type) async {
|
||||
BaseModel baseModel = await NetUtil().get(API.market.refundOrder,
|
||||
params: {
|
||||
"goodsAppointmentId": goodsAppointmentId,
|
||||
"backReason": reson,
|
||||
"backType": type
|
||||
},
|
||||
showMessage: true);
|
||||
return baseModel;
|
||||
}
|
||||
|
||||
///取消预约
|
||||
static Future cancelOrder(int goodsAppointmentId) async {
|
||||
BaseModel baseModel = await NetUtil().get(API.market.cancleOrder,
|
||||
params: {"goodsAppointmentId": goodsAppointmentId}, showMessage: true);
|
||||
return baseModel;
|
||||
}
|
||||
|
||||
///商品评价
|
||||
static Future goodsEvalution(
|
||||
int goodsAppointmentId, int rating, String evaluationReason) async {
|
||||
BaseModel baseModel = await NetUtil().get(API.market.goodsEvaluation,
|
||||
params: {
|
||||
"goodsAppointmentId": goodsAppointmentId,
|
||||
"score": rating,
|
||||
"evaluationReason": evaluationReason
|
||||
},
|
||||
showMessage: true);
|
||||
return baseModel;
|
||||
}
|
||||
|
||||
|
||||
///获取商品详情
|
||||
static Future getOrderDetail(int goodsAppointmentId) async {
|
||||
BaseModel baseModel = await NetUtil().get(API.market.orderDetail,
|
||||
params: {"goodsAppointmentId": goodsAppointmentId});
|
||||
if (baseModel.status! && baseModel.data != null) {
|
||||
return OrderDetailModel.fromJson(baseModel.data);
|
||||
}
|
||||
}
|
||||
}
|