From 5c4c332e308afcbfc83a572959f12379e1bc913c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=AB=A0=E6=96=87=E8=BD=A9?= <12812285557@qq.com> Date: Fri, 12 Nov 2021 14:08:41 +0800 Subject: [PATCH] =?UTF-8?q?=E5=91=A8=E8=BE=B9=E4=BC=81=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/constants/api.dart | 5 ++ .../surrounding_enterprises_model.dart | 40 +++++++++++++ .../Surrounding_enterprises_page.dart | 56 ++++++++++++----- .../surrounding_enterprises_detail_page.dart | 60 +++++++++---------- 4 files changed, 115 insertions(+), 46 deletions(-) create mode 100644 lib/models/surrounding_enterprises/surrounding_enterprises_model.dart diff --git a/lib/constants/api.dart b/lib/constants/api.dart index b9369d30..3b5da96f 100644 --- a/lib/constants/api.dart +++ b/lib/constants/api.dart @@ -320,6 +320,11 @@ class _Manager { String get houseType => '/user/houseTypeDescription/list'; + + ///查询所有的周边企业信息 + String get surroundingEnterprises => + '/user/surroundingEnterprises/list'; + } class _Community { diff --git a/lib/models/surrounding_enterprises/surrounding_enterprises_model.dart b/lib/models/surrounding_enterprises/surrounding_enterprises_model.dart new file mode 100644 index 00000000..8bc76632 --- /dev/null +++ b/lib/models/surrounding_enterprises/surrounding_enterprises_model.dart @@ -0,0 +1,40 @@ +import 'package:aku_community/model/common/img_model.dart'; +import 'package:flustars/flustars.dart'; + +class SurroundingEnterprisesModel { + int? id; + String? name; + String? content; + String? releaseDate; + List? imgList; + + DateTime? get getReleaseDate => DateUtil.getDateTime(releaseDate!); + + SurroundingEnterprisesModel( + {this.id, this.name, this.content, this.releaseDate, this.imgList}); + + SurroundingEnterprisesModel.fromJson(Map json) { + id = json['id']; + name = json['name']; + content = json['content']; + releaseDate = json['releaseDate']; + if (json['imgList'] != null) { + imgList = []; + json['imgList'].forEach((v) { + imgList!.add(new ImgModel.fromJson(v)); + }); + } + } + + Map toJson() { + final Map data = new Map(); + data['id'] = this.id; + data['name'] = this.name; + data['content'] = this.content; + data['releaseDate'] = this.releaseDate; + if (this.imgList != null) { + data['imgList'] = this.imgList!.map((v) => v.toJson()).toList(); + } + return data; + } +} \ No newline at end of file diff --git a/lib/pages/surrounding_enterprises/Surrounding_enterprises_page.dart b/lib/pages/surrounding_enterprises/Surrounding_enterprises_page.dart index fb4c0584..d1922280 100644 --- a/lib/pages/surrounding_enterprises/Surrounding_enterprises_page.dart +++ b/lib/pages/surrounding_enterprises/Surrounding_enterprises_page.dart @@ -1,19 +1,17 @@ import 'package:aku_community/models/house_introduce/house_introduce_model.dart'; +import 'package:aku_community/models/surrounding_enterprises/surrounding_enterprises_model.dart'; import 'package:aku_community/pages/surrounding_enterprises/surrounding_enterprises_detail_page.dart'; -import 'package:aku_community/utils/hive_store.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 'package:velocity_x/velocity_x.dart'; import 'package:aku_community/base/base_style.dart'; import 'package:aku_community/constants/api.dart'; import 'package:aku_community/constants/app_theme.dart'; import 'package:aku_community/model/common/img_model.dart'; -import 'package:aku_community/model/user/committee_item_model.dart'; import 'package:aku_community/pages/things_page/widget/bee_list_view.dart'; import 'package:aku_community/utils/headers.dart'; import 'package:aku_community/widget/bee_scaffold.dart'; @@ -30,6 +28,8 @@ class SurroundingEnterprisesPage extends StatefulWidget { class _SurroundingEnterprisesPageState extends State { EasyRefreshController _refreshController = EasyRefreshController(); + int _page = 1; + int _size = 10; @override void initState() { super.initState(); @@ -44,10 +44,10 @@ class _SurroundingEnterprisesPageState extends State } - Widget _buildCard(HouseIntroduceModel model) { + Widget _buildCard(SurroundingEnterprisesModel model) { return GestureDetector( onTap: (){ - Get.to(SurroundingEnterprisesDetailPage(houseIntroduceModel: model,)); + Get.to(SurroundingEnterprisesDetailPage(surroundingEnterprisesModel: model,)); }, child: Container( padding: EdgeInsets.all(20.w), @@ -62,7 +62,7 @@ class _SurroundingEnterprisesPageState extends State borderRadius: BorderRadius.circular(4.w), child: FadeInImage.assetNetwork( placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP, - image: API.image(ImgModel.first(model.imgUrls)), + image: API.image(ImgModel.first(model.imgList)), height: 200.w, width: 240.w, fit: BoxFit.fill, @@ -86,13 +86,36 @@ class _SurroundingEnterprisesPageState extends State overflow: TextOverflow.ellipsis, ), ), - Spacer(), - '发布于:${model.getReleaseDate}' - .text - .size(20.sp) - .color(ktextThirdColor) - .make(), + 20.hb, + Container( + width: 440.w, + child: Text( + '${model.content}', + style: TextStyle( + fontSize: 24.sp, + color: ktextPrimary + ), + maxLines: 2, + overflow: TextOverflow.ellipsis, + ), + ), + Spacer(), + Row( + children: [ + '南宁人才公寓' + .text + .size(20.sp) + .color(ktextThirdColor) + .make(), + Spacer(), + '发布于:${model.getReleaseDate}' + .text + .size(20.sp) + .color(ktextThirdColor) + .make(), + ], + ) ], ), ], @@ -103,13 +126,14 @@ class _SurroundingEnterprisesPageState extends State Widget build(BuildContext context) { return BeeScaffold( - title: '住房介绍', + title: '周边企业', systemStyle: SystemStyle.genStyle(bottom: Color(0xFF2A2A2A)), - body: BeeListView( - path: API.manager.houseType, + body: BeeListView( + path: API.manager.surroundingEnterprises, + extraParams: {'pageNum': _page, 'size': _size}, convert: (model) { return model.tableList! - .map((e) => HouseIntroduceModel.fromJson(e)) + .map((e) => SurroundingEnterprisesModel.fromJson(e)) .toList(); }, controller: _refreshController, diff --git a/lib/pages/surrounding_enterprises/surrounding_enterprises_detail_page.dart b/lib/pages/surrounding_enterprises/surrounding_enterprises_detail_page.dart index 886ef45f..2ba9a1e3 100644 --- a/lib/pages/surrounding_enterprises/surrounding_enterprises_detail_page.dart +++ b/lib/pages/surrounding_enterprises/surrounding_enterprises_detail_page.dart @@ -1,4 +1,5 @@ import 'package:aku_community/models/house_introduce/house_introduce_model.dart'; +import 'package:aku_community/models/surrounding_enterprises/surrounding_enterprises_model.dart'; import 'package:flutter/material.dart'; import 'package:flutter_easyrefresh/easy_refresh.dart'; @@ -15,9 +16,9 @@ import 'package:aku_community/utils/network/net_util.dart'; import 'package:aku_community/widget/bee_scaffold.dart'; class SurroundingEnterprisesDetailPage extends StatefulWidget { - final HouseIntroduceModel houseIntroduceModel; + final SurroundingEnterprisesModel surroundingEnterprisesModel; - SurroundingEnterprisesDetailPage({Key? key, required this.houseIntroduceModel}) + SurroundingEnterprisesDetailPage({Key? key, required this.surroundingEnterprisesModel}) : super(key: key); @override @@ -25,7 +26,6 @@ class SurroundingEnterprisesDetailPage extends StatefulWidget { } class _SurroundingEnterprisesDetailPageState extends State { - bool _onload = false; @override Widget build(BuildContext context) { @@ -39,38 +39,38 @@ class _SurroundingEnterprisesDetailPageState extends State