diff --git a/lib/constants/saas_api.dart b/lib/constants/saas_api.dart index e3110241..e87e8f3e 100644 --- a/lib/constants/saas_api.dart +++ b/lib/constants/saas_api.dart @@ -39,6 +39,7 @@ class SAASAPI { static _Balance balance = _Balance(); static _CommunityIntroduce communityIntroduce = _CommunityIntroduce(); static _ConveniencePhone conveniencePhone = _ConveniencePhone(); + static _CommitteeStaff committeeStaff = _CommitteeStaff(); ///二级分类 static _ProfileApi profile = _ProfileApi(); @@ -352,3 +353,7 @@ class _ConveniencePhone { ///查询app便民电话 String get list => '/app/user/conveniencePhone/list'; } +class _CommitteeStaff { + ///查询业委会列表 + String get list => '/app/user/industryCommittee/list'; +} \ No newline at end of file diff --git a/lib/model/user/committee_item_model.dart b/lib/model/user/committee_item_model.dart index bfc15d40..6565a1da 100644 --- a/lib/model/user/committee_item_model.dart +++ b/lib/model/user/committee_item_model.dart @@ -1,86 +1,53 @@ import 'package:aku_new_community/model/common/img_model.dart'; +import 'package:common_utils/common_utils.dart'; +import 'package:json_annotation/json_annotation.dart'; +@JsonSerializable() class CommitteeItemModel { - int? id; - int? positionId; - String? name; - int? sexId; - int? age; - int? educationId; - String? roomName; - String? profession; - String? roomNumber; - int? unitNo; - int? estateNo; - List? imgUrls; + final int? id; + final String? name; + final String? tel; + final String? industryCommitteeTypeName; + final String? buildingName; + final String? unitName; + final String? estateName; + final String? appointmentStartTime; + final String? appointmentEndTime; + final String? createDate; + final List? imgList; - String get sexValue { - if (sexId == 0 || sexId == null) return '未设置'; - if (sexId == 1) return '男'; - if (sexId == 2) return '女'; - return '未设置'; - } - - String get positionValue { - switch (positionId) { - case 1: - return '业委会主任'; - case 2: - return '业委会副主任'; - case 3: - return '业委会委员'; - default: - return ''; - } - } - - CommitteeItemModel({ - this.id, - this.positionId, - this.name, - this.sexId, - this.age, - this.educationId, - this.roomName, - this.profession, - this.roomNumber, - this.unitNo, - this.estateNo, - this.imgUrls, + factory CommitteeItemModel.fromJson(Map json) => + _$CommitteeItemModel(json); + DateTime? get appointmentStartDT => DateUtil.getDateTime(appointmentStartTime!); + DateTime? get appointmentEndDT => DateUtil.getDateTime(appointmentEndTime!); + DateTime? get createDateDT => DateUtil.getDateTime(createDate!); + const CommitteeItemModel({ + required this.id, + required this.name, + required this.tel, + required this.industryCommitteeTypeName, + required this.buildingName, + required this.unitName, + required this.estateName, + required this.appointmentStartTime, + required this.appointmentEndTime, + required this.createDate, + required this.imgList, }); - - CommitteeItemModel.fromJson(Map 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']; - if (json['imgUrls'] != null) { - imgUrls = - (json['imgUrls'] as List).map((e) => ImgModel.fromJson(e)).toList(); - } else - imgUrls = []; - } - - Map toJson() { - final Map data = new Map(); - 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; - } } +CommitteeItemModel _$CommitteeItemModel(Map json) => + CommitteeItemModel( + id: json['id'] as int, + name: json['name'] as String, + tel: json['tel'] as String, + industryCommitteeTypeName: json['industryCommitteeTypeName'] as String, + buildingName: json['buildingName'] as String, + unitName: json['unitName'] as String, + estateName: json['estateName'] as String, + appointmentStartTime: json['appointmentStartTime'] as String, + appointmentEndTime: json['appointmentEndTime'] as String, + createDate: json['createDate'] as String, + imgList: (json['imgList'] as List) + .map((e) => ImgModel.fromJson(e as Map)) + .toList(), + ); \ No newline at end of file diff --git a/lib/pages/industry_committee/industry_committee_page.dart b/lib/pages/industry_committee/industry_committee_page.dart index 63724928..745b43cf 100644 --- a/lib/pages/industry_committee/industry_committee_page.dart +++ b/lib/pages/industry_committee/industry_committee_page.dart @@ -9,12 +9,15 @@ import 'package:aku_new_community/utils/headers.dart'; import 'package:aku_new_community/utils/hive_store.dart'; import 'package:aku_new_community/utils/websocket/tips_dialog.dart'; import 'package:aku_new_community/widget/bee_scaffold.dart'; +import 'package:common_utils/common_utils.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_easyrefresh/easy_refresh.dart'; import 'package:get/get.dart'; import 'package:url_launcher/url_launcher.dart'; +import '../../utils/network/net_util.dart'; + class IndustryCommitteePage extends StatefulWidget { IndustryCommitteePage({Key? key}) : super(key: key); @@ -23,19 +26,20 @@ class IndustryCommitteePage extends StatefulWidget { } class _IndustryCommitteePageState extends State { + List _models = []; EasyRefreshController _refreshController = EasyRefreshController(); @override void initState() { super.initState(); - Future.delayed(Duration(milliseconds: 0), () async { - var agreement = - await HiveStore.appBox?.get('IndustryCommitteePage') ?? false; - if (!agreement) { - await TipsDialog.tipsDialog(); - HiveStore.appBox!.put('IndustryCommitteePage', true); - } - }); + // Future.delayed(Duration(milliseconds: 0), () async { + // var agreement = + // await HiveStore.appBox?.get('IndustryCommitteePage') ?? false; + // if (!agreement) { + // await TipsDialog.tipsDialog(); + // HiveStore.appBox!.put('IndustryCommitteePage', true); + // } + // }); } Widget _buildBottomNavi() { @@ -95,7 +99,7 @@ class _IndustryCommitteePageState extends State { borderRadius: BorderRadius.circular(4.w), child: FadeInImage.assetNetwork( placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP, - image: SAASAPI.image(ImgModel.first(model.imgUrls)), + image: SAASAPI.image(ImgModel.first(model.imgList)), height: 150.w, width: 150.w, fit: BoxFit.cover, @@ -112,9 +116,10 @@ class _IndustryCommitteePageState extends State { height: 44.w, padding: EdgeInsets.symmetric(horizontal: 22.w, vertical: 6.w), - child: model.positionValue.text + child: model.industryCommitteeTypeName!.text .size(24.sp) .color(ktextPrimary) + .bold .make(), decoration: BoxDecoration( color: Color(0xFFFFF3CD), @@ -123,17 +128,17 @@ class _IndustryCommitteePageState extends State { ), ), ].row(), - 6.hb, + 15.hb, ...[ - '住址:${model.roomName}' + '住址:${model.buildingName}幢${model.unitName}单元${model.estateName}房间' .text - .size(24.sp) + .size(23.sp) .color(ktextSubColor) .make(), // '任职期限:XXXXX'.text.size(24.sp).color(ktextSubColor).make(), - '从事岗位:${model.profession}' + '任职期限:${DateUtil.formatDate(model.appointmentStartDT, format: 'yyyy年MM月dd日')}-${DateUtil.formatDate(model.appointmentEndDT, format: 'yyyy年MM月dd日')}' .text - .size(24.sp) + .size(23.sp) .color(ktextSubColor) .make(), ].sepWidget(separate: 10.hb), @@ -148,23 +153,54 @@ class _IndustryCommitteePageState extends State { return BeeScaffold( title: '业委会', systemStyle: SystemStyle.genStyle(bottom: Color(0xFF2A2A2A)), - body: BeeListView( - path: API.manager.commiteeStaff, - convert: (model) { - return model.rows.map((e) => CommitteeItemModel.fromJson(e)).toList(); - }, - controller: _refreshController, - builder: (items) { - return ListView.separated( - padding: EdgeInsets.symmetric(horizontal: 32.w, vertical: 20.w), + body: Container( + child: EasyRefresh( + firstRefresh: true, + header: MaterialHeader(), + controller: _refreshController, + onRefresh: () async { + var base = await NetUtil().get(SAASAPI.committeeStaff.list); + if (base.success) { + print(base.success); + _models = (base.data as List) + .map((e) => CommitteeItemModel.fromJson(e)) + .toList(); + } + setState(() {}); + }, + child: ListView.separated( + padding: EdgeInsets.symmetric(horizontal: 32.w, vertical: 24.w), itemBuilder: (context, index) { - return _buildCard(items[index]); + return _buildCard(_models[index]); }, - separatorBuilder: (context, index) => 20.hb, - itemCount: items.length, - ); - }, + separatorBuilder: (context, index) { + return Divider( + thickness: 1.w, + height: 40.w, + color: Color(0xFFD8D8D8), + ); + }, + itemCount: _models.length, + ), + ), ), + // BeeListView( + // path: SAASAPI.committeeStaff.list, + // convert: (model) { + // return model.rows.map((e) => CommitteeItemModel.fromJson(e)).toList(); + // }, + // controller: _refreshController, + // builder: (items) { + // return ListView.separated( + // padding: EdgeInsets.symmetric(horizontal: 32.w, vertical: 20.w), + // itemBuilder: (context, index) { + // return _buildCard(items[index]); + // }, + // separatorBuilder: (context, index) => 20.hb, + // itemCount: items.length, + // ); + // }, + // ), bottomNavi: _buildBottomNavi(), ); } diff --git a/lib/utils/application_utils.dart b/lib/utils/application_utils.dart index 2b21d711..d8d40ce5 100644 --- a/lib/utils/application_utils.dart +++ b/lib/utils/application_utils.dart @@ -71,8 +71,6 @@ class ApplicationUtil { title: '业委会', imgPath: Assets.newIcon.icYwh.path, onTap: () { - BotToast.showText(text: '此功能暂未上线'); - return; Get.to(() => IndustryCommitteePage()); }), // AppElement('建议咨询', R.ASSETS_ICONS_FUNC_JYZX_PNG, @@ -111,8 +109,6 @@ class ApplicationUtil { title: '问卷调查', imgPath: Assets.newIcon.icWjdc.path, onTap: () { - BotToast.showText(text: '此功能暂未上线'); - return; Get.to(() => QuestionnairePage()); }), AppElement(