对接楼栋和单元接口

添加接口对应页面
完成登陆页面
hmxc
小赖 4 years ago
parent ac4b56b2e1
commit 02fe969be0

@ -11,4 +11,10 @@ class _Login {
///
String get loginBySMS => '/login/loginSMSUser';
/// ID
String get buildingInfo => '/login/findAllBuildingIAN';
///ID
String get unitInfo => '/login/findEstateIANByBuilding';
}

@ -1,4 +1,5 @@
import 'package:akuCommunity/pages/splash/splash_page.dart';
import 'package:akuCommunity/provider/sign_up_provider.dart';
import 'package:akuCommunity/provider/user_provider.dart';
import 'package:akuCommunity/utils/developer_util.dart';
import 'package:akuCommunity/utils/hive_store.dart';
@ -47,6 +48,7 @@ class _MyAppState extends State<MyApp> {
providers: [
ChangeNotifierProvider(create: (context) => CartProvidde()),
ChangeNotifierProvider(create: (context) => UserProvider()),
ChangeNotifierProvider(create: (context) => SignUpProvider()),
],
child: GetMaterialApp(
title: '智慧社区',

@ -0,0 +1,18 @@
class PickBuildingModel {
int value;
String label;
PickBuildingModel({this.value, this.label});
PickBuildingModel.fromJson(Map<String, dynamic> json) {
value = json['value'];
label = json['label'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['value'] = this.value;
data['label'] = this.label;
return data;
}
}

@ -13,7 +13,6 @@ import 'package:akuCommunity/painters/user_bottom_bar_painter.dart';
import 'package:akuCommunity/provider/user_provider.dart';
import 'package:akuCommunity/utils/network/net_util.dart';
import 'package:akuCommunity/widget/grid_buttons.dart';
import 'package:ani_route/ani_route.dart';
import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter_icons/flutter_icons.dart';
@ -141,7 +140,7 @@ class _PersonalIndexState extends State<PersonalIndex>
},
child: Container(
margin: EdgeInsets.only(left: 16.w),
child: userProvider.isSigned
child: userProvider.isLogin
? Text(
'Cheailune',
style: TextStyle(

@ -1,7 +1,7 @@
import 'package:akuCommunity/constants/api.dart';
import 'package:akuCommunity/model/user/pick_building_model.dart';
import 'package:akuCommunity/utils/network/base_model.dart';
import 'package:akuCommunity/utils/network/net_util.dart';
import 'package:bot_toast/bot_toast.dart';
import 'package:dio/dio.dart';
class SignFunc {
@ -21,4 +21,21 @@ class SignFunc {
);
return response;
}
static Future<List<PickBuildingModel>> getBuildingInfo() async {
BaseModel model = await NetUtil().get(API.login.buildingInfo);
return (model.data as List)
.map((e) => PickBuildingModel.fromJson(e))
.toList();
}
static Future<List<PickBuildingModel>> getUnitInfo(int id) async {
BaseModel model = await NetUtil().get(
API.login.unitInfo,
params: {"buildingId": id},
);
return (model.data as List)
.map((e) => PickBuildingModel.fromJson(e))
.toList();
}
}

@ -6,6 +6,10 @@ import 'package:akuCommunity/pages/setting_page/agreement_page/privacy_page.dart
import 'package:akuCommunity/pages/sign/sign_func.dart';
import 'package:akuCommunity/extensions/num_ext.dart';
import 'package:akuCommunity/const/resource.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';
import 'package:ani_route/ani_route.dart';
import 'package:bot_toast/bot_toast.dart';
import 'package:common_utils/common_utils.dart';
@ -18,6 +22,7 @@ import 'package:akuCommunity/base/base_style.dart';
import 'package:akuCommunity/base/assets_image.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart' hide Response;
import 'package:provider/provider.dart';
import 'package:velocity_x/velocity_x.dart';
class SignInPage extends StatefulWidget {
@ -76,14 +81,27 @@ class _SignInPageState extends State<SignInPage> {
}
_parseLogin(bool result) async {
final userProvider = Provider.of<UserProvider>(Get.context, listen: false);
final signUpProvider =
Provider.of<SignUpProvider>(Get.context, listen: false);
if (!result) return;
BotToast.showLoading();
CancelFunc cancel = BotToast.showLoading();
Response response = await SignFunc.login(_phone.text, _code.text);
BotToast.cleanAll();
if (response.data['status']) {
if (response.data['choose'] == 1) {
userProvider.setLogin(response.data['token'] as String);
Get.offAll(TabNavigator());
} else {
cancel();
signUpProvider.setTel(_phone.text);
await Get.to(SignUpPickPlotPage());
signUpProvider.clearAll();
}
} else {
BotToast.showText(text: response.data['message']);
cancel();
}
}
@ -92,6 +110,7 @@ class _SignInPageState extends State<SignInPage> {
padding: EdgeInsets.symmetric(horizontal: 80.w),
child: MaterialButton(
onPressed: () async {
FocusScope.of(context).unfocus();
if (TextUtil.isEmpty(_phone.text))
BotToast.showText(text: '手机号不能为空');
else if (TextUtil.isEmpty(_code.text))

@ -0,0 +1,17 @@
import 'package:akuCommunity/base/base_style.dart';
import 'package:flutter/material.dart';
import 'package:velocity_x/velocity_x.dart';
import 'package:akuCommunity/utils/headers.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
signUpTitle(String subTitle) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
'欢迎登录小蜜蜂'.text.bold.size(38.sp).color(ktextPrimary).make(),
8.hb,
subTitle.text.size(28.sp).color(ktextSubColor).make(),
],
);
}

@ -0,0 +1,48 @@
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';
import 'package:flutter/material.dart';
import 'package:flutter_easyrefresh/easy_refresh.dart';
import 'package:get/get.dart';
import 'package:velocity_x/velocity_x.dart';
class SignUpPickBuildingPage extends StatefulWidget {
SignUpPickBuildingPage({Key key}) : super(key: key);
@override
_SignUpPickBuildingPageState createState() => _SignUpPickBuildingPageState();
}
class _SignUpPickBuildingPageState extends State<SignUpPickBuildingPage> {
List<PickBuildingModel> _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,
),
),
);
}
}

@ -0,0 +1,29 @@
import 'package:akuCommunity/pages/sign/sign_up/sign_up_pick_building_page.dart';
import 'package:akuCommunity/widget/bee_scaffold.dart';
import 'package:akuCommunity/extensions/page_router.dart';
import 'package:flutter/material.dart';
import 'package:velocity_x/velocity_x.dart';
class SignUpPickPlotPage extends StatefulWidget {
SignUpPickPlotPage({Key key}) : super(key: key);
@override
_SignUpPickPlotPageState createState() => _SignUpPickPlotPageState();
}
class _SignUpPickPlotPageState extends State<SignUpPickPlotPage> {
@override
Widget build(BuildContext context) {
return BeeScaffold(
title: '选择小区',
body: ListView(
children: [
ListTile(
title: 'PLACEHOLDER PLOT'.text.make(),
onTap: SignUpPickBuildingPage().to,
).material(color: Colors.white),
],
),
);
}
}

@ -0,0 +1,59 @@
import 'package:akuCommunity/base/base_style.dart';
import 'package:akuCommunity/pages/sign/sign_up/sign_up_common_widget.dart';
import 'package:akuCommunity/provider/sign_up_provider.dart';
import 'package:akuCommunity/utils/headers.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:velocity_x/velocity_x.dart';
class SignUpPickRolePage extends StatefulWidget {
SignUpPickRolePage({Key key}) : super(key: key);
@override
_SignUpPickRolePageState createState() => _SignUpPickRolePageState();
}
class _SignUpPickRolePageState extends State<SignUpPickRolePage> {
Widget _buildTile(int type, String title) {
final signUpProvider = Provider.of<SignUpProvider>(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: () {},
elevation: 0,
).pLTRB(82.w, 0, 82.w, 155.w),
);
}
}

