From 6cad032aa90ce8f039f034b8d5d3cffe2e05b540 Mon Sep 17 00:00:00 2001 From: laiiihz Date: Tue, 6 Apr 2021 16:09:31 +0800 Subject: [PATCH] remove unused codes & update login logic --- lib/main.dart | 2 - .../widget/image_horizontal_list.dart | 64 ------ lib/pages/home/widget/animate_app_bar.dart | 17 +- lib/pages/sign/sign_in_page.dart | 4 +- .../sign_up/sign_up_pick_building_page.dart | 50 ---- .../sign/sign_up/sign_up_pick_plot_page.dart | 31 --- .../sign/sign_up/sign_up_pick_role_page.dart | 63 ------ .../sign/sign_up/sign_up_pick_unit_page.dart | 56 ----- .../sign_up/sign_up_set_nickname_page.dart | 11 +- .../sign/sign_up/sign_up_verify_page.dart | 2 - lib/provider/cart.dart | 176 -------------- lib/provider/sign_up_provider.dart | 61 +---- lib/service/base_model.dart | 13 -- lib/service/net.dart | 214 ------------------ lib/service/net_header.dart | 9 - lib/service/net_url.dart | 25 -- lib/service/net_util.dart | 55 ----- lib/utils/fade_route.dart | 24 -- lib/utils/sp_key.dart | 33 --- lib/utils/sp_util.dart | 115 ---------- lib/widget/cart_count.dart | 93 -------- 21 files changed, 20 insertions(+), 1098 deletions(-) delete mode 100644 lib/pages/goods_deto_page/widget/image_horizontal_list.dart delete mode 100644 lib/pages/sign/sign_up/sign_up_pick_building_page.dart delete mode 100644 lib/pages/sign/sign_up/sign_up_pick_plot_page.dart delete mode 100644 lib/pages/sign/sign_up/sign_up_pick_role_page.dart delete mode 100644 lib/pages/sign/sign_up/sign_up_pick_unit_page.dart delete mode 100644 lib/provider/cart.dart delete mode 100644 lib/service/base_model.dart delete mode 100644 lib/service/net.dart delete mode 100644 lib/service/net_header.dart delete mode 100644 lib/service/net_url.dart delete mode 100644 lib/service/net_util.dart delete mode 100644 lib/utils/fade_route.dart delete mode 100644 lib/utils/sp_key.dart delete mode 100644 lib/utils/sp_util.dart delete mode 100644 lib/widget/cart_count.dart diff --git a/lib/main.dart b/lib/main.dart index c4dd5d5b..e7d0e834 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -13,7 +13,6 @@ import 'package:provider/provider.dart'; import 'package:akuCommunity/constants/app_theme.dart'; import 'package:akuCommunity/pages/splash/splash_page.dart'; import 'package:akuCommunity/provider/app_provider.dart'; -import 'package:akuCommunity/provider/cart.dart'; import 'package:akuCommunity/provider/sign_up_provider.dart'; import 'package:akuCommunity/provider/user_provider.dart'; import 'package:akuCommunity/utils/developer_util.dart'; @@ -72,7 +71,6 @@ class _MyAppState extends State { Widget build(BuildContext context) { return MultiProvider( providers: [ - ChangeNotifierProvider(create: (context) => CartProvidde()), ChangeNotifierProvider(create: (context) => UserProvider()), ChangeNotifierProvider(create: (context) => AppProvider()), ChangeNotifierProvider(create: (context) => SignUpProvider()), diff --git a/lib/pages/goods_deto_page/widget/image_horizontal_list.dart b/lib/pages/goods_deto_page/widget/image_horizontal_list.dart deleted file mode 100644 index 16c9cee1..00000000 --- a/lib/pages/goods_deto_page/widget/image_horizontal_list.dart +++ /dev/null @@ -1,64 +0,0 @@ -import 'dart:math'; - -import 'package:flutter/cupertino.dart'; -import 'package:flutter/material.dart'; - -import 'package:akuCommunity/utils/fade_route.dart'; -import 'package:akuCommunity/utils/headers.dart'; -import 'package:akuCommunity/widget/gallery_photo_view_wrapper.dart'; - -class ImageHorizontalList extends StatelessWidget { - final List imageUrl; - ImageHorizontalList({Key key, this.imageUrl}) : super(key: key); - - final Random _random = new Random(); - int next(int min, int max) => min + _random.nextInt(max - min); - List imageModel() { - List imgList = List(); - for (int x = 0; x < imageUrl.length; x++) { - GalleryExampleItem item = GalleryExampleItem(); - item.id = '${next(x + 100, x + 1000)}'; - item.resource = imageUrl[x]; - imgList.add(item); - } - - return imgList; - } - - @override - Widget build(BuildContext context) { - return Container( - height: 184.w, - child: ListView.builder( - shrinkWrap: true, - scrollDirection: Axis.horizontal, - itemBuilder: (BuildContext context, int index) { - return AspectRatio( - aspectRatio: 1, - child: Container( - margin: EdgeInsets.only(right: 16.w), - child: ClipRRect( - borderRadius: BorderRadius.all(Radius.circular(4)), - child: GalleryExampleItemThumbnail( - galleryExampleItem: imageModel()[index], - onTap: () { - Navigator.of(context).push(new FadeRoute( - page: GalleryPhotoViewWrapper( - galleryItems: imageModel(), - backgroundDecoration: const BoxDecoration( - color: Colors.black, - ), - initialIndex: index, - ), - )); - }, - ), - ), - ), - ); - }, - itemCount: imageUrl.length, - ), - ); - } -} diff --git a/lib/pages/home/widget/animate_app_bar.dart b/lib/pages/home/widget/animate_app_bar.dart index eb48d877..fd7ca639 100644 --- a/lib/pages/home/widget/animate_app_bar.dart +++ b/lib/pages/home/widget/animate_app_bar.dart @@ -40,7 +40,7 @@ class _AnimateAppBarState extends State { Widget build(BuildContext context) { final appProvider = Provider.of(context); return AppBar( - title: Text( S.of(context).tempPlotName), + title: Text(S.of(context).tempPlotName), backgroundColor: _bgColor, leading: Container( margin: EdgeInsets.only(left: 32.w), @@ -48,14 +48,15 @@ class _AnimateAppBarState extends State { mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text( - appProvider?.location['city'] ?? '', - style: TextStyle( - fontWeight: FontWeight.w600, - fontSize: 24.sp, - color: Color(0xff333333), + if (appProvider?.location != null) + Text( + appProvider?.location['city'] ?? '', + style: TextStyle( + fontWeight: FontWeight.w600, + fontSize: 24.sp, + color: Color(0xff333333), + ), ), - ), Text( '${appProvider.weatherType} ${appProvider.weatherTemp}℃', style: TextStyle( diff --git a/lib/pages/sign/sign_in_page.dart b/lib/pages/sign/sign_in_page.dart index 951ccb56..79b1aea6 100644 --- a/lib/pages/sign/sign_in_page.dart +++ b/lib/pages/sign/sign_in_page.dart @@ -1,6 +1,7 @@ import 'dart:async'; import 'dart:ui'; +import 'package:akuCommunity/pages/sign/sign_up/sign_up_set_nickname_page.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -21,7 +22,6 @@ import 'package:akuCommunity/extensions/num_ext.dart'; import 'package:akuCommunity/pages/setting_page/agreement_page/agreement_page.dart'; import 'package:akuCommunity/pages/setting_page/agreement_page/privacy_page.dart'; import 'package:akuCommunity/pages/sign/sign_func.dart'; -import 'package:akuCommunity/pages/sign/sign_up/sign_up_pick_plot_page.dart'; import 'package:akuCommunity/pages/tab_navigator.dart'; import 'package:akuCommunity/provider/sign_up_provider.dart'; import 'package:akuCommunity/provider/user_provider.dart'; @@ -98,7 +98,7 @@ class _SignInPageState extends State { } else { cancel(); signUpProvider.setTel(_phone.text); - await Get.to(() => SignUpPickPlotPage()); + await Get.to(() => SignUpSetNicknamePage()); signUpProvider.clearAll(); } } else { diff --git a/lib/pages/sign/sign_up/sign_up_pick_building_page.dart b/lib/pages/sign/sign_up/sign_up_pick_building_page.dart deleted file mode 100644 index 505abe41..00000000 --- a/lib/pages/sign/sign_up/sign_up_pick_building_page.dart +++ /dev/null @@ -1,50 +0,0 @@ -import 'package:flutter/material.dart'; - -import 'package:flutter_easyrefresh/easy_refresh.dart'; -import 'package:get/get.dart'; -import 'package:velocity_x/velocity_x.dart'; - -import 'package:akuCommunity/model/user/pick_building_model.dart'; -import 'package:akuCommunity/pages/sign/sign_func.dart'; -import 'package:akuCommunity/pages/sign/sign_up/sign_up_pick_unit_page.dart'; -import 'package:akuCommunity/widget/bee_scaffold.dart'; - -class SignUpPickBuildingPage extends StatefulWidget { - SignUpPickBuildingPage({Key key}) : super(key: key); - - @override - _SignUpPickBuildingPageState createState() => _SignUpPickBuildingPageState(); -} - -class _SignUpPickBuildingPageState extends State { - List _buildingModels = []; - _buildItem(PickBuildingModel model) { - return ListTile( - title: model.label.text.make(), - onTap: () { - Get.off(SignUpPickUnitPage(buildingId: model.value)); - }, - ).material(color: Colors.white); - } - - @override - Widget build(BuildContext context) { - return BeeScaffold( - title: '选择楼栋', - body: EasyRefresh( - header: MaterialHeader(), - firstRefresh: true, - onRefresh: () async { - _buildingModels = await SignFunc.getBuildingInfo(); - setState(() {}); - }, - child: ListView.builder( - itemBuilder: (context, index) { - return _buildItem(_buildingModels[index]); - }, - itemCount: _buildingModels.length, - ), - ), - ); - } -} diff --git a/lib/pages/sign/sign_up/sign_up_pick_plot_page.dart b/lib/pages/sign/sign_up/sign_up_pick_plot_page.dart deleted file mode 100644 index 46de4bfa..00000000 --- a/lib/pages/sign/sign_up/sign_up_pick_plot_page.dart +++ /dev/null @@ -1,31 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:get/get.dart'; - -import 'package:velocity_x/velocity_x.dart'; - -import 'package:akuCommunity/pages/sign/sign_up/sign_up_pick_building_page.dart'; -import 'package:akuCommunity/widget/bee_scaffold.dart'; - -class SignUpPickPlotPage extends StatefulWidget { - SignUpPickPlotPage({Key key}) : super(key: key); - - @override - _SignUpPickPlotPageState createState() => _SignUpPickPlotPageState(); -} - -class _SignUpPickPlotPageState extends State { - @override - Widget build(BuildContext context) { - return BeeScaffold( - title: '选择小区', - body: ListView( - children: [ - ListTile( - title: '五象新区人才公寓'.text.make(), - onTap: () => Get.to(SignUpPickBuildingPage()), - ).material(color: Colors.white), - ], - ), - ); - } -} diff --git a/lib/pages/sign/sign_up/sign_up_pick_role_page.dart b/lib/pages/sign/sign_up/sign_up_pick_role_page.dart deleted file mode 100644 index 3cb522a2..00000000 --- a/lib/pages/sign/sign_up/sign_up_pick_role_page.dart +++ /dev/null @@ -1,63 +0,0 @@ -import 'package:flutter/material.dart'; - -import 'package:get/get.dart'; -import 'package:provider/provider.dart'; -import 'package:velocity_x/velocity_x.dart'; - -import 'package:akuCommunity/base/base_style.dart'; -import 'package:akuCommunity/pages/sign/sign_up/sign_up_common_widget.dart'; -import 'package:akuCommunity/pages/sign/sign_up/sign_up_set_nickname_page.dart'; -import 'package:akuCommunity/provider/sign_up_provider.dart'; -import 'package:akuCommunity/utils/headers.dart'; - -class SignUpPickRolePage extends StatefulWidget { - SignUpPickRolePage({Key key}) : super(key: key); - - @override - _SignUpPickRolePageState createState() => _SignUpPickRolePageState(); -} - -class _SignUpPickRolePageState extends State { - Widget _buildTile(int type, String title) { - final signUpProvider = Provider.of(context); - return RadioListTile( - groupValue: signUpProvider.type, - onChanged: (int value) => signUpProvider.setType(value), - value: type, - title: title.text.make(), - ); - } - - @override - Widget build(BuildContext context) { - return Scaffold( - body: ListView( - padding: EdgeInsets.symmetric(horizontal: 32.w), - children: [ - 148.hb, - signUpTitle('身份选择'), - 190.hb, - ...[ - _buildTile(1, '租客'), - _buildTile(2, '业主'), - _buildTile(3, '亲属'), - ].sepWidget( - separate: Divider( - height: 1.w, - thickness: 1.w, - color: Color(0xFFD8D8D8), - )), - ], - ), - bottomNavigationBar: MaterialButton( - height: 89.w, - color: kPrimaryColor, - shape: StadiumBorder(), - disabledColor: kPrimaryColor.withOpacity(0.3), - child: '提交'.text.make(), - onPressed: () => Get.to(() => SignUpSetNicknamePage()), - elevation: 0, - ).pLTRB(82.w, 0, 82.w, 155.w), - ); - } -} diff --git a/lib/pages/sign/sign_up/sign_up_pick_unit_page.dart b/lib/pages/sign/sign_up/sign_up_pick_unit_page.dart deleted file mode 100644 index a0ed8ed9..00000000 --- a/lib/pages/sign/sign_up/sign_up_pick_unit_page.dart +++ /dev/null @@ -1,56 +0,0 @@ -import 'package:flutter/material.dart'; - -import 'package:flutter_easyrefresh/easy_refresh.dart'; -import 'package:get/get.dart'; -import 'package:provider/provider.dart'; -import 'package:velocity_x/velocity_x.dart'; - -import 'package:akuCommunity/model/user/pick_building_model.dart'; -import 'package:akuCommunity/pages/sign/sign_func.dart'; -import 'package:akuCommunity/pages/sign/sign_up/sign_up_pick_role_page.dart'; -import 'package:akuCommunity/provider/sign_up_provider.dart'; -import 'package:akuCommunity/widget/bee_scaffold.dart'; - -class SignUpPickUnitPage extends StatefulWidget { - final int buildingId; - SignUpPickUnitPage({Key key, this.buildingId}) : super(key: key); - - @override - _SignUpPickUnitPageState createState() => _SignUpPickUnitPageState(); -} - -class _SignUpPickUnitPageState extends State { - List _buildingModels = []; - _buildItem(PickBuildingModel model) { - return ListTile( - title: model.label.text.make(), - onTap: () { - final signUpProvider = - Provider.of(context, listen: false); - signUpProvider.setEstateId(model.value); - Get.off(SignUpPickRolePage()); - }, - ).material(color: Colors.white); - } - - @override - Widget build(BuildContext context) { - return BeeScaffold( - title: '选择单元', - body: EasyRefresh( - header: MaterialHeader(), - firstRefresh: true, - onRefresh: () async { - _buildingModels = await SignFunc.getUnitInfo(widget.buildingId); - setState(() {}); - }, - child: ListView.builder( - itemBuilder: (context, index) { - return _buildItem(_buildingModels[index]); - }, - itemCount: _buildingModels.length, - ), - ), - ); - } -} diff --git a/lib/pages/sign/sign_up/sign_up_set_nickname_page.dart b/lib/pages/sign/sign_up/sign_up_set_nickname_page.dart index 31c5636e..c62b0994 100644 --- a/lib/pages/sign/sign_up/sign_up_set_nickname_page.dart +++ b/lib/pages/sign/sign_up/sign_up_set_nickname_page.dart @@ -1,3 +1,6 @@ +import 'package:akuCommunity/pages/sign/sign_func.dart'; +import 'package:akuCommunity/pages/tab_navigator.dart'; +import 'package:bot_toast/bot_toast.dart'; import 'package:flutter/material.dart'; import 'package:flustars/flustars.dart'; @@ -8,7 +11,6 @@ import 'package:velocity_x/velocity_x.dart'; import 'package:akuCommunity/base/base_style.dart'; import 'package:akuCommunity/pages/sign/sign_up/sign_up_common_widget.dart'; -import 'package:akuCommunity/pages/sign/sign_up/sign_up_verify_page.dart'; import 'package:akuCommunity/provider/sign_up_provider.dart'; import 'package:akuCommunity/utils/headers.dart'; @@ -68,12 +70,15 @@ class _SignUpSetNicknamePageState extends State { height: 89.w, child: '保存'.text.make(), shape: StadiumBorder(), - onPressed: () { + onPressed: () async { + final cancel = BotToast.showLoading(); if (_globalKey.currentState.validate()) { final signUpProvider = Provider.of(context, listen: false); signUpProvider.setNickName(_textEditingController.text); - Get.to(() => SignUpVerifyPage()); + cancel(); + bool result = await SignFunc.signUp(); + if (result) Get.offAll(() => TabNavigator()); } }, ), diff --git a/lib/pages/sign/sign_up/sign_up_verify_page.dart b/lib/pages/sign/sign_up/sign_up_verify_page.dart index 0303c132..3e311126 100644 --- a/lib/pages/sign/sign_up/sign_up_verify_page.dart +++ b/lib/pages/sign/sign_up/sign_up_verify_page.dart @@ -83,8 +83,6 @@ class _SignUpVerifyPageState extends State { Provider.of(context, listen: false); if (_formKey.currentState.validate()) { - signUpProvider.setName(_nameController.text); - signUpProvider.setIdNumber(_idNumberController.text); bool result = await SignFunc.signUp(); if (result) Get.offAll(() => TabNavigator()); } diff --git a/lib/provider/cart.dart b/lib/provider/cart.dart deleted file mode 100644 index 78e7d732..00000000 --- a/lib/provider/cart.dart +++ /dev/null @@ -1,176 +0,0 @@ -import 'dart:convert'; - -import 'package:flutter/cupertino.dart'; -import 'package:flutter/material.dart'; - -import 'package:shared_preferences/shared_preferences.dart'; - -import 'package:akuCommunity/model/aku_shop_model.dart'; - -class CartProvidde with ChangeNotifier { - String cartString; - List cartList = []; - - double allPrice = 0; - int allGoodsCount = 0; - bool isAllCheck = true; - - save(itemid, itemtitle, count, itemprice, itempic) async { - SharedPreferences prefs = await SharedPreferences.getInstance(); - cartString = prefs.getString("cartString"); - var temp = cartString == null ? [] : json.decode(cartString.toString()); - List tempList = (temp as List).cast(); - bool isSave = false; - int ival = 0; - tempList.forEach((item) { - if (item["itemid"] == itemid) { - tempList[ival]["count"] = item["count"] + 1; - cartList[ival].count++; - isSave = true; - } - ival++; - }); - if (!isSave) { - Map newGoods = { - "itemid": itemid, - "itemtitle": itemtitle, - "count": count, - "itemprice": itemprice, - "itempic": itempic, - "isCheck": false - }; - tempList.add(newGoods); - AkuShopModel _newgoods = AkuShopModel.fromJson(newGoods); - int _goodIndex = cartList.indexWhere((element) { - return element.itemid == _newgoods.itemid; - }); - _goodIndex > -1 - ? cartList[_goodIndex].count += count - : cartList.add(_newgoods); - } - cartString = json.encode(tempList).toString(); - print(cartString); - print(cartList); - prefs.setString("cartInfo", cartString); - notifyListeners(); - } - - remove() async { - SharedPreferences prefs = await SharedPreferences.getInstance(); - prefs.clear(); - cartList = []; - print('清空购物车'); - notifyListeners(); - } - - ///获取商品列表 - getCartInfo() async { - SharedPreferences prefs = await SharedPreferences.getInstance(); - cartString = prefs.getString("cartInfo"); - // cartList = []; - if (cartString == null) { - cartList = []; - } else { - List tempList = (json.decode(cartString.toString()) as List).cast(); - - ///总价格和总数量初始化 - allPrice = 0; - allGoodsCount = 0; - isAllCheck = true; - tempList.forEach((item) { - if (item["isCheck"]) { - allPrice += (item["count"] * (double.parse(item["itemprice"]))); - allGoodsCount++; - } else { - isAllCheck = false; - } - cartList.add(AkuShopModel.fromJson(item)); - }); - } - notifyListeners(); - } - - ///删除单个购物车商品 - deleteGoods(String itemid) async { - // SharedPreferences prefs = await SharedPreferences.getInstance(); - // cartString = prefs.getString("cartInfo"); - // List tempList = (json.decode(cartString.toString()) as List).cast(); - // int tempIndex = 0; - // int deleteIndex = 0; - // tempList.forEach((item) { - // if (item["itemid"] == itemid) { - // deleteIndex = tempIndex; - // } - // tempIndex++; - // }); - // tempList.removeAt(deleteIndex); - // cartString = json.encode(tempList).toString(); - // prefs.setString("cartInfo", cartString); - // await getCartInfo(); - - cartList.removeWhere((element) => element.itemid == itemid); - notifyListeners(); - } - - ///单选商品 - changeCheckState(AkuShopModel cartItem) async { - // SharedPreferences prefs = await SharedPreferences.getInstance(); - // cartString = prefs.getString("cartInfo"); - // List tempList = (json.decode(cartString.toString()) as List).cast(); - // int tempIndex = 0; - // int changeIndex = 0; - // tempList.forEach((item) { - // if (item["itemid"] == cartItem.itemid) { - // changeIndex = tempIndex; - // } - // tempIndex++; - // }); - // tempList[changeIndex] = cartItem.toJson(); - // cartString = json.encode(tempList).toString(); - // prefs.setString("cartInfo", cartString); - // await getCartInfo(); - notifyListeners(); - } - - ///全选商品 - changeALlCheckState(bool isCheck) async { - SharedPreferences prefs = await SharedPreferences.getInstance(); - cartString = prefs.getString("cartInfo"); - List tempList = (json.decode(cartString.toString()) as List).cast(); - List newList = []; - tempList.forEach((item) { - var newItem = item; - newItem["isCheck"] = isCheck; - newList.add(newItem); - }); - cartString = json.encode(newList).toString(); - prefs.setString("cartInfo", cartString); - // await getCartInfo(); - notifyListeners(); - } - - ///商品数量加减 - addOrReduceAction(AkuShopModel cartItem, String todo) async { - // SharedPreferences prefs = await SharedPreferences.getInstance(); - // cartString = prefs.getString("cartInfo"); - // List tempList = (json.decode(cartString.toString()) as List).cast(); - // int tempIndex = 0; - // int changeIndex = 0; - // tempList.forEach((item) { - // if (item["itemid"] == cartItem.itemid) { - // changeIndex = tempIndex; - // } - // tempIndex++; - // }); - if (todo == 'add') { - cartItem.count++; - } else if (cartItem.count > 1) { - cartItem.count--; - } - notifyListeners(); - // tempList[changeIndex] = cartItem.toJson(); - // cartString = json.encode(tempList).toString(); - // // prefs.setString("cartInfo", cartString); - // await getCartInfo(); - } -} diff --git a/lib/provider/sign_up_provider.dart b/lib/provider/sign_up_provider.dart index bb7c5ac1..1015381d 100644 --- a/lib/provider/sign_up_provider.dart +++ b/lib/provider/sign_up_provider.dart @@ -1,89 +1,30 @@ import 'package:flutter/material.dart'; class SignUpProvider extends ChangeNotifier { - int _estateId; - int get estateId => _estateId; - int _type = 1; - int get type => _type; String _nickName; String get nickName => _nickName; - String _name; - String get name => _name; + String _tel; String get tel => _tel; - ///default is 1 - /// - ///证件类型 - ///1. 身份证 - ///2. 营业执照 - ///3. 军人证 - int _idType = 1; - - ///default is 1 - /// - ///证件类型 - ///1. 身份证 - ///2. 营业执照 - ///3. 军人证 - int get idType => _idType; - String _idNumber; - - String get idNumber => _idNumber; - Map get toMap => { - 'estateId': _estateId, - 'type': _type, 'nickName': _nickName, - 'name': _name, 'tel': _tel, - 'idType': _idType, - 'idNumber': _idNumber, }; - setEstateId(int id) { - _estateId = id; - notifyListeners(); - } - - setType(int type) { - _type = type; - notifyListeners(); - } - setNickName(String name) { _nickName = name; notifyListeners(); } - setName(String name) { - _name = name; - notifyListeners(); - } - setTel(String tel) { _tel = tel; notifyListeners(); } - setIdType(int idType) { - _idType = idType; - notifyListeners(); - } - - setIdNumber(String idNumber) { - _idNumber = idNumber; - notifyListeners(); - } - clearAll() { - _estateId = null; - _type = 1; _nickName = null; - _name = null; _tel = null; - _idType = null; - _idNumber = null; notifyListeners(); } } diff --git a/lib/service/base_model.dart b/lib/service/base_model.dart deleted file mode 100644 index 355805e0..00000000 --- a/lib/service/base_model.dart +++ /dev/null @@ -1,13 +0,0 @@ -class BaseModel { - int code; - dynamic result; - String message; - - BaseModel({this.code, this.result, this.message}); - - BaseModel.fromJson(Map json) { - code = json['Code'] != null ? json['Code'] : json['code']; - result = json['Result'] != null ? json['Result'] : json['data']; - message = json['Message'] != null ? json['Message'] : json['msg']; - } -} diff --git a/lib/service/net.dart b/lib/service/net.dart deleted file mode 100644 index 57f8ab09..00000000 --- a/lib/service/net.dart +++ /dev/null @@ -1,214 +0,0 @@ -import 'dart:convert'; -import 'dart:io'; - -import 'package:dio/adapter.dart'; -import 'package:dio/dio.dart'; - -import 'base_model.dart'; - -// import 'net_header.dart'; -// import 'package:light_wave/utils/global_toast.dart'; -// import 'package:light_wave/pages/login/login_page.dart'; -// import 'package:light_wave/routers/application.dart'; -// import 'package:fluttertoast/fluttertoast.dart'; - -/// 自定义枚举 -enum Method { get, post } - -@Deprecated("net need to be cleaned.") -class Net { - // 工厂模式 - factory Net() => _getInstance(); - static Net get instance => _getInstance(); - static Net _instance; - - Dio dio; - Net._internal() { - // 初始化 - dio = Dio( - BaseOptions( - connectTimeout: 60000, // 连接服务器超时时间,单位是毫秒. - receiveTimeout: 10000, // 响应流上前后两次接受到数据的间隔,单位为毫秒, 这并不是接收数据的总时限. - // contentType: ContentType.parse('x-www-form-urlencoded').toString(), - // responseType: ResponseType.plain, - // responseType: ResponseType.json, - ), - ); - - (dio.httpClientAdapter as DefaultHttpClientAdapter).onHttpClientCreate = - (client) { - client.badCertificateCallback = - (X509Certificate cert, String host, int port) { - //TODO - return true; - }; - }; - } - - /// 打印拦截器(便于调试) - static final interceptors = InterceptorsWrapper( - /// 请求发送前处理处理一些事情 - onRequest: (options, handler) { - print("--------------------请求参数---------------------"); - print(json.encode(options.headers)); - print(options.method); - print(options.queryParameters); - print(options.baseUrl + options.path); - print(options.data); - print("--------------------请求参数---------------------"); - return handler.next(options); - }, - - /// 在数据响应前做一些预处理 - onResponse: (response, handler) { - // Log.i("--------------------响应结果---------------------"); - // Log.e("response.statusCode", "${response.statusCode}"); - // Log.e("response.data", "${json.encode(response.data)}"); - // Log.e("response.headers", "${response.headers}"); - // Log.i("--------------------响应结果---------------------"); - return handler.next(response); - }, - - /// 错误处理 - onError: (DioError e, handler) { - // Log.e("DioError", "$e"); - return handler.next(e); - }, - ); - // 单列模式 - static Net _getInstance() { - if (_instance == null) { - _instance = Net._internal(); - } - return _instance; - } - - get(String url, Map params, - {Function success, Function failure}) { - _doRequest(url, params, Method.get, success, failure); - } - - post(String url, Map params, - {Function success, Function failure}) { - _doRequest(url, params, Method.post, success, failure); - } - - void _doRequest(String url, Map params, Method method, - Function successCallBack, Function failureCallBack) async { - try { - /// 可以添加header - // if (isIntelligent) { - // dio.options.headers.addAll(await NetHeader.getZnToken()); - // } else { - // if (isContentType) { - // dio.options.contentType = - // ContentType.parse("application/x-www-form-urlencoded").toString(); - // } - // dio.options.headers.addAll(NetHeader.dmsHeaders); - // } - dio.interceptors.add(interceptors); - Response response; - switch (method) { - case Method.get: - if (params != null && params.isNotEmpty) { - response = await dio.get(url, queryParameters: params); - } else { - response = await dio.get(url); - } - break; - case Method.post: - if (params != null && params.isNotEmpty) { - response = await dio.post(url, data: params); - } else { - response = await dio.post(url); - } - break; - } - Map result = json.decode(response.toString()); - // 打印信息 - print('''api: $url\nparams: $params\nresult: $result'''); - // 转化为model - BaseModel model = BaseModel.fromJson(result); - if (model.code == 100 || model.code == 0) { - // 100 请求成功 - if (successCallBack != null) { - //返回请求数据 - if (model.result == null) { - successCallBack(model.message); - } else { - successCallBack(model.result); - } - } - } else { - //TODO - //直接使用Toast弹出错误信息 - //返回失败信息 - // GlobalToast.globalToast('${model.message}!~'); - if (failureCallBack != null) { - failureCallBack(model.code); - // if (model.code == 1 && model.message == 'token过期') { - // Application.navigatorKey.currentState.pushNamedAndRemoveUntil( - // "/LoginPage", ModalRoute.withName("/")); - // } - // failureCallBack(model.message); - } - } - } catch (exception) { - print('错误:${exception.toString()}'); - // FlutterToast.showToast(msg: "请求失败,请稍后再试"); - if (failureCallBack != null) { - failureCallBack(exception.toString()); - } - } - } - -// 上传文件(图片) -// doUploadFile(String url, File file, String loadingText,Function successCallBack, -// Function failureCallBack) async { -// try { -// String timeStamp = DateTime.now().millisecondsSinceEpoch.toString(); -// FormData formData = FormData.from({ -// 'file': UploadFileInfo(file, '$timeStamp.jpg', -// contentType: ContentType.parse("image/jpeg")) -// }); -// Response response = await dio.post(url, data: formData); -// print('$response'); // 在需要生成model时需要json格式 -// Map result = json.decode(response.toString()); -// assert(() { -// // assert只会在debug模式下执行,release模式下不会执行 -// // 打印信息 -// print('''api: $url\nresult: $result'''); -// return true; -// }()); - -// BaseModel model = BaseModel.fromJson(result); -// if (model.code == 200) { -// // 200 请求成功 -// if (successCallBack != null) { -// if (model.data != null) { -// successCallBack(model.data); -// } else { -// successCallBack({}); -// } -// } -// } else { -// //Fluttertoast.showToast(msg: "${model.msg}"); -// if (failureCallBack != null) { -// failureCallBack(model.msg); -// } -// } -// } catch (exception) { -// assert(() { -// // 打印信息 -// print('''api: $url\n错误:${exception.toString()}'''); -// return true; -// }()); - -// // Fluttertoast.showToast(msg: '加载失败'); -// if (failureCallBack != null) { -// failureCallBack(exception.toString()); -// } -// } -// } - -} diff --git a/lib/service/net_header.dart b/lib/service/net_header.dart deleted file mode 100644 index 34de824d..00000000 --- a/lib/service/net_header.dart +++ /dev/null @@ -1,9 +0,0 @@ -class NetHeader { - /// 自定义Header - static String appID = 'MOBILE-APP-ZNY'; - static String appSecret = '293FCB579B80BC1D5E6414F0B41C6FF4'; - static Map dmsHeaders = { - 'AppID': appID, - 'AppSecret': appSecret, - }; -} diff --git a/lib/service/net_url.dart b/lib/service/net_url.dart deleted file mode 100644 index 62c19704..00000000 --- a/lib/service/net_url.dart +++ /dev/null @@ -1,25 +0,0 @@ -class NetUrl { - /// DMS服务器地址 - static const String BASE_URL = - "https://www.easy-mock.com/mock/5f68981b08d0e90f8b2abb6a/akuCommunity"; - - static const String Shop = BASE_URL + "/shop"; - - static const String ShopClass = BASE_URL + "/shopClass"; - - static const String JJSH = BASE_URL + "/jjsh"; - - static const String SMJD = BASE_URL + "/smjd"; - - static const String XXFS = BASE_URL + "/xxfs"; - - static const String ZBBJ = BASE_URL + "/zbbj"; - - static const String CZXS = BASE_URL + "/czxs"; - - static const String FSXB = BASE_URL + "/fsxb"; - - static const String MYWJ = BASE_URL + "/mywj"; - - static const String YLJS = BASE_URL + "/yljs"; -} diff --git a/lib/service/net_util.dart b/lib/service/net_util.dart deleted file mode 100644 index eda8033c..00000000 --- a/lib/service/net_util.dart +++ /dev/null @@ -1,55 +0,0 @@ -import "net.dart"; -import 'net_url.dart'; - -class NetUtil { - /// 测试商品获取 - static void akuShop(Map params, - {Function success, Function failure}) { - Net().get(NetUrl.Shop, params, success: success, failure: failure); - } - - static void akuShopClass(Map params, - {Function success, Function failure}) { - Net().get(NetUrl.ShopClass, params, success: success, failure: failure); - } - - static void akuShopJJSH(Map params, - {Function success, Function failure}) { - Net().get(NetUrl.JJSH, params, success: success, failure: failure); - } - - static void akuShopSMJD(Map params, - {Function success, Function failure}) { - Net().get(NetUrl.SMJD, params, success: success, failure: failure); - } - - static void akuShopXXFS(Map params, - {Function success, Function failure}) { - Net().get(NetUrl.XXFS, params, success: success, failure: failure); - } - - static void akuShopZBBJ(Map params, - {Function success, Function failure}) { - Net().get(NetUrl.ZBBJ, params, success: success, failure: failure); - } - - static void akuShopCZXS(Map params, - {Function success, Function failure}) { - Net().get(NetUrl.CZXS, params, success: success, failure: failure); - } - - static void akuShopFSXB(Map params, - {Function success, Function failure}) { - Net().get(NetUrl.FSXB, params, success: success, failure: failure); - } - - static void akuShopMYWJ(Map params, - {Function success, Function failure}) { - Net().get(NetUrl.MYWJ, params, success: success, failure: failure); - } - - static void akuShopYLJS(Map params, - {Function success, Function failure}) { - Net().get(NetUrl.YLJS, params, success: success, failure: failure); - } -} diff --git a/lib/utils/fade_route.dart b/lib/utils/fade_route.dart deleted file mode 100644 index e8288814..00000000 --- a/lib/utils/fade_route.dart +++ /dev/null @@ -1,24 +0,0 @@ -import 'package:flutter/material.dart'; - -class FadeRoute extends PageRouteBuilder { - final Widget page; - FadeRoute({this.page}) - : super( - pageBuilder: ( - BuildContext context, - Animation animation, - Animation secondaryAnimation, - ) => - page, - transitionsBuilder: ( - BuildContext context, - Animation animation, - Animation secondaryAnimation, - Widget child, - ) => - FadeTransition( - opacity: animation, - child: child, - ), - ); -} diff --git a/lib/utils/sp_key.dart b/lib/utils/sp_key.dart deleted file mode 100644 index f4bc5251..00000000 --- a/lib/utils/sp_key.dart +++ /dev/null @@ -1,33 +0,0 @@ -/// 所有Sp存储的键值对 -//TODO CLEAN BOTTOM CODES. -@Deprecated("sh*t sp_key need to be cleaned.") -class SpKey { - // 智能token - static final String zntoken = "Authorization"; - // 智能全部登录信息(除token外) - static final String loginInfo = "loginInfo"; - // 智能用户id - static final String znMemberId = "memberId"; - // 智能用户手机 - static final String znLoginPhone = "loginPhone"; - // 智能性别 - static final String znSex = "sex"; - // 智能生日 - static final String znBirthday = "birthday"; - // 智能头像 - static final String znMemberAvatar = "memberAvatar"; - // 智能昵称 - static final String znMemberName = "memberName"; - // 智能签名 - static final String znIntroduction = "introduction"; - // 智能token过期返回的值 - static final String znTokenFailure = "token"; - // 智能是否是第一次安装app - static final String znIsFirst = "firstLunch"; - // 智能身高 - static final String znHeight = "height"; - // 分销的UID - static final String dmsUID = "UID"; - // 分销的token - static final String dmstoken = "AccessToken"; -} diff --git a/lib/utils/sp_util.dart b/lib/utils/sp_util.dart deleted file mode 100644 index 8db8d149..00000000 --- a/lib/utils/sp_util.dart +++ /dev/null @@ -1,115 +0,0 @@ -import 'dart:async'; - -import 'package:shared_preferences/shared_preferences.dart'; -import 'package:synchronized/synchronized.dart'; - -class SpUtil { - static SpUtil _singleton; - static SharedPreferences _prefs; - static Lock _lock = Lock(); - - static Future getInstance() async { - if (_singleton == null) { - await _lock.synchronized(() async { - if (_singleton == null) { - // keep local instance till it is fully initialized. - // 保持本地实例直到完全初始化。 - var singleton = SpUtil._(); - await singleton._init(); - _singleton = singleton; - } - }); - } - return _singleton; - } - - SpUtil._(); - - Future _init() async { - _prefs = await SharedPreferences.getInstance(); - } - - /// sp获取动态类型型值 - static Future getDynamic(String key) async { - SharedPreferences prefs = await SharedPreferences.getInstance(); - return await prefs.get(key); - } - - /// sp存储bool型值 - static Future saveBool(String key, bool value) async { - SharedPreferences prefs = await SharedPreferences.getInstance(); - return await prefs.setBool(key, value); - } - - /// sp获取bool型值 - static Future getBool(String key) async { - SharedPreferences prefs = await SharedPreferences.getInstance(); - return prefs.getBool(key); - } - - /// sp存储int型值 - static Future saveInt(String key, int value) async { - SharedPreferences prefs = await SharedPreferences.getInstance(); - return await prefs.setInt(key, value); - } - - /// sp获取int型值 - static Future getInt(String key) async { - SharedPreferences prefs = await SharedPreferences.getInstance(); - return prefs.getInt(key); - } - - /// sp存储double型值 - static Future saveDouble(String key, double value) async { - SharedPreferences prefs = await SharedPreferences.getInstance(); - return await prefs.setDouble(key, value); - } - - /// sp获取double型值 - static double getDouble(String key, double defValue) { - if (_prefs == null) return defValue; - return _prefs.getDouble(key) ?? defValue; - } - - /// sp存储String型值 - static Future saveString(String key, String value) async { - SharedPreferences prefs = await SharedPreferences.getInstance(); - return await prefs.setString(key, value); - } - - /// sp获取String型值 - static Future getString(String key) async { - SharedPreferences prefs = await SharedPreferences.getInstance(); - return prefs.getString(key); - } - - /// sp存储List型值 - static Future saveStrings(String key, List value) async { - SharedPreferences prefs = await SharedPreferences.getInstance(); - return await prefs.setStringList(key, value); - } - - /// sp获取List型值 - static Future> getStrings(String key) async { - SharedPreferences prefs = await SharedPreferences.getInstance(); - return prefs.getStringList(key); - } - - /// sp清除所有缓存,返回bool型值,true为清除成功 - static Future clear() async { - SharedPreferences prefs = await SharedPreferences.getInstance(); - return await prefs.clear(); - } - - /// sp清除单个缓存 - static Future remove(String key) async { - SharedPreferences prefs = await SharedPreferences.getInstance(); - return await prefs.remove(key); - } - - /// sp获取所有已经存储的key值,返回结果为Set类型 - static Future> getKeys() async { - SharedPreferences prefs = await SharedPreferences.getInstance(); - return prefs.getKeys(); - } -} diff --git a/lib/widget/cart_count.dart b/lib/widget/cart_count.dart deleted file mode 100644 index a382801e..00000000 --- a/lib/widget/cart_count.dart +++ /dev/null @@ -1,93 +0,0 @@ -import 'package:flutter/material.dart'; - -import 'package:provider/provider.dart'; - -import 'package:akuCommunity/model/aku_shop_model.dart'; -import 'package:akuCommunity/provider/cart.dart'; -import 'package:akuCommunity/utils/headers.dart'; - -class CartCount extends StatelessWidget { - final AkuShopModel cartItem; - CartCount({Key key, this.cartItem}) : super(key: key); - - //减按钮 - Widget _reduceBtn(CartProvidde model) { - return InkWell( - onTap: cartItem.count > 1 - ? () { - model.addOrReduceAction(cartItem, 'reduce'); - } - : null, - child: Container( - width: 52.w, - height: 52.w, - alignment: Alignment.center, - decoration: BoxDecoration( - color: cartItem.count > 1 ? Color(0xffffffff) : Colors.black12, - border: - Border(right: BorderSide(width: 0.5, color: Colors.black12))), - child: Icon( - Icons.remove, - color: Color(0xff979797), - size: 38.sp, - ), - ), - ); - } - - //加按钮 - Widget _addBtn(CartProvidde model) { - return InkWell( - onTap: () { - model.addOrReduceAction(cartItem, 'add'); - }, - child: Container( - width: 52.w, - height: 52.w, - alignment: Alignment.center, - decoration: BoxDecoration( - color: Color(0xffffffff), - border: - Border(left: BorderSide(width: 0.5, color: Colors.black12))), - child: Icon( - Icons.add, - color: Color(0xff979797), - size: 38.sp, - ), - ), - ); - } - - //中间数量显示区域 - Widget _countArea() { - return Container( - width: 52.w, - height: 52.w, - alignment: Alignment.center, - color: Colors.white, - child: Text( - '${cartItem.count}', - style: TextStyle( - fontSize: 24.sp, - color: Color(0xff333333), - ), - ), - ); - } - - @override - Widget build(BuildContext context) { - return Container( - width: 160.w, - decoration: BoxDecoration( - border: - Border.all(width: 0.5, color: Colors.black12) //设置所有的边框宽度为1 颜色为浅灰 - ), - child: Consumer(builder: (context, model, child) { - return Row( - children: [_reduceBtn(model), _countArea(), _addBtn(model)], - ); - }), - ); - } -}