|
|
|
@ -46,7 +46,8 @@ class _GoodsSearchPage extends State<GoodsSearchPage>
|
|
|
|
|
int _pageIndex = 1; |
|
|
|
|
BusinessApiService businessService; |
|
|
|
|
List<AdminProductVoList> adminProductVoList = []; |
|
|
|
|
bool _shimmer =true; |
|
|
|
|
String networkError = ""; |
|
|
|
|
int networkStatus = 0; |
|
|
|
|
|
|
|
|
|
@override |
|
|
|
|
void didChangeMetrics() { |
|
|
|
@ -91,7 +92,6 @@ class _GoodsSearchPage extends State<GoodsSearchPage>
|
|
|
|
|
status: S.current.zhengzaijiazai, |
|
|
|
|
maskType: EasyLoadingMaskType.black); |
|
|
|
|
await queryGoodsList(); |
|
|
|
|
_shimmer = false; |
|
|
|
|
EasyLoading.dismiss(); |
|
|
|
|
if (!mounted) return; |
|
|
|
|
if (refreshController.isRefresh) refreshController.refreshCompleted(); |
|
|
|
@ -116,8 +116,9 @@ class _GoodsSearchPage extends State<GoodsSearchPage>
|
|
|
|
|
"pageSize": 10, |
|
|
|
|
"status": widget.arguments["onSaleStatus"], |
|
|
|
|
}).catchError((error) { |
|
|
|
|
SmartDialog.showToast(AppUtils.dioErrorTypeToString(error.type), |
|
|
|
|
alignment: Alignment.center); |
|
|
|
|
networkError = AppUtils.dioErrorTypeToString(error.type); |
|
|
|
|
networkStatus = -1; |
|
|
|
|
setState(() {}); |
|
|
|
|
refreshController.refreshFailed(); |
|
|
|
|
refreshController.loadFailed(); |
|
|
|
|
}); |
|
|
|
@ -129,6 +130,7 @@ class _GoodsSearchPage extends State<GoodsSearchPage>
|
|
|
|
|
refreshController.loadNoData(); |
|
|
|
|
else |
|
|
|
|
refreshController.loadComplete(); |
|
|
|
|
networkStatus = 1; |
|
|
|
|
} else { |
|
|
|
|
SmartDialog.showToast(baseData.msg, alignment: Alignment.center); |
|
|
|
|
} |
|
|
|
@ -147,20 +149,21 @@ class _GoodsSearchPage extends State<GoodsSearchPage>
|
|
|
|
|
tenant: BusinessInstance.instance.businessTenant, |
|
|
|
|
storeId: widget.arguments["storeId"]); |
|
|
|
|
} |
|
|
|
|
BaseData baseData = |
|
|
|
|
await businessService.goodsUpdate({ |
|
|
|
|
BaseData baseData = await businessService.goodsUpdate({ |
|
|
|
|
"productId": productId, |
|
|
|
|
"sell": widget.arguments["onSaleStatus"] == "1" ? false : true, |
|
|
|
|
}).catchError((error) { |
|
|
|
|
}); |
|
|
|
|
}).catchError((error) {}); |
|
|
|
|
if (baseData != null && baseData.isSuccess) { |
|
|
|
|
_pageIndex = 1; |
|
|
|
|
adminProductVoList.clear(); |
|
|
|
|
await _onRefresh(isShowLoad: false); |
|
|
|
|
SmartDialog.showToast(widget.arguments["onSaleStatus"] == "1"?"商品下架成功":"商品上架成功", alignment: Alignment.center); |
|
|
|
|
SmartDialog.showToast( |
|
|
|
|
widget.arguments["onSaleStatus"] == "1" ? "商品下架成功" : "商品上架成功", |
|
|
|
|
alignment: Alignment.center); |
|
|
|
|
} else { |
|
|
|
|
SmartDialog.showToast(baseData.msg, alignment: Alignment.center); |
|
|
|
|
}}finally{ |
|
|
|
|
} |
|
|
|
|
} finally { |
|
|
|
|
EasyLoading.dismiss(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -184,8 +187,7 @@ class _GoodsSearchPage extends State<GoodsSearchPage>
|
|
|
|
|
Container( |
|
|
|
|
color: Colors.white, |
|
|
|
|
margin: EdgeInsets.only(bottom: 16.h), |
|
|
|
|
child: |
|
|
|
|
Container( |
|
|
|
|
child: Container( |
|
|
|
|
height: 40.h, |
|
|
|
|
margin: EdgeInsets.fromLTRB(18.w, 17.h, 18.w, 10.h), |
|
|
|
|
alignment: Alignment.center, |
|
|
|
@ -210,8 +212,7 @@ class _GoodsSearchPage extends State<GoodsSearchPage>
|
|
|
|
|
hintStyle: TextStyle( |
|
|
|
|
fontSize: 15.sp, |
|
|
|
|
color: Color(0xFF808080), |
|
|
|
|
fontWeight: MyFontWeight.regular |
|
|
|
|
), |
|
|
|
|
fontWeight: MyFontWeight.regular), |
|
|
|
|
isCollapsed: true, |
|
|
|
|
prefixIcon: Padding( |
|
|
|
|
padding: EdgeInsets.only(left: 5.w, right: 5.w), |
|
|
|
@ -228,7 +229,9 @@ class _GoodsSearchPage extends State<GoodsSearchPage>
|
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
Expanded( |
|
|
|
|
child: Container( |
|
|
|
|
child: networkStatus == -1 |
|
|
|
|
? noNetwork() |
|
|
|
|
: Container( |
|
|
|
|
child: SmartRefresher( |
|
|
|
|
controller: refreshController, |
|
|
|
|
enablePullDown: true, |
|
|
|
@ -251,7 +254,8 @@ class _GoodsSearchPage extends State<GoodsSearchPage>
|
|
|
|
|
_pageIndex++; |
|
|
|
|
_onRefresh(isShowLoad: false); |
|
|
|
|
}, |
|
|
|
|
child: (_shimmer)?ListView.builder( |
|
|
|
|
child: networkStatus == 0 |
|
|
|
|
? ListView.builder( |
|
|
|
|
padding: EdgeInsets.zero, |
|
|
|
|
itemCount: 10, |
|
|
|
|
scrollDirection: Axis.vertical, |
|
|
|
@ -260,8 +264,8 @@ class _GoodsSearchPage extends State<GoodsSearchPage>
|
|
|
|
|
itemBuilder: (context, position) { |
|
|
|
|
return searchGoodsItemSm(); |
|
|
|
|
}, |
|
|
|
|
): |
|
|
|
|
((adminProductVoList == null || |
|
|
|
|
) |
|
|
|
|
: ((adminProductVoList == null || |
|
|
|
|
adminProductVoList.length == 0) |
|
|
|
|
? NoDataView( |
|
|
|
|
src: "assets/image/bs_no data_logo.webp", |
|
|
|
@ -274,12 +278,14 @@ class _GoodsSearchPage extends State<GoodsSearchPage>
|
|
|
|
|
margin: EdgeInsets.only(bottom: 20.h), |
|
|
|
|
child: ListView.builder( |
|
|
|
|
padding: EdgeInsets.zero, |
|
|
|
|
itemCount: adminProductVoList?.length ?? 0, |
|
|
|
|
itemCount: |
|
|
|
|
adminProductVoList?.length ?? 0, |
|
|
|
|
scrollDirection: Axis.vertical, |
|
|
|
|
shrinkWrap: true, |
|
|
|
|
physics: NeverScrollableScrollPhysics(), |
|
|
|
|
itemBuilder: (context, position) { |
|
|
|
|
return searchGoodsItem(adminProductVoList[position]); |
|
|
|
|
return searchGoodsItem( |
|
|
|
|
adminProductVoList[position]); |
|
|
|
|
}, |
|
|
|
|
), |
|
|
|
|
)), |
|
|
|
@ -403,8 +409,8 @@ class _GoodsSearchPage extends State<GoodsSearchPage>
|
|
|
|
|
width: 1, |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
padding: |
|
|
|
|
EdgeInsets.symmetric(vertical: 2.h, horizontal: 12.w), |
|
|
|
|
padding: EdgeInsets.symmetric( |
|
|
|
|
vertical: 2.h, horizontal: 12.w), |
|
|
|
|
child: Text( |
|
|
|
|
widget.arguments["onSaleStatus"] == "1" ? "下架" : "上架", |
|
|
|
|
style: TextStyle( |
|
|
|
@ -413,8 +419,7 @@ class _GoodsSearchPage extends State<GoodsSearchPage>
|
|
|
|
|
color: Color(0xFF30415B), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
) |
|
|
|
|
) |
|
|
|
|
)) |
|
|
|
|
], |
|
|
|
|
) |
|
|
|
|
], |
|
|
|
@ -508,7 +513,9 @@ class _GoodsSearchPage extends State<GoodsSearchPage>
|
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
SizedBox(height: 7.h,), |
|
|
|
|
SizedBox( |
|
|
|
|
height: 7.h, |
|
|
|
|
), |
|
|
|
|
Row( |
|
|
|
|
children: [ |
|
|
|
|
Shimmer.fromColors( |
|
|
|
@ -544,4 +551,52 @@ class _GoodsSearchPage extends State<GoodsSearchPage>
|
|
|
|
|
), |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Widget noNetwork() { |
|
|
|
|
return Container( |
|
|
|
|
color: Colors.white, |
|
|
|
|
width: double.infinity, |
|
|
|
|
child: Column( |
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center, |
|
|
|
|
children: [ |
|
|
|
|
Text( |
|
|
|
|
networkError.substring(0, 4), |
|
|
|
|
style: TextStyle( |
|
|
|
|
fontSize: 14.sp, |
|
|
|
|
color: Color(0xFF0D0D0D), |
|
|
|
|
fontWeight: MyFontWeight.bold), |
|
|
|
|
), |
|
|
|
|
Padding( |
|
|
|
|
padding: EdgeInsets.symmetric(vertical: 10.h), |
|
|
|
|
child: Text( |
|
|
|
|
"请检查网络设置或稍后重试", |
|
|
|
|
style: TextStyle( |
|
|
|
|
fontSize: 12.sp, |
|
|
|
|
color: Color(0xFF7A797F), |
|
|
|
|
fontWeight: MyFontWeight.regular), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
GestureDetector( |
|
|
|
|
behavior: HitTestBehavior.opaque, |
|
|
|
|
onTap: () { |
|
|
|
|
_onRefresh(); |
|
|
|
|
}, |
|
|
|
|
child: Container( |
|
|
|
|
decoration: BoxDecoration( |
|
|
|
|
color: Color(0xFF30415B), |
|
|
|
|
borderRadius: BorderRadius.circular(15), |
|
|
|
|
), |
|
|
|
|
padding: EdgeInsets.symmetric(horizontal: 12.w, vertical: 3.h), |
|
|
|
|
child: Text( |
|
|
|
|
"重试", |
|
|
|
|
style: TextStyle( |
|
|
|
|
fontSize: 14.sp, |
|
|
|
|
color: Colors.white, |
|
|
|
|
fontWeight: MyFontWeight.regular), |
|
|
|
|
)), |
|
|
|
|
) |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|