From a1597faeb1444015ec8a06734bbd3143235f3356 Mon Sep 17 00:00:00 2001 From: zhang <494089941@qq.com> Date: Thu, 4 Feb 2021 17:26:06 +0800 Subject: [PATCH] dock interface:eventVoting/list add event voting detail page --- lib/constants/api.dart | 3 + lib/model/manager/event_voting_model.dart | 30 +++-- lib/model/manager/voting_detail_page.dart | 119 ++++++++++++++++++ .../event_activity/event_voting_page.dart | 23 +++- .../event_activity/voting_detail_page.dart | 39 ++++++ lib/pages/manager_func.dart | 19 ++- 6 files changed, 211 insertions(+), 22 deletions(-) create mode 100644 lib/model/manager/voting_detail_page.dart create mode 100644 lib/pages/event_activity/voting_detail_page.dart diff --git a/lib/constants/api.dart b/lib/constants/api.dart index 53ede965..2b5c52d3 100644 --- a/lib/constants/api.dart +++ b/lib/constants/api.dart @@ -148,6 +148,9 @@ class _Manager { ///活动投票:app查询所有活动投票信息 String get enventVotingList => '/user/eventVoting/list'; + + ///活动投票:投票详情 + String get voteDetail => '/user/eventVoting/voteDetail'; } class _Community { diff --git a/lib/model/manager/event_voting_model.dart b/lib/model/manager/event_voting_model.dart index 536dfc9a..62a01680 100644 --- a/lib/model/manager/event_voting_model.dart +++ b/lib/model/manager/event_voting_model.dart @@ -1,3 +1,5 @@ +import 'package:akuCommunity/model/common/img_model.dart'; + class EventVotingModel { int id; String title; @@ -5,8 +7,8 @@ class EventVotingModel { String beginDate; String endDate; int status; - List imgUrls; - List headImgURls; + List imgUrls; + List headImgURls; EventVotingModel( {this.id, @@ -25,13 +27,19 @@ class EventVotingModel { beginDate = json['beginDate']; endDate = json['endDate']; status = json['status']; - imgUrls = json['imgUrls'].cast(); + if (json['imgUrls'] != null) { + imgUrls = new List(); + json['imgUrls'].forEach((v) { + imgUrls.add(new ImgModel.fromJson(v)); + }); + } else + imgUrls = []; if (json['headImgURls'] != null) { - headImgURls = new List(); + headImgURls = new List(); json['headImgURls'].forEach((v) { - headImgURls.add(new HeadImgURls.fromJson(v)); + headImgURls.add(new ImgModel.fromJson(v)); }); - } + }else headImgURls=[]; } Map toJson() { @@ -42,7 +50,9 @@ class EventVotingModel { data['beginDate'] = this.beginDate; data['endDate'] = this.endDate; data['status'] = this.status; - data['imgUrls'] = this.imgUrls; + if (this.imgUrls != null) { + data['imgUrls'] = this.imgUrls.map((v) => v.toJson()).toList(); + } if (this.headImgURls != null) { data['headImgURls'] = this.headImgURls.map((v) => v.toJson()).toList(); } @@ -50,16 +60,16 @@ class EventVotingModel { } } -class HeadImgURls { +class ImgUrls { String url; String size; int longs; int paragraph; int sort; - HeadImgURls({this.url, this.size, this.longs, this.paragraph, this.sort}); + ImgUrls({this.url, this.size, this.longs, this.paragraph, this.sort}); - HeadImgURls.fromJson(Map json) { + ImgUrls.fromJson(Map json) { url = json['url']; size = json['size']; longs = json['longs']; diff --git a/lib/model/manager/voting_detail_page.dart b/lib/model/manager/voting_detail_page.dart new file mode 100644 index 00000000..47e5e2e2 --- /dev/null +++ b/lib/model/manager/voting_detail_page.dart @@ -0,0 +1,119 @@ +import 'package:akuCommunity/model/common/img_model.dart'; + +class VotingDetailModel { + int id; + String title; + String content; + int status; + int totals; + List imgUrls; + List appVoteCandidateVos; + + VotingDetailModel( + {this.id, + this.title, + this.content, + this.status, + this.totals, + this.imgUrls, + this.appVoteCandidateVos}); + + VotingDetailModel.fromJson(Map json) { + id = json['id']; + title = json['title']; + content = json['content']; + status = json['status']; + totals = json['totals']; + if (json['imgUrls'] != null) { + imgUrls = new List(); + json['imgUrls'].forEach((v) { + imgUrls.add(new ImgModel.fromJson(v)); + }); + } else + imgUrls = []; + if (json['appVoteCandidateVos'] != null) { + appVoteCandidateVos = new List(); + json['appVoteCandidateVos'].forEach((v) { + appVoteCandidateVos.add(new AppVoteCandidateVos.fromJson(v)); + }); + } + } + + Map toJson() { + final Map data = new Map(); + data['id'] = this.id; + data['title'] = this.title; + data['content'] = this.content; + data['status'] = this.status; + data['totals'] = this.totals; + if (this.imgUrls != null) { + data['imgUrls'] = this.imgUrls.map((v) => v.toJson()).toList(); + } + if (this.appVoteCandidateVos != null) { + data['appVoteCandidateVos'] = + this.appVoteCandidateVos.map((v) => v.toJson()).toList(); + } + return data; + } +} + +class ImgUrls { + String url; + String size; + int longs; + int paragraph; + int sort; + + ImgUrls({this.url, this.size, this.longs, this.paragraph, this.sort}); + + ImgUrls.fromJson(Map json) { + url = json['url']; + size = json['size']; + longs = json['longs']; + paragraph = json['paragraph']; + sort = json['sort']; + } + + Map toJson() { + final Map data = new Map(); + data['url'] = this.url; + data['size'] = this.size; + data['longs'] = this.longs; + data['paragraph'] = this.paragraph; + data['sort'] = this.sort; + return data; + } +} + +class AppVoteCandidateVos { + int id; + String name; + int total; + List imgUrls; + + AppVoteCandidateVos({this.id, this.name, this.total, this.imgUrls}); + + AppVoteCandidateVos.fromJson(Map json) { + id = json['id']; + name = json['name']; + total = json['total']; + if (json['imgUrls'] != null) { + imgUrls = new List(); + json['imgUrls'].forEach((v) { + imgUrls.add(new ImgModel.fromJson(v)); + }); + } else + imgUrls = []; + } + + Map toJson() { + final Map data = new Map(); + data['id'] = this.id; + data['name'] = this.name; + data['total'] = this.total; + if (this.imgUrls != null) { + data['imgUrls'] = this.imgUrls.map((v) => v.toJson()).toList(); + } + return data; + } +} diff --git a/lib/pages/event_activity/event_voting_page.dart b/lib/pages/event_activity/event_voting_page.dart index a14f5ba8..48a28326 100644 --- a/lib/pages/event_activity/event_voting_page.dart +++ b/lib/pages/event_activity/event_voting_page.dart @@ -1,6 +1,7 @@ import 'package:akuCommunity/base/base_style.dart'; import 'package:akuCommunity/constants/api.dart'; import 'package:akuCommunity/model/manager/event_voting_model.dart'; +import 'package:akuCommunity/pages/event_activity/voting_detail_page.dart'; import 'package:akuCommunity/pages/things_page/widget/bee_list_view.dart'; import 'package:akuCommunity/widget/bee_scaffold.dart'; import 'package:akuCommunity/widget/others/stack_avatar.dart'; @@ -44,15 +45,20 @@ class _EventVotingPageState extends State { Widget _buildCard(EventVotingModel model) { return Container( - clipBehavior: Clip.antiAliasWithSaveLayer, + // clipBehavior: Clip., decoration: BoxDecoration( color: kForeGroundColor, borderRadius: BorderRadius.circular(8.w)), child: Column( children: [ - ClipRect( - child: FadeInImage.assetNetwork( - placeholder: R.ASSETS_IMAGES_LOGO_PNG, - image: API.image(model.imgUrls[0])), + SizedBox( + height: 210.w, + width: double.infinity, + child: ClipRect( + child: FadeInImage.assetNetwork( + placeholder: R.ASSETS_IMAGES_LOGO_PNG, + image: API.image( + model.imgUrls.isNotEmpty ? model.imgUrls.first.url : '')), + ), ), Padding( padding: EdgeInsets.fromLTRB(24.w, 16.w, 24.w, 24.w), @@ -90,12 +96,17 @@ class _EventVotingPageState extends State { avatars: model.headImgURls.map((e) => e.url).toList()), Spacer(), MaterialButton( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(22.w)), color: model.status == 3 ? kDarkSubColor : kPrimaryColor, minWidth: 120.w, + height: 44.w, padding: EdgeInsets.symmetric(horizontal: 30.w, vertical: 8.w), elevation: 0, - onPressed: () {}, + onPressed: () { + VotingDetailPage(id: model.id,).to(); + }, child: (_getButtonText(model.status)) .text .black diff --git a/lib/pages/event_activity/voting_detail_page.dart b/lib/pages/event_activity/voting_detail_page.dart new file mode 100644 index 00000000..63ceab89 --- /dev/null +++ b/lib/pages/event_activity/voting_detail_page.dart @@ -0,0 +1,39 @@ +import 'package:akuCommunity/model/manager/voting_detail_page.dart'; +import 'package:akuCommunity/pages/manager_func.dart'; +import 'package:akuCommunity/widget/bee_scaffold.dart'; +import 'package:flutter/material.dart'; +import 'package:akuCommunity/utils/headers.dart'; + +class VotingDetailPage extends StatefulWidget { + final int id; + VotingDetailPage({Key key, this.id}) : super(key: key); + + @override + _VotingDetailPageState createState() => _VotingDetailPageState(); +} + +class _VotingDetailPageState extends State { + VotingDetailModel _model; + @override + void initState() { + super.initState(); + ManagerFunc.voteDetail(widget.id).then((value) { + _model = value.data; + return true; + }); + } + + @override + Widget build(BuildContext context) { + return BeeScaffold( + title: '活动详情', + body: ListView( + padding: EdgeInsets.symmetric( + horizontal: 32.w, + vertical: 26.w, + ), + children: [], + ), + ); + } +} diff --git a/lib/pages/manager_func.dart b/lib/pages/manager_func.dart index f11a6667..a81fc613 100644 --- a/lib/pages/manager_func.dart +++ b/lib/pages/manager_func.dart @@ -147,23 +147,30 @@ class ManagerFunc { ); return baseModel; } - - static Future fromLoss(int id)async{ + + static Future fromLoss(int id) async { BaseModel baseModel = await NetUtil().post( API.manager.fromLoss, - params: { - 'articleBorrowId':id - }, + params: {'articleBorrowId': id}, showMessage: true, ); return baseModel; } - static Future findEstatelsPayment()async{ + static Future findEstatelsPayment() async { BaseModel baseModel = await NetUtil().get( API.manager.findEstatelsPament, showMessage: false, ); return baseModel.data; } + + static Future voteDetail(int id) async { + BaseModel baseModel = await NetUtil().get(API.manager.voteDetail, + params: { + 'voteId': 1, + }, + showMessage: false); + return baseModel.data; + } }