diff --git a/api/v2/all.api.js b/api/v2/all.api.js
index 8707f54..ad15573 100644
--- a/api/v2/all.api.js
+++ b/api/v2/all.api.js
@@ -252,11 +252,7 @@ export default {
* 获取投票列表
*/
getVoteList: (params) => {
- return HttpHandler.Get(`/apis/console.api.vote.kunkunyu.com/v1alpha1/votes`, params, {
- custom: {
- personalToken: getPersonalToken()
- }
- })
+ return HttpHandler.Get(`/apis/api.vote.kunkunyu.com/v1alpha1/votes`, params)
},
/**
* 获取投票详情
diff --git a/common/styles/app.base.scss b/common/styles/app.base.scss
index b90fe74..ffcdeae 100644
--- a/common/styles/app.base.scss
+++ b/common/styles/app.base.scss
@@ -340,5 +340,10 @@ $spacing-sizes: (
}
.justify-center {
- justify-content: center;
+ justify-content: center;
}
+
+.text-break {
+ overflow-wrap: break-word;
+ word-break: break-all;
+}
\ No newline at end of file
diff --git a/components/article-vote/article-vote.vue b/components/article-vote/article-vote.vue
index e6d97e3..48cab13 100644
--- a/components/article-vote/article-vote.vue
+++ b/components/article-vote/article-vote.vue
@@ -5,25 +5,34 @@
-
- {{ index+1 }}
+
+
+ {{ index+1 }}
- 单选
- 多选
- 双选PK
+ 单选
+ 多选
+ 双选PK
- 已结束
- 进行中
+ 已结束
+ 未开始
+ 进行中
+
+
+
+ 查看投票详情
+
{{ vote.spec.title }}
-
@@ -35,38 +44,58 @@
-
-
-
- {{option.title }}
-
-
- {{option.percent }}%
-
+
+
+
+
+ {{option.title }}
+
+
+ {{option.percent }}%
+
+
-
+
+
+
+ {{option.title }}
+
+
-
-
-
- {{option.title }}
-
-
- {{option.percent }}%
-
+
+
+
+
+ {{option.title }}
+
+
+ {{option.percent }}%
+
+
-
+
+
+
+ {{option.title }}
+
+
@@ -84,16 +113,29 @@
@@ -101,8 +143,15 @@
@@ -53,37 +68,57 @@
class="sub-title-count">(最多选择 {{ vote.spec.maxVotes }} 项)
-
-
-
- {{option.title }}
-
-
- {{option.percent }}%
-
+
+
+
+
+ {{option.title }}
+
+
+ {{option.percent }}%
+
+
-
+
+
+
+ {{option.title }}
+
+
-
-
-
- {{option.title }}
-
-
- {{option.percent }}%
-
+
+
+
+
+ {{option.title }}
+
+
+ {{option.percent }}%
+
+
-
+
+
+
+ {{option.title }}
+
+
@@ -91,26 +126,37 @@
+ :style="{width: option.percent + '%'}">
{{option.percent }}%
-
+
+
+
+
+ 选项{{ optionIndex+1}}:{{option.title }}
+
+
@@ -122,21 +168,32 @@
{{ vote.stats.voteCount }}
人已参与
- 已投票
+
+
+
+
+
不允许匿名投票
+ :block="true" @click="handleSubmit()">不支持匿名投票
您已参与投票
提交投票(请选择选项)
- 提交投票
+ 提交投票
@@ -170,6 +227,7 @@
return {
safeAreaBottom: 24,
loading: 'loading',
+ submitLoading: false,
pageTitle: '加载中...',
name: '',
@@ -184,7 +242,7 @@
onLoad(e) {
this.name = e.name;
this.fnGetData();
-
+ this.fnGetVoteUserList();
// #ifndef H5
const systemInfo = uni.getSystemInfoSync();
this.safeAreaBottom = systemInfo.safeAreaInsets.bottom + 12;
@@ -192,6 +250,7 @@
},
onPullDownRefresh() {
this.fnGetData();
+ this.fnGetVoteUserList();
},
methods: {
fnGetData() {
@@ -207,6 +266,7 @@
tempVoteRes.vote.spec.isVoted = this.fnCalcIsVoted()
tempVoteRes.vote.spec.disabled = this.fnCalcIsVoted()
+ tempVoteRes.vote.spec._state = this.handleCalcVoteState(tempVoteRes.vote)
tempVoteRes.vote.spec.options.map((option, index) => {
option.value = option.id
@@ -227,9 +287,7 @@
return option
})
-
this.vote = tempVoteRes.vote
- console.log("this.vote", this.vote)
this.detail = tempVoteRes;
setTimeout(() => {
@@ -249,6 +307,16 @@
}, 200);
});
},
+ fnGetVoteUserList() {
+ this.$httpApi.v2
+ .getVoteUserList(this.name)
+ .then(res => {
+ console.log("查询投票用户列表")
+ })
+ .catch(err => {
+ console.log("err")
+ })
+ },
fnCalcPercent(voteOption, stats) {
if (!this.fnCalcIsVoted()) return 0;
if (!stats?.voteDataList) return 0;
@@ -268,7 +336,23 @@
const checked = data.selected.includes(option.id)
return checked
},
+ handleCalcVoteState(vote) {
+ if (vote.spec.timeLimit !== 'custom') {
+ return vote.spec.hasEnd ? "已结束" : "进行中"
+ }
+ const nowTime = new Date().getTime()
+ const startTime = new Date(vote.spec.startDate).getTime()
+ const endTime = new Date(vote.spec.endDate).getTime()
+
+ if (nowTime < startTime) {
+ return "未开始"
+ }
+ if (nowTime < endTime) {
+ return "进行中"
+ }
+ return vote.spec.hasEnd ? "已结束" : "进行中"
+ },
onOptionRadioChange(e) {
this.submitForm.voteData = e.map(item => this.vote.spec.options[item.index]?.id);
},
@@ -281,18 +365,15 @@
formatJsonStr(jsonStr) {
return jsonStr ? JSON.parse(jsonStr) : {}
},
- handleSubmitTip(){
- uni.showToast({
- icon: "none",
- title: "请选择选项后继续"
- })
+ handleSubmitTip() {
+ this.showToast("请选择选项后继续")
},
handleSubmit() {
if (!this.vote.spec.canAnonymously) {
uni.showModal({
icon: "none",
title: "提示",
- content: "该投票不允许匿名,请到博主的 网站端 进行投票!",
+ content: "该投票不支持匿名,请到博主的 网站端 进行投票!",
cancelColor: "#666666",
cancelText: "关闭",
confirmText: "复制地址",
@@ -305,6 +386,7 @@
return
}
+ this.submitLoading = true
uni.showLoading({
title: "正在保存..."
})
@@ -312,11 +394,8 @@
this.$httpApi.v2
.submitVote(this.name, this.submitForm, this.vote.spec.canAnonymously)
.then(res => {
- uni.showToast({
- icon: "none",
- title: "提交成功"
- })
+ this.showToast("提交成功")
voteCacheUtil.set(this.name, {
selected: [...this.submitForm.voteData],
data: this.vote
@@ -324,18 +403,21 @@
setTimeout(() => {
uni.startPullDownRefresh()
+ this.submitLoading = false
}, 1500);
})
.catch(err => {
console.error(err);
- uni.showToast({
- icon: "none",
- title: "提交失败,请重试"
- })
+ this.showToast("提交失败,请重试")
+ this.submitLoading = false
})
},
handleSelectSingleOption(option) {
+ if (this.vote.spec._state == '未开始') {
+ this.showToast(`投票未开始`)
+ return
+ }
if (this.vote.spec.disabled) return
this.vote.spec.options.map(item => {
if (option.id == item.id) {
@@ -349,15 +431,16 @@
},
handleSelectCheckboxOption(option) {
+ if (this.vote.spec._state == '未开始') {
+ this.showToast(`投票未开始`)
+ return
+ }
if (this.vote.spec.disabled) return
const checkedList = this.vote.spec.options.filter(x => x.checked && x.id != option.id)
if (this.vote.spec.type === 'multiple' && checkedList.length >= this.vote.spec.maxVotes) {
- uni.showToast({
- icon: "none",
- title: `最多选择 ${this.vote.spec.maxVotes} 项`
- })
+ this.showToast(`最多选择 ${this.vote.spec.maxVotes} 项`)
return
}
@@ -368,6 +451,13 @@
})
this.submitForm.voteData = this.vote.spec.options.filter(x => x.checked).map(item => item.id)
+ },
+ showToast(content) {
+ uni.showToast({
+ icon: "none",
+ title: content,
+ mask: true
+ })
}
}
};
@@ -460,54 +550,74 @@
border-top: 2rpx solid #eee;
}
+ .is-voted-item {
+ min-height: 72rpx;
+ box-sizing: border-box;
+ position: relative;
+ border-radius: 12rpx;
+ background-color: rgba(229, 229, 229, 0.75);
+ font-size: 24rpx;
+ overflow: hidden;
- .single {
- ::v-deep {
- .tm-groupradio {
- box-sizing: border-box;
- display: flex;
- flex-wrap: wrap;
- gap: 16rpx 0;
- }
+ &::before {
+ content: "";
+ width: var(--percent);
+ position: absolute;
+ left: 0;
+ top: 0;
+ bottom: 0;
+ background-color: rgba(208, 208, 208, 1);
+ z-index: 0;
+ border-radius: 6rpx;
+ }
- .tm-checkbox {
- box-sizing: border-box;
- // display: block;
- // width: 100%;
- }
+ &.selected {
+ background-color: rgba(3, 169, 244, 0.35);
+ color: #ffffff;
- .tm-button-label {
- width: 100%;
+ &::before {
+ background-color: rgba(3, 169, 244, 1);
}
}
}
- .multiple {
- ::v-deep {
- .tm-groupcheckbox {
- box-sizing: border-box;
- display: flex;
- flex-wrap: wrap;
- gap: 16rpx 0;
- }
+ .is-voted-item-content {
+ box-sizing: border-box;
+ min-height: 72rpx;
+ padding: 12rpx 24rpx;
+ position: relative;
+ z-index: 2;
+ }
- .tm-checkbox {
- box-sizing: border-box;
- // display: block;
- // width: 100%;
- }
+ .vote-select-option {
+ box-sizing: border-box;
+ padding: 20rpx 24rpx;
+ font-size: 24rpx;
+ border-radius: 12rpx;
+ transition: all 0.1s ease-in-out;
+ }
- .tm-button-label {
- width: 100%;
- }
+
+ ::v-deep {
+ .tm-button-label {
+ width: 100%;
}
}
+ .single {
+ ::v-deep {}
+ }
+
+ .multiple {
+ ::v-deep {}
+ }
+
.pk {
box-sizing: border-box;
width: 100%;
::v-deep {
+
.pk-container {
box-sizing: border-box;
width: 100%;
diff --git a/pagesA/votes/votes.vue b/pagesA/votes/votes.vue
index 4fd1e09..e75d489 100644
--- a/pagesA/votes/votes.vue
+++ b/pagesA/votes/votes.vue
@@ -260,7 +260,7 @@
const tempItems = res.items.map(item => {
item.spec.disabled = true
item.spec.isVoted = this.fnCalcIsVoted(item.metadata.name)
-
+ item.spec._state = this.handleCalcVoteState(item)
item.spec.options.map((option, index) => {
option.checked = this.fnCalcIsChecked(item.metadata.name, option)
@@ -326,6 +326,23 @@
const checked = data.selected.includes(option.id)
return checked
},
+ handleCalcVoteState(vote) {
+ if (vote.spec.timeLimit !== 'custom') {
+ return vote.spec.hasEnd ? "已结束" : "进行中"
+ }
+
+ const nowTime = new Date().getTime()
+ const startTime = new Date(vote.spec.startDate).getTime()
+ const endTime = new Date(vote.spec.endDate).getTime()
+
+ if (nowTime < startTime) {
+ return "未开始"
+ }
+ if (nowTime < endTime) {
+ return "进行中"
+ }
+ return vote.spec.hasEnd ? "已结束" : "进行中"
+ },
//跳转详情
fnToDetail(item) {
if (this.calcAuditModeEnabled) return;