diff --git a/lib/business_system/date_select/date_picker.dart b/lib/business_system/date_select/date_picker.dart new file mode 100644 index 00000000..5934b5aa --- /dev/null +++ b/lib/business_system/date_select/date_picker.dart @@ -0,0 +1,121 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:widgetpicker/widgetpicker.dart'; + +import '../../generated/l10n.dart'; +import '../../utils/font_weight.dart'; + +class DatePickerWidget extends StatelessWidget { + final _years = List.generate((DateTime.now().year - 2019 +1), (i) => "${i + 2019}年"); + final _months = List.generate(12, (i) => "${i + 1}月"); + final showChange; + + DatePickerWidget({this.showChange = true}); + + @override + Widget build(BuildContext context) { + bool monOn = true; + String _currentYear = "${DateTime.now().year.toString()}年"; + String _currentMonth = "${DateTime.now().month.toString()}月"; + String _currentTimeStr = + "${_currentYear.replaceAll("年", "")}-${_currentMonth.length == 2 ? "0${_currentMonth.replaceAll("月", "")}" : _currentMonth.replaceAll("月", "")}"; + return StatefulBuilder(builder: (context1, state) { + return Container( + height: 260.h, + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.only( + topLeft: Radius.circular(8), + topRight: Radius.circular(8), + ), + ), + child: Column( + children: [ + Container( + height: 50.h, + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + InkWell( + onTap: () { + Navigator.of(context).pop(); + }, + child: Container( + child: Text( + S.of(context).quxiao, + style: TextStyle( + fontSize: 16, + fontWeight: MyFontWeight.semi_bold, + color: Colors.black), + ), + margin: EdgeInsets.only(left: 6), + padding: EdgeInsets.all(10), + ), + ), + InkWell( + onTap: () { + Navigator.of(context).pop(_currentTimeStr); + }, + child: Container( + child: Text( + S.of(context).queren, + style: TextStyle( + fontSize: 16, + fontWeight: MyFontWeight.semi_bold, + color:Color(0xFF30415B)), + ), + margin: EdgeInsets.only(left: 6), + padding: EdgeInsets.all(10), + ), + ), + ], + ), + ), + Container( + height: 2.h, + color: Color(0xFFF4F4F4), + ), + Expanded(child: Container( + child: + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + WidgetPicker( + value: _currentYear, + options: _years, + textStyle: TextStyle( + fontSize: 16.sp, color: Color(0xFFDDDDDD),), + selectedTextStyle: + TextStyle(fontSize: 16.sp, color: Colors.black,fontWeight: MyFontWeight.medium), + onChanged: (value) => state(() => { + _currentYear = value, + _currentTimeStr = monOn + ? "${_currentYear.replaceAll("年", "")}-${_currentMonth.length == 2 ? "0${_currentMonth.replaceAll("月", "")}" : _currentMonth.replaceAll("月", "")}" + : "${_currentYear.replaceAll("年", "")}" + }), + ), + if (monOn) + WidgetPicker( + value: _currentMonth, + options: _months, + textStyle: TextStyle( + fontSize: 16.sp, color: Color(0xFFDDDDDD)), + selectedTextStyle: + TextStyle(fontSize: 16.sp, color: Colors.black,fontWeight: MyFontWeight.medium), + onChanged: (value) => state(() => { + _currentMonth = value, + _currentTimeStr = monOn + ? "${_currentYear.replaceAll("年", "")}-${_currentMonth.length == 2 ? "0${_currentMonth.replaceAll("月", "")}" : _currentMonth.replaceAll("月", "")}" + : "${_currentYear.replaceAll("年", "")}" + }), + ), + ], + ), + )), + ], + ), + ); + }); + } +} diff --git a/lib/business_system/goods/business_goods_page.dart b/lib/business_system/goods/business_goods_page.dart index c9a1c962..06e8a992 100644 --- a/lib/business_system/goods/business_goods_page.dart +++ b/lib/business_system/goods/business_goods_page.dart @@ -72,7 +72,7 @@ class _BusinessGoodsPage extends State body: TabBarView( children: [ OnSalePage(widget.storeId), - OffShelfPage(),], + OffShelfPage(widget.storeId)], ), ), ),), diff --git a/lib/business_system/goods/off_shelf/off_shelf_page.dart b/lib/business_system/goods/off_shelf/off_shelf_page.dart index a5a0d360..a97a08b9 100644 --- a/lib/business_system/goods/off_shelf/off_shelf_page.dart +++ b/lib/business_system/goods/off_shelf/off_shelf_page.dart @@ -1,14 +1,25 @@ +import 'package:dio/dio.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_easyloading/flutter_easyloading.dart'; +import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:huixiang/retrofit/retrofit_api.dart'; import 'package:huixiang/view_widget/classic_header.dart'; import 'package:huixiang/view_widget/my_footer.dart'; import 'package:pull_to_refresh/pull_to_refresh.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; +import '../../../generated/l10n.dart'; +import '../../../retrofit/business_api.dart'; +import '../../../retrofit/data/base_data.dart'; +import '../../../retrofit/data/business_goods.dart'; +import '../../../utils/business_instance.dart'; +import '../../../utils/flutter_utils.dart'; import '../../../utils/font_weight.dart'; class OffShelfPage extends StatefulWidget { + final String storeId; + OffShelfPage(this.storeId); @override State createState() { return _OffShelfPage(); @@ -18,6 +29,10 @@ class OffShelfPage extends StatefulWidget { class _OffShelfPage extends State { final RefreshController _refreshController = RefreshController(); var checkStatus = false; + int _pageIndex = 1; + BusinessApiService businessService; + List adminProductVoList = []; + String _total; @override void dispose() { @@ -28,9 +43,57 @@ class _OffShelfPage extends State { @override void initState() { super.initState(); + _onRefresh(); } - _onRefresh() async {} + _onRefresh({bool isShowLoad = true}) async { + if (isShowLoad) + EasyLoading.show( + status: S.current.zhengzaijiazai, + maskType: EasyLoadingMaskType.black); + await queryGoodsList(); + EasyLoading.dismiss(); + if (!mounted) return; + if (_refreshController.isRefresh) _refreshController.refreshCompleted(); + setState(() {}); + } + + ///下架商品列表 + queryGoodsList() async { + if (businessService == null) { + businessService = BusinessApiService(Dio(), + context: context, + token: BusinessInstance.instance.businessToken, + tenant: BusinessInstance.instance.businessTenant, + storeId: widget.storeId); + } + BaseData baseData = + await businessService.findAdminProductLis({ + "groupId": "", + "hasStock": 1, + "keyword": "", + "pageIndex": _pageIndex, + "pageSize": 10, + "status": "0" + }).catchError((error) { + SmartDialog.showToast(AppUtils.dioErrorTypeToString(error.type), + alignment: Alignment.center); + _refreshController.refreshFailed(); + _refreshController.loadFailed(); + }); + if (!mounted) return; + if (baseData != null && baseData.isSuccess) { + adminProductVoList.addAll(baseData?.data?.adminProductVOList ?? []); + _total = baseData.data.total.toString(); + if ((baseData?.data?.adminProductVOList ?? []).isEmpty || + adminProductVoList.length == baseData.data.total) + _refreshController.loadNoData(); + else + _refreshController.loadComplete(); + } else { + SmartDialog.showToast(baseData.msg, alignment: Alignment.center); + } + } @override Widget build(BuildContext context) { @@ -41,18 +104,13 @@ class _OffShelfPage extends State { children: [ Column( children: [ - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - goodsSearch(), - ], - ), + goodsSearch(), Expanded( child: Container( child: SmartRefresher( controller: _refreshController, enablePullDown: true, - enablePullUp: false, + enablePullUp: true, header: MyHeader(), physics: BouncingScrollPhysics(), footer: CustomFooter( @@ -61,9 +119,13 @@ class _OffShelfPage extends State { }, ), onRefresh: () { - setState(() { - _onRefresh(); - }); + _pageIndex = 1; + adminProductVoList.clear(); + _onRefresh(); + }, + onLoading: () { + _pageIndex++; + _onRefresh(); }, child: SingleChildScrollView( physics: NeverScrollableScrollPhysics(), @@ -98,16 +160,17 @@ class _OffShelfPage extends State { ), ],),), ListView.builder( - itemCount:15, + itemCount:adminProductVoList?.length ?? 0, physics: BouncingScrollPhysics(), shrinkWrap: true, itemBuilder: (context, position) { return GestureDetector( onTap: () {}, - child: shelfGoodsItem(), + child: shelfGoodsItem(adminProductVoList[position]), ); }, ), + if(adminProductVoList.length >= 10) SizedBox(height:70.h,) ], ), @@ -198,7 +261,7 @@ class _OffShelfPage extends State { ); } - Widget shelfGoodsItem(){ + Widget shelfGoodsItem(AdminProductVoList adminProductVoList){ return Container( margin: EdgeInsets.only(bottom: 22.h), padding: EdgeInsets.only(left: 5.w,), @@ -229,7 +292,7 @@ class _OffShelfPage extends State { children: [ Padding(padding:EdgeInsets.only(bottom:11.h,top: 2.h), child: Text( - "台湾甄选手抓饺子三生", + adminProductVoList?.productName ?? "", maxLines:1, overflow: TextOverflow.ellipsis, style: TextStyle( @@ -241,7 +304,7 @@ class _OffShelfPage extends State { Row( children: [ Text( - "库存4321", + "库存${adminProductVoList?.stock ?? 0}", style: TextStyle( fontSize: 10.sp, fontWeight: MyFontWeight.regular, @@ -250,7 +313,7 @@ class _OffShelfPage extends State { ), SizedBox(width: 8.w,), Text( - "销量4321", + "销量${adminProductVoList?.sellCount ?? 0}", style: TextStyle( fontSize: 10.sp, fontWeight: MyFontWeight.regular, @@ -272,7 +335,7 @@ class _OffShelfPage extends State { ), ), TextSpan( - text: "19", + text: adminProductVoList?.price ?? "", style: TextStyle( fontSize: 14.sp, fontWeight: MyFontWeight.medium, diff --git a/lib/business_system/goods/on_sale/batch_shelf.dart b/lib/business_system/goods/on_sale/batch_shelf.dart index 63ff2b67..638ab222 100644 --- a/lib/business_system/goods/on_sale/batch_shelf.dart +++ b/lib/business_system/goods/on_sale/batch_shelf.dart @@ -3,6 +3,7 @@ import 'package:huixiang/view_widget/my_appbar.dart'; import 'package:pull_to_refresh/pull_to_refresh.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; +import '../../../generated/l10n.dart'; import '../../../utils/font_weight.dart'; import '../../../view_widget/classic_header.dart'; import '../../../view_widget/my_footer.dart'; @@ -36,6 +37,17 @@ class _BatchShelf extends State { background: Colors.white, leadingColor: Colors.black, brightness: Brightness.dark, + action: Container( + alignment: Alignment.center, + child: Text( + S.of(context).queren, + style: TextStyle( + color: Color(0xFF30415B), + fontSize: 14.sp, + fontWeight: MyFontWeight.semi_bold, + ), + ), + ), ), body: SmartRefresher( controller: refreshController, diff --git a/lib/business_system/goods/on_sale/on_sale_page.dart b/lib/business_system/goods/on_sale/on_sale_page.dart index 6ab96843..bf4fa703 100644 --- a/lib/business_system/goods/on_sale/on_sale_page.dart +++ b/lib/business_system/goods/on_sale/on_sale_page.dart @@ -3,11 +3,11 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; -import 'package:huixiang/retrofit/retrofit_api.dart'; import 'package:huixiang/view_widget/classic_header.dart'; import 'package:huixiang/view_widget/my_footer.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 '../../../generated/l10n.dart'; import '../../../retrofit/business_api.dart'; @@ -34,6 +34,7 @@ class _OnSalePage extends State { BusinessApiService businessService; ProductGroupList productGroupList; BusinessGoods businessGoods; + int _loadCount = 0; @override void dispose() { @@ -44,29 +45,37 @@ class _OnSalePage extends State { @override void initState() { super.initState(); - } - _onRefresh({bool isShowLoad = true}) async { - if (isShowLoad) - EasyLoading.show( - status: S.current.zhengzaijiazai, - maskType: EasyLoadingMaskType.black); - await queryGroupList(); - await queryGoodsList(); - EasyLoading.dismiss(); - if (!mounted) return; - if (_refreshController.isRefresh) _refreshController.refreshCompleted(); - setState(() {}); + _onRefresh(); } - ///分组列表 - queryGroupList() async { - if (businessService == null) { + _onRefresh() async { + EasyLoading.show( + status: S.current.zhengzaijiazai, maskType: EasyLoadingMaskType.black); + SharedPreferences.getInstance().then((value) { businessService = BusinessApiService(Dio(), context: context, token: BusinessInstance.instance.businessToken, tenant: BusinessInstance.instance.businessTenant, - storeId: widget.storeId); + storeId: widget.storeId); + queryGroupList(); + queryGoodsList(); + }); + } + + addLoadCount() { + _loadCount += 1; + if (_loadCount == 2) { + _loadCount = 0; + EasyLoading.dismiss(); + if (_refreshController.isRefresh) _refreshController.refreshCompleted(); + if (!mounted) + setState(() {}); } + } + + ///分组列表 + queryGroupList() async { + try{ BaseData baseData = await businessService.productGroup({ "current":1, @@ -81,6 +90,8 @@ class _OnSalePage extends State { }).catchError((error) { SmartDialog.showToast(AppUtils.dioErrorTypeToString(error.type), alignment: Alignment.center); + _refreshController.refreshFailed(); + _refreshController.loadFailed(); }); if (!mounted) return; if (baseData != null && baseData.isSuccess) { @@ -88,17 +99,14 @@ class _OnSalePage extends State { } else { SmartDialog.showToast(baseData.msg, alignment: Alignment.center); } + }finally{ + addLoadCount(); + } } ///商品列表 queryGoodsList() async { - if (businessService == null) { - businessService = BusinessApiService(Dio(), - context: context, - token: BusinessInstance.instance.businessToken, - tenant: BusinessInstance.instance.businessTenant, - storeId: widget.storeId); - } + try{ BaseData baseData = await businessService.findAdminProductLis({ "groupId": "", @@ -114,6 +122,8 @@ class _OnSalePage extends State { businessGoods = baseData.data; } else { SmartDialog.showToast(baseData.msg, alignment: Alignment.center); + }}finally{ + addLoadCount(); } } @@ -149,7 +159,7 @@ class _OnSalePage extends State { return MyFooter(mode); }, ), - onRefresh: _onRefresh(), + onRefresh: _onRefresh, child: SingleChildScrollView( physics: NeverScrollableScrollPhysics(), child: Container( @@ -230,8 +240,8 @@ class _OnSalePage extends State { ), Image.asset( "assets/image/business.webp", - width: 18, - height: 18, + width: 18.h, + height: 18.h, ), ], ), @@ -244,7 +254,7 @@ class _OnSalePage extends State { Navigator.of(context).pushNamed('/router/goods_sort'); }, child: Row( - mainAxisAlignment: MainAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.end, children: [ Text( "商品排序", @@ -259,39 +269,40 @@ class _OnSalePage extends State { ), Image.asset( "assets/image/bs_px.webp", - width: 18, - height: 18, - ), - ], - )), - ), - Expanded( - child: GestureDetector( - behavior: HitTestBehavior.opaque, - onTap: (){ - Navigator.of(context).pushNamed('/router/batch_shelf');}, - child: Row( - mainAxisAlignment: MainAxisAlignment.end, - children: [ - Text( - "批量下架", - style: TextStyle( - fontSize: 14.sp, - fontWeight: MyFontWeight.semi_bold, - color: Color(0xFF30415B), - ), - ), - SizedBox( - width: 2.w, - ), - Image.asset( - "assets/image/bs_xj.webp", - width: 18, - height: 18, + width: 18.h, + height: 18.h, ), ], )), ), + //暂时不支持该功能 + // Expanded( + // child: GestureDetector( + // behavior: HitTestBehavior.opaque, + // onTap: (){ + // Navigator.of(context).pushNamed('/router/batch_shelf');}, + // child: Row( + // mainAxisAlignment: MainAxisAlignment.end, + // children: [ + // Text( + // "批量下架", + // style: TextStyle( + // fontSize: 14.sp, + // fontWeight: MyFontWeight.semi_bold, + // color: Color(0xFF30415B), + // ), + // ), + // SizedBox( + // width: 2.w, + // ), + // Image.asset( + // "assets/image/bs_xj.webp", + // width: 18, + // height: 18, + // ), + // ], + // )), + // ), ], ), ), diff --git a/lib/business_system/home/business_home_page.dart b/lib/business_system/home/business_home_page.dart index 2a4ec070..ec0edde4 100644 --- a/lib/business_system/home/business_home_page.dart +++ b/lib/business_system/home/business_home_page.dart @@ -112,6 +112,8 @@ class _BusinessHomePage extends State }).catchError((error) { SmartDialog.showToast(AppUtils.dioErrorTypeToString(error.type), alignment: Alignment.center); + refreshController.refreshFailed(); + refreshController.loadFailed(); }); if (baseData != null && baseData.isSuccess) { dayCount = baseData.data; diff --git a/lib/business_system/home/flow_page.dart b/lib/business_system/home/flow_page.dart index d397c637..d9c772eb 100644 --- a/lib/business_system/home/flow_page.dart +++ b/lib/business_system/home/flow_page.dart @@ -1,6 +1,5 @@ import 'package:dio/dio.dart'; import 'package:flutter/material.dart'; -import 'package:flutter_datetime_picker/flutter_datetime_picker.dart'; import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:huixiang/utils/font_weight.dart'; @@ -19,6 +18,7 @@ import '../../utils/flutter_utils.dart'; import '../../view_widget/classic_header.dart'; import '../../view_widget/my_footer.dart'; import '../../view_widget/no_data_view.dart'; +import '../date_select/date_picker.dart'; class FlowPage extends StatefulWidget { final arguments; @@ -37,6 +37,8 @@ class _FlowPage extends State { BusinessApiService businessService; List dayFlowList = []; int _loadCount = 0; + String _datetime; + @override void initState() { @@ -54,7 +56,7 @@ class _FlowPage extends State { token: BusinessInstance.instance.businessToken, tenant: BusinessInstance.instance.businessTenant, storeId: storeId); - queryDayFlow(DateFormat("yyyy-MM-dd").format(DateTime.now()), "0", + queryDayFlow(_datetime == null ? DateFormat("yyyy-MM-dd").format(DateTime.now()):(_datetime+"-01"), "0", isSing: false); }); } @@ -140,7 +142,7 @@ class _FlowPage extends State { child: Row( children: [ Text( - DateFormat("yyyy年MM月").format(DateTime.now()), + _datetime == null ? DateFormat("yyyy年MM月").format(DateTime.now()) : "${_datetime.replaceAll("-", "年")}日", style: TextStyle( fontSize: 15.sp, fontWeight: MyFontWeight.semi_bold, @@ -330,25 +332,16 @@ class _FlowPage extends State { )); } - showDateSelector() { - DatePicker.showDatePicker(context, - showTitleActions: true, - minTime: DateTime.now().subtract(const Duration(days: 360)), - maxTime: DateTime.now(), - theme: DatePickerTheme( - headerColor: Colors.white, - backgroundColor: Colors.white, - itemStyle: TextStyle( - color: Colors.black, - fontWeight: MyFontWeight.bold, - fontSize: 18), - doneStyle: TextStyle(color: Color(0xFF30415B), fontSize: 16.sp)), - onChanged: (date) { - print('change $date in time zone ' + - date.timeZoneOffset.inHours.toString()); - }, onConfirm: (date) { - // "2023-09-04"; - // setState(() {}); - }, currentTime: DateTime.now(), locale: LocaleType.zh); + showDateSelector() async { + String dateTime = await showModalBottomSheet( + backgroundColor: Colors.transparent, + context: context, + builder: (_) { + return DatePickerWidget(); + }); + if (dateTime != null) { + _datetime = dateTime; + queryDayFlow(_datetime+"-01", "0"); + } } } diff --git a/lib/business_system/mine/business_mine_page.dart b/lib/business_system/mine/business_mine_page.dart index ebd87c9d..3cdce4e0 100644 --- a/lib/business_system/mine/business_mine_page.dart +++ b/lib/business_system/mine/business_mine_page.dart @@ -212,6 +212,7 @@ class _BusinessMinePage extends State onTap: (){ Navigator.of(context).pushNamed('/router/security_setting',arguments:{ "storeId":widget.storeId, + "businessLoginInfo":widget.businessLoginInfo, }); }, child: commonFunctionsItem("assets/image/bs_secure.webp", "安全设置", "登录手机号/密码") diff --git a/lib/business_system/mine/security_setting.dart b/lib/business_system/mine/security_setting.dart index f3ba1683..dd98b804 100644 --- a/lib/business_system/mine/security_setting.dart +++ b/lib/business_system/mine/security_setting.dart @@ -1,8 +1,16 @@ +import 'package:dio/dio.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:huixiang/view_widget/my_appbar.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 '../../retrofit/business_api.dart'; +import '../../retrofit/data/base_data.dart'; +import '../../retrofit/data/business_login_info.dart'; +import '../../utils/business_instance.dart'; +import '../../utils/flutter_utils.dart'; import '../../utils/font_weight.dart'; import '../../view_widget/classic_header.dart'; import '../../view_widget/my_footer.dart'; @@ -11,6 +19,7 @@ class SecuritySetting extends StatefulWidget { final Map arguments; SecuritySetting({this.arguments}); + @override State createState() { return _SecuritySetting(); @@ -24,6 +33,9 @@ class _SecuritySetting extends State { final TextEditingController oldPasswordController = TextEditingController(); FocusNode _focusNode = FocusNode(); bool isKeyBoardShow = false; + BusinessLoginInfo businessLoginInfo; + BusinessApiService businessService; + String oldPassword; @override void initState() { @@ -42,6 +54,11 @@ class _SecuritySetting extends State { } }); }); + businessLoginInfo = widget.arguments["businessLoginInfo"]; + if(oldPasswordController.text != "" && newPasswordController.text != ""){ + oldPasswordController.text = ""; + newPasswordController.text = ""; + } } ///离开页面记着销毁和清除 @@ -51,18 +68,44 @@ class _SecuritySetting extends State { super.dispose(); } + ///修改密码 + modifyCode() async { + if (businessService == null) { + businessService = BusinessApiService(Dio(), + context: context, + token: BusinessInstance.instance.businessToken, + tenant: BusinessInstance.instance.businessTenant, + storeId: widget.arguments["storeId"]); + } + BaseData baseData = await businessService.modifyPassword({ + "id": businessLoginInfo?.userId ?? "", + "account": businessLoginInfo?.account ?? "", + "password": newPasswordController.text, + "name": businessLoginInfo?.name ?? "", + }).catchError((error) { + SmartDialog.showToast(AppUtils.dioErrorTypeToString(error.type), + alignment: Alignment.center); + }); + if (baseData != null && baseData.isSuccess) { + SmartDialog.showToast("修改成功", alignment: Alignment.center); + pageState = 1; + setState(() {}); + } else { + SmartDialog.showToast(baseData.msg, alignment: Alignment.center); + } + } @override Widget build(BuildContext context) { return GestureDetector( behavior: HitTestBehavior.opaque, - onTap: (){ + onTap: () { FocusScope.of(context).requestFocus(FocusNode()); }, child: Scaffold( backgroundColor: Color(0xFFF8F8FA), appBar: MyAppBar( - title: pageState == 1 ?"安全设置": "修改登录密码", + title: pageState == 1 ? "安全设置" : "修改登录密码", titleColor: Colors.black, background: Colors.white, leadingColor: Colors.black, @@ -80,17 +123,16 @@ class _SecuritySetting extends State { return MyFooter(mode); }, ), - onRefresh: () { - }, + onRefresh: () {}, physics: BouncingScrollPhysics(), scrollController: ScrollController(), child: SingleChildScrollView( physics: BouncingScrollPhysics(), - child:Container( - margin: EdgeInsets.only(top: 24.h,left: 16.w,right: 16.w), - child:Column( + child: Container( + margin: EdgeInsets.only(top: 24.h, left: 16.w, right: 16.w), + child: Column( children: [ - if(pageState == 1) + if (pageState == 1) Container( decoration: BoxDecoration( color: Colors.white, @@ -104,17 +146,23 @@ class _SecuritySetting extends State { ), ], ), - padding: EdgeInsets.only(top: 16.h,left: 16.w,right: 16.w,), + padding: EdgeInsets.only( + top: 16.h, + left: 16.w, + right: 16.w, + ), child: Column( children: [ Row( children: [ - Expanded(child:Text( + Expanded( + child: Text( "登录手机号", style: TextStyle( fontSize: 14.sp, color: Color(0xFF808080), - fontWeight: MyFontWeight.medium),)), + fontWeight: MyFontWeight.medium), + )), Text( "134****7777", maxLines: 2, @@ -123,35 +171,37 @@ class _SecuritySetting extends State { style: TextStyle( fontSize: 14.sp, color: Color(0xFF1A1A1A), - fontWeight: MyFontWeight.medium),), + fontWeight: MyFontWeight.medium), + ), ], ), Container( height: 1.h, width: double.infinity, color: Color(0xFFEBECEF), - margin: EdgeInsets.only(top:16.h,bottom: 16.h), + margin: EdgeInsets.only(top: 16.h, bottom: 16.h), ), GestureDetector( behavior: HitTestBehavior.opaque, - onTap: (){ - setState((){ + onTap: () { + setState(() { pageState = 2; }); }, child: Row( children: [ - Expanded(child:Text( + Expanded( + child: Text( "修改登录密码", style: TextStyle( fontSize: 14.sp, color: Color(0xFF808080), - fontWeight: MyFontWeight.medium),)), - + fontWeight: MyFontWeight.medium), + )), Image.asset( "assets/image/icon_right_z.webp", width: 16, - height:16, + height: 16, color: Color(0xFF353535), ), ], @@ -161,30 +211,39 @@ class _SecuritySetting extends State { height: 1.h, width: double.infinity, color: Color(0xFFEBECEF), - margin: EdgeInsets.only(top:16.h,bottom: 16.h), + margin: EdgeInsets.only(top: 16.h, bottom: 16.h), ), ], ), ), - if(pageState == 2) - changePassword(), - if(pageState == 2) + if (pageState == 2) changePassword(), + if (pageState == 2) GestureDetector( behavior: HitTestBehavior.opaque, - onTap: (){ - setState((){ - pageState = 1; + onTap: () { + SharedPreferences.getInstance().then((value) { + oldPassword = value.getString("password"); }); + if(oldPasswordController.text == ""){ + SmartDialog.showToast("请输入旧密码", alignment: Alignment.center); + return; + }else if(newPasswordController.text == ""){ + SmartDialog.showToast("请输入新密码", alignment: Alignment.center); + return;}else if(oldPasswordController.text != oldPassword){ + SmartDialog.showToast("旧密码输入错误", alignment: Alignment.center); + return; + }else{ + modifyCode(); + } }, child: Container( width: double.infinity, alignment: Alignment.center, - margin: EdgeInsets.only(bottom:55.h,top: 36.h), - padding: EdgeInsets.symmetric(vertical:16.h), + margin: EdgeInsets.only(bottom: 55.h, top: 36.h), + padding: EdgeInsets.symmetric(vertical: 16.h), decoration: BoxDecoration( borderRadius: BorderRadius.circular(27), - color: Color(0xFF30415B) - ), + color: Color(0xFF30415B)), child: Text( "确认修改", style: TextStyle( @@ -204,101 +263,101 @@ class _SecuritySetting extends State { ); } - Widget changePassword(){ + Widget changePassword() { return Container( - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(8.w), - boxShadow: [ - BoxShadow( - color: Color(0x0F06152E).withAlpha(12), - offset: Offset(0, 2), - blurRadius: 4, - spreadRadius: 0, - ), - ], - ), - padding: EdgeInsets.only(top: 16.h,left: 16.w,right: 16.w,), - child: Column( - children: [ - Row( - children: [ - Text( - "旧密码", - style: TextStyle( - fontSize: 14.sp, - color: Color(0xFF808080), - fontWeight: MyFontWeight.medium),), - Expanded( - child: TextField( - controller: oldPasswordController, - decoration: InputDecoration( - hintText: "请输入旧密码", - hintStyle: TextStyle( - color: Color(0xFF808080), - fontSize: 14.sp, - fontWeight: MyFontWeight.regular - ), - border: InputBorder.none, - contentPadding: EdgeInsets.only(left: 16.w), - ), - keyboardType: TextInputType.phone, - style: TextStyle( + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(8.w), + boxShadow: [ + BoxShadow( + color: Color(0x0F06152E).withAlpha(12), + offset: Offset(0, 2), + blurRadius: 4, + spreadRadius: 0, + ), + ], + ), + padding: EdgeInsets.only( + top: 16.h, + left: 16.w, + right: 16.w, + ), + child: Column( + children: [ + Row( + children: [ + Text( + "旧密码", + style: TextStyle( + fontSize: 14.sp, + color: Color(0xFF808080), + fontWeight: MyFontWeight.medium), + ), + Expanded( + child: TextField( + controller: oldPasswordController, + decoration: InputDecoration( + hintText: "请输入旧密码", + hintStyle: TextStyle( color: Color(0xFF808080), fontSize: 14.sp, - fontWeight: MyFontWeight.regular - ), + fontWeight: MyFontWeight.regular), + border: InputBorder.none, + contentPadding: EdgeInsets.only(left: 16.w), ), - ), - ], - ), - Container( - height: 1.h, - width: double.infinity, - color: Color(0xFFEBECEF), - margin: EdgeInsets.only(bottom: 16.h), - ), - Row( - children: [ - Text( - "新密码", + keyboardType: TextInputType.phone, style: TextStyle( - fontSize: 14.sp, color: Color(0xFF808080), - fontWeight: MyFontWeight.medium),), - Expanded( - child: TextField( - controller: newPasswordController, - decoration: InputDecoration( - hintText: "请输入新密码", - hintStyle: TextStyle( - color: Color(0xFF808080), - fontSize: 14.sp, - fontWeight: MyFontWeight.regular - ), - border: InputBorder.none, - contentPadding: EdgeInsets.only(left: 16.w), - ), - keyboardType: TextInputType.phone, - style: TextStyle( + fontSize: 14.sp, + fontWeight: MyFontWeight.regular), + ), + ), + ], + ), + Container( + height: 1.h, + width: double.infinity, + color: Color(0xFFEBECEF), + margin: EdgeInsets.only(bottom: 16.h), + ), + Row( + children: [ + Text( + "新密码", + style: TextStyle( + fontSize: 14.sp, + color: Color(0xFF808080), + fontWeight: MyFontWeight.medium), + ), + Expanded( + child: TextField( + controller: newPasswordController, + decoration: InputDecoration( + hintText: "请输入新密码", + hintStyle: TextStyle( color: Color(0xFF808080), fontSize: 14.sp, - fontWeight: MyFontWeight.regular - ), + fontWeight: MyFontWeight.regular), + border: InputBorder.none, + contentPadding: EdgeInsets.only(left: 16.w), ), + keyboardType: TextInputType.phone, + style: TextStyle( + color: Color(0xFF808080), + fontSize: 14.sp, + fontWeight: MyFontWeight.regular), ), - ], - ), - Container( - height: 1.h, - width: double.infinity, - color: Color(0xFFEBECEF), - margin: EdgeInsets.only(bottom: 16.h), - ), - ], - ), - ); + ), + ], + ), + Container( + height: 1.h, + width: double.infinity, + color: Color(0xFFEBECEF), + margin: EdgeInsets.only(bottom: 16.h), + ), + ], + ), + ); } - - } diff --git a/lib/business_system/order/order_list.dart b/lib/business_system/order/order_list.dart index 37eddd30..a4a12167 100644 --- a/lib/business_system/order/order_list.dart +++ b/lib/business_system/order/order_list.dart @@ -101,6 +101,8 @@ class _OrderList extends State { }).catchError((error) { SmartDialog.showToast(AppUtils.dioErrorTypeToString(error.type), alignment: Alignment.center); + _refreshController.refreshFailed(); + _refreshController.loadFailed(); }); if (!mounted) return; if (baseData != null && baseData.isSuccess) { diff --git a/lib/retrofit/business_api.dart b/lib/retrofit/business_api.dart index 785f4a54..47544fcb 100644 --- a/lib/retrofit/business_api.dart +++ b/lib/retrofit/business_api.dart @@ -204,4 +204,14 @@ abstract class BusinessApiService { Future> findAdminProductLis( @Body() Map param); + ///修改密码 + @PUT("user") + Future modifyPassword( + @Body() Map param); + + ///商品上下架 + @POST("product/update") + Future goodsUpdate( + @Body() Map param); + } diff --git a/lib/retrofit/business_api.g.dart b/lib/retrofit/business_api.g.dart index 6aec7c5a..3aa8b97b 100644 --- a/lib/retrofit/business_api.g.dart +++ b/lib/retrofit/business_api.g.dart @@ -367,4 +367,49 @@ class _BusinessApiService implements BusinessApiService { return value; } + @override + Future modifyPassword(param) async { + ArgumentError.checkNotNull(param, 'param'); + const _extra = {}; + final queryParameters = {}; + final _data = {}; + _data.addAll(param ?? {}); + final _result = await _dio.request>('user', + queryParameters: queryParameters, + options: RequestOptions( + method: 'PUT', + headers: {}, + extra: _extra, + baseUrl: baseUrl), + data: _data); + final value = BaseData.fromJson( + _result.data, + (json) => json == null ? null : json, + ); + return value; + } + + @override + Future goodsUpdate(param) async { + ArgumentError.checkNotNull(param, 'param'); + const _extra = {}; + final queryParameters = {}; + final _data = {}; + _data.addAll(param ?? {}); + final _result = await _dio.request>('product/update', + queryParameters: queryParameters, + options: RequestOptions( + method: 'POST', + headers: {}, + extra: _extra, + baseUrl: baseUrl), + data: _data); + final value = BaseData.fromJson( + _result.data, + (json) => json == null ? null : json, + ); + return value; + } + + } diff --git a/lib/union/union_list.dart b/lib/union/union_list.dart index eb50c42c..3b0c5bf1 100644 --- a/lib/union/union_list.dart +++ b/lib/union/union_list.dart @@ -114,6 +114,18 @@ class _UnionList extends State with AutomaticKeepAliveClientMixin { return InkWell( onTap: () { { + // if (storeList[position].storeName == "一心回乡商城") { + // Navigator.of(context).pushNamed( + // '/router/shopping_mall_home', + // arguments: { + // "type": 0, + // "id": storeList[position].id, + // "tenant": storeList[position].tenantCode, + // "storeName":storeList[position].storeName + // }, + // ); + // } + // else Navigator.of(context).pushNamed( '/router/store_order', arguments: { diff --git a/pubspec.lock b/pubspec.lock index 9f3eb3cb..fc533d95 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -434,6 +434,13 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "2.0.0" + infinite_listview: + dependency: transitive + description: + name: infinite_listview + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.1.0" intl: dependency: "direct main" description: @@ -1050,6 +1057,13 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "2.0.14" + widgetpicker: + dependency: "direct main" + description: + name: widgetpicker + url: "https://pub.flutter-io.cn" + source: hosted + version: "0.1.1" win32: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 71b7b705..703678fa 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -123,6 +123,8 @@ dependencies: # 时间选择器 flutter_datetime_picker: ^1.5.1 + widgetpicker: ^0.1.1 + syncfusion_flutter_datepicker: ^19.4.38