@ -0,0 +1,54 @@
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';
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';
class SignUpPickUnitPage extends StatefulWidget {
final int buildingId;
SignUpPickUnitPage({Key key, this.buildingId}) : super(key: key);
@override
_SignUpPickUnitPageState createState() => _SignUpPickUnitPageState();
}
class _SignUpPickUnitPageState extends State<SignUpPickUnitPage> {
List<PickBuildingModel> _buildingModels = [];
_buildItem(PickBuildingModel model) {
return ListTile(
title: model.label.text.make(),
onTap: () {
final signUpProvider =
Provider.of<SignUpProvider>(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,
),
),
);
}
}

@ -1,4 +1,6 @@
import 'package:akuCommunity/pages/tab_navigator.dart';
import 'package:akuCommunity/utils/hive_store.dart';
import 'package:akuCommunity/utils/logger/logger_view.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:velocity_x/velocity_x.dart';
@ -14,11 +16,15 @@ class SplashPage extends StatefulWidget {
class _SplashPageState extends State<SplashPage> {
Future _initOp() async {
await Future.delayed(Duration(seconds: 2));
print(HiveStore.appBox.get('token'));
}
@override
void initState() {
super.initState();
Future.delayed(Duration(milliseconds: 300), () {
if (mounted) LoggerFAB.openLogger(context);
});
_initOp().then((value) => Get.offAll(TabNavigator()));
}

@ -1,4 +1,3 @@
import 'package:akuCommunity/utils/logger/logger_view.dart';
import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
@ -28,9 +27,7 @@ class _TabNavigatorState extends State<TabNavigator> {
@override
void initState() {
super.initState();
Future.delayed(Duration(milliseconds: 300), () {
if (mounted) LoggerFAB.openLogger(context);
});
_pages = [
HomePage(),
// MarketPage(),

@ -0,0 +1,59 @@
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;
int _idType;
int get idType => _idType;
String _idNumber;
String get idNumber => _idNumber;
setEstateId(int id) {
_estateId = id;
notifyListeners();
}
setType(int type) {
_type = type;
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();
}
}

@ -1,4 +1,5 @@
import 'package:akuCommunity/utils/hive_store.dart';
import 'package:akuCommunity/utils/network/net_util.dart';
import 'package:flutter/material.dart';
class UserProvider extends ChangeNotifier {
@ -12,8 +13,9 @@ class UserProvider extends ChangeNotifier {
bool _isLogin = false;
bool get isLogin => _isLogin;
setLogin(bool state, String token) {
_isLogin = state;
setLogin(String token) {
_isLogin = true;
NetUtil().dio.options.headers.putIfAbsent('App-Admin-Token', () => token);
HiveStore.appBox.put('token', token);
notifyListeners();
}
@ -21,10 +23,15 @@ class UserProvider extends ChangeNotifier {
logout() {
_isLogin = false;
_token = null;
NetUtil().dio.options.headers.remove('App-Admin-Token');
HiveStore.appBox.delete('token');
notifyListeners();
}
updateProfile() async {
// await
}
String _token;
String get token => _token ?? '';
}

@ -1,5 +1,7 @@
export 'package:flutter_screenutil/flutter_screenutil.dart';
export 'package:akuCommunity/extensions/page_router.dart';
export 'package:akuCommunity/extensions/num_ext.dart';
export 'package:akuCommunity/extensions/widget_list_ext.dart';
// class Screenutil {
// static double length(double lengthNum) => ScreenUtil().setWidth(lengthNum);

@ -377,6 +377,13 @@ packages:
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.4.0"
flutter_easyrefresh:
dependency: "direct main"
description:
name: flutter_easyrefresh
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.1.8"
flutter_html:
dependency: "direct main"
description:

@ -100,6 +100,7 @@ dependencies:
hive:
hive_flutter:
logger: ^0.9.4
flutter_easyrefresh: ^2.1.8
dev_dependencies:
flutter_test:

Loading…
Cancel
Save