From 0f2c878bdf5ad4df8eeff04814fe5b66e1b827a4 Mon Sep 17 00:00:00 2001 From: zhangmeng <494089941@qq.com> Date: Tue, 25 May 2021 11:26:53 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=95=86=E5=93=81=E8=AF=A6?= =?UTF-8?q?=E6=83=85=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../market/order/my_order_list_model.dart | 20 +- lib/ui/market/order/my_order_card.dart | 8 +- lib/ui/market/order/my_order_detail_page.dart | 323 +++++++++++++++++- .../order/my_order_evaluation_page.dart | 13 +- lib/ui/market/order/my_order_func.dart | 12 + lib/ui/market/order/my_order_refund_page.dart | 13 +- 6 files changed, 369 insertions(+), 20 deletions(-) diff --git a/lib/models/market/order/my_order_list_model.dart b/lib/models/market/order/my_order_list_model.dart index 139dca5f..b0fdc174 100644 --- a/lib/models/market/order/my_order_list_model.dart +++ b/lib/models/market/order/my_order_list_model.dart @@ -53,12 +53,18 @@ class MyOrderListModel extends Equatable { case 2: return '已发货'; case 3: - return '已收货'; + return '已到货'; case 4: - return '申请退换货'; + return '已收货'; case 5: - return '申请通过'; + return '未知'; case 6: + return '已评价'; + case 8: + return '申请退换'; + case 9: + return '申请通过'; + case 10: return '申请驳回'; default: return '未知'; @@ -74,11 +80,15 @@ class MyOrderListModel extends Equatable { case 3: return Color(0xFF999999); case 4: - return Color(0xFFFB4702); - case 5: return Color(0xFF999999); case 6: return Color(0xFF999999); + case 8: + return Color(0xFFFB4702); + case 9: + return Color(0xFF3F8FFE); + case 10: + return Color(0xFFE60E0E); default: return Colors.black; } diff --git a/lib/ui/market/order/my_order_card.dart b/lib/ui/market/order/my_order_card.dart index cd99d407..09ef441f 100644 --- a/lib/ui/market/order/my_order_card.dart +++ b/lib/ui/market/order/my_order_card.dart @@ -2,6 +2,8 @@ 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_detail_page.dart'; +import 'package:aku_community/ui/market/order/my_order_evaluation_page.dart'; import 'package:aku_community/ui/market/order/my_order_func.dart'; import 'package:aku_community/ui/market/order/my_order_refund_page.dart'; import 'package:aku_community/widget/buttons/card_bottom_button.dart'; @@ -27,7 +29,9 @@ class _MyOrderCardState extends State { @override Widget build(BuildContext context) { return GestureDetector( - onTap: () {}, + onTap: () { + Get.to(() => MyOrderDetailPage(model: widget.model,)); + }, child: Container( width: double.infinity, decoration: BoxDecoration( @@ -69,6 +73,7 @@ class _MyOrderCardState extends State { image: API.image(ImgModel.first(widget.model.goodsImgList))), ), + 24.w.widthBox, SizedBox( height: 160.w, child: Column( @@ -172,6 +177,7 @@ class _MyOrderCardState extends State { CardBottomButton.white( text: '评价商品', onPressed: () async { + await Get.to(() => MyOrderEvaluationPage(model: widget.model)); widget.callRefresh(); }), CardBottomButton.white( diff --git a/lib/ui/market/order/my_order_detail_page.dart b/lib/ui/market/order/my_order_detail_page.dart index 1b84ce3f..2fee07ec 100644 --- a/lib/ui/market/order/my_order_detail_page.dart +++ b/lib/ui/market/order/my_order_detail_page.dart @@ -1,19 +1,338 @@ +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/models/market/order/my_order_list_model.dart'; +import 'package:aku_community/ui/market/goods/goods_card.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:flutter/cupertino.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'; +import 'package:aku_community/const/resource.dart'; +import 'package:waterfall_flow/waterfall_flow.dart'; +import 'package:aku_community/extensions/widget_list_ext.dart'; class MyOrderDetailPage extends StatefulWidget { - MyOrderDetailPage({Key? key}) : super(key: key); + final MyOrderListModel model; + MyOrderDetailPage({Key? key, required this.model}) : super(key: key); @override _MyOrderDetailPageState createState() => _MyOrderDetailPageState(); } class _MyOrderDetailPageState extends State { + late EasyRefreshController _refreshController; + late List _topGoods; + bool _onload = true; + @override + void initState() { + super.initState(); + _refreshController = EasyRefreshController(); + } + + @override + void dispose() { + _refreshController.dispose(); + super.dispose(); + } + @override Widget build(BuildContext context) { return BeeScaffold( title: '订单详情', - body: ListView(), + body: EasyRefresh( + firstRefresh: true, + header: MaterialHeader(), + onRefresh: () async { + _topGoods = await MyOrderFunc.getHotTops(); + _onload = false; + setState(() { + + }); + }, + child: _onload + ? Container() + : ListView( + padding: EdgeInsets.symmetric(vertical: 32.w, horizontal: 32.w), + children: [ + _statusInfo(), + _goodsInfoWidget(), + _orderInfo(), + _extraWidget(_topGoods), + ].sepWidget( + separate: 24.w.heightBox, + ), + ), + ), + ); + } + + Widget _statusInfo() { + return Container( + width: double.infinity, + decoration: BoxDecoration( + color: Colors.white, borderRadius: BorderRadius.circular(8.w)), + padding: EdgeInsets.symmetric(vertical: 24.w, horizontal: 32.w), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + children: [ + Container( + width: 32.w, + height: 32.w, + decoration: BoxDecoration( + color: Color(0xFFFB4702).withOpacity(0.2), + borderRadius: BorderRadius.circular(16.w), + ), + child: Icon( + _icondata, + size: 32.w, + color: Color(0xFFFB4702), + ), + ), + 20.w.widthBox, + widget.model.statusString.text + .size(32.sp) + .bold + .color(ktextPrimary) + .make(), + ], + ), + 20.w.heightBox, + '2020-05-14 14:22:11' + .text + .size(28.sp) + .bold + .color(ktextPrimary.withOpacity(0.8)) + .make() + ], + ), + ); + } + + Widget _extraInfo(String reason, String text) { + return Container( + width: double.infinity, + decoration: BoxDecoration( + color: Colors.white, borderRadius: BorderRadius.circular(8.w)), + padding: EdgeInsets.symmetric(vertical: 24.w, horizontal: 32.w), + child: Column( + children: [ + Row( + children: [ + reason.text.size(32.sp).bold.color(ktextPrimary).make(), + ], + ), + 20.w.heightBox, + text.text.size(28.sp).color(ktextSubColor).make(), + 20.w.heightBox, + '2020-05-14 14:22:11' + .text + .size(28.sp) + .bold + .color(ktextPrimary.withOpacity(0.8)) + .make() + ], + ), + ); + } + + IconData get _icondata { + switch (widget.model.status) { + case 1: + case 2: + return CupertinoIcons.stopwatch; + case 3: + case 4: + case 6: + return CupertinoIcons.checkmark_alt; + case 8: + return CupertinoIcons.stopwatch; + case 9: + return CupertinoIcons.checkmark_alt; + case 10: + return CupertinoIcons.multiply; + default: + return CupertinoIcons.multiply_circle; + } + } + + Widget _orderInfo() { + return Container( + width: double.infinity, + padding: EdgeInsets.symmetric(vertical: 24.w, horizontal: 32.w), + decoration: BoxDecoration( + color: Colors.white, borderRadius: BorderRadius.circular(8.w)), + child: Column( + children: [ + Row( + children: [ + '订单信息'.text.size(32.sp).bold.color(ktextPrimary).make(), + ], + ), + 24.w.heightBox, + ...[ + _rowTile('订单编号', widget.model.code), + _rowTile('预约时间', ''), + _rowTile('交易时间', ''), + ].sepWidget( + separate: 20.w.heightBox, + ) + ], + ), + ); + } + + Widget _rowTile( + String title, + String content, + ) { + return Row( + children: [ + // (160 + 24).w.widthBox, + title.text.size(24.sp).color(ktextSubColor).make(), + Spacer(), + content.text.size(24.sp).color(ktextPrimary).make(), + ], + ); + } + + Widget _goodsInfoWidget() { + return Container( + width: double.infinity, + decoration: BoxDecoration( + color: Colors.white, borderRadius: BorderRadius.circular(8.w)), + 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))), + ), + 24.w.widthBox, + 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 _extraWidget(List models) { + return Container( + decoration: BoxDecoration(color: Colors.white), + width: double.infinity, + padding: EdgeInsets.symmetric(vertical: 32.w, horizontal: 32.w), + child: Column( + children: [ + Row( + children: [ + '其他(${models.length})' + .text + .size(24.sp) + .color(ktextPrimary) + .bold + .make(), + ], + ), + 24.w.heightBox, + SizedBox( + height: 1000.w, + child: WaterfallFlow.count( + crossAxisCount: 2, + mainAxisSpacing: 20.w, + crossAxisSpacing: 24.w, + physics: NeverScrollableScrollPhysics(), + children: List.generate( + models.length, + (index) => GoodsCard( + item: models[index], + border: true, + ), + ), + ), + ), + ], + ), ); } } diff --git a/lib/ui/market/order/my_order_evaluation_page.dart b/lib/ui/market/order/my_order_evaluation_page.dart index 51a5e1f2..3e4d25a1 100644 --- a/lib/ui/market/order/my_order_evaluation_page.dart +++ b/lib/ui/market/order/my_order_evaluation_page.dart @@ -69,17 +69,17 @@ class _MyOrderEvaluationPageState extends State { children: [ Row( children: [ - widget.model.goodsName.text + '商品信息'.text .size(32.sp) .bold .color(ktextPrimary) .make(), Spacer(), - widget.model.statusString.text - .size(30.sp) - .bold - .color(widget.model.statusColor) - .make(), + // widget.model.statusString.text + // .size(30.sp) + // .bold + // .color(widget.model.statusColor) + // .make(), ], ), 16.w.heightBox, @@ -99,6 +99,7 @@ class _MyOrderEvaluationPageState extends State { image: API.image(ImgModel.first(widget.model.goodsImgList))), ), + 24.w.widthBox, SizedBox( height: 160.w, child: Column( diff --git a/lib/ui/market/order/my_order_func.dart b/lib/ui/market/order/my_order_func.dart index 360052a8..4a318512 100644 --- a/lib/ui/market/order/my_order_func.dart +++ b/lib/ui/market/order/my_order_func.dart @@ -1,4 +1,5 @@ import 'package:aku_community/constants/api.dart'; +import 'package:aku_community/models/market/goods_item.dart'; import 'package:aku_community/utils/network/base_model.dart'; import 'package:aku_community/utils/network/net_util.dart'; @@ -33,4 +34,15 @@ class MyOrderFunc { }, showMessage: true); } + + /// 获取热度最高的商品 + static Future> getHotTops() async { + BaseModel baseModel = await NetUtil().get(API.market.hotTop); + if (baseModel.status == true && baseModel.data != null) { + return (baseModel.data as List) + .map((e) => GoodsItem.fromJson(e)) + .toList(); + } + return []; + } } diff --git a/lib/ui/market/order/my_order_refund_page.dart b/lib/ui/market/order/my_order_refund_page.dart index 899f4aae..3ad844a8 100644 --- a/lib/ui/market/order/my_order_refund_page.dart +++ b/lib/ui/market/order/my_order_refund_page.dart @@ -69,17 +69,17 @@ class _MyOrderRefundPageState extends State { children: [ Row( children: [ - widget.model.goodsName.text + '商品信息'.text .size(32.sp) .bold .color(ktextPrimary) .make(), Spacer(), - widget.model.statusString.text - .size(30.sp) - .bold - .color(widget.model.statusColor) - .make(), + // widget.model.statusString.text + // .size(30.sp) + // .bold + // .color(widget.model.statusColor) + // .make(), ], ), 16.w.heightBox, @@ -99,6 +99,7 @@ class _MyOrderRefundPageState extends State { image: API.image(ImgModel.first(widget.model.goodsImgList))), ), + 24.w.widthBox, SizedBox( height: 160.w, child: Column(