添加 商品评价页面

添加 商品退换页面
对接其接口
hmxc
张萌 4 years ago
parent 69bccd0f71
commit d814615f64

@ -327,6 +327,9 @@ class _Market {
///app
String get confirmReceive => '/user/shop/confirmReceipt';
///app
String get goodsEvaluation => '/user/shop/evaluation';
}
class _Upload {

@ -1,9 +1,10 @@
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';
import 'package:aku_community/model/common/img_model.dart';
part 'my_order_list_model.g.dart';
@JsonSerializable()
@ -17,6 +18,9 @@ class MyOrderListModel extends Equatable {
final double sellingPrice;
final double? markingPrice;
final int num;
final String supplierName;
final String levelOneCategory;
final String levelTwoCategory;
final int status;
final String arrivalTime;
MyOrderListModel({
@ -29,6 +33,9 @@ class MyOrderListModel extends Equatable {
required this.sellingPrice,
this.markingPrice,
required this.num,
required this.supplierName,
required this.levelOneCategory,
required this.levelTwoCategory,
required this.status,
required this.arrivalTime,
});
@ -89,6 +96,9 @@ class MyOrderListModel extends Equatable {
sellingPrice,
markingPrice,
num,
supplierName,
levelOneCategory,
levelTwoCategory,
status,
arrivalTime,
];

@ -19,6 +19,9 @@ MyOrderListModel _$MyOrderListModelFromJson(Map<String, dynamic> json) {
sellingPrice: (json['sellingPrice'] as num).toDouble(),
markingPrice: (json['markingPrice'] as num?)?.toDouble(),
num: json['num'] as int,
supplierName: json['supplierName'] as String,
levelOneCategory: json['levelOneCategory'] as String,
levelTwoCategory: json['levelTwoCategory'] as String,
status: json['status'] as int,
arrivalTime: json['arrivalTime'] as String,
);

@ -3,10 +3,12 @@ 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/ui/market/order/my_order_refund_page.dart';
import 'package:aku_community/widget/buttons/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:get/get.dart';
import 'package:velocity_x/velocity_x.dart';
import 'package:aku_community/const/resource.dart';
import 'package:aku_community/extensions/widget_list_ext.dart';
@ -24,7 +26,9 @@ class MyOrderCard extends StatefulWidget {
class _MyOrderCardState extends State<MyOrderCard> {
@override
Widget build(BuildContext context) {
return Container(
return GestureDetector(
onTap: () {},
child: Container(
width: double.infinity,
decoration: BoxDecoration(
color: Colors.white,
@ -65,7 +69,9 @@ class _MyOrderCardState extends State<MyOrderCard> {
image:
API.image(ImgModel.first(widget.model.goodsImgList))),
),
Column(
SizedBox(
height: 160.w,
child: Column(
children: [
Row(
crossAxisAlignment: CrossAxisAlignment.start,
@ -86,30 +92,55 @@ class _MyOrderCardState extends State<MyOrderCard> {
.make(),
],
),
//TODO:
Spacer(),
Row(
children: [
('${widget.model.levelOneCategory}|${widget.model.levelTwoCategory}')
.text
.size(24.sp)
.color(ktextSubColor)
.make()
],
),
// 12.w.heightBox,
// Row(
// children: [
// ('${widget.model.levelTwoCategory}')
// .text
// .size(24.sp)
// .color(ktextSubColor)
// .make()
// ],
// ),
],
),
).expand()
],
),
40.w.heightBox,
...[
_rowTile('下单时间', widget.model.arrivlaTimeString),
_rowTile('到达地点', '人才公寓小区北侧门口'),
_rowTile('发货时间', widget.model.arrivlaTimeString),
].sepWidget(separate: 16.w.heightBox),
],
)
..._bottomWidget(),
],
),
_bottomWidget(),
],
),
);
}
Widget _bottomWidget() {
List<Widget> _bottomWidget() {
List<Widget> _buttons = _getBottomButton(widget.model.status);
return _buttons.isEmpty
? SizedBox()
: Row(
? []
: [
40.w.heightBox,
Row(
children: [Spacer(), ..._buttons],
);
),
];
}
List<Widget> _getBottomButton(int status) {
@ -122,6 +153,13 @@ class _MyOrderCardState extends State<MyOrderCard> {
await MyOrderFunc.cancelOrder(widget.model.id);
widget.callRefresh();
}),
].sepWidget(separate: 24.w.widthBox);
case 2:
return <Widget>[
CardBottomButton.yellow(text: '查看详情', onPressed: () {}),
].sepWidget(separate: 24.w.widthBox);
case 3:
return [
CardBottomButton.yellow(
text: '确认收货',
onPressed: () async {
@ -129,26 +167,30 @@ class _MyOrderCardState extends State<MyOrderCard> {
widget.callRefresh();
}),
].sepWidget(separate: 24.w.widthBox);
case 2:
case 4:
return <Widget>[
// CardBottomButton.white(text: '提醒商家', onPressed: () {}),
].sepWidget(separate: 24.w.widthBox);
case 3:
return [
// CardBottomButton.white(text: '商品投诉', onPressed: () {}),
CardBottomButton.white(
text: '评价商品',
onPressed: () async {
widget.callRefresh();
}),
CardBottomButton.white(
text: '申请退换',
onPressed: () async {
await MyOrderFunc.refundOrder(widget.model.id);
await Get.to(() => MyOrderRefundPage(
model: widget.model,
));
widget.callRefresh();
}),
// CardBottomButton.yellow(text: '查看详情', onPressed: () {}),
].sepWidget(separate: 24.w.widthBox);
case 4:
case 6:
return <Widget>[
// CardBottomButton.white(text: '查看详情', onPressed: () {}),
// CardBottomButton.yellow(text: '完成退换', onPressed: () {}),
].sepWidget(separate: 24.w.widthBox);
CardBottomButton.yellow(text: '查看详情', onPressed: () {}),
];
case 8:
return <Widget>[
CardBottomButton.yellow(text: '查看详情', onPressed: () {}),
];
default:
return [];
}
@ -160,6 +202,7 @@ class _MyOrderCardState extends State<MyOrderCard> {
) {
return Row(
children: [
// (160 + 24).w.widthBox,
title.text.size(24.sp).color(ktextSubColor).make(),
Spacer(),
content.text.size(24.sp).color(ktextPrimary).make(),

@ -0,0 +1,19 @@
import 'package:aku_community/widget/bee_scaffold.dart';
import 'package:flutter/material.dart';
class MyOrderDetailPage extends StatefulWidget {
MyOrderDetailPage({Key? key}) : super(key: key);
@override
_MyOrderDetailPageState createState() => _MyOrderDetailPageState();
}
class _MyOrderDetailPageState extends State<MyOrderDetailPage> {
@override
Widget build(BuildContext context) {
return BeeScaffold(
title: '订单详情',
body: ListView(),
);
}
}

@ -0,0 +1,191 @@
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/widget/bee_divider.dart';
import 'package:aku_community/widget/bee_scaffold.dart';
import 'package:aku_community/widget/buttons/bottom_button.dart';
import 'package:aku_community/widget/others/bee_text_field.dart';
import 'package:flutter/material.dart';
import 'package:flutter_rating_bar/flutter_rating_bar.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:velocity_x/velocity_x.dart';
import 'package:aku_community/const/resource.dart';
class MyOrderEvaluationPage extends StatefulWidget {
final MyOrderListModel model;
MyOrderEvaluationPage({Key? key, required this.model}) : super(key: key);
@override
_MyOrderEvaluationPageState createState() => _MyOrderEvaluationPageState();
}
class _MyOrderEvaluationPageState extends State<MyOrderEvaluationPage> {
late TextEditingController _editingController;
int _rating = 10;
@override
void initState() {
super.initState();
_editingController = TextEditingController();
}
@override
void dispose() {
_editingController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return BeeScaffold(
title: '商品评价',
body: ListView(
padding: EdgeInsets.all(32.w),
children: [
_goodsInfoWidget(),
24.w.heightBox,
_resonWidget(),
],
),
bottomNavi: BottomButton(
onPressed: () async {
await MyOrderFunc.goodsEvalution(
widget.model.id, _rating, _editingController.text);
},
child: '确认提交'.text.size(32.sp).color(ktextPrimary).bold.make()),
);
}
Widget _goodsInfoWidget() {
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))),
),
SizedBox(
height: 160.w,
child: 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(),
],
),
Spacer(),
Row(
children: [
('${widget.model.levelOneCategory}|${widget.model.levelTwoCategory}')
.text
.size(24.sp)
.color(ktextSubColor)
.make()
],
),
// 12.w.heightBox,
// Row(
// children: [
// ('${widget.model.levelTwoCategory}')
// .text
// .size(24.sp)
// .color(ktextSubColor)
// .make()
// ],
// ),
],
),
).expand()
],
),
],
),
);
}
Widget _resonWidget() {
return Container(
padding: EdgeInsets.symmetric(vertical: 32.w, horizontal: 24.w),
width: double.infinity,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(8.w),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
'商品评价'.text.size(32.sp).bold.color(ktextPrimary).make(),
32.w.heightBox,
RatingBar.builder(
initialRating: _rating / 2,
minRating: 0,
direction: Axis.horizontal,
allowHalfRating: true,
itemCount: 5,
// itemPadding: EdgeInsets.symmetric(horizontal: 16.w),
itemBuilder: (context, _) => Icon(
Icons.star_border_rounded,
color: kPrimaryColor,
),
itemSize: 64.w,
onRatingUpdate: (rating) {
_rating = rating.floor();
},
glow: false,
),
32.w.heightBox,
BeeTextField(controller: _editingController, hintText: '请输入评价内容')
],
),
);
}
}

