diff --git a/assets/image/2x/bs_user_switch.webp b/assets/image/2x/bs_user_switch.webp new file mode 100644 index 00000000..fa46888e Binary files /dev/null and b/assets/image/2x/bs_user_switch.webp differ diff --git a/assets/image/3x/bs_user_switch.webp b/assets/image/3x/bs_user_switch.webp new file mode 100644 index 00000000..2e16b369 Binary files /dev/null and b/assets/image/3x/bs_user_switch.webp differ diff --git a/assets/image/bs_user_switch.webp b/assets/image/bs_user_switch.webp new file mode 100644 index 00000000..ce025a2c Binary files /dev/null and b/assets/image/bs_user_switch.webp differ diff --git a/lib/business_system/goods/goods_search_page.dart b/lib/business_system/goods/goods_search_page.dart index b7c58659..358fa198 100644 --- a/lib/business_system/goods/goods_search_page.dart +++ b/lib/business_system/goods/goods_search_page.dart @@ -14,10 +14,12 @@ import '../../retrofit/data/base_data.dart'; import '../../retrofit/data/business_goods.dart'; import '../../utils/business_instance.dart'; import '../../utils/flutter_utils.dart'; +import '../../view_widget/border_text.dart'; import '../../view_widget/custom_image.dart'; import '../../view_widget/my_appbar.dart'; import '../../view_widget/my_footer.dart'; import '../../view_widget/no_data_view.dart'; +import '../../view_widget/round_button.dart'; class GoodsSearchPage extends StatefulWidget { final Map arguments; @@ -398,7 +400,7 @@ class _GoodsSearchPage extends State GestureDetector( behavior: HitTestBehavior.opaque, onTap: () { - queryGoodsUpdate(adminProductVoList.id ?? ""); + showGoodsStateDialog(adminProductVoList.id ?? ""); }, child: Container( decoration: BoxDecoration( @@ -429,6 +431,82 @@ class _GoodsSearchPage extends State ); } + ///商品上下架状态提示弹窗 + showGoodsStateDialog(productIds) { + showDialog( + context: context, + builder: (context) { + return AlertDialog( + content: Container( + width: MediaQuery.of(context).size.width - 84, + height: 139.h, + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Text( + "选中数据将被${widget.arguments["onSaleStatus"] == "1" ? "下架" : "上架"}, 是否继续?", + style: TextStyle( + color: Color(0xFFF4524D), + fontSize: 16.sp, + fontWeight: MyFontWeight.regular, + ), + ), + SizedBox( + height: 35.h, + ), + Row( + children: [ + Expanded( + child: InkWell( + child: BorderText( + text: S.of(context).quxiao, + textColor: Color(0xFF30415B), + fontSize: 16.sp, + fontWeight: FontWeight.bold, + borderColor: Color(0xFF30415B), + radius: 4, + padding: EdgeInsets.all(12), + borderWidth: 1, + ), + onTap: () { + Navigator.of(context).pop(); + }, + ), + flex: 1, + ), + SizedBox( + width: 16.w, + ), + Expanded( + child: InkWell( + child: RoundButton( + text: S.of(context).queren, + textColor: Colors.white, + radius: 4, + padding: EdgeInsets.all(12), + backgroup: Color(0xFF30415B), + fontSize: 16.sp, + fontWeight: FontWeight.bold, + ), + onTap: () { + Navigator.of(context).pop(); + queryGoodsUpdate(productIds ?? ""); + }, + ), + flex: 1, + ), + ], + ) + ], + ), + ), + ); + }, + ); + } + + Widget searchGoodsItemSm() { return Container( decoration: BoxDecoration( 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 03b16391..a703f49d 100644 --- a/lib/business_system/goods/off_shelf/off_shelf_page.dart +++ b/lib/business_system/goods/off_shelf/off_shelf_page.dart @@ -41,6 +41,7 @@ class _OffShelfPage extends State { List adminProductVoList = []; String networkError = ""; int networkStatus = 0; + int dialogIndex = 0; @override void dispose() { @@ -200,65 +201,70 @@ class _OffShelfPage extends State { ), ), Expanded( - child: networkStatus == -1?noNetwork():Container( - child: SmartRefresher( - controller: _refreshController, - enablePullDown: true, - enablePullUp: true, - header: MyHeader( - color: Color(0xFF30415B), - ), - physics: BouncingScrollPhysics(), - footer: CustomFooter( - builder: (context, mode) { - return MyFooter(mode); - }, + child: networkStatus == -1 + ? noNetwork() + : Container( + child: SmartRefresher( + controller: _refreshController, + enablePullDown: true, + enablePullUp: true, + header: MyHeader( + color: Color(0xFF30415B), + ), + physics: BouncingScrollPhysics(), + footer: CustomFooter( + builder: (context, mode) { + return MyFooter(mode); + }, + ), + onRefresh: () { + _pageIndex = 1; + adminProductVoList.clear(); + _onRefresh(isShowLoad: false); + }, + onLoading: () { + _pageIndex++; + _onRefresh(isShowLoad: false); + }, + child: Container( + color: Colors.white, + child: networkStatus == 0 + ? ListView.builder( + itemCount: 10, + physics: BouncingScrollPhysics(), + shrinkWrap: true, + itemBuilder: (context, position) { + return GestureDetector( + onTap: () {}, + child: shelfGoodsItemSm(), + ); + }, + ) + : ((adminProductVoList == null || + adminProductVoList.length == 0) + ? NoDataView( + src: + "assets/image/bs_no data_logo.webp", + isShowBtn: false, + text: "暂无下架商品", + fontSize: 16.sp, + margin: EdgeInsets.all(20.h), + ) + : ListView.builder( + itemCount: + adminProductVoList?.length ?? 0, + physics: BouncingScrollPhysics(), + shrinkWrap: true, + itemBuilder: (context, position) { + return GestureDetector( + onTap: () {}, + child: shelfGoodsItem( + adminProductVoList[ + position]), + ); + }, + )))), ), - onRefresh: () { - _pageIndex = 1; - adminProductVoList.clear(); - _onRefresh(isShowLoad: false); - }, - onLoading: () { - _pageIndex++; - _onRefresh(isShowLoad: false); - }, - child: Container( - color: Colors.white, - child: networkStatus == 0 ?ListView.builder( - itemCount:10, - physics: BouncingScrollPhysics(), - shrinkWrap: true, - itemBuilder: (context, position) { - return GestureDetector( - onTap: () {}, - child: shelfGoodsItemSm(), - ); - }, - ): - ((adminProductVoList == null || - adminProductVoList.length == 0) - ? NoDataView( - src: "assets/image/bs_no data_logo.webp", - isShowBtn: false, - text: "暂无下架商品", - fontSize: 16.sp, - margin: EdgeInsets.all(20.h), - ) - : ListView.builder( - itemCount: adminProductVoList?.length ?? 0, - physics: BouncingScrollPhysics(), - shrinkWrap: true, - itemBuilder: (context, position) { - return GestureDetector( - onTap: () {}, - child: shelfGoodsItem( - adminProductVoList[position]), - ); - }, - )) - )), - ), ), SizedBox( height: 60.h, @@ -273,15 +279,14 @@ class _OffShelfPage extends State { onTap: () { List productIds = []; adminProductVoList.forEach((element) { - if (element.isSelect) - productIds.add(element.id); + if (element.isSelect) productIds.add(element.id); }); if (productIds.length == 0) { SmartDialog.showToast("请选择要上架的商品", alignment: Alignment.center); return; } else { - queryGoodsUpdate(productIds); + showDelGoodsDialog(productIds, 1); } }, child: Container( @@ -308,15 +313,14 @@ class _OffShelfPage extends State { onTap: () { List productIds = []; adminProductVoList.forEach((element) { - if (element.isSelect) - productIds.add(element.id); + if (element.isSelect) productIds.add(element.id); }); if (productIds.length == 0) { SmartDialog.showToast("请选择要删除的商品", alignment: Alignment.center); return; } else { - showDelGoodsDialog(productIds); + showDelGoodsDialog(productIds, 2); } }, child: Container( @@ -389,8 +393,8 @@ class _OffShelfPage extends State { ); } - ///删除商品提示弹窗 - showDelGoodsDialog(productIds) { + ///删除商品/批量上架提示弹窗 + showDelGoodsDialog(productIds, index) { showDialog( context: context, builder: (context) { @@ -403,7 +407,7 @@ class _OffShelfPage extends State { crossAxisAlignment: CrossAxisAlignment.center, children: [ Text( - "选中数据将被永久删除, 是否继续?", + "选中数据将被${index == 1 ? "上架" : "永久删除"}, 是否继续?", style: TextStyle( color: Color(0xFFF4524D), fontSize: 16.sp, @@ -449,7 +453,10 @@ class _OffShelfPage extends State { ), onTap: () { Navigator.of(context).pop(); - queryDelProduct(productIds); + if (index == 1) + queryGoodsUpdate(productIds); + else + queryDelProduct(productIds); }, ), flex: 1, @@ -608,56 +615,39 @@ class _OffShelfPage extends State { ), Expanded( child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Padding( - padding: EdgeInsets.only(bottom: 11.h, top: 2.h), - child: Shimmer.fromColors( - baseColor: Color(0XFFD8D8D8), - highlightColor: Color(0XFFD8D8D8), - child: Container( - decoration: BoxDecoration( - color: Color(0XFFD8D8D8), - borderRadius: BorderRadius.circular(2), - ), - width: 112.w, - height: 20.h, - ), + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Padding( + padding: EdgeInsets.only(bottom: 11.h, top: 2.h), + child: Shimmer.fromColors( + baseColor: Color(0XFFD8D8D8), + highlightColor: Color(0XFFD8D8D8), + child: Container( + decoration: BoxDecoration( + color: Color(0XFFD8D8D8), + borderRadius: BorderRadius.circular(2), ), + width: 112.w, + height: 20.h, ), - Row( - children: [ - Shimmer.fromColors( - baseColor: Color(0XFFD8D8D8), - highlightColor: Color(0XFFD8D8D8), - child: Container( - decoration: BoxDecoration( - color: Color(0XFFD8D8D8), - borderRadius: BorderRadius.circular(2), - ), - width: 43.w, - height: 18.h, - ), - ), - SizedBox( - width: 8.w, - ), - Shimmer.fromColors( - baseColor: Color(0XFFD8D8D8), - highlightColor: Color(0XFFD8D8D8), - child: Container( - decoration: BoxDecoration( - color: Color(0XFFD8D8D8), - borderRadius: BorderRadius.circular(2), - ), - width: 43.w, - height: 18.h, - ), + ), + ), + Row( + children: [ + Shimmer.fromColors( + baseColor: Color(0XFFD8D8D8), + highlightColor: Color(0XFFD8D8D8), + child: Container( + decoration: BoxDecoration( + color: Color(0XFFD8D8D8), + borderRadius: BorderRadius.circular(2), ), - ], + width: 43.w, + height: 18.h, + ), ), SizedBox( - height: 7.h, + width: 8.w, ), Shimmer.fromColors( baseColor: Color(0XFFD8D8D8), @@ -667,12 +657,29 @@ class _OffShelfPage extends State { color: Color(0XFFD8D8D8), borderRadius: BorderRadius.circular(2), ), - width: 28.w, - height: 20.h, + width: 43.w, + height: 18.h, ), ), ], - )), + ), + SizedBox( + height: 7.h, + ), + Shimmer.fromColors( + baseColor: Color(0XFFD8D8D8), + highlightColor: Color(0XFFD8D8D8), + child: Container( + decoration: BoxDecoration( + color: Color(0XFFD8D8D8), + borderRadius: BorderRadius.circular(2), + ), + width: 28.w, + height: 20.h, + ), + ), + ], + )), ], ), ); @@ -685,7 +692,7 @@ class _OffShelfPage extends State { mainAxisAlignment: MainAxisAlignment.center, children: [ Text( - networkError.substring(0,4), + networkError.substring(0, 4), style: TextStyle( fontSize: 14.sp, color: Color(0xFF0D0D0D), diff --git a/lib/business_system/goods/on_sale/batch_shelf.dart b/lib/business_system/goods/on_sale/batch_shelf.dart index e7ad3c79..0a80a38d 100644 --- a/lib/business_system/goods/on_sale/batch_shelf.dart +++ b/lib/business_system/goods/on_sale/batch_shelf.dart @@ -16,10 +16,12 @@ import '../../../retrofit/data/product_group_list.dart'; import '../../../utils/business_instance.dart'; import '../../../utils/flutter_utils.dart'; import '../../../utils/font_weight.dart'; +import '../../../view_widget/border_text.dart'; import '../../../view_widget/classic_header.dart'; import '../../../view_widget/custom_image.dart'; import '../../../view_widget/my_footer.dart'; import '../../../view_widget/no_data_view.dart'; +import '../../../view_widget/round_button.dart'; class BatchShelf extends StatefulWidget { final Map arguments; @@ -207,7 +209,7 @@ class _BatchShelf extends State { alignment: Alignment.center); return; } else { - queryGoodsUpdate(); + showGoodsStateDialog(); } }, child: Container( @@ -325,6 +327,81 @@ class _BatchShelf extends State { ); } + ///商品确认下架提示弹窗 + showGoodsStateDialog() { + showDialog( + context: context, + builder: (context) { + return AlertDialog( + content: Container( + width: MediaQuery.of(context).size.width - 84, + height: 139.h, + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Text( + "选中数据将被下架, 是否继续?", + style: TextStyle( + color: Color(0xFFF4524D), + fontSize: 16.sp, + fontWeight: MyFontWeight.regular, + ), + ), + SizedBox( + height: 35.h, + ), + Row( + children: [ + Expanded( + child: InkWell( + child: BorderText( + text: S.of(context).quxiao, + textColor: Color(0xFF30415B), + fontSize: 16.sp, + fontWeight: FontWeight.bold, + borderColor: Color(0xFF30415B), + radius: 4, + padding: EdgeInsets.all(12), + borderWidth: 1, + ), + onTap: () { + Navigator.of(context).pop(); + }, + ), + flex: 1, + ), + SizedBox( + width: 16.w, + ), + Expanded( + child: InkWell( + child: RoundButton( + text: S.of(context).queren, + textColor: Colors.white, + radius: 4, + padding: EdgeInsets.all(12), + backgroup: Color(0xFF30415B), + fontSize: 16.sp, + fontWeight: FontWeight.bold, + ), + onTap: () { + Navigator.of(context).pop(); + queryGoodsUpdate(); + }, + ), + flex: 1, + ), + ], + ) + ], + ), + ), + ); + }, + ); + } + ///左边list Widget shelfLeftItem(Records records, index){ return Container( 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 8d02b450..886c3ba2 100644 --- a/lib/business_system/goods/on_sale/on_sale_page.dart +++ b/lib/business_system/goods/on_sale/on_sale_page.dart @@ -18,8 +18,10 @@ import '../../../retrofit/data/product_group_list.dart'; import '../../../utils/business_instance.dart'; import '../../../utils/flutter_utils.dart'; import '../../../utils/font_weight.dart'; +import '../../../view_widget/border_text.dart'; import '../../../view_widget/custom_image.dart'; import '../../../view_widget/no_data_view.dart'; +import '../../../view_widget/round_button.dart'; class OnSalePage extends StatefulWidget { final String storeId; @@ -600,7 +602,7 @@ class _OnSalePage extends State { )), GestureDetector( onTap: () { - queryGoodsUpdate(adminProductVoList.id ?? ""); + showOffShelfDialog(adminProductVoList.id ?? ""); }, child: Container( decoration: BoxDecoration( @@ -632,6 +634,80 @@ class _OnSalePage extends State { ); } + showOffShelfDialog(productIds) { + showDialog( + context: context, + builder: (context) { + return AlertDialog( + content: Container( + width: MediaQuery.of(context).size.width - 84, + height: 139.h, + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Text( + "选中数据将被下架, 是否继续?", + style: TextStyle( + color: Color(0xFFF4524D), + fontSize: 16.sp, + fontWeight: MyFontWeight.regular, + ), + ), + SizedBox( + height: 35.h, + ), + Row( + children: [ + Expanded( + child: InkWell( + child: BorderText( + text: S.of(context).quxiao, + textColor: Color(0xFF30415B), + fontSize: 16.sp, + fontWeight: FontWeight.bold, + borderColor: Color(0xFF30415B), + radius: 4, + padding: EdgeInsets.all(12), + borderWidth: 1, + ), + onTap: () { + Navigator.of(context).pop(); + }, + ), + flex: 1, + ), + SizedBox( + width: 16.w, + ), + Expanded( + child: InkWell( + child: RoundButton( + text: S.of(context).queren, + textColor: Colors.white, + radius: 4, + padding: EdgeInsets.all(12), + backgroup: Color(0xFF30415B), + fontSize: 16.sp, + fontWeight: FontWeight.bold, + ), + onTap: () { + Navigator.of(context).pop(); + queryGoodsUpdate(productIds ?? ""); + }, + ), + flex: 1, + ), + ], + ) + ], + ), + ), + ); + }, + ); + } + Widget leftItemSm() { return Container( alignment: Alignment.center, diff --git a/lib/business_system/home/business_home_page.dart b/lib/business_system/home/business_home_page.dart index b89679d7..4d580baf 100644 --- a/lib/business_system/home/business_home_page.dart +++ b/lib/business_system/home/business_home_page.dart @@ -73,20 +73,22 @@ class _BusinessHomePage extends State super.dispose(); } - _onRefresh({int index,isLoading = true}) async { - if(isLoading) - EasyLoading.show( - status: S.current.zhengzaijiazai, maskType: EasyLoadingMaskType.black); + _onRefresh({int index, isLoading = true}) async { + if (isLoading) + 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.businessLoginInfo.storeList[index??widget.selectStoreIndex] - .name == + storeId: widget.businessLoginInfo + .storeList[index ?? widget.selectStoreIndex].name == "所有门店" ? "0" - : widget.businessLoginInfo.storeList[index??widget.selectStoreIndex].id); + : widget.businessLoginInfo + .storeList[index ?? widget.selectStoreIndex].id); queryDayAmount(); queryPopularList(isSing: false); queryOrderTrend(); @@ -218,7 +220,7 @@ class _BusinessHomePage extends State return MyFooter(mode); }, ), - onRefresh:(){ + onRefresh: () { _onRefresh(isLoading: false); }, child: SingleChildScrollView( @@ -291,6 +293,20 @@ class _BusinessHomePage extends State ], ), )), + GestureDetector( + behavior: HitTestBehavior.opaque, + onTap: () { + showIdentitySwitchDialog(); + }, + child: Container( + padding: EdgeInsets.symmetric(horizontal: 10.w), + child: Image.asset( + "assets/image/bs_user_switch.webp", + width: 25.h, + height: 25.h, + color: Colors.white, + ), + )), GestureDetector( behavior: HitTestBehavior.opaque, onTap: () { @@ -313,7 +329,7 @@ class _BusinessHomePage extends State ], ), Container( - margin: EdgeInsets.only(top:14.h), + margin: EdgeInsets.only(top: 14.h), padding: EdgeInsets.symmetric(vertical: 12.h), decoration: BoxDecoration( color: Colors.white, @@ -508,6 +524,90 @@ class _BusinessHomePage extends State } } + ///用户身份切换 + showIdentitySwitchDialog() async { + SharedPreferences sharedPreferences = await SharedPreferences.getInstance(); + showDialog( + context: context, + builder: (context) { + return AlertDialog( + content: Column( + mainAxisSize: MainAxisSize.min, + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + GestureDetector( + behavior: HitTestBehavior.opaque, + onTap: () { + sharedPreferences.setString('identitySwitch', "1"); + Navigator.of(context).pop(); + }, + child: Padding( + padding: EdgeInsets.only(top: 10.h, bottom: 10.h), + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Image.asset( + "assets/image/bs_shop_logo.webp", + width: 28.h, + height: 28.h, + color: Color(0xFF30415B), + ), + SizedBox( + width: 10.w, + ), + Text( + "商家端", + style: TextStyle( + color: Color(0xFF0D0D0D), + fontSize: 15.sp, + fontWeight: MyFontWeight.bold, + ), + ), + ], + ), + ), + ), + GestureDetector( + behavior: HitTestBehavior.opaque, + onTap: () { + sharedPreferences.setString('identitySwitch', "2"); + Navigator.of(context).pushNamedAndRemoveUntil( + '/router/main_page', + (route) => false, + ); + }, + child: Padding( + padding: EdgeInsets.only(top: 10.h, bottom: 10.h), + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Icon( + Icons.person, + size: 28.sp, + color: Color(0xFF30415B), + ), + SizedBox( + width: 10.w, + ), + Text( + "用户端", + style: TextStyle( + color: Color(0xFF0D0D0D), + fontSize: 15.sp, + fontWeight: MyFontWeight.bold, + ), + ), + ], + ), + )) + ], + ), + ); + }, + ); + } + ///生意总览 Widget tradeOverview() { return Container( diff --git a/lib/business_system/home/home_view/home_sideslip_dialog.dart b/lib/business_system/home/home_view/home_sideslip_dialog.dart index c98ce54e..dc827438 100644 --- a/lib/business_system/home/home_view/home_sideslip_dialog.dart +++ b/lib/business_system/home/home_view/home_sideslip_dialog.dart @@ -184,7 +184,9 @@ class _HomeSideslipDialog extends State SharedPreferences.getInstance().then((value) { value.setString("account", ""); value.setString("password", ""); - Navigator.of(context).pop(-1); + // Navigator.of(context).pop(-1); + Navigator.of(context) + .pushNamedAndRemoveUntil('/router/main_page',(route) => false,); }); }, child: Container( diff --git a/lib/business_system/home/select_shop.dart b/lib/business_system/home/select_shop.dart index e10a421b..28e28833 100644 --- a/lib/business_system/home/select_shop.dart +++ b/lib/business_system/home/select_shop.dart @@ -41,7 +41,8 @@ class _SelectShop extends State { appBar: MyAppBar( title: "选择门店", titleColor: Colors.black, - leadingColor: Colors.black, + leading: (widget.arguments["routeSource"] == "门店设置")?true:false, + leadingColor: Colors.black, brightness: Brightness.dark, ), body: SmartRefresher( diff --git a/lib/business_system/login/business_login_page.dart b/lib/business_system/login/business_login_page.dart index 704f8b81..9c5c0b32 100644 --- a/lib/business_system/login/business_login_page.dart +++ b/lib/business_system/login/business_login_page.dart @@ -100,17 +100,16 @@ class _BusinessLoginPage extends State { BusinessInstance.instance.businessToken = businessLoginInfo.token; sharedPreferences.setString('account', _userPhoneController.text); sharedPreferences.setString('password', _passwordController.text); + sharedPreferences.setString('identitySwitch', "1"); if (businessLoginInfo.storeList.length > 1) { Navigator.of(context) - .pushReplacementNamed('/router/select_shop', arguments: { + .popAndPushNamed('/router/select_shop', arguments: { "businessLoginInfo": businessLoginInfo, "routeSource":"登录", }); } else { Navigator.of(context) - .pushReplacementNamed('/router/business_page', arguments: { - "businessLoginInfo": businessLoginInfo, - }); + .popAndPushNamed('/router/business_page', arguments: {"businessLoginInfo": businessLoginInfo}); } } else { if (baseData.msg != null) @@ -166,7 +165,7 @@ class _BusinessLoginPage extends State { height: 15.h, ), SizedBox(width: 4.w), - Text("手机号码", + Text("手机号码/用户名", style: TextStyle( fontSize: 14.sp, color: Color(0xD9000000), @@ -177,13 +176,13 @@ class _BusinessLoginPage extends State { margin: EdgeInsets.only(top: 13.h, bottom: 24.h), child: TextField( controller: _userPhoneController, - keyboardType: TextInputType.phone, + keyboardType: TextInputType.text, style: TextStyle( fontSize: 14.sp, color: Color(0xFF000000), fontWeight: MyFontWeight.regular), decoration: InputDecoration( - hintText: "请输入手机号码", + hintText: "请输入手机号码或用户名", hintStyle: TextStyle( fontSize: 14.sp, color: Color(0xFF262626), @@ -204,9 +203,9 @@ class _BusinessLoginPage extends State { } refresh(); }, - inputFormatters: [ - LengthLimitingTextInputFormatter(11) - ], + // inputFormatters: [ + // LengthLimitingTextInputFormatter(11) + // ], ), ), Row( @@ -228,7 +227,7 @@ class _BusinessLoginPage extends State { margin: EdgeInsets.only(top: 12.h, bottom: 75.h), child: TextField( controller: _passwordController, - keyboardType: TextInputType.phone, + keyboardType: TextInputType.text, style: TextStyle( fontSize: 14.sp, color: Color(0xFF000000), diff --git a/lib/login/new_login_page.dart b/lib/login/new_login_page.dart index ebea1056..c05319b7 100644 --- a/lib/login/new_login_page.dart +++ b/lib/login/new_login_page.dart @@ -25,7 +25,10 @@ import 'package:shared_preferences/shared_preferences.dart'; import 'package:sharesdk_plugin/sharesdk_interface.dart'; import '../main.dart'; +import '../retrofit/business_api.dart'; +import '../retrofit/data/business_login_info.dart'; import '../retrofit/data/channels_list.dart'; +import '../utils/business_instance.dart'; import 'captcha/block_puzzle_captcha.dart'; class NewLoginPage extends StatefulWidget { @@ -260,7 +263,6 @@ class _NewLoginPage extends State { isLogin() async { SharedPreferences sharedPreferences = await SharedPreferences.getInstance(); - if (sharedPreferences.getBool("isShowPrivacyPolicy") == null || !sharedPreferences.getBool("isShowPrivacyPolicy")) { showAlertDialog(); @@ -271,7 +273,14 @@ class _NewLoginPage extends State { sharedPreferences.getString("token") != "") { ExamineInstance.instance.isExamine = sharedPreferences.getString("mobile") == "13800138000"; - Navigator.of(context).popAndPushNamed('/router/main_page'); + if (sharedPreferences.getString("identitySwitch") == null || sharedPreferences.getString("identitySwitch") == "2" || (sharedPreferences.getString("account")== "" || + sharedPreferences.getString("password")== "")) { + Navigator.of(context) + .popAndPushNamed('/router/main_page'); + } else { + businessLogin(sharedPreferences.getString("account"), + sharedPreferences.getString("password")); + } } else { apiService = ApiService(Dio(), context: context); initController(); @@ -280,6 +289,46 @@ class _NewLoginPage extends State { } } + businessLogin(account, password) async { + var param = { + "grantType": "password", + "account": account, + "password": password, + }; + EasyLoading.show( + status: S.of(context).zhengzaijiazai, + maskType: EasyLoadingMaskType.black); + + BusinessApiService businessService = + BusinessApiService(Dio(), context: context); + BaseData baseData = + await businessService.annoToken(param).catchError((error) { + print(error.message); + }); + if (baseData != null && baseData.isSuccess) { + var businessLoginInfo = BusinessLoginInfo.fromJson(baseData.data); + if(businessLoginInfo.storeList.length > 1) { + businessLoginInfo.storeList.insert(0, StoreList(name: "所有门店")); + } + BusinessInstance.instance.businessTenant = businessLoginInfo.tenantCode; + BusinessInstance.instance.businessToken = businessLoginInfo.token; + if (businessLoginInfo.storeList.length > 1) { + Navigator.of(context) + .popAndPushNamed('/router/select_shop', arguments: { + "businessLoginInfo": businessLoginInfo, + }); + } else { + Navigator.of(context) + .popAndPushNamed('/router/business_page', arguments: { + "businessLoginInfo": businessLoginInfo, + }); + } + } else { + Navigator.of(context).popAndPushNamed('/router/business_login_page'); + } + EasyLoading.dismiss(); + } + @override void dispose() { if (_timer != null && _timer.isActive) _timer.cancel(); diff --git a/lib/mine/mine_view/mine_item.dart b/lib/mine/mine_view/mine_item.dart index 79ebd698..86688e96 100644 --- a/lib/mine/mine_view/mine_item.dart +++ b/lib/mine/mine_view/mine_item.dart @@ -13,6 +13,7 @@ import 'package:url_launcher/url_launcher.dart'; import '../../retrofit/business_api.dart'; import '../../retrofit/data/base_data.dart'; import '../../retrofit/data/business_login_info.dart'; +import '../../retrofit/data/examine_instance.dart'; import '../../utils/business_instance.dart'; class MineItem extends StatefulWidget { @@ -26,6 +27,7 @@ class _MineItem extends State { var isShowMore = false; login(account, password) async { + SharedPreferences sharedPreferences = await SharedPreferences.getInstance(); var param = { "grantType": "password", "account": account, @@ -48,14 +50,15 @@ class _MineItem extends State { } BusinessInstance.instance.businessTenant = businessLoginInfo.tenantCode; BusinessInstance.instance.businessToken = businessLoginInfo.token; + sharedPreferences.setString('identitySwitch', "1"); if (businessLoginInfo.storeList.length > 1) { Navigator.of(context) - .pushNamed('/router/select_shop', arguments: { + .popAndPushNamed('/router/select_shop', arguments: { "businessLoginInfo": businessLoginInfo, }); } else { Navigator.of(context) - .pushNamed('/router/business_page', arguments: { + .popAndPushNamed('/router/business_page', arguments: { "businessLoginInfo": businessLoginInfo, }); } @@ -69,7 +72,6 @@ class _MineItem extends State { Widget build(BuildContext context) { return Container( margin: EdgeInsets.fromLTRB(16.w, 0.h, 16.w, 30.h), - // padding: EdgeInsets.fromLTRB(20.w, 12.h, 20.w, 12.h), decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(8), @@ -350,13 +352,12 @@ class _MineItem extends State { ///商家管理 Expanded( - child: InkWell( + child: ExamineInstance.instance.isExamine ? Container():InkWell( onTap: () { SharedPreferences.getInstance().then((value) { if (value.getString("account") == "" || value.getString("password") == "") { - Navigator.of(context) - .pushNamed('/router/business_login_page'); + Navigator.of(context).pushNamed('/router/business_login_page'); } else { login(value.getString("account"), value.getString("password")); diff --git a/lib/settlement/settlement.dart b/lib/settlement/settlement.dart index 6d24a134..50a33874 100644 --- a/lib/settlement/settlement.dart +++ b/lib/settlement/settlement.dart @@ -140,7 +140,9 @@ class _Settlement extends State { storeId: storeId, showLoading: false); queryMemberInfo(); - if (widget.arguments["pid"] != null && widget.arguments["pid"] != "" && tableId <= 0) { + if (widget.arguments["pid"] != null && + widget.arguments["pid"] != "" && + tableId <= 0) { queryOrderInfo( address != null ? address.id : null, ((storeInfo?.pickupType?.dineInTakeStatus ?? false) == true && @@ -161,7 +163,9 @@ class _Settlement extends State { count1, payChannel, tableId); - } else if ( widget.arguments["cid"] != null && widget.arguments["cid"] != "" && tableId <= 0) { + } else if (widget.arguments["cid"] != null && + widget.arguments["cid"] != "" && + tableId <= 0) { queryOrderInfo( address != null ? address.id : null, ((storeInfo?.pickupType?.dineInTakeStatus ?? false) == true && @@ -170,7 +174,7 @@ class _Settlement extends State { selectedBtn != 2) ? diningStatus : selectedBtn, - widget.arguments["cid"]??0, + widget.arguments["cid"] ?? 0, 0, productId ?? 0, productSkuId ?? "", @@ -228,7 +232,9 @@ class _Settlement extends State { payChannel, tableId) async { try { - EasyLoading.show(status: S.current.zhengzaijiazai,maskType: EasyLoadingMaskType.black); + EasyLoading.show( + status: S.current.zhengzaijiazai, + maskType: EasyLoadingMaskType.black); BaseData baseData = await minService.getOrderInfo({ "addressId": addressId, @@ -329,7 +335,8 @@ class _Settlement extends State { ///查看订单详情 queryOrderDetails(id) async { - EasyLoading.show(status: S.current.zhengzaijiazai,maskType: EasyLoadingMaskType.black); + EasyLoading.show( + status: S.current.zhengzaijiazai, maskType: EasyLoadingMaskType.black); BaseData baseData = await minService.getOrderDetails({ "id": pageType != null ? widget.arguments["orderId"] : id ?? parentId, }).catchError((error) {}); @@ -557,129 +564,141 @@ class _Settlement extends State { ///小程序下单 queryPlaceOrderFirst() async { - // for (int i = 0; i < settleOrderInfo.orderProductList.length; i++) { - // settleOrderInfo.orderProductList.forEach((element1) { - // if (settleOrderInfo.orderProductList[i].productId == - // element1.productId) { - // settleOrderInfo.orderProductList[i].skuId = element1.skuId; - // } - // }); - // } - - placeOrderFirst = PlaceOrderFirst(); - placeOrderFirst.cartNum = settleOrderInfo.orderNum; - placeOrderFirst.cartSum = settleOrderInfo.price; - placeOrderFirst.addressId = address == null ? null : address.id; - placeOrderFirst.isSubscribe = - ((subscribeParam?.isEnableSubscribe ?? false) == true) - ? true - : false; //是否预约 - placeOrderFirst.isTakeOut = - ((storeInfo?.pickupType?.dineInTakeStatus ?? false) == true && - (subscribeParam?.isEnableSubscribe ?? false) == false && - selectedBtn != 1 && - selectedBtn != 2) - ? diningStatus - : selectedBtn; - placeOrderFirst.notes = remakers + - (reservationTime ?? "") + - ((subscribeParam?.isEnableSubscribe ?? false) == true - ? "预约门店:${((subscribeParam?.stores?.length ?? 0) == 1 ? (subscribeParam.stores[0]) : (subscribeStoresName ?? ""))}" - : ""); - placeOrderFirst.numberOfPeople = "$numberOfPeople"; - placeOrderFirst.orderSource = 2; - placeOrderFirst.orderType = "0"; - placeOrderFirst.orderTypeId = 0; - placeOrderFirst.parentCode = parentCode; // 火锅加菜 - placeOrderFirst.parentId = parentId; // 火锅加菜 - placeOrderFirst.payChannel = ((placeOrderFirst.cartSum == "0.00") - ? payChannel = 0 - : ((tableId > 0 - ? (minOrderInfo?.isRaise ?? false) - : (settleOrderInfo?.isRaise ?? false)) - ? 7 - : payChannel)); - placeOrderFirst.promotionInfoDTO = PromotionInfoDTOBean(); - placeOrderFirst.promotionInfoDTO.promotionId = - (promotion != null && tableId <= 0) ? promotion.id : ""; - // : widget.arguments["pid"] ?? ""; - placeOrderFirst.promotionInfoDTO.couponId = - (couponListBean != null && tableId <= 0) ? couponListBean.id : ""; - // : widget.arguments["cid"] ?? ""; - // placeOrderFirst.promotionInfoDTO.useVipPrice = (settleOrderInfo.isRaise || payChannel == 5 || ((payChannel == 4 && (settleOrderInfo.usePlateMoney == false))) ) ? false : useVipPriceSelect; - // placeOrderFirst.promotionInfoDTO.useBenefit = (settleOrderInfo.isRaise || payChannel == 5 || ((payChannel == 4 && settleOrderInfo.usePlateMoney == false))) ? false : useBenefitSelect; - placeOrderFirst.promotionInfoDTO.discountType = (!placeOrder) ? "AUTO" :settleOrderInfo?.discountType ?? ""; - placeOrderFirst.recMobile = - (mobile == null || mobile == "") ? mobile : storeInfo.headMobile; - placeOrderFirst.shoppingCartSkuItemList = settleOrderInfo.orderProductList; - placeOrderFirst.skuItemDTOList = []; - placeOrderFirst.source = 1; - placeOrderFirst.storeId = storeInfo.id; - placeOrderFirst.subcribeTime = subTime ?? ""; //预约时间 - placeOrderFirst.tableId = "$tableId"; - for (int i = 0; - i < (shopCarGoods?.shoppingCartSkuItemList?.length ?? 0); - i++) { - placeOrderFirst.shoppingCartSkuItemList[i].setMealDataList = - shopCarGoods.shoppingCartSkuItemList[i].setMealDataList; - } + try { + EasyLoading.show( + status: S.current.zhengzaijiazai, + maskType: EasyLoadingMaskType.black); + // for (int i = 0; i < settleOrderInfo.orderProductList.length; i++) { + // settleOrderInfo.orderProductList.forEach((element1) { + // if (settleOrderInfo.orderProductList[i].productId == + // element1.productId) { + // settleOrderInfo.orderProductList[i].skuId = element1.skuId; + // } + // }); + // } - if (tableId == 0) { - ///正常的商店下单 - BaseData baseData = await minService - .placeOrderFirst(placeOrderFirst.toJson()) - .catchError((error) { - print("error: $error"); - }); - if (baseData != null && baseData.isSuccess) { - EasyLoading.show(status: S.current.zhengzaijiazai,maskType: EasyLoadingMaskType.black); - placeOrder = true; - this.downOrder = DownOrder.fromJson(baseData.data); - querySettlement(); - } else { - // orderButton = false; - SmartDialog.showToast(baseData?.msg, alignment: Alignment.center); + placeOrderFirst = PlaceOrderFirst(); + placeOrderFirst.cartNum = settleOrderInfo.orderNum; + placeOrderFirst.cartSum = settleOrderInfo.price; + placeOrderFirst.addressId = address == null ? null : address.id; + placeOrderFirst.isSubscribe = + ((subscribeParam?.isEnableSubscribe ?? false) == true) + ? true + : false; //是否预约 + placeOrderFirst.isTakeOut = + ((storeInfo?.pickupType?.dineInTakeStatus ?? false) == true && + (subscribeParam?.isEnableSubscribe ?? false) == false && + selectedBtn != 1 && + selectedBtn != 2) + ? diningStatus + : selectedBtn; + placeOrderFirst.notes = remakers + + (reservationTime ?? "") + + ((subscribeParam?.isEnableSubscribe ?? false) == true + ? "预约门店:${((subscribeParam?.stores?.length ?? 0) == 1 ? (subscribeParam.stores[0]) : (subscribeStoresName ?? ""))}" + : ""); + placeOrderFirst.numberOfPeople = "$numberOfPeople"; + placeOrderFirst.orderSource = 2; + placeOrderFirst.orderType = "0"; + placeOrderFirst.orderTypeId = 0; + placeOrderFirst.parentCode = parentCode; // 火锅加菜 + placeOrderFirst.parentId = parentId; // 火锅加菜 + placeOrderFirst.payChannel = ((placeOrderFirst.cartSum == "0.00") + ? payChannel = 0 + : ((tableId > 0 + ? (minOrderInfo?.isRaise ?? false) + : (settleOrderInfo?.isRaise ?? false)) + ? 7 + : payChannel)); + placeOrderFirst.promotionInfoDTO = PromotionInfoDTOBean(); + placeOrderFirst.promotionInfoDTO.promotionId = + (promotion != null && tableId <= 0) ? promotion.id : ""; + // : widget.arguments["pid"] ?? ""; + placeOrderFirst.promotionInfoDTO.couponId = + (couponListBean != null && tableId <= 0) ? couponListBean.id : ""; + // : widget.arguments["cid"] ?? ""; + // placeOrderFirst.promotionInfoDTO.useVipPrice = (settleOrderInfo.isRaise || payChannel == 5 || ((payChannel == 4 && (settleOrderInfo.usePlateMoney == false))) ) ? false : useVipPriceSelect; + // placeOrderFirst.promotionInfoDTO.useBenefit = (settleOrderInfo.isRaise || payChannel == 5 || ((payChannel == 4 && settleOrderInfo.usePlateMoney == false))) ? false : useBenefitSelect; + placeOrderFirst.promotionInfoDTO.discountType = + (!placeOrder) ? "AUTO" : settleOrderInfo?.discountType ?? ""; + placeOrderFirst.recMobile = + (mobile == null || mobile == "") ? mobile : storeInfo.headMobile; + placeOrderFirst.shoppingCartSkuItemList = + settleOrderInfo.orderProductList; + placeOrderFirst.skuItemDTOList = []; + placeOrderFirst.source = 1; + placeOrderFirst.storeId = storeInfo.id; + placeOrderFirst.subcribeTime = subTime ?? ""; //预约时间 + placeOrderFirst.tableId = "$tableId"; + for (int i = 0; + i < (shopCarGoods?.shoppingCartSkuItemList?.length ?? 0); + i++) { + placeOrderFirst.shoppingCartSkuItemList[i].setMealDataList = + shopCarGoods.shoppingCartSkuItemList[i].setMealDataList; } - } else { - ///火锅店下单, 等待结算 - BaseData baseData; - if (placeOrder) { - // 结算 - querySettlement(); - return; - } else { - if (parentId == "") { - // 下单 - baseData = await minService - .placeOrderFirst(placeOrderFirst.toJson()) - .catchError((error) { - print("error: $error"); - }); + + if (tableId == 0) { + ///正常的商店下单 + BaseData baseData = await minService + .placeOrderFirst(placeOrderFirst.toJson()) + .catchError((error) { + print("error: $error"); + }); + if (baseData != null && baseData.isSuccess) { + // EasyLoading.show( + // status: S.current.zhengzaijiazai, + // maskType: EasyLoadingMaskType.black); + placeOrder = true; + this.downOrder = DownOrder.fromJson(baseData.data); + await querySettlement(); } else { - //加菜 - baseData = await minService - .addOrder(placeOrderFirst.toJson()) - .catchError((error) { - print("error: $error"); - }); + // orderButton = false; + SmartDialog.showToast(baseData?.msg, alignment: Alignment.center); } - } - // orderButton = false; - if (baseData != null && baseData.isSuccess) { - placeOrder = true; - this.downOrder = DownOrder.fromJson(baseData.data); - parentId = this.downOrder.id ?? this.downOrder.parentId; - queryOrderDetails(parentId); - setState(() {}); } else { + ///火锅店下单, 等待结算 + BaseData baseData; + if (placeOrder) { + // 结算 + querySettlement(); + return; + } else { + if (parentId == "") { + // 下单 + baseData = await minService + .placeOrderFirst(placeOrderFirst.toJson()) + .catchError((error) { + print("error: $error"); + }); + } else { + //加菜 + baseData = await minService + .addOrder(placeOrderFirst.toJson()) + .catchError((error) { + print("error: $error"); + }); + } + } // orderButton = false; - SmartDialog.showToast(baseData?.msg, alignment: Alignment.center); + if (baseData != null && baseData.isSuccess) { + placeOrder = true; + this.downOrder = DownOrder.fromJson(baseData.data); + parentId = this.downOrder.id ?? this.downOrder.parentId; + queryOrderDetails(parentId); + setState(() {}); + } else { + // orderButton = false; + SmartDialog.showToast(baseData?.msg, alignment: Alignment.center); + } } + } finally { + // EasyLoading.dismiss(); } } ///结算 querySettlement() async { + try{ placeOrderFirst.id = ((parentId != "") ? parentId : downOrder.id); placeOrderFirst.orderProductVOList = ((downOrder == null) ? minOrderInfo.orderProductVOList @@ -716,10 +735,10 @@ class _Settlement extends State { timeStamp: int.tryParse(wxPay.timeStamp), sign: wxPay.sign, ); - }else{ + } else { EasyLoading.dismiss(); SmartDialog.showToast(baseData.msg, alignment: Alignment.center); - Future.delayed(Duration(seconds:2), () { + Future.delayed(Duration(seconds: 2), () { toOrderDetails(placeOrderFirst.id); }); } @@ -743,6 +762,8 @@ class _Settlement extends State { text: "${baseData?.msg}", )); } + }}finally{ + EasyLoading.dismiss(); } } @@ -950,8 +971,10 @@ class _Settlement extends State { ///会员优惠选择 if ((settleOrderInfo != null || - minOrderInfo != null) && (placeOrder && tableId <= 0 && - !(settleOrderInfo?.isRaise ?? false))) + minOrderInfo != null) && + (placeOrder && + tableId <= 0 && + !(settleOrderInfo?.isRaise ?? false))) VipDiscountsSelect( vipSelectCheck, settleOrderInfo, @@ -1534,13 +1557,19 @@ class _Settlement extends State { selectedBtn != 2) ? diningStatus : selectedBtn, - ((couponBean?.id??0) == 0 && (promotion?.id ?? productId ?? 0) !=0) ? 0: couponBean?.id, + ((couponBean?.id ?? 0) == 0 && (promotion?.id ?? productId ?? 0) != 0) + ? 0 + : couponBean?.id, 0, - ((couponBean?.id??0) == 0 && (promotion?.id ?? productId ?? 0) !=0) ? promotion?.id ?? productId :0, + ((couponBean?.id ?? 0) == 0 && (promotion?.id ?? productId ?? 0) != 0) + ? promotion?.id ?? productId + : 0, productSkuId ?? "", actProductId ?? "", actProductSkuId ?? "", - (couponBean?.id ?? 0) == 0 ? ((promotion?.id ?? productId ?? 0) !=0 ? "ACTIVITY":"AUTO") : "COUPON", + (couponBean?.id ?? 0) == 0 + ? ((promotion?.id ?? productId ?? 0) != 0 ? "ACTIVITY" : "AUTO") + : "COUPON", // useVipPriceSelect, // useBenefitSelect, count1, @@ -1574,13 +1603,21 @@ class _Settlement extends State { selectedBtn != 2) ? diningStatus : selectedBtn, - (((pro?.id ?? 0) ?? (productId ?? 0)) == 0 && (couponListBean?.id ??0) != 0)?couponListBean?.id:0, + (((pro?.id ?? 0) ?? (productId ?? 0)) == 0 && + (couponListBean?.id ?? 0) != 0) + ? couponListBean?.id + : 0, 0, - (((pro?.id ?? 0) ?? (productId ?? 0)) == 0 && (couponListBean?.id ??0) != 0) ? 0 :((pro?.id ?? 0) ?? productId), + (((pro?.id ?? 0) ?? (productId ?? 0)) == 0 && + (couponListBean?.id ?? 0) != 0) + ? 0 + : ((pro?.id ?? 0) ?? productId), productSkuId ?? "", actProductId ?? "", actProductSkuId ?? "", - (((pro?.id ?? 0) ?? (productId ?? 0)) == 0 ? ((couponListBean?.id ??0) != 0 ? "COUPON":"AUTO") : "ACTIVITY"), + (((pro?.id ?? 0) ?? (productId ?? 0)) == 0 + ? ((couponListBean?.id ?? 0) != 0 ? "COUPON" : "AUTO") + : "ACTIVITY"), // useVipPriceSelect, // useBenefitSelect, count1,