投票功能

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

@ -41,6 +41,7 @@ class SAASAPI {
static _ConveniencePhone conveniencePhone = _ConveniencePhone();
static _CommitteeStaff committeeStaff = _CommitteeStaff();
static _Advice advice = _Advice();
static _Vote vote = _Vote();
///
static _ProfileApi profile = _ProfileApi();
@ -373,4 +374,12 @@ class _Advice{
String get evaluate => '/app/user/advice/evaluate';
////
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:common_utils/common_utils.dart';
class EventVotingModel {
int? id;
@ -9,6 +10,11 @@ class EventVotingModel {
int? status;
List<ImgModel>? imgUrls;
List<ImgModel>? headImgURls;
bool? vote;
bool? allowVote;
DateTime? get beginDT => DateUtil.getDateTime(beginDate!);
DateTime? get endDT => DateUtil.getDateTime(endDate!);
EventVotingModel(
{this.id,
@ -18,7 +24,9 @@ class EventVotingModel {
this.endDate,
this.status,
this.imgUrls,
this.headImgURls});
this.headImgURls,
this.vote,
this.allowVote,});
EventVotingModel.fromJson(Map<String, dynamic> json) {
id = json['id'];
@ -27,20 +35,22 @@ class EventVotingModel {
beginDate = json['beginDate'];
endDate = json['endDate'];
status = json['status'];
if (json['imgUrls'] != null) {
if (json['imgList'] != null) {
imgUrls = [];
json['imgUrls'].forEach((v) {
json['imgList'].forEach((v) {
imgUrls!.add(new ImgModel.fromJson(v));
});
} else
imgUrls = [];
if (json['headImgURls'] != null) {
if (json['headImgList'] != null) {
headImgURls = [];
json['headImgURls'].forEach((v) {
json['headImgList'].forEach((v) {
headImgURls!.add(new ImgModel.fromJson(v));
});
} else
headImgURls = [];
vote=json['vote'];
allowVote=json['allowVote'];
}
Map<String, dynamic> toJson() {
@ -52,11 +62,13 @@ class EventVotingModel {
data['endDate'] = this.endDate;
data['status'] = this.status;
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) {
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;
}
}

@ -1,4 +1,5 @@
import 'package:aku_new_community/model/common/img_model.dart';
import 'package:common_utils/common_utils.dart';
class VotingDetailModel {
int? id;
@ -6,8 +7,17 @@ class VotingDetailModel {
String? content;
int? status;
int? totals;
String? beginDate;
String? endDate;
List<ImgModel>? imgUrls;
List<AppVoteCandidateVos>? appVoteCandidateVos;
bool? vote;
bool? allowVote;
DateTime? get beginDT => DateUtil.getDateTime(beginDate!);
DateTime? get endDT => DateUtil.getDateTime(endDate!);
VotingDetailModel(
{this.id,
@ -15,8 +25,12 @@ class VotingDetailModel {
this.content,
this.status,
this.totals,
this.beginDate,
this.endDate,
this.imgUrls,
this.appVoteCandidateVos});
this.appVoteCandidateVos,
this.vote,
this.allowVote});
VotingDetailModel.fromJson(Map<String, dynamic> json) {
id = json['id'];
@ -24,19 +38,23 @@ class VotingDetailModel {
content = json['content'];
status = json['status'];
totals = json['totals'];
if (json['imgUrls'] != null) {
beginDate = json['beginDate'];
endDate = json['endDate'];
if (json['imgList'] != null) {
imgUrls = [];
json['imgUrls'].forEach((v) {
json['imgList'].forEach((v) {
imgUrls!.add(new ImgModel.fromJson(v));
});
} else
imgUrls = [];
if (json['appVoteCandidateVos'] != null) {
if (json['candidateVoList'] != null) {
appVoteCandidateVos = [];
json['appVoteCandidateVos'].forEach((v) {
json['candidateVoList'].forEach((v) {
appVoteCandidateVos!.add(new AppVoteCandidateVos.fromJson(v));
});
}
vote = json['vote'];
allowVote = json['allowVote'];
}
Map<String, dynamic> toJson() {
@ -47,12 +65,14 @@ class VotingDetailModel {
data['status'] = this.status;
data['totals'] = this.totals;
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) {
data['appVoteCandidateVos'] =
data['candidateVoList'] =
this.appVoteCandidateVos!.map((v) => v.toJson()).toList();
}
data['vote']=this.vote;
data['allowVote']=this.allowVote;
return data;
}
}
@ -97,9 +117,9 @@ class AppVoteCandidateVos {
id = json['id'];
name = json['name'];
total = json['total'];
if (json['imgUrls'] != null) {
if (json['imgList'] != null) {
imgUrls = [];
json['imgUrls'].forEach((v) {
json['imgList'].forEach((v) {
imgUrls!.add(new ImgModel.fromJson(v));
});
} else
@ -112,7 +132,7 @@ class AppVoteCandidateVos {
data['name'] = this.name;
data['total'] = this.total;
if (this.imgUrls != null) {
data['imgUrls'] = this.imgUrls!.map((v) => v.toJson()).toList();
data['imgList'] = this.imgUrls!.map((v) => v.toJson()).toList();
}
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/widget/bee_scaffold.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_easyrefresh/easy_refresh.dart';
import 'package:get/get.dart';
@ -37,12 +38,11 @@ class _EventVotingPageState extends State<EventVotingPage> {
String _getButtonText(int? status) {
switch (status) {
case 1:
return '未开始';
case 2:
return '去参与';
return '进行中';
case 3:
return '已结束';
case 4:
return '已填写';
default:
return '';
}
@ -92,7 +92,7 @@ class _EventVotingPageState extends State<EventVotingPage> {
color: ktextPrimary,
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,
@ -135,7 +135,7 @@ class _EventVotingPageState extends State<EventVotingPage> {
return BeeScaffold(
title: '活动投票',
body: BeeListView<EventVotingModel>(
path: API.manager.enventVotingList,
path: SAASAPI.vote.list,
controller: _controller,
convert: (model) {
return model.rows.map((e) => EventVotingModel.fromJson(e)).toList();

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

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

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

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

Loading…
Cancel
Save