parent
55046344f1
commit
d52ef2e578
@ -1,169 +0,0 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:pull_to_refresh/pull_to_refresh.dart';
|
||||
import 'package:recook/base/base_store_state.dart';
|
||||
import 'package:recook/constants/api.dart';
|
||||
import 'package:recook/constants/constants.dart';
|
||||
import 'package:recook/constants/header.dart';
|
||||
import 'package:recook/manager/http_manager.dart';
|
||||
import 'package:recook/manager/user_manager.dart';
|
||||
import 'package:recook/models/shop_summary_model.dart';
|
||||
import 'package:recook/pages/shop/order/shop_order_center_page.dart';
|
||||
import 'package:recook/pages/shop/shop_page_order_view.dart';
|
||||
import 'package:recook/pages/shop/widget/shop_page_upgrade_alert.dart';
|
||||
import 'package:recook/pages/user/order/order_after_sale_page.dart';
|
||||
import 'package:recook/utils/user_level_tool.dart';
|
||||
import 'package:recook/widgets/refresh_widget.dart';
|
||||
|
||||
class ShopPage extends StatefulWidget {
|
||||
@override
|
||||
State<StatefulWidget> createState() {
|
||||
return _ShopPageState();
|
||||
}
|
||||
}
|
||||
|
||||
class _ShopPageState extends BaseStoreState<ShopPage> {
|
||||
GSRefreshController _gsRefreshController;
|
||||
ShopSummaryModel _shopSummaryModel;
|
||||
|
||||
String msgCode = "msgCode";
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_gsRefreshController = GSRefreshController(initialRefresh: true);
|
||||
UserManager.instance.refreshShopPage.addListener(() {
|
||||
_getShopSummary();
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
bool get wantKeepAlive => true;
|
||||
|
||||
@override
|
||||
Widget buildContext(BuildContext context, {store}) {
|
||||
Scaffold scaffold = Scaffold(
|
||||
// backgroundColor: Color.fromARGB(255, 243, 245, 247),
|
||||
backgroundColor: Color(0xff3a3943),
|
||||
body: RefreshWidget(
|
||||
header: ClassicHeader(
|
||||
outerBuilder: (child) {
|
||||
return Container(
|
||||
child: child,
|
||||
);
|
||||
},
|
||||
height: ScreenUtil.statusBarHeight + kToolbarHeight,
|
||||
textStyle: TextStyle(
|
||||
fontSize: ScreenAdapterUtils.setSp(14), color: Colors.white),
|
||||
refreshingText: "正在努力获取数据...",
|
||||
completeText: "刷新完成",
|
||||
failedText: "网络出了一点问题呢",
|
||||
idleText: "下拉刷新",
|
||||
releaseText: "松开刷新",
|
||||
),
|
||||
isInNest: true,
|
||||
// headerTriggerDistance: ScreenUtil.statusBarHeight+kToolbarHeight,
|
||||
color: Colors.black,
|
||||
onRefresh: () {
|
||||
_getShopSummary();
|
||||
},
|
||||
controller: _gsRefreshController,
|
||||
body: _shopSummaryModel == null
|
||||
? Container(
|
||||
color: AppColor.frenchColor,
|
||||
child: noDataView(''),
|
||||
)
|
||||
: ListView(
|
||||
physics: BouncingScrollPhysics(),
|
||||
children: _bodyListWidget(),
|
||||
)),
|
||||
);
|
||||
|
||||
return AnnotatedRegion<SystemUiOverlayStyle>(
|
||||
value: SystemUiOverlayStyle.light,
|
||||
child: scaffold,
|
||||
);
|
||||
}
|
||||
|
||||
_bodyListWidget() {
|
||||
List<Widget> listWidget = [];
|
||||
listWidget.add(Container(
|
||||
height: 10,
|
||||
color: AppColor.frenchColor,
|
||||
));
|
||||
|
||||
listWidget.add(Container(
|
||||
height: 10,
|
||||
color: AppColor.frenchColor,
|
||||
));
|
||||
//订单中心
|
||||
listWidget.add(ShopPageOrderView(
|
||||
clickListener: (index) {
|
||||
if (index == 4) {
|
||||
AppRouter.push(context, RouteName.ORDER_AFTER_SALE_GOODS_LIST,
|
||||
arguments: OrderAfterSalePage.setArguments(
|
||||
OrderAfterSaleType.shopPage, null, null));
|
||||
return;
|
||||
}
|
||||
push(RouteName.SHOP_ORDER_LIST_PAGE,
|
||||
arguments: ShopOrderCenterPage.setArguments(index));
|
||||
},
|
||||
shopSummaryModel: _shopSummaryModel,
|
||||
));
|
||||
|
||||
return listWidget;
|
||||
}
|
||||
|
||||
_getShopSummary() async {
|
||||
ResultData resultData = await HttpManager.post(ShopApi.shop_index, {
|
||||
"userId": UserManager.instance.user.info.id,
|
||||
});
|
||||
if (_gsRefreshController.isRefresh()) {
|
||||
_gsRefreshController.refreshCompleted();
|
||||
}
|
||||
if (!resultData.result) {
|
||||
if (mounted) {
|
||||
showError(resultData.msg);
|
||||
}
|
||||
return;
|
||||
}
|
||||
ShopSummaryModel model = ShopSummaryModel.fromJson(resultData.data);
|
||||
// String jsonString = jsonEncode(resultData.data);
|
||||
if (model.code != HttpStatus.SUCCESS) {
|
||||
if (mounted) {
|
||||
showError(model.msg);
|
||||
}
|
||||
return;
|
||||
}
|
||||
_shopSummaryModel = model;
|
||||
if (UserManager.instance.user.info.roleLevel !=
|
||||
_shopSummaryModel.data.roleLevel) {
|
||||
UserManager.instance.user.info.roleLevel =
|
||||
_shopSummaryModel.data.roleLevel;
|
||||
UserManager.instance.refreshUserRole.value =
|
||||
!UserManager.instance.refreshUserRole.value;
|
||||
UserManager.updateUserInfo(getStore());
|
||||
}
|
||||
if (mounted) setState(() {});
|
||||
if (model.data.upNotify.isNotify) {
|
||||
_showUpgradeAlert();
|
||||
}
|
||||
}
|
||||
|
||||
_showUpgradeAlert() {
|
||||
showDialog(
|
||||
context: context,
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
child: ShopPageUpgradeAlert(
|
||||
width: MediaQuery.of(context).size.width,
|
||||
userRoleLevel:
|
||||
UserLevelTool.roleLevelEnum(_shopSummaryModel.data.roleLevel),
|
||||
),
|
||||
));
|
||||
}
|
||||
}
|
@ -1,247 +0,0 @@
|
||||
import 'package:extended_text/extended_text.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:recook/constants/constants.dart';
|
||||
import 'package:recook/constants/styles.dart';
|
||||
import 'package:recook/models/shop_summary_model.dart';
|
||||
import 'package:recook/widgets/custom_image_button.dart';
|
||||
|
||||
class ShopPageOrderView extends StatefulWidget {
|
||||
final Function(int index) clickListener;
|
||||
final ShopSummaryModel shopSummaryModel;
|
||||
|
||||
const ShopPageOrderView({Key key, this.shopSummaryModel, this.clickListener})
|
||||
: super(key: key);
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() {
|
||||
return _ShopPageOrderViewState();
|
||||
}
|
||||
}
|
||||
|
||||
class _ShopPageOrderViewState extends State<ShopPageOrderView> {
|
||||
TextStyle selectStyle = TextStyle(
|
||||
fontWeight: FontWeight.w500,
|
||||
color: AppColor.themeColor,
|
||||
fontSize: ScreenAdapterUtils.setSp(13));
|
||||
TextStyle normalStyle = TextStyle(
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Colors.black.withOpacity(0.32),
|
||||
fontSize: ScreenAdapterUtils.setSp(12));
|
||||
TextStyle titleStyle = TextStyle(
|
||||
fontWeight: FontWeight.w300,
|
||||
color: Colors.black.withOpacity(0.9),
|
||||
fontSize: ScreenAdapterUtils.setSp(12));
|
||||
TextStyle greyTitleStyle = TextStyle(
|
||||
fontWeight: FontWeight.w300,
|
||||
color: Colors.black.withOpacity(0.32),
|
||||
fontSize: ScreenAdapterUtils.setSp(12));
|
||||
TextStyle numberStyle = TextStyle(
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Colors.black,
|
||||
fontSize: ScreenAdapterUtils.setSp(15));
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
color: AppColor.frenchColor,
|
||||
child: _orderWidget(),
|
||||
);
|
||||
}
|
||||
|
||||
_orderWidget() {
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
// borderRadius: BorderRadius.all(Radius.circular(5)),
|
||||
// border: Border.all(width: 0.5, color: Colors.black.withOpacity(0.1))
|
||||
),
|
||||
padding: EdgeInsets.symmetric(horizontal: 15),
|
||||
margin: EdgeInsets.only(bottom: 10),
|
||||
height: 130,
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
Container(
|
||||
height: 40,
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
Container(
|
||||
width: 10,
|
||||
),
|
||||
Container(
|
||||
child: ExtendedText.rich(TextSpan(children: [
|
||||
TextSpan(
|
||||
text: '订单中心 ',
|
||||
style: AppTextStyle.generate(16,
|
||||
fontWeight: FontWeight.w700),
|
||||
),
|
||||
TextSpan(
|
||||
text: '(导购)',
|
||||
style: AppTextStyle.generate(14,
|
||||
fontWeight: FontWeight.w400),
|
||||
),
|
||||
])),
|
||||
),
|
||||
Spacer(),
|
||||
GestureDetector(
|
||||
child: _rightArrowWidget('全部订单'),
|
||||
onTap: () {
|
||||
widget.clickListener(0);
|
||||
},
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
Container(
|
||||
height: 0.4,
|
||||
color: Colors.black12,
|
||||
),
|
||||
Container(
|
||||
padding: EdgeInsets.symmetric(horizontal: 10),
|
||||
height: 88,
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
child: CustomImageButton(
|
||||
padding: EdgeInsets.symmetric(vertical: rSize(10)),
|
||||
dotPosition: DotPosition(right: 15, top: 8),
|
||||
dotNum:
|
||||
widget.shopSummaryModel.data.orderCenter.waitSend == 0
|
||||
? null
|
||||
: widget.shopSummaryModel.data.orderCenter.waitSend
|
||||
.toString(),
|
||||
dotColor: AppColor.themeColor,
|
||||
icon: Container(
|
||||
height: 40,
|
||||
alignment: Alignment.center,
|
||||
child: Image.asset(
|
||||
'assets/shop_deliver.png',
|
||||
fit: BoxFit.cover,
|
||||
width: 25,
|
||||
height: 25,
|
||||
)),
|
||||
title: "待发货",
|
||||
fontSize: ScreenAdapterUtils.setSp(12),
|
||||
color: Colors.grey[700],
|
||||
contentSpacing: 5,
|
||||
onPressed: () {
|
||||
widget.clickListener(1);
|
||||
},
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: CustomImageButton(
|
||||
padding: EdgeInsets.symmetric(vertical: rSize(10)),
|
||||
dotPosition: DotPosition(right: 15, top: 8),
|
||||
dotNum:
|
||||
widget.shopSummaryModel.data.orderCenter.waitRecv == 0
|
||||
? null
|
||||
: widget.shopSummaryModel.data.orderCenter.waitRecv
|
||||
.toString(),
|
||||
dotColor: AppColor.themeColor,
|
||||
icon: Container(
|
||||
height: 40,
|
||||
alignment: Alignment.center,
|
||||
child: Image.asset(
|
||||
'assets/shop_shipped.png',
|
||||
fit: BoxFit.cover,
|
||||
width: 25,
|
||||
height: 25,
|
||||
)),
|
||||
title: "已发货",
|
||||
fontSize: ScreenAdapterUtils.setSp(12),
|
||||
color: Colors.grey[700],
|
||||
contentSpacing: 5,
|
||||
onPressed: () {
|
||||
widget.clickListener(2);
|
||||
},
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: CustomImageButton(
|
||||
padding: EdgeInsets.symmetric(vertical: rSize(10)),
|
||||
// dotPosition: DotPosition(right: 15,top: 8),
|
||||
// dotNum: widget.shopSummaryModel.data.orderStatistics.shipCount== 0 ?null:widget.shopSummaryModel.data.orderStatistics.shipCount.toString(),
|
||||
// dotColor: AppColor.themeColor,
|
||||
icon: Container(
|
||||
height: 40,
|
||||
alignment: Alignment.center,
|
||||
child: Image.asset(
|
||||
'assets/shop_received.png',
|
||||
fit: BoxFit.cover,
|
||||
width: 25,
|
||||
height: 25,
|
||||
)),
|
||||
title: "已收货",
|
||||
fontSize: ScreenAdapterUtils.setSp(12),
|
||||
color: Colors.grey[700],
|
||||
contentSpacing: 5,
|
||||
onPressed: () {
|
||||
widget.clickListener(3);
|
||||
},
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: CustomImageButton(
|
||||
padding: EdgeInsets.symmetric(vertical: rSize(10)),
|
||||
// dotPosition: DotPosition(right: 15,top: 8),
|
||||
// dotNum: widget.shopSummaryModel.data.orderStatistics.shipCount== 0 ?null:widget.shopSummaryModel.data.orderStatistics.shipCount.toString(),
|
||||
// dotColor: AppColor.themeColor,
|
||||
icon: Container(
|
||||
height: 40,
|
||||
alignment: Alignment.center,
|
||||
child: Image.asset(
|
||||
'assets/shop_aftersale.png',
|
||||
fit: BoxFit.cover,
|
||||
width: 25,
|
||||
height: 25,
|
||||
)),
|
||||
title: "售后/退货",
|
||||
fontSize: ScreenAdapterUtils.setSp(12),
|
||||
color: Colors.grey[700],
|
||||
contentSpacing: 5,
|
||||
onPressed: () {
|
||||
widget.clickListener(4);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
_rightArrowWidget(title) {
|
||||
return Row(
|
||||
children: <Widget>[
|
||||
Container(
|
||||
child: Text(title,
|
||||
style: TextStyle(color: Color(0xff999999), fontSize: 12)),
|
||||
),
|
||||
Icon(Icons.keyboard_arrow_right, size: 16, color: Colors.grey),
|
||||
Container(
|
||||
width: 10,
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
// _iconTitleWidget(icon, title, Function click){
|
||||
// return Column(
|
||||
// mainAxisAlignment: MainAxisAlignment.center,
|
||||
// children: <Widget>[
|
||||
// Container(
|
||||
// height: 40, alignment: Alignment.center,
|
||||
// child: Image.asset(icon, fit: BoxFit.cover,width: 25, height: 25,)
|
||||
// ),
|
||||
// Container(height: 5,),
|
||||
// Container(
|
||||
// alignment: Alignment.topCenter,
|
||||
// child: Text(title, style: TextStyle(fontWeight: FontWeight.w300, color: Colors.black.withOpacity(0.8), fontSize: ScreenAdapterUtils.setSp(13)),),
|
||||
// ),
|
||||
// ],
|
||||
// );
|
||||
// }
|
||||
|
||||
}
|
@ -1,91 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:recook/base/base_store_state.dart';
|
||||
import 'package:recook/constants/header.dart';
|
||||
import 'package:recook/manager/user_manager.dart';
|
||||
import 'package:recook/pages/shop/member_benefits_page.dart';
|
||||
import 'package:recook/pages/shop/shop_page.dart';
|
||||
import 'package:recook/utils/user_level_tool.dart';
|
||||
import 'package:recook/widgets/custom_image_button.dart';
|
||||
|
||||
class NormalShopPage extends StatefulWidget {
|
||||
NormalShopPage({Key key}) : super(key: key);
|
||||
|
||||
@override
|
||||
_NormalShopPageState createState() => _NormalShopPageState();
|
||||
}
|
||||
|
||||
class _NormalShopPageState extends BaseStoreState<NormalShopPage> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
UserManager.instance.refreshUserRole.addListener(_refreshUserRoleTabBar);
|
||||
}
|
||||
|
||||
_refreshUserRoleTabBar() {
|
||||
setState(() {});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget buildContext(BuildContext context, {store}) {
|
||||
return _bodyWidget();
|
||||
}
|
||||
|
||||
_widget() {
|
||||
return (UserLevelTool.currentUserLevelEnum() == UserLevel.Others ||
|
||||
UserLevelTool.currentUserLevelEnum() == UserLevel.First ||
|
||||
UserLevelTool.currentUserLevelEnum() == UserLevel.Second) &&
|
||||
UserLevelTool.currentRoleLevelEnum() == UserRoleLevel.Vip
|
||||
? MemberBenefitsPage()
|
||||
: ShopPage();
|
||||
}
|
||||
|
||||
_bodyWidget() {
|
||||
if (UserManager.instance.haveLogin) {
|
||||
// 登录了就渲染用户界面
|
||||
return _widget();
|
||||
} else {
|
||||
//没登录就渲染一个登录按钮
|
||||
return ListView(
|
||||
physics: AlwaysScrollableScrollPhysics(),
|
||||
children: <Widget>[
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
Container(
|
||||
margin: EdgeInsets.only(top: rSize(120)),
|
||||
width: rSize(70),
|
||||
height: rSize(70),
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
child: AspectRatio(
|
||||
aspectRatio: 1.0 / 1.0,
|
||||
child: Image.asset(AppImageName.recook_icon_300,
|
||||
fit: BoxFit.fill),
|
||||
),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
height: 150,
|
||||
),
|
||||
Container(
|
||||
margin: EdgeInsets.symmetric(horizontal: 100),
|
||||
child: CustomImageButton(
|
||||
padding: EdgeInsets.symmetric(vertical: 8),
|
||||
title: " 登录 ",
|
||||
backgroundColor: AppColor.themeColor,
|
||||
color: Colors.white,
|
||||
fontSize: ScreenAdapterUtils.setSp(16),
|
||||
borderRadius: BorderRadius.all(Radius.circular(8)),
|
||||
onPressed: () {
|
||||
AppRouter.pushAndRemoveUntil(context, RouteName.LOGIN);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in new issue