张萌 4 years ago
commit 739f9d4a38

@ -4,6 +4,7 @@ class API {
static const int networkTimeOut = 10000; static const int networkTimeOut = 10000;
static _Login login = _Login(); static _Login login = _Login();
static _User user = _User(); static _User user = _User();
static _Manager manager = _Manager();
} }
class _Login { class _Login {
@ -42,3 +43,7 @@ class _User {
/// ///
String get updateTel =>'/user/personalData/updateTel'; String get updateTel =>'/user/personalData/updateTel';
} }
class _Manager {
String get commiteeStaff => '/ownersCommittee/findAll';
}

@ -0,0 +1,63 @@
class CommitteeItemModel {
int id;
int positionId;
String name;
int sexId;
int age;
int educationId;
String roomName;
String profession;
String roomNumber;
int unitNo;
int estateNo;
String get sexValue {
if (sexId == 0 || sexId == null) return '未设置';
if (sexId == 1) return '';
if (sexId == 2) return '';
return '未设置';
}
CommitteeItemModel(
{this.id,
this.positionId,
this.name,
this.sexId,
this.age,
this.educationId,
this.roomName,
this.profession,
this.roomNumber,
this.unitNo,
this.estateNo});
CommitteeItemModel.fromJson(Map<String, dynamic> json) {
id = json['id'];
positionId = json['positionId'];
name = json['name'];
sexId = json['sexId'];
age = json['age'];
educationId = json['educationId'];
roomName = json['roomName'];
profession = json['profession'];
roomNumber = json['roomNumber'];
unitNo = json['unitNo'];
estateNo = json['estateNo'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this.id;
data['positionId'] = this.positionId;
data['name'] = this.name;
data['sexId'] = this.sexId;
data['age'] = this.age;
data['educationId'] = this.educationId;
data['roomName'] = this.roomName;
data['profession'] = this.profession;
data['roomNumber'] = this.roomNumber;
data['unitNo'] = this.unitNo;
data['estateNo'] = this.estateNo;
return data;
}
}

@ -1,8 +1,13 @@
import 'package:akuCommunity/base/base_style.dart'; import 'package:akuCommunity/base/base_style.dart';
import 'package:akuCommunity/constants/api.dart';
import 'package:akuCommunity/model/user/committee_item_model.dart';
import 'package:akuCommunity/pages/industry_committee/committee_mailbox/committee_mailbox_page.dart'; import 'package:akuCommunity/pages/industry_committee/committee_mailbox/committee_mailbox_page.dart';
import 'package:akuCommunity/utils/network/base_list_model.dart';
import 'package:akuCommunity/utils/network/net_util.dart';
import 'package:akuCommunity/widget/bee_scaffold.dart'; import 'package:akuCommunity/widget/bee_scaffold.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter_easyrefresh/easy_refresh.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:url_launcher/url_launcher.dart'; import 'package:url_launcher/url_launcher.dart';
import 'package:akuCommunity/utils/headers.dart'; import 'package:akuCommunity/utils/headers.dart';
@ -16,6 +21,38 @@ class IndustryCommitteePage extends StatefulWidget {
} }
class _IndustryCommitteePageState extends State<IndustryCommitteePage> { class _IndustryCommitteePageState extends State<IndustryCommitteePage> {
EasyRefreshController _refreshController = EasyRefreshController();
BaseListModel _listModel = BaseListModel.zero();
List<CommitteeItemModel> _committeeModels = [];
int _page = 0;
Future<List<CommitteeItemModel>> _getCommitteeList() async {
_listModel = await NetUtil().getList(API.manager.commiteeStaff, params: {
'pageNum': _page,
'size': 10,
});
return _listModel.tableList
.map((e) => CommitteeItemModel.fromJson(e))
.toList();
}
Future<void> refresh() async {
_page = 0;
_listModel = BaseListModel.zero();
_committeeModels.clear();
_committeeModels = await _getCommitteeList();
setState(() {});
}
Future addPage() async {
_page++;
if (_page >= _listModel.pageCount)
_refreshController.finishLoad(noMore: true);
else
_committeeModels.addAll(await _getCommitteeList());
setState(() {});
}
Widget _buildBottomNavi() { Widget _buildBottomNavi() {
return [ return [
MaterialButton( MaterialButton(
@ -65,11 +102,75 @@ class _IndustryCommitteePageState extends State<IndustryCommitteePage> {
].row(); ].row();
} }
Widget _buildCard(CommitteeItemModel model) {
return VxBox(
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
ClipRRect(
borderRadius: BorderRadius.circular(4.w),
child: SizedBox(
height: 150.w,
width: 150.w,
child: Placeholder(),
),
),
24.wb,
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
[
model.name.text.size(28.sp).color(ktextPrimary).make(),
Spacer(),
Container(
height: 44.w,
padding:
EdgeInsets.symmetric(horizontal: 22.w, vertical: 6.w),
child: 'XXX'.text.size(24.sp).color(ktextPrimary).make(),
decoration: BoxDecoration(
color: Color(0xFFFFF3CD),
borderRadius: BorderRadius.circular(22.w),
border: Border.all(color: Color(0xFFFFC40C), width: 1.w),
),
),
].row(),
6.hb,
...[
'住址:${model.roomName}'
.text
.size(24.sp)
.color(ktextSubColor)
.make(),
'任职期限XXXXX'.text.size(24.sp).color(ktextSubColor).make(),
'从事岗位:${model.profession}'
.text
.size(24.sp)
.color(ktextSubColor)
.make(),
].sepWidget(separate: 10.hb),
],
).expand(),
],
),
).padding(EdgeInsets.all(20.w)).white.withRounded(value: 8.w).make();
}
Widget build(BuildContext context) { Widget build(BuildContext context) {
return BeeScaffold( return BeeScaffold(
title: '业委会', title: '业委会',
body: Stack( body: EasyRefresh(
children: [], firstRefresh: true,
header: MaterialHeader(),
controller: _refreshController,
onRefresh: refresh,
child: ListView.separated(
padding: EdgeInsets.symmetric(horizontal: 32.w, vertical: 20.w),
itemBuilder: (context, index) {
return _buildCard(_committeeModels[index]);
},
separatorBuilder: (context, index) => 20.hb,
itemCount: _committeeModels.length,
),
), ),
bottomNavi: _buildBottomNavi(), bottomNavi: _buildBottomNavi(),
); );

@ -0,0 +1,27 @@
class BaseListModel {
int pageCount;
int rowCount;
List<dynamic> tableList;
BaseListModel({
this.pageCount,
this.rowCount,
this.tableList,
});
BaseListModel.zero({
this.pageCount = 0,
this.rowCount = 0,
this.tableList = const [],
});
BaseListModel.err({
this.pageCount = 0,
this.rowCount = 0,
this.tableList = const [],
});
BaseListModel.fromJson(Map<String, dynamic> json) {
pageCount = json['pageCount'] ?? 0;
rowCount = json['rowCount'] ?? 0;
tableList = json['tableList'] ?? [];
}
}

@ -1,4 +1,5 @@
import 'package:akuCommunity/utils/logger/logger_data.dart'; import 'package:akuCommunity/utils/logger/logger_data.dart';
import 'package:akuCommunity/utils/network/base_list_model.dart';
import 'package:akuCommunity/utils/network/base_model.dart'; import 'package:akuCommunity/utils/network/base_model.dart';
import 'package:bot_toast/bot_toast.dart'; import 'package:bot_toast/bot_toast.dart';
import 'package:dio/dio.dart'; import 'package:dio/dio.dart';
@ -37,6 +38,9 @@ class NetUtil {
_dio.options.headers.putIfAbsent('App-Admin-Token', () => token); _dio.options.headers.putIfAbsent('App-Admin-Token', () => token);
} }
/// ## alias of Dio().get
///
/// GET method
Future<BaseModel> get( Future<BaseModel> get(
String path, { String path, {
Map<String, dynamic> params, Map<String, dynamic> params,
@ -60,6 +64,11 @@ class NetUtil {
return BaseModel.err(); return BaseModel.err();
} }
/// ## alias of Dio().post
///
/// POST method
///
/// only work with JSON.
Future<BaseModel> post( Future<BaseModel> post(
String path, { String path, {
Map<String, dynamic> params, Map<String, dynamic> params,
@ -84,6 +93,27 @@ class NetUtil {
return BaseModel.err(); return BaseModel.err();
} }
Future<BaseListModel> getList(
String path, {
Map<String, dynamic> params,
}) async {
try {
Response res = await _dio.get(path, queryParameters: params);
_logger.v({
'path': res.request.path,
'header': res.request.headers,
'params': res.request.queryParameters,
'data': res.data,
});
LoggerData.addData(res);
BaseListModel baseListModel = BaseListModel.fromJson(res.data);
return baseListModel;
} on DioError catch (e) {
_parseErr(e);
}
return BaseListModel.err();
}
_parseErr(DioError err) { _parseErr(DioError err) {
_logger.v({ _logger.v({
'type': err.type.toString(), 'type': err.type.toString(),

Loading…
Cancel
Save