@ -3,18 +3,34 @@ 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 {
///退
static Future refundOrder(int goodsAppointmentId, String reson) async {
BaseModel baseModel = await NetUtil().get(API.market.confirmReceive,
params: {"goodsAppointmentId": goodsAppointmentId}, showMessage: true);
params: {"goodsAppointmentId": goodsAppointmentId, "backReason": reson},
showMessage: true);
}
///
static Future cancelOrder(int goodsAppointmentId) async {
BaseModel baseModel = await NetUtil().get(API.market.confirmReceive,
params: {"goodsAppointmentId": goodsAppointmentId}, showMessage: true);
}
///
static Future goodsEvalution(
int goodsAppointmentId, int rating, String evaluationReason) async {
BaseModel baseModel = await NetUtil().get(API.market.confirmReceive,
params: {
"goodsAppointmentId": goodsAppointmentId,
"score": rating,
"evaluationReason": evaluationReason
},
showMessage: true);
}
}

@ -17,8 +17,10 @@ class _MyOrderPageState extends State<MyOrderPage>
List<String> _tabs = [
'待发货',
'已发货',
'已到货',
'已收货',
'退换/投诉',
'已评价',
'退换货申请',
];
@override
@ -33,18 +35,43 @@ class _MyOrderPageState extends State<MyOrderPage>
super.dispose();
}
int _transIndes(int index) {
switch (index) {
case 0:
return 1;
case 1:
return 2;
case 2:
return 3;
case 3:
return 4;
case 4:
return 6;
case 5:
return 8;
default:
return 0;
}
}
@override
Widget build(BuildContext context) {
return BeeScaffold(
title: '我的订单',
appBarBottom: PreferredSize(
preferredSize: Size.fromHeight(88.w),
child: BeeTabBar(controller: _tabController, tabs: _tabs),
child: BeeTabBar(
scrollable: true, controller: _tabController, tabs: _tabs),
),
body: TabBarView(
controller: _tabController,
children: List.generate(
_tabs.length, (index) => MyOrderView(index: index))),
_tabs.length,
(index) => MyOrderView(
index: _transIndes(index),
),
),
),
);
}
}

