You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
485 lines
17 KiB
485 lines
17 KiB
import 'package:dio/dio.dart'; |
|
import 'package:flutter/cupertino.dart'; |
|
import 'package:flutter/material.dart'; |
|
import 'package:huixiang/generated/l10n.dart'; |
|
import 'package:huixiang/retrofit/data/activity_order_list.dart'; |
|
import 'package:huixiang/retrofit/data/base_data.dart'; |
|
import 'package:huixiang/retrofit/data/exchange_order.dart'; |
|
import 'package:huixiang/retrofit/data/page.dart'; |
|
import 'package:huixiang/retrofit/min_api.dart'; |
|
import 'package:huixiang/retrofit/retrofit_api.dart'; |
|
import 'package:huixiang/utils/font_weight.dart'; |
|
import 'package:huixiang/view_widget/classic_header.dart'; |
|
import 'package:huixiang/view_widget/custom_image.dart'; |
|
import 'package:huixiang/view_widget/icon_text.dart'; |
|
import 'package:huixiang/view_widget/my_appbar.dart'; |
|
import 'package:huixiang/view_widget/my_footer.dart'; |
|
import 'package:huixiang/view_widget/my_tab.dart'; |
|
import 'package:huixiang/view_widget/no_data_view.dart'; |
|
import 'package:huixiang/view_widget/round_button.dart'; |
|
import 'package:pull_to_refresh/pull_to_refresh.dart'; |
|
import 'package:flutter_screenutil/flutter_screenutil.dart'; |
|
import 'package:shared_preferences/shared_preferences.dart'; |
|
import 'package:shared_preferences/shared_preferences.dart'; |
|
|
|
class BargainGroupOrder extends StatefulWidget { |
|
final Map<String, dynamic> arguments; |
|
|
|
BargainGroupOrder({this.arguments}); |
|
@override |
|
State<StatefulWidget> createState() { |
|
return _BargainGroupOrder(); |
|
} |
|
} |
|
|
|
class _BargainGroupOrder extends State<BargainGroupOrder> |
|
with SingleTickerProviderStateMixin { |
|
List<Widget> tabs; |
|
List<Widget> _pages; |
|
TabController tabcontroller; |
|
int type = 0; |
|
|
|
@override |
|
void initState() { |
|
super.initState(); |
|
type = widget.arguments["type"]; |
|
} |
|
|
|
@override |
|
void didChangeDependencies() { |
|
super.didChangeDependencies(); |
|
if (tabcontroller == null) |
|
tabcontroller = TabController(length: 4, vsync: this); |
|
tabs = [ |
|
MyTab( |
|
text: S.of(context).quanbu, |
|
), |
|
MyTab( |
|
text: "进行中", |
|
), |
|
MyTab( |
|
text: "成功", |
|
), |
|
MyTab( |
|
text: "失败", |
|
) |
|
]; |
|
_pages = [ |
|
ExchangeHistoryList(0,type), |
|
ExchangeHistoryList(1,type), |
|
ExchangeHistoryList(2,type), |
|
ExchangeHistoryList(3,type) |
|
]; |
|
} |
|
|
|
@override |
|
Widget build(BuildContext context) { |
|
return DefaultTabController( |
|
length: 4, |
|
child: Scaffold( |
|
appBar: MyAppBar( |
|
title:type == 1 ? S.of(context).wodepintuan :S.of(context).wodekanjia, |
|
titleColor: Colors.black, |
|
titleSize: 18.sp, |
|
background: Color(0xFFFFFFFF), |
|
leadingColor: Colors.black, |
|
toolbarHeight: kToolbarHeight + MediaQuery.of(context).padding.top, |
|
bottom: PreferredSize( |
|
preferredSize: Size(double.infinity, 38.h), |
|
child: TabBar( |
|
controller: tabcontroller, |
|
indicatorWeight: 2, |
|
indicatorColor: Color(0xFF39B54A), |
|
indicatorSize: TabBarIndicatorSize.label, |
|
indicatorPadding: EdgeInsets.only(top: 3), |
|
unselectedLabelStyle: TextStyle( |
|
fontSize: 16.sp, |
|
fontWeight: FontWeight.normal, |
|
), |
|
labelStyle: TextStyle( |
|
color: Colors.black, |
|
fontSize: 16.sp, |
|
fontWeight: MyFontWeight.semi_bold), |
|
labelColor: Colors.black, |
|
tabs: tabs, |
|
), |
|
), |
|
), |
|
body: TabBarView( |
|
children: _pages, |
|
controller: tabcontroller, |
|
), |
|
), |
|
); |
|
} |
|
} |
|
|
|
class ExchangeHistoryList extends StatefulWidget { |
|
final int orderStatus; |
|
final int type; |
|
|
|
ExchangeHistoryList(this.orderStatus,this.type); |
|
|
|
@override |
|
State<StatefulWidget> createState() { |
|
return _ExchangeHistoryList(); |
|
} |
|
} |
|
|
|
class _ExchangeHistoryList extends State<ExchangeHistoryList> { |
|
MinApiService minService; |
|
List<ActivityOrderList> activityOrderList = []; |
|
RefreshController _refreshController = |
|
RefreshController(initialRefresh: false); |
|
int type = 0; |
|
|
|
@override |
|
void initState() { |
|
super.initState(); |
|
SharedPreferences.getInstance().then((value) { |
|
String minToken = value.getString("minToken"); |
|
String tenant = value.getString("tenant"); |
|
String storeId = value.getString("storeId"); |
|
minService = MinApiService( |
|
Dio(), |
|
context: context, |
|
token: minToken, |
|
tenant: tenant, |
|
storeId: storeId, |
|
); |
|
queryShowMyActList(); |
|
}); |
|
} |
|
|
|
///查看我的拼团、砍价、列表 |
|
queryShowMyActList() async { |
|
BaseData<List<ActivityOrderList>> baseData = |
|
await minService.showMyActList({ |
|
"state":0, |
|
"type" :widget.type, |
|
}).catchError((error) { |
|
_refreshController.loadFailed(); |
|
_refreshController.refreshFailed(); |
|
}); |
|
if (baseData != null && baseData.isSuccess) { |
|
_refreshController.refreshCompleted(); |
|
setState(() { |
|
activityOrderList.clear(); |
|
if(baseData.data.length > 0) |
|
activityOrderList.addAll(baseData.data); |
|
}); |
|
} else { |
|
_refreshController.refreshFailed(); |
|
_refreshController.loadFailed(); |
|
} |
|
} |
|
|
|
_refresh() { |
|
queryShowMyActList(); |
|
} |
|
|
|
@override |
|
Widget build(BuildContext context) { |
|
return Container( |
|
child: SmartRefresher( |
|
enablePullDown: true, |
|
enablePullUp: true, |
|
header: MyHeader(), |
|
footer: CustomFooter( |
|
builder: (BuildContext context, LoadStatus mode) { |
|
return MyFooter(mode); |
|
}, |
|
), |
|
controller: _refreshController, |
|
physics: BouncingScrollPhysics(), |
|
onLoading: _refresh, |
|
onRefresh: _refresh, |
|
child: (activityOrderList != null && activityOrderList.length > 0) |
|
? |
|
ListView.builder( |
|
itemCount: activityOrderList?.length ?? 0, |
|
shrinkWrap: true, |
|
physics: NeverScrollableScrollPhysics(), |
|
itemBuilder: (context, position) { |
|
return bargainOrder(activityOrderList[position]); |
|
}, |
|
):NoDataView( |
|
src: "assets/image/icon_empty.png", |
|
isShowBtn: false, |
|
text: "还没有订单,快去下一单吧~", |
|
fontSize: 16.sp, |
|
margin: EdgeInsets.only(top: 120.h), |
|
), |
|
), |
|
); |
|
} |
|
|
|
String orderStatus(state) { |
|
String orderStatus = ""; |
|
switch (state) { |
|
case 1: |
|
orderStatus = S.of(context).weiwancheng; |
|
break; |
|
case 2: |
|
orderStatus = S.of(context).yiwancheng; |
|
break; |
|
case 9: |
|
orderStatus = S.of(context).yiquxiao; |
|
break; |
|
} |
|
return orderStatus; |
|
} |
|
|
|
Widget bargainOrder(ActivityOrderList activityOrderList) { |
|
return Container( |
|
margin: EdgeInsets.fromLTRB(16.w, 8.h, 16.w, 8.h), |
|
decoration: BoxDecoration( |
|
color: Colors.white, |
|
borderRadius: BorderRadius.circular(4), |
|
boxShadow: [ |
|
BoxShadow( |
|
color: Colors.black.withAlpha(25), |
|
offset: Offset(0, 1), |
|
blurRadius: 12, |
|
spreadRadius: 0, |
|
), |
|
], |
|
), |
|
child: Column( |
|
mainAxisAlignment: MainAxisAlignment.spaceAround, |
|
crossAxisAlignment: CrossAxisAlignment.start, |
|
children: [ |
|
Row( |
|
mainAxisAlignment: MainAxisAlignment.spaceBetween, |
|
crossAxisAlignment: CrossAxisAlignment.start, |
|
children: [ |
|
// Container( |
|
// width: 19.w, |
|
// height:21.h, |
|
// margin: EdgeInsets.only(left: 12.w, top: 12.h), |
|
// alignment: Alignment.center, |
|
// decoration: BoxDecoration( |
|
// color: Color(0xff32A060), |
|
// borderRadius: BorderRadius.circular(2), |
|
// ), |
|
// child: Text( |
|
// // (orderInfo != null && orderInfo.isTakeOut == 0) ? "自" : "外", |
|
// "自", |
|
// style: TextStyle( |
|
// fontSize: 12.sp, |
|
// fontWeight: FontWeight.bold, |
|
// color: Colors.white, |
|
// ), |
|
// ), |
|
// ), |
|
Expanded( |
|
child: Container( |
|
width: double.infinity, |
|
margin: EdgeInsets.only(left: 6.w, top: 12.h), |
|
alignment: Alignment.centerLeft, |
|
child: Text( |
|
activityOrderList?.storeName ?? "", |
|
style: TextStyle( |
|
fontWeight: FontWeight.bold, |
|
fontSize: 14.sp, |
|
color: Color(0xFF353535), |
|
), |
|
), |
|
), |
|
flex: 1, |
|
), |
|
Padding( |
|
padding: EdgeInsets.only(top: 12.h, right: 12.w), |
|
child:Text( |
|
// (orderInfo != null && |
|
// orderInfo.storeVO != null && |
|
// orderInfo.storeVO.posType != null) |
|
// ? StatusUtils.statusText( |
|
// context, |
|
// orderInfo.refundStatus, |
|
// orderInfo.orderStatus, |
|
// orderInfo.payStatus, |
|
// orderInfo.sendStatus, |
|
// orderInfo.isTakeOut) |
|
// : "", |
|
(type == 1)?(activityOrderList.howManyMore != 0 ? "还差${activityOrderList?.howManyMore ?? 0}人拼团成功" : "拼团成功") |
|
:(activityOrderList.howManyMoney != 0 ? "还差¥${activityOrderList?.howManyMoney ?? 0}砍价成功" : "成功"), |
|
style: TextStyle( |
|
fontSize: 14.sp, |
|
fontWeight: FontWeight.bold, |
|
color: |
|
// (orderInfo == null) |
|
// ? Color(0xFF32A060) |
|
// : (orderInfo.refundStatus == 1 || |
|
// orderInfo.orderStatus >= 5) |
|
// ? Colors.grey |
|
// : (orderInfo.orderStatus == 4) |
|
// ? Color(0xFF32A060) |
|
// : |
|
Color(0xffFE951E), |
|
), |
|
), |
|
), |
|
], |
|
), |
|
Container( |
|
margin: EdgeInsets.only(left: 37.w), |
|
child: Column( |
|
mainAxisAlignment: MainAxisAlignment.start, |
|
crossAxisAlignment: CrossAxisAlignment.start, |
|
children: [ |
|
Text( |
|
S.of(context).xiadanshijian_(activityOrderList?.joinTime ?? ""), |
|
style: TextStyle( |
|
fontSize: 10.sp, |
|
color: Color(0xFF727272), |
|
), |
|
), |
|
SizedBox( |
|
height: 8.h, |
|
), |
|
Container( |
|
height: 81.h, |
|
margin: EdgeInsets.only(right: 12), |
|
child: Row( |
|
mainAxisAlignment: MainAxisAlignment.spaceBetween, |
|
crossAxisAlignment: CrossAxisAlignment.start, |
|
children: [ |
|
MImage( |
|
activityOrderList?.productImg ?? "", |
|
width: 81.w, |
|
height: 81.h, |
|
fit: BoxFit.cover, |
|
errorSrc: "assets/image/default_1.png", |
|
fadeSrc: "assets/image/default_1.png", |
|
), |
|
SizedBox( |
|
width: 10, |
|
), |
|
Expanded( |
|
child: Column( |
|
mainAxisAlignment: MainAxisAlignment.spaceAround, |
|
crossAxisAlignment: CrossAxisAlignment.start, |
|
children: [ |
|
Text( |
|
activityOrderList?.storeName ?? "", |
|
maxLines: 2, |
|
overflow: TextOverflow.ellipsis, |
|
style: TextStyle( |
|
fontSize: 14.sp, |
|
fontWeight: MyFontWeight.medium, |
|
color: Color(0xFF353535), |
|
), |
|
), |
|
Text( |
|
activityOrderList?.productSkuName ?? "", |
|
style: TextStyle( |
|
fontSize: 10.sp, |
|
fontWeight: MyFontWeight.medium, |
|
color: Color(0xFF727272), |
|
), |
|
), |
|
Row( |
|
mainAxisAlignment: MainAxisAlignment.spaceBetween, |
|
crossAxisAlignment: CrossAxisAlignment.start, |
|
children: [ |
|
Text( |
|
"x1", |
|
style: TextStyle( |
|
fontSize: 10.sp, |
|
fontWeight: MyFontWeight.semi_bold, |
|
color: Color(0xFF727272), |
|
), |
|
), |
|
Text.rich( |
|
TextSpan( |
|
children: [ |
|
TextSpan( |
|
// text: "已砍至:", |
|
text: S.of(context).heji, |
|
style: TextStyle( |
|
fontSize: 12.sp, |
|
fontWeight: MyFontWeight.regular, |
|
color: Color(0xFF868686), |
|
), |
|
), |
|
TextSpan( |
|
text:activityOrderList?.orderSum ?? "0", |
|
style: TextStyle( |
|
fontSize: 14.sp, |
|
fontWeight: MyFontWeight.semi_bold, |
|
color: Color(0xFF32A060), |
|
), |
|
), |
|
TextSpan( |
|
text: "元", |
|
style: TextStyle( |
|
fontSize: 12.sp, |
|
fontWeight: MyFontWeight.regular, |
|
color: Color(0xFF868686), |
|
), |
|
), |
|
], |
|
), |
|
), |
|
], |
|
), |
|
], |
|
)), |
|
], |
|
), |
|
), |
|
], |
|
), |
|
), |
|
SizedBox( |
|
height: 12.h, |
|
), |
|
Container( |
|
margin: EdgeInsets.only(right: 12.w, bottom: 16.h), |
|
child: Directionality( |
|
textDirection: TextDirection.rtl, |
|
child: Row( |
|
children: [ |
|
GestureDetector( |
|
onTap: () { |
|
Navigator.of(context) |
|
.pushNamed('/router/group_details', arguments: { |
|
"actRecordId": activityOrderList.actRecordId, |
|
"actProduct":activityOrderList, |
|
"limitNumber":activityOrderList.successNumber, |
|
}); |
|
}, |
|
child: RoundButton( |
|
height: 25.h, |
|
text: "查看详情", |
|
textColor: Colors.white, |
|
fontSize: 12.sp, |
|
backgroup: Color(0xFF32A060), |
|
radius: 2, |
|
padding: EdgeInsets.fromLTRB(17.w,0, 17.w,0), |
|
), |
|
), |
|
// GestureDetector( |
|
// onTap: () { |
|
// |
|
// }, |
|
// child:RoundButton( |
|
// height: 25.h, |
|
// padding: EdgeInsets.fromLTRB(8, 4, 8, 4), |
|
// text: S.of(context).chakanxiangqing, |
|
// textColor: Colors.white, |
|
// fontSize: 12, |
|
// backgroup: Color(0xFF32A060), |
|
// radius: 2, |
|
// ), |
|
// ), |
|
], |
|
), |
|
), |
|
), |
|
], |
|
), |
|
); |
|
} |
|
}
|
|
|