parent
a089f0848a
commit
69bccd0f71
@ -0,0 +1,96 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
import 'package:aku_community/model/common/img_model.dart';
|
||||
import 'package:flustars/flustars.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
part 'my_order_list_model.g.dart';
|
||||
|
||||
@JsonSerializable()
|
||||
class MyOrderListModel extends Equatable {
|
||||
final int id;
|
||||
final String code;
|
||||
final int goodsId;
|
||||
final String goodsName;
|
||||
final int? backType;
|
||||
final List<ImgModel> goodsImgList;
|
||||
final double sellingPrice;
|
||||
final double? markingPrice;
|
||||
final int num;
|
||||
final int status;
|
||||
final String arrivalTime;
|
||||
MyOrderListModel({
|
||||
required this.id,
|
||||
required this.code,
|
||||
required this.goodsId,
|
||||
required this.goodsName,
|
||||
this.backType,
|
||||
required this.goodsImgList,
|
||||
required this.sellingPrice,
|
||||
this.markingPrice,
|
||||
required this.num,
|
||||
required this.status,
|
||||
required this.arrivalTime,
|
||||
});
|
||||
|
||||
factory MyOrderListModel.fromJson(Map<String, dynamic> json) =>
|
||||
_$MyOrderListModelFromJson(json);
|
||||
|
||||
String get arrivlaTimeString =>
|
||||
DateUtil.formatDateStr(this.arrivalTime, format: 'yyyy-MM-dd HH:mm');
|
||||
|
||||
String get statusString {
|
||||
switch (this.status) {
|
||||
case 1:
|
||||
return '待发货';
|
||||
case 2:
|
||||
return '已发货';
|
||||
case 3:
|
||||
return '已收货';
|
||||
case 4:
|
||||
return '申请退换货';
|
||||
case 5:
|
||||
return '申请通过';
|
||||
case 6:
|
||||
return '申请驳回';
|
||||
default:
|
||||
return '未知';
|
||||
}
|
||||
}
|
||||
|
||||
Color get statusColor {
|
||||
switch (this.status) {
|
||||
case 1:
|
||||
return Color(0xFFFF8200);
|
||||
case 2:
|
||||
return Color(0xFF030303);
|
||||
case 3:
|
||||
return Color(0xFF999999);
|
||||
case 4:
|
||||
return Color(0xFFFB4702);
|
||||
case 5:
|
||||
return Color(0xFF999999);
|
||||
case 6:
|
||||
return Color(0xFF999999);
|
||||
default:
|
||||
return Colors.black;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
List<Object?> get props {
|
||||
return [
|
||||
id,
|
||||
code,
|
||||
goodsId,
|
||||
goodsName,
|
||||
backType,
|
||||
goodsImgList,
|
||||
sellingPrice,
|
||||
markingPrice,
|
||||
num,
|
||||
status,
|
||||
arrivalTime,
|
||||
];
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'my_order_list_model.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
MyOrderListModel _$MyOrderListModelFromJson(Map<String, dynamic> json) {
|
||||
return MyOrderListModel(
|
||||
id: json['id'] as int,
|
||||
code: json['code'] as String,
|
||||
goodsId: json['goodsId'] as int,
|
||||
goodsName: json['goodsName'] as String,
|
||||
backType: json['backType'] as int?,
|
||||
goodsImgList: (json['goodsImgList'] as List<dynamic>)
|
||||
.map((e) => ImgModel.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
sellingPrice: (json['sellingPrice'] as num).toDouble(),
|
||||
markingPrice: (json['markingPrice'] as num?)?.toDouble(),
|
||||
num: json['num'] as int,
|
||||
status: json['status'] as int,
|
||||
arrivalTime: json['arrivalTime'] as String,
|
||||
);
|
||||
}
|
@ -0,0 +1,169 @@
|
||||
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/order/my_order_list_model.dart';
|
||||
import 'package:aku_community/ui/market/order/my_order_func.dart';
|
||||
import 'package:aku_community/utils/card_bottom_button.dart';
|
||||
import 'package:aku_community/widget/bee_divider.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:velocity_x/velocity_x.dart';
|
||||
import 'package:aku_community/const/resource.dart';
|
||||
import 'package:aku_community/extensions/widget_list_ext.dart';
|
||||
|
||||
class MyOrderCard extends StatefulWidget {
|
||||
final MyOrderListModel model;
|
||||
final VoidCallback callRefresh;
|
||||
MyOrderCard({Key? key, required this.model, required this.callRefresh})
|
||||
: super(key: key);
|
||||
|
||||
@override
|
||||
_MyOrderCardState createState() => _MyOrderCardState();
|
||||
}
|
||||
|
||||
class _MyOrderCardState extends State<MyOrderCard> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
),
|
||||
padding: EdgeInsets.symmetric(vertical: 32.w, horizontal: 32.w),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
widget.model.goodsName.text
|
||||
.size(32.sp)
|
||||
.bold
|
||||
.color(ktextPrimary)
|
||||
.make(),
|
||||
Spacer(),
|
||||
widget.model.statusString.text
|
||||
.size(30.sp)
|
||||
.bold
|
||||
.color(widget.model.statusColor)
|
||||
.make(),
|
||||
],
|
||||
),
|
||||
16.w.heightBox,
|
||||
BeeDivider.horizontal(),
|
||||
24.w.heightBox,
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
ClipRRect(
|
||||
borderRadius: BorderRadius.circular(8.w),
|
||||
clipBehavior: Clip.antiAlias,
|
||||
child: FadeInImage.assetNetwork(
|
||||
width: 160.w,
|
||||
height: 160.w,
|
||||
fit: BoxFit.cover,
|
||||
placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP,
|
||||
image:
|
||||
API.image(ImgModel.first(widget.model.goodsImgList))),
|
||||
),
|
||||
Column(
|
||||
children: [
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
widget.model.goodsName.text
|
||||
.size(28.sp)
|
||||
.color(ktextPrimary)
|
||||
.maxLines(2)
|
||||
.overflow(TextOverflow.ellipsis)
|
||||
.bold
|
||||
.make(),
|
||||
Spacer(),
|
||||
'¥${widget.model.sellingPrice}'
|
||||
.text
|
||||
.size(28.sp)
|
||||
.bold
|
||||
.color(Color(0xFFE60E0E))
|
||||
.make(),
|
||||
],
|
||||
),
|
||||
//TODO: 缺少字段 居家生活等副标题及商品规格
|
||||
...[
|
||||
_rowTile('下单时间', widget.model.arrivlaTimeString),
|
||||
_rowTile('到达地点', '人才公寓小区北侧门口'),
|
||||
_rowTile('发货时间', widget.model.arrivlaTimeString),
|
||||
].sepWidget(separate: 16.w.heightBox),
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
_bottomWidget(),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _bottomWidget() {
|
||||
List<Widget> _buttons = _getBottomButton(widget.model.status);
|
||||
|
||||
return _buttons.isEmpty
|
||||
? SizedBox()
|
||||
: Row(
|
||||
children: [Spacer(), ..._buttons],
|
||||
);
|
||||
}
|
||||
|
||||
List<Widget> _getBottomButton(int status) {
|
||||
switch (status) {
|
||||
case 1:
|
||||
return [
|
||||
CardBottomButton.white(
|
||||
text: '取消预约',
|
||||
onPressed: () async {
|
||||
await MyOrderFunc.cancelOrder(widget.model.id);
|
||||
widget.callRefresh();
|
||||
}),
|
||||
CardBottomButton.yellow(
|
||||
text: '确认收货',
|
||||
onPressed: () async {
|
||||
await MyOrderFunc.confirmReceive(widget.model.id);
|
||||
widget.callRefresh();
|
||||
}),
|
||||
].sepWidget(separate: 24.w.widthBox);
|
||||
case 2:
|
||||
return <Widget>[
|
||||
// CardBottomButton.white(text: '提醒商家', onPressed: () {}),
|
||||
].sepWidget(separate: 24.w.widthBox);
|
||||
case 3:
|
||||
return [
|
||||
// CardBottomButton.white(text: '商品投诉', onPressed: () {}),
|
||||
CardBottomButton.white(
|
||||
text: '申请退换',
|
||||
onPressed: () async {
|
||||
await MyOrderFunc.refundOrder(widget.model.id);
|
||||
widget.callRefresh();
|
||||
}),
|
||||
// CardBottomButton.yellow(text: '查看详情', onPressed: () {}),
|
||||
].sepWidget(separate: 24.w.widthBox);
|
||||
case 4:
|
||||
return <Widget>[
|
||||
// CardBottomButton.white(text: '查看详情', onPressed: () {}),
|
||||
// CardBottomButton.yellow(text: '完成退换', onPressed: () {}),
|
||||
].sepWidget(separate: 24.w.widthBox);
|
||||
default:
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
Widget _rowTile(
|
||||
String title,
|
||||
String content,
|
||||
) {
|
||||
return Row(
|
||||
children: [
|
||||
title.text.size(24.sp).color(ktextSubColor).make(),
|
||||
Spacer(),
|
||||
content.text.size(24.sp).color(ktextPrimary).make(),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
import 'package:aku_community/constants/api.dart';
|
||||
import 'package:aku_community/utils/network/base_model.dart';
|
||||
import 'package:aku_community/utils/network/net_util.dart';
|
||||
|
||||
class MyOrderFunc {
|
||||
static Future confirmReceive(int goodsAppointmentId) async {
|
||||
BaseModel baseModel = await NetUtil().get(API.market.confirmReceive,
|
||||
params: {"goodsAppointmentId": goodsAppointmentId}, showMessage: true);
|
||||
}
|
||||
|
||||
static Future refundOrder(int goodsAppointmentId) async {
|
||||
BaseModel baseModel = await NetUtil().get(API.market.confirmReceive,
|
||||
params: {"goodsAppointmentId": goodsAppointmentId}, showMessage: true);
|
||||
}
|
||||
|
||||
static Future cancelOrder(int goodsAppointmentId) async {
|
||||
BaseModel baseModel = await NetUtil().get(API.market.confirmReceive,
|
||||
params: {"goodsAppointmentId": goodsAppointmentId}, showMessage: true);
|
||||
}
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
import 'package:aku_community/ui/market/order/my_order_view.dart';
|
||||
import 'package:aku_community/widget/bee_scaffold.dart';
|
||||
import 'package:aku_community/widget/tab_bar/bee_tab_bar.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
|
||||
class MyOrderPage extends StatefulWidget {
|
||||
MyOrderPage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
_MyOrderPageState createState() => _MyOrderPageState();
|
||||
}
|
||||
|
||||
class _MyOrderPageState extends State<MyOrderPage>
|
||||
with TickerProviderStateMixin {
|
||||
late TabController _tabController;
|
||||
List<String> _tabs = [
|
||||
'待发货',
|
||||
'已发货',
|
||||
'已收货',
|
||||
'退换/投诉',
|
||||
];
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
_tabController = TabController(length: _tabs.length, vsync: this);
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_tabController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BeeScaffold(
|
||||
title: '我的订单',
|
||||
appBarBottom: PreferredSize(
|
||||
preferredSize: Size.fromHeight(88.w),
|
||||
child: BeeTabBar(controller: _tabController, tabs: _tabs),
|
||||
),
|
||||
body: TabBarView(
|
||||
controller: _tabController,
|
||||
children: List.generate(
|
||||
_tabs.length, (index) => MyOrderView(index: index))),
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,62 @@
|
||||
import 'package:aku_community/constants/api.dart';
|
||||
import 'package:aku_community/models/market/order/my_order_list_model.dart';
|
||||
import 'package:aku_community/pages/things_page/widget/bee_list_view.dart';
|
||||
import 'package:aku_community/ui/market/order/my_order_card.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_easyrefresh/easy_refresh.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:velocity_x/velocity_x.dart';
|
||||
|
||||
class MyOrderView extends StatefulWidget {
|
||||
final int index;
|
||||
MyOrderView({Key? key, required this.index}) : super(key: key);
|
||||
|
||||
@override
|
||||
_MyOrderViewState createState() => _MyOrderViewState();
|
||||
}
|
||||
|
||||
class _MyOrderViewState extends State<MyOrderView> {
|
||||
late EasyRefreshController _refreshController;
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_refreshController = EasyRefreshController();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_refreshController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BeeListView(
|
||||
path: API.market.myOrderList,
|
||||
controller: _refreshController,
|
||||
extraParams: {
|
||||
"orderStart":widget.index+1
|
||||
},
|
||||
convert: (models) {
|
||||
return models.tableList!
|
||||
.map((e) => MyOrderListModel.fromJson(e))
|
||||
.toList();
|
||||
},
|
||||
builder: (items) {
|
||||
return ListView.separated(
|
||||
padding: EdgeInsets.symmetric(vertical: 24.w,horizontal: 32.w),
|
||||
itemBuilder: (context, index) {
|
||||
return MyOrderCard(
|
||||
model: items[index],
|
||||
callRefresh: () {
|
||||
_refreshController.callRefresh();
|
||||
},
|
||||
);
|
||||
},
|
||||
separatorBuilder: (_, __) {
|
||||
return 24.w.heightBox;
|
||||
},
|
||||
itemCount: items.length);
|
||||
});
|
||||
}
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
import 'package:aku_community/base/base_style.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:velocity_x/velocity_x.dart';
|
||||
|
||||
class CardBottomButton extends StatelessWidget {
|
||||
final String text;
|
||||
final Color textColor;
|
||||
final Color bgColor;
|
||||
final bool hasBorder;
|
||||
final VoidCallback onPressed;
|
||||
const CardBottomButton(
|
||||
{Key? key,
|
||||
required this.text,
|
||||
required this.textColor,
|
||||
required this.bgColor,
|
||||
this.hasBorder = false,
|
||||
required this.onPressed})
|
||||
: super(key: key);
|
||||
CardBottomButton.white(
|
||||
{Key? key,
|
||||
required this.text,
|
||||
required this.onPressed,
|
||||
}) : this.bgColor = Colors.white,
|
||||
this.textColor = ktextPrimary,
|
||||
this.hasBorder = true,
|
||||
super(key: key);
|
||||
CardBottomButton.yellow(
|
||||
{Key? key,
|
||||
required this.text,
|
||||
required this.onPressed,
|
||||
}) : this.bgColor = Color(0xFFFFC40C),
|
||||
this.textColor = ktextPrimary,
|
||||
this.hasBorder = false,
|
||||
super(key: key);
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialButton(
|
||||
onPressed: this.onPressed,
|
||||
elevation: 0,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(74.w),
|
||||
side: this.hasBorder
|
||||
? BorderSide(color: Color(0xFF999999), width: 2.w)
|
||||
: BorderSide.none),
|
||||
child: text.text.size(26.sp).color(this.textColor).bold.make(),
|
||||
color: this.bgColor,
|
||||
padding: EdgeInsets.symmetric(vertical: 8.w, horizontal: 24.w),
|
||||
height: 52.w,
|
||||
);
|
||||
}
|
||||
}
|
Loading…
Reference in new issue