@ -0,0 +1,197 @@
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/widget/bee_divider.dart';
import 'package:aku_community/widget/bee_scaffold.dart';
import 'package:aku_community/widget/buttons/aku_single_check_button.dart';
import 'package:aku_community/widget/buttons/bottom_button.dart';
import 'package:aku_community/widget/others/bee_text_field.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';
class MyOrderRefundPage extends StatefulWidget {
final MyOrderListModel model;
MyOrderRefundPage({Key? key, required this.model})
: super(key: key);
@override
_MyOrderRefundPageState createState() => _MyOrderRefundPageState();
}
class _MyOrderRefundPageState extends State<MyOrderRefundPage> {
int _type = 1; //退1退2
late TextEditingController _editingController;
@override
void initState() {
super.initState();
_editingController = TextEditingController();
}
@override
void dispose() {
_editingController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return BeeScaffold(
title: '商品退换',
body: ListView(
padding: EdgeInsets.all(32.w),
children: [
_goodsInfoWidget(),
24.w.heightBox,
_resonWidget(),
],
),
bottomNavi: BottomButton(
onPressed: () async {
await MyOrderFunc.refundOrder(widget.model.id, _editingController.text);
},
child: '确认提交'.text.size(32.sp).color(ktextPrimary).bold.make()),
);
}
Widget _goodsInfoWidget() {
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))),
),
SizedBox(
height: 160.w,
child: 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(),
],
),
Spacer(),
Row(
children: [
('${widget.model.levelOneCategory}|${widget.model.levelTwoCategory}')
.text
.size(24.sp)
.color(ktextSubColor)
.make()
],
),
// 12.w.heightBox,
// Row(
// children: [
// ('${widget.model.levelTwoCategory}')
// .text
// .size(24.sp)
// .color(ktextSubColor)
// .make()
// ],
// ),
],
),
).expand()
],
),
],
),
);
}
Widget _resonWidget() {
return Container(
padding: EdgeInsets.symmetric(vertical: 32.w, horizontal: 24.w),
width: double.infinity,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(8.w),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
'退换原因'.text.size(32.sp).bold.color(ktextPrimary).make(),
32.w.heightBox,
Row(
children: [
AkuSingleCheckButton(
text: '正常',
value: 1,
gropValue: _type,
onPressed: () {
_type = 1;
setState(() {});
},
),
80.w.widthBox,
AkuSingleCheckButton(
text: '异常',
value: 2,
gropValue: _type,
onPressed: () {
_type = 2;
setState(() {});
},
),
],
),
32.w.heightBox,
BeeTextField(controller: _editingController, hintText: '请详细描述问题及原因')
],
),
);
}
}

