投票功能

pull/1/head
戴余标 3 years ago
parent 5036d2e368
commit 5daea645f9

@ -41,6 +41,7 @@ class SAASAPI {
static _ConveniencePhone conveniencePhone = _ConveniencePhone(); static _ConveniencePhone conveniencePhone = _ConveniencePhone();
static _CommitteeStaff committeeStaff = _CommitteeStaff(); static _CommitteeStaff committeeStaff = _CommitteeStaff();
static _Advice advice = _Advice(); static _Advice advice = _Advice();
static _Vote vote = _Vote();
/// ///
static _ProfileApi profile = _ProfileApi(); static _ProfileApi profile = _ProfileApi();
@ -373,4 +374,12 @@ class _Advice{
String get evaluate => '/app/user/advice/evaluate'; String get evaluate => '/app/user/advice/evaluate';
//// ////
String get delete => '/app/user/advice/delete'; String get delete => '/app/user/advice/delete';
}
class _Vote{
///
String get list =>'/app/user/vote/list';
///
String get vote =>'/app/user/vote/vote';
///
String get details =>'/app/user/vote/details';
} }

@ -1,4 +1,5 @@
import 'package:aku_new_community/model/common/img_model.dart'; import 'package:aku_new_community/model/common/img_model.dart';
import 'package:common_utils/common_utils.dart';
class EventVotingModel { class EventVotingModel {
int? id; int? id;
@ -9,6 +10,11 @@ class EventVotingModel {
int? status; int? status;
List<ImgModel>? imgUrls; List<ImgModel>? imgUrls;
List<ImgModel>? headImgURls; List<ImgModel>? headImgURls;
bool? vote;
bool? allowVote;
DateTime? get beginDT => DateUtil.getDateTime(beginDate!);
DateTime? get endDT => DateUtil.getDateTime(endDate!);
EventVotingModel( EventVotingModel(
{this.id, {this.id,
@ -18,7 +24,9 @@ class EventVotingModel {
this.endDate, this.endDate,
this.status, this.status,
this.imgUrls, this.imgUrls,
this.headImgURls}); this.headImgURls,
this.vote,
this.allowVote,});
EventVotingModel.fromJson(Map<String, dynamic> json) { EventVotingModel.fromJson(Map<String, dynamic> json) {
id = json['id']; id = json['id'];
@ -27,20 +35,22 @@ class EventVotingModel {
beginDate = json['beginDate']; beginDate = json['beginDate'];
endDate = json['endDate']; endDate = json['endDate'];
status = json['status']; status = json['status'];
if (json['imgUrls'] != null) { if (json['imgList'] != null) {
imgUrls = []; imgUrls = [];
json['imgUrls'].forEach((v) { json['imgList'].forEach((v) {
imgUrls!.add(new ImgModel.fromJson(v)); imgUrls!.add(new ImgModel.fromJson(v));
}); });
} else } else
imgUrls = []; imgUrls = [];
if (json['headImgURls'] != null) { if (json['headImgList'] != null) {
headImgURls = []; headImgURls = [];
json['headImgURls'].forEach((v) { json['headImgList'].forEach((v) {
headImgURls!.add(new ImgModel.fromJson(v)); headImgURls!.add(new ImgModel.fromJson(v));
}); });
} else } else
headImgURls = []; headImgURls = [];
vote=json['vote'];
allowVote=json['allowVote'];
} }
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
@ -52,11 +62,13 @@ class EventVotingModel {
data['endDate'] = this.endDate; data['endDate'] = this.endDate;
data['status'] = this.status; data['status'] = this.status;
if (this.imgUrls != null) { if (this.imgUrls != null) {
data['imgUrls'] = this.imgUrls!.map((v) => v.toJson()).toList(); data['imgList'] = this.imgUrls!.map((v) => v.toJson()).toList();
} }
if (this.headImgURls != null) { if (this.headImgURls != null) {
data['headImgURls'] = this.headImgURls!.map((v) => v.toJson()).toList(); data['headImgList'] = this.headImgURls!.map((v) => v.toJson()).toList();
} }
data['vote'] = this.vote;
data['allowVote'] = this.allowVote;
return data; return data;
} }
} }

@ -1,4 +1,5 @@
import 'package:aku_new_community/model/common/img_model.dart'; import 'package:aku_new_community/model/common/img_model.dart';
import 'package:common_utils/common_utils.dart';
class VotingDetailModel { class VotingDetailModel {
int? id; int? id;
@ -6,8 +7,17 @@ class VotingDetailModel {
String? content; String? content;
int? status; int? status;
int? totals; int? totals;
String? beginDate;
String? endDate;
List<ImgModel>? imgUrls; List<ImgModel>? imgUrls;
List<AppVoteCandidateVos>? appVoteCandidateVos; List<AppVoteCandidateVos>? appVoteCandidateVos;
bool? vote;
bool? allowVote;
DateTime? get beginDT => DateUtil.getDateTime(beginDate!);
DateTime? get endDT => DateUtil.getDateTime(endDate!);
VotingDetailModel( VotingDetailModel(
{this.id, {this.id,
@ -15,8 +25,12 @@ class VotingDetailModel {
this.content, this.content,
this.status, this.status,
this.totals, this.totals,
this.beginDate,
this.endDate,
this.imgUrls, this.imgUrls,
this.appVoteCandidateVos}); this.appVoteCandidateVos,
this.vote,
this.allowVote});
VotingDetailModel.fromJson(Map<String, dynamic> json) { VotingDetailModel.fromJson(Map<String, dynamic> json) {
id = json['id']; id = json['id'];
@ -24,19 +38,23 @@ class VotingDetailModel {
content = json['content']; content = json['content'];
status = json['status']; status = json['status'];
totals = json['totals']; totals = json['totals'];
if (json['imgUrls'] != null) { beginDate = json['beginDate'];
endDate = json['endDate'];
if (json['imgList'] != null) {
imgUrls = []; imgUrls = [];
json['imgUrls'].forEach((v) { json['imgList'].forEach((v) {
imgUrls!.add(new ImgModel.fromJson(v)); imgUrls!.add(new ImgModel.fromJson(v));
}); });
} else } else
imgUrls = []; imgUrls = [];
if (json['appVoteCandidateVos'] != null) { if (json['candidateVoList'] != null) {
appVoteCandidateVos = []; appVoteCandidateVos = [];
json['appVoteCandidateVos'].forEach((v) { json['candidateVoList'].forEach((v) {
appVoteCandidateVos!.add(new AppVoteCandidateVos.fromJson(v)); appVoteCandidateVos!.add(new AppVoteCandidateVos.fromJson(v));
}); });
} }
vote = json['vote'];
allowVote = json['allowVote'];
} }
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
@ -47,12 +65,14 @@ class VotingDetailModel {
data['status'] = this.status; data['status'] = this.status;
data['totals'] = this.totals; data['totals'] = this.totals;
if (this.imgUrls != null) { if (this.imgUrls != null) {
data['imgUrls'] = this.imgUrls!.map((v) => v.toJson()).toList(); data['imgList'] = this.imgUrls!.map((v) => v.toJson()).toList();
} }
if (this.appVoteCandidateVos != null) { if (this.appVoteCandidateVos != null) {
data['appVoteCandidateVos'] = data['candidateVoList'] =
this.appVoteCandidateVos!.map((v) => v.toJson()).toList(); this.appVoteCandidateVos!.map((v) => v.toJson()).toList();
} }
data['vote']=this.vote;
data['allowVote']=this.allowVote;
return data; return data;
} }
} }
@ -97,9 +117,9 @@ class AppVoteCandidateVos {
id = json['id']; id = json['id'];
name = json['name']; name = json['name'];
total = json['total']; total = json['total'];
if (json['imgUrls'] != null) { if (json['imgList'] != null) {
imgUrls = []; imgUrls = [];
json['imgUrls'].forEach((v) { json['imgList'].forEach((v) {
imgUrls!.add(new ImgModel.fromJson(v)); imgUrls!.add(new ImgModel.fromJson(v));
}); });
} else } else
@ -112,7 +132,7 @@ class AppVoteCandidateVos {
data['name'] = this.name; data['name'] = this.name;
data['total'] = this.total; data['total'] = this.total;
if (this.imgUrls != null) { if (this.imgUrls != null) {
data['imgUrls'] = this.imgUrls!.map((v) => v.toJson()).toList(); data['imgList'] = this.imgUrls!.map((v) => v.toJson()).toList();
} }
return data; return data;
} }

@ -8,6 +8,7 @@ import 'package:aku_new_community/pages/things_page/widget/bee_list_view.dart';
import 'package:aku_new_community/utils/headers.dart'; import 'package:aku_new_community/utils/headers.dart';
import 'package:aku_new_community/widget/bee_scaffold.dart'; import 'package:aku_new_community/widget/bee_scaffold.dart';
import 'package:aku_new_community/widget/others/stack_avatar.dart'; import 'package:aku_new_community/widget/others/stack_avatar.dart';
import 'package:common_utils/common_utils.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_easyrefresh/easy_refresh.dart'; import 'package:flutter_easyrefresh/easy_refresh.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
@ -37,12 +38,11 @@ class _EventVotingPageState extends State<EventVotingPage> {
String _getButtonText(int? status) { String _getButtonText(int? status) {
switch (status) { switch (status) {
case 1: case 1:
return '未开始';
case 2: case 2:
return '去参与'; return '进行中';
case 3: case 3:
return '已结束'; return '已结束';
case 4:
return '已填写';
default: default:
return ''; return '';
} }
@ -92,7 +92,7 @@ class _EventVotingPageState extends State<EventVotingPage> {
color: ktextPrimary, color: ktextPrimary,
fontSize: 24.sp, fontSize: 24.sp,
), ),
text: model.beginDate! + '' + model.endDate!, text: DateUtil.formatDate(model.beginDT,format: 'MM月dd日 HH:mm',) + '' + DateUtil.formatDate(model.endDT,format: 'MM月dd日 HH:mm',),
), ),
])), ])),
16.w.heightBox, 16.w.heightBox,
@ -135,7 +135,7 @@ class _EventVotingPageState extends State<EventVotingPage> {
return BeeScaffold( return BeeScaffold(
title: '活动投票', title: '活动投票',
body: BeeListView<EventVotingModel>( body: BeeListView<EventVotingModel>(
path: API.manager.enventVotingList, path: SAASAPI.vote.list,
controller: _controller, controller: _controller,
convert: (model) { convert: (model) {
return model.rows.map((e) => EventVotingModel.fromJson(e)).toList(); return model.rows.map((e) => EventVotingModel.fromJson(e)).toList();

@ -35,7 +35,7 @@ class _VotingDetailPageState extends State<VotingDetailPage> {
bool _hasVoted = false; bool _hasVoted = false;
bool get finishVoted { bool get finishVoted {
if ((_model.status == 4) || _hasVoted || (_model.status == 3)) { if ((_model.vote!) || _hasVoted || (_model.status == 3)) {
return true; return true;
} }
return false; return false;
@ -268,9 +268,13 @@ class _VotingDetailPageState extends State<VotingDetailPage> {
), ),
bottomNavi: BottomButton( bottomNavi: BottomButton(
onPressed: _model.status != 2 onPressed: _model.status != 2
? () {} ? () {
BotToast.showText(text: '投票未开始或已结束');
}
: () async { : () async {
if (_selectId == null) { if (_model.allowVote!) {
BotToast.showText(text: '投票失败');
} else if (_selectId == null) {
BotToast.showText(text: '请先选择候选人!'); BotToast.showText(text: '请先选择候选人!');
} else { } else {
BaseModel baseModel = BaseModel baseModel =

@ -18,7 +18,7 @@ class ManagerFunc {
static insertVisitorInfo(int id, int type, String name, int sex, String tel, static insertVisitorInfo(int id, int type, String name, int sex, String tel,
String carNum, DateTime expectedVisitDate) async { String carNum, DateTime expectedVisitDate) async {
BaseModel baseModel = await NetUtil().post( BaseModel baseModel = await NetUtil().post(
API.manager.insertVisitorInfo, SAASAPI.vote.details,
params: { params: {
'buildingUnitEstateId': id, 'buildingUnitEstateId': id,
'type': type, 'type': type,
@ -214,7 +214,7 @@ class ManagerFunc {
static Future<VotingDetailModel> voteDetail(int? id) async { static Future<VotingDetailModel> voteDetail(int? id) async {
BaseModel baseModel = await NetUtil().get( BaseModel baseModel = await NetUtil().get(
API.manager.voteDetail, SAASAPI.vote.details,
params: {'voteId': id}, params: {'voteId': id},
showMessage: false, showMessage: false,
); );
@ -222,8 +222,8 @@ class ManagerFunc {
} }
static Future<BaseModel> vote(int? voteId, int? candleId) async { static Future<BaseModel> vote(int? voteId, int? candleId) async {
BaseModel baseModel = await NetUtil().post(API.manager.vote, params: { BaseModel baseModel = await NetUtil().post(SAASAPI.vote.vote, params: {
'voteId': voteId, 'id': voteId,
'candidateId': candleId, 'candidateId': candleId,
}); });
return baseModel; return baseModel;

@ -33,7 +33,7 @@ class _QuestionnairePageState extends State<QuestionnairePage> {
Future.delayed(Duration(milliseconds: 0), () async { Future.delayed(Duration(milliseconds: 0), () async {
var agreement = await HiveStore.appBox?.get('QuestionnairePage') ?? false; var agreement = await HiveStore.appBox?.get('QuestionnairePage') ?? false;
if (!agreement) { if (!agreement) {
await TipsDialog.tipsDialog(); //await TipsDialog.tipsDialog();
HiveStore.appBox!.put('QuestionnairePage', true); HiveStore.appBox!.put('QuestionnairePage', true);
} }
}); });

@ -85,8 +85,6 @@ class ApplicationUtil {
title: '活动投票', title: '活动投票',
imgPath: Assets.newIcon.icHdtp.path, imgPath: Assets.newIcon.icHdtp.path,
onTap: () { onTap: () {
BotToast.showText(text: '此功能暂未上线');
return;
Get.to(() => EventVotingPage()); Get.to(() => EventVotingPage());
}), }),
AppElement( AppElement(

Loading…
Cancel
Save