@ -35,7 +35,7 @@ class _MyOrderViewState extends State<MyOrderView> {
path: API.market.myOrderList,
controller: _refreshController,
extraParams: {
"orderStart":widget.index+1
"orderStart":widget.index
},
convert: (models) {
return models.tableList!

@ -0,0 +1,48 @@
// Flutter imports:
import 'package:flutter/material.dart';
// Package imports:
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:velocity_x/velocity_x.dart';
class AkuSingleCheckButton<T> extends StatefulWidget {
final String text;
final T value;
final T gropValue;
final VoidCallback onPressed;
AkuSingleCheckButton(
{Key? key,
required this.text,
required this.value,
required this.gropValue,
required this.onPressed})
: super(key: key);
@override
_AkuSingleCheckButtonState createState() => _AkuSingleCheckButtonState();
}
class _AkuSingleCheckButtonState extends State<AkuSingleCheckButton> {
bool get isSelect => widget.value == widget.gropValue;
@override
Widget build(BuildContext context) {
return Container(
alignment: Alignment.center,
decoration: BoxDecoration(
color: isSelect ? Color(0xFFFFF8E0) : Colors.white,
border: Border.all(
color: isSelect ? Color(0xFFFFC40C) : Color(0xFF999999),
width: 3.w),
borderRadius: BorderRadius.circular(4.w)),
width: 180.w,
height: 72.w,
child: widget.text.text
.color(isSelect ? Color(0xFF333333) : Color(0xFF999999))
.bold
.size(32.sp)
.make(),
).onInkTap(() {
widget.onPressed();
});
}
}

@ -0,0 +1,59 @@
import 'package:aku_community/base/base_style.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
class BeeTextField extends StatefulWidget {
final TextEditingController controller;
final VoidCallback? onChange;
final String hintText;
final int? minLines;
final int? maxLines;
BeeTextField(
{Key? key,
required this.controller,
this.onChange,
required this.hintText,
this.minLines,
this.maxLines})
: super(key: key);
@override
_BeeTextFieldState createState() => _BeeTextFieldState();
}
class _BeeTextFieldState extends State<BeeTextField> {
@override
Widget build(BuildContext context) {
return Container(
width: double.infinity,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8.w),
border: Border.all(
width: 2.w,
color: Color(0xFFE8E8E8),
),
),
child: TextField(
minLines: widget.minLines ?? 5,
maxLines: widget.maxLines ?? 10,
autofocus: false,
onChanged: (value) {
if (widget.onChange != null) {
widget.onChange!();
}
},
decoration: InputDecoration(
hintText: widget.hintText,
hintStyle: TextStyle(
fontSize: 28.sp,
color: ktextSubColor,
),
contentPadding:
EdgeInsets.symmetric(vertical: 16.w, horizontal: 24.w),
border: InputBorder.none,
isDense: true,
),
),
);
}
}
Loading…
Cancel
Save