From 615e16a778ece15ea737f867bf5ad62caee25f87 Mon Sep 17 00:00:00 2001
From: zengh <123456>
Date: Fri, 11 Feb 2022 16:04:31 +0800
Subject: [PATCH] 1、投票功能完善
---
pages/registerUser/registerUser.vue | 2
pages/issue/issue.vue | 29 +
pages/alarm_list/integral/integral.vue | 5
pages.json | 100 ++--
pages/business/business.vue | 17
pages/voting/voteManage.vue | 22 +
pages/loging/loging.vue | 8
pages/myself/myself.vue | 2
pages/reported/reported.vue | 42 -
pages/voting/vote.vue | 586 +++++++++++++++++++++++++++
pages/voting/voteDetail.vue | 407 +++++++++++++++++++
11 files changed, 1,134 insertions(+), 86 deletions(-)
diff --git a/pages.json b/pages.json
index 2015f65..ebafdd3 100644
--- a/pages.json
+++ b/pages.json
@@ -257,7 +257,7 @@
"bottom": "0",
"background": "transparent",
"zindex": 1
-
+
}
}, {
"id": "input-box",
@@ -450,48 +450,64 @@
"style": {
"navigationBarTitleText": "500"
}
+ }, {
+ "path": "pages/alarm_list/integral/integral",
+ "style": {
+ "navigationBarTitleText": "查积分",
+ "navigationBarBackgroundColor": "#103289",
+ "navigationBarTextStyle": "white"
+ }
+
+ }, {
+ "path": "pages/alarm_list/organ/organ",
+ "style": {
+ "navigationBarTitleText": "组织申请",
+ "navigationBarBackgroundColor": "#103289",
+ "navigationBarTextStyle": "white"
+ }
+
+ }, {
+ "path": "pages/alarm_list/industry/industry",
+ "style": {
+ "navigationBarTitleText": "行业政策",
+ "navigationBarBackgroundColor": "#103289",
+ "navigationBarTextStyle": "white"
+ }
+
+ }, {
+ "path": "pages/alarm_list/industry/industry_detail",
+ "style": {
+ "navigationBarTitleText": "行业政策",
+ "navigationBarBackgroundColor": "#103289",
+ "navigationBarTextStyle": "white"
+ }
+
+ }, {
+ "path": "pages/voting/vote",
+ "style": {
+ "navigationBarTitleText": "投票发起",
+ "navigationBarBackgroundColor": "#103289",
+ "navigationBarTextStyle": "white"
+ }
+
+ }, {
+ "path": "pages/voting/voteManage",
+ "style": {
+ "navigationBarTitleText": "我的投票",
+ "navigationBarBackgroundColor": "#103289",
+ "navigationBarTextStyle": "white"
+ }
+
+ }, {
+ "path": "pages/voting/voteDetail",
+ "style": {
+ "navigationBarTitleText": "投票详情",
+ "navigationBarBackgroundColor": "#103289",
+ "navigationBarTextStyle": "white"
+ }
+
}
- ,{
- "path" : "pages/alarm_list/integral/integral",
- "style" :
- {
- "navigationBarTitleText": "查积分",
- "navigationBarBackgroundColor": "#103289",
- "navigationBarTextStyle": "white"
- }
-
- }
- ,{
- "path" : "pages/alarm_list/organ/organ",
- "style" :
- {
- "navigationBarTitleText": "组织申请",
- "navigationBarBackgroundColor": "#103289",
- "navigationBarTextStyle": "white"
- }
-
- }
- ,{
- "path" : "pages/alarm_list/industry/industry",
- "style" :
- {
- "navigationBarTitleText": "行业政策",
- "navigationBarBackgroundColor": "#103289",
- "navigationBarTextStyle": "white"
- }
-
- }
- ,{
- "path" : "pages/alarm_list/industry/industry_detail",
- "style" :
- {
- "navigationBarTitleText": "行业政策",
- "navigationBarBackgroundColor": "#103289",
- "navigationBarTextStyle": "white"
- }
-
- }
- ],
+ ],
"globalStyle": { //将组件安装在项目的components目录下,并符合components/组件名称/组件名称.vue目录结构。可以不用引用、注册,直接在页面中使用。
"autoscan": true
},
diff --git a/pages/alarm_list/integral/integral.vue b/pages/alarm_list/integral/integral.vue
index a37f384..fcac601 100644
--- a/pages/alarm_list/integral/integral.vue
+++ b/pages/alarm_list/integral/integral.vue
@@ -21,7 +21,7 @@
<view class="bomList">
<view class="">
<u-dropdown border-bottom="true">
- <u-dropdown-item v-model="value1" title="收支类型" :options="options1"></u-dropdown-item>
+ <u-dropdown-item v-model="value1" @change="change" title="收支类型" :options="options1"></u-dropdown-item>
</u-dropdown>
</view>
@@ -95,6 +95,9 @@
goDetail() {
},
+ change(e){
+ alert(e)
+ },
onReady() {
let that = this;
uni.getSystemInfo({
diff --git a/pages/business/business.vue b/pages/business/business.vue
index 990eb62..362c7a2 100644
--- a/pages/business/business.vue
+++ b/pages/business/business.vue
@@ -34,14 +34,23 @@
<view class="nav-item-name">通讯录</view>
</navigator>
</u-grid-item>
+ </u-grid>
+ </view>
+ </view>
+ <!-- 我的订阅 end -->
+
+ <view class="card wrap">
+ <view class="title">管理</view>
+ <view class="list">
+ <u-grid :col="4" :border="false">
<u-grid-item bg-color="transparent">
- <navigator url="" hover-class="none" class="nav-item">
+ <navigator url="/pages/voting/voteManage" hover-class="none" class="nav-item">
<image src="../../static/workbench/task5.png" mode="widthFix" class="nav-item-img"></image>
<view class="nav-item-name">我的投票</view>
</navigator>
</u-grid-item>
<u-grid-item bg-color="transparent">
- <navigator url="" hover-class="none" class="nav-item">
+ <navigator url="/pages/voting/vote" hover-class="none" class="nav-item">
<image src="../../static/workbench/task6.png" mode="widthFix" class="nav-item-img"></image>
<view class="nav-item-name">投票发起</view>
</navigator>
@@ -49,7 +58,7 @@
</u-grid>
</view>
</view>
- <!-- 我的订阅 end -->
+
</view>
<!-- 底部导航条 -->
<u-tabbar :list="tabbar" :mid-button="true"></u-tabbar>
@@ -182,7 +191,7 @@
width: 5rpx;
height: 36rpx;
margin-right: 10rpx;
- background: #3ac4d1;
+ background: #103289;
}
}
}
diff --git a/pages/issue/issue.vue b/pages/issue/issue.vue
index aa017f1..dcf8aa6 100644
--- a/pages/issue/issue.vue
+++ b/pages/issue/issue.vue
@@ -238,16 +238,29 @@
box-sizing: border-box;
}
- .but {
- width: 30%;
- margin: 0 auto;
+ // .but {
+ // width: 30%;
+ // margin: 0 auto;
- .custom-style {
- background-image: linear-gradient(to right, #08EFF6, #0693FD);
- border-radius: 20px;
- margin-top: 2rem;
- }
+ // .custom-style {
+ // background-image: linear-gradient(to right, #08EFF6, #0693FD);
+ // border-radius: 20px;
+ // margin-top: 2rem;
+ // }
+ // }
+
+ .custom-style{
+ margin: 30rpx 70rpx 50rpx;
+ border: none;
+ width: 572rpx;
+ height: 86rpx;
+ line-height: 86rpx;
+ box-sizing: border-box;
+ border-radius: 15rpx;
+ background-color: #103289;
+ color: #ffffff;
}
+
.shipMp4img {
position: absolute;
diff --git a/pages/loging/loging.vue b/pages/loging/loging.vue
index 0e079b4..92742a9 100644
--- a/pages/loging/loging.vue
+++ b/pages/loging/loging.vue
@@ -176,7 +176,7 @@
span {
font-weight: 600;
font-size: 6vw;
- color: #14b9c8;
+ color: #103289;
}
}
.container {
@@ -240,7 +240,7 @@
line-height: 30rpx;
text {
- color: #14b9c8;
+ color: #103289;
}
}
@@ -282,7 +282,7 @@
line-height: 86rpx;
box-sizing: border-box;
border-radius: 15rpx;
- background-color: #14b9c8;
+ background-color: #103289;
color: #ffffff;
&::after {
@@ -327,7 +327,7 @@
font-size: 22rpx;
font-family: Adobe Heiti Std;
font-weight: normal;
- color: #14b9c8;
+ color: #103289;
line-height: 34rpx;
}
diff --git a/pages/myself/myself.vue b/pages/myself/myself.vue
index 9f3964b..e689ecc 100644
--- a/pages/myself/myself.vue
+++ b/pages/myself/myself.vue
@@ -340,7 +340,7 @@
.m-top {
width: 100%;
height: 12rem;
- border-radius: 0px 0px 12px 12px;
+ border-radius: 0rpx 0rpx 60rpx 60rpx;
background-image: linear-gradient(to bottom, #103289, #174cd1);
color: #fff;
flex-direction: column;
diff --git a/pages/registerUser/registerUser.vue b/pages/registerUser/registerUser.vue
index 59ef97a..49858a7 100644
--- a/pages/registerUser/registerUser.vue
+++ b/pages/registerUser/registerUser.vue
@@ -460,7 +460,7 @@
line-height: 86rpx;
box-sizing: border-box;
border-radius: 15rpx;
- background-color: #14b9c8;
+ background-color: #103289;
color: #ffffff;
&::after {
diff --git a/pages/reported/reported.vue b/pages/reported/reported.vue
index e57a345..12e2691 100644
--- a/pages/reported/reported.vue
+++ b/pages/reported/reported.vue
@@ -35,9 +35,10 @@
<input v-model="place" placeholder="请输入地址" />
</view>
<seeImgs :imgs="[]" :videos="videos" @del="delVideo" :type="'videos'"></seeImgs>
- <view class="form-btn">
+ <!-- <view class="form-btn">
<view class="butb" @click="upData">提交</view>
- </view>
+ </view> -->
+ <u-button class="butb" @click="upData">提交</u-button>
</view>
</template>
@@ -162,7 +163,7 @@
for (var i = 0; i < tempFilePath.length; i++) {
uni.uploadFile({
// url: 'https://web.byisf.com/api/blade-jfpts/depl/put-depl', //仅为示例,非真实的接口地址
- url: that.$store.state.piAPI+'/depl/put-depl',
+ url: that.$store.state.piAPI + '/depl/put-depl',
filePath: tempFilePath[i],
name: 'file',
formData: {
@@ -204,7 +205,7 @@
})
uni.uploadFile({
// url: 'https://web.byisf.com/api/blade-jfpts/depl/put-depl',
- url: that.$store.state.piAPI+'/depl/put-depl',
+ url: that.$store.state.piAPI + '/depl/put-depl',
filePath: tempFilePath,
name: 'file',
formData: {
@@ -333,7 +334,7 @@
height: 15rem;
display: flex;
flex-direction: column;
- border-bottom: 1px solid rgba($color: #f3f3f3, $alpha: 0.7);
+ // border-bottom: 1px solid rgba($color: #f3f3f3, $alpha: 0.7);
.title {
height: 100rpx;
@@ -344,7 +345,7 @@
textarea {
// background-color: #00BFFF;
width: 100%;
- border: 1px solid #808080;
+ // border: 1px solid #808080;
line-height: 1.5;
font-size: 14px;
flex: 1;
@@ -389,26 +390,17 @@
}
}
- .form-btn {
- margin-top: 2rem;
- display: flex;
- justify-content: center;
- .butb {
- margin-bottom: 4.5rem;
- width: 100%;
- height: 3rem;
- // border: 1px solid rgb(46, 118, 228);
- border-radius: 8px;
- display: flex;
- align-items: center;
- justify-content: center;
- color: #fff;
- font-weight: 600;
- font-size: 1.4rem;
- letter-spacing: 10px;
- background-image: linear-gradient(to bottom, #3CA7F4, #169BD5);
- }
+ .butb {
+ margin: 30rpx 50rpx 50rpx;
+ border: none;
+ width: 572rpx;
+ height: 86rpx;
+ line-height: 86rpx;
+ box-sizing: border-box;
+ border-radius: 15rpx;
+ background-color: #103289;
+ color: #ffffff;
}
}
</style>
diff --git a/pages/voting/vote.vue b/pages/voting/vote.vue
new file mode 100644
index 0000000..d24b527
--- /dev/null
+++ b/pages/voting/vote.vue
@@ -0,0 +1,586 @@
+<template>
+ <view>
+ <view class="content_1">
+ <view class="titleOption">基本信息</view>
+ <u-form label-position="top">
+ <u-form-item left-icon="pushpin-fill" :left-icon-style="{ fontSize: '16px', color: '#103289' }"
+ label="活动标题" :label-style="{ fontSize: '16px', fontWeight: 'bold' }">
+ <u-input v-model="obj.activityTitle" maxlength="5000" placeholder="请输入活动标题" />
+ </u-form-item>
+ <u-form-item :border-bottom="false" left-icon="edit-pen-fill" :left-icon-style="{ fontSize: '16px', color: '#103289' }"
+ label="投票介绍" :label-style="{ fontSize: '16px', fontWeight: 'bold' }">
+ <u-input v-model="obj.voteIntroduce" maxlength="5000" placeholder="请输入投票介绍" />
+ </u-form-item>
+ </u-form>
+ </view>
+
+ <view class="content_1 voteOptionContent">
+ <view class="titleOption">选项管理</view>
+ <u-form label-position="top">
+ <u-form-item v-for="(item, index) in obj.voteItemlist" :key="index">
+ <view style="display: flex;width: 100%;">
+ <u-icon name="minus-circle" color="#103289" size="32" @click="deleteItem(index)"></u-icon>
+ <u-input class="u-input" v-model="item.content" maxlength="5000" placeholder="请输入投票选项" />
+ </view>
+ </u-form-item>
+ <u-form-item :border-bottom="false">
+ <view @click="addItem()" style="width:100%;">
+ <u-icon name="plus-circle" color="#103289" size="32"></u-icon>
+ <text class="addItem">添加选项</text>
+ </view>
+ </u-form-item>
+ </u-form>
+ </view>
+ <view class="content_1">
+ <view class="titleOption">投票规则</view>
+ <u-form class="voteRule">
+ <u-form-item left-icon="clock-fill" :left-icon-style="{ fontSize: '16px', color: '#103289' }"
+ label="投票开始时间" :label-style="{ fontSize: '16px', fontWeight: 'bold' }">
+ <view style="width:100%;text-align: end;" @click="ShowStart()">
+ <text>{{ obj.startTime }}</text>
+ </view>
+ </u-form-item>
+ <u-form-item left-icon="clock-fill" :left-icon-style="{ fontSize: '16px', color: '#103289' }"
+ label="投票结束时间" :label-style="{ fontSize: '16px', fontWeight: 'bold' }">
+ <view style="width:100%;text-align: end;" @click="ShowEnd()">
+ <text>{{ obj.endTime }}</text>
+ </view>
+ </u-form-item>
+ <u-form-item left-icon="grid-fill" :left-icon-style="{ fontSize: '16px', color: '#103289' }"
+ label="投票次数" :label-style="{ fontSize: '16px', fontWeight: 'bold' }">
+ <view style="width:100%;text-align: end;" @click="ShowNun()">
+ <text>{{ obj.voteMoreTxt }}</text>
+ <u-icon name="arrow-right" color="#103289" size="32"></u-icon>
+ </view>
+ </u-form-item>
+ <u-form-item :border-bottom="false" left-icon="home-fill" :left-icon-style="{ fontSize: '16px', color: '#103289' }"
+ label="是否置顶展示" :label-style="{ fontSize: '16px', fontWeight: 'bold' }">
+ <u-switch slot="right" v-model="obj.switchVal"></u-switch>
+ </u-form-item>
+ </u-form>
+ </view>
+ <!-- <view class="content_1" style="padding: 20rpx 0;">
+ <u-button shape="circle" class="custom-style" @click="submitData" :ripple="true">发布投票</u-button>
+ </view> -->
+
+ <view class="but">
+ <u-button class="custom-style" type="primary" @click="submitData" :ripple="true">发布投票</u-button>
+ </view>
+
+ <!-- 弹窗 -->
+ <u-toast ref="uToast" class="uToast" />
+ <!-- 时间选择弹窗 -->
+ <u-picker v-model="startTimeShow" mode="time" :params="params" @confirm="confirmStartTime"></u-picker>
+ <!-- 时间选择弹窗 -->
+ <u-picker v-model="endTimeShow" mode="time" :params="params" @confirm="confirmEndTime"></u-picker>
+ <!-- 投票次数选择 -->
+ <u-select v-model="nunShow" mode="mutil-column-auto" :list="numlist" @confirm="confirmNum"></u-select>
+ </view>
+</template>
+
+<script>
+ export default {
+ data() {
+ return {
+ params: {
+ year: true,
+ month: true,
+ day: true,
+ hour: true,
+ minute: true
+ },
+ startTimeShow: false,
+ endTimeShow: false,
+ nunShow: false, //投票次数配置
+ numlist: [{
+ value: 1,
+ label: '每天',
+ children: [{
+ value: 1,
+ label: '1次'
+ },
+ {
+ value: 2,
+ label: '2次'
+ },
+ {
+ value: 3,
+ label: '3次'
+ },
+ {
+ value: 4,
+ label: '4次'
+ },
+ {
+ value: 5,
+ label: '5次'
+ },
+ {
+ value: 6,
+ label: '6次'
+ },
+ {
+ value: 7,
+ label: '7次'
+ },
+ {
+ value: 8,
+ label: '8次'
+ },
+ {
+ value: 9,
+ label: '9次'
+ },
+ {
+ value: 10,
+ label: '10次'
+ },
+ {
+ value: 11,
+ label: '11次'
+ },
+ {
+ value: 12,
+ label: '12次'
+ },
+ {
+ value: 13,
+ label: '13次'
+ },
+ {
+ value: 14,
+ label: '14次'
+ },
+ {
+ value: 15,
+ label: '15次'
+ },
+ {
+ value: 16,
+ label: '16次'
+ },
+ {
+ value: 17,
+ label: '17次'
+ },
+ {
+ value: 18,
+ label: '18次'
+ },
+ {
+ value: 19,
+ label: '19次'
+ },
+ {
+ value: 20,
+ label: '20次'
+ }
+ ]
+ },
+ {
+ value: 2,
+ label: '总共',
+ children: [{
+ value: 1,
+ label: '1次'
+ },
+ {
+ value: 2,
+ label: '2次'
+ },
+ {
+ value: 3,
+ label: '3次'
+ },
+ {
+ value: 4,
+ label: '4次'
+ },
+ {
+ value: 5,
+ label: '5次'
+ },
+ {
+ value: 6,
+ label: '6次'
+ },
+ {
+ value: 7,
+ label: '7次'
+ },
+ {
+ value: 8,
+ label: '8次'
+ },
+ {
+ value: 9,
+ label: '9次'
+ },
+ {
+ value: 10,
+ label: '10次'
+ },
+ {
+ value: 11,
+ label: '11次'
+ },
+ {
+ value: 12,
+ label: '12次'
+ },
+ {
+ value: 13,
+ label: '13次'
+ },
+ {
+ value: 14,
+ label: '14次'
+ },
+ {
+ value: 15,
+ label: '15次'
+ },
+ {
+ value: 16,
+ label: '16次'
+ },
+ {
+ value: 17,
+ label: '17次'
+ },
+ {
+ value: 18,
+ label: '18次'
+ },
+ {
+ value: 19,
+ label: '19次'
+ },
+ {
+ value: 20,
+ label: '20次'
+ }
+ ]
+ }
+ ],
+ obj: {
+ pageview: 0,
+ activityTitle: '',
+ voteIntroduce: '',
+ voteItemlist: [{
+ index: 1,
+ vote: 0, //票数
+ content: ''
+ },
+ {
+ index: 2,
+ vote: 0, //票数
+ content: ''
+ }
+ ],
+ startTime: this.getTime(),
+ endTime: this.getTomorrow(),
+ voteMoreTxt: '总共1次',
+ voteMore: '1',
+ updateInfo: [], //更新用户信息
+ switchVal: true,
+ status: 1,
+ openid: '',
+ creatUserInfo: '',
+ voteType: 'textVote'
+ }
+ };
+ },
+ methods: {
+ addItem() {
+ this.obj.voteItemlist.push({
+ index: this.obj.voteItemlist.length + 1,
+ vote: 0,
+ content: ''
+ });
+ },
+ deleteItem(index) {
+ if (this.obj.voteItemlist.length == 2) {
+ this.$refs.uToast.show({
+ title: '至少要有两个投票选项',
+ type: 'error',
+ position: 'top'
+ });
+ return false;
+ }
+ this.obj.voteItemlist.splice(index, 1);
+ },
+ ShowStart() {
+ this.startTimeShow = true;
+ },
+ ShowEnd() {
+ this.endTimeShow = true;
+ },
+ ShowNun() {
+ this.nunShow = true;
+ },
+ confirmStartTime(obj) {
+ this.obj.startTime = `${obj.year}-${obj.month}-${obj.day} ${obj.hour}:${obj.minute}`;
+ },
+ confirmEndTime(obj) {
+ this.obj.endTime = `${obj.year}-${obj.month}-${obj.day} ${obj.hour}:${obj.minute}`;
+ },
+ confirmNum(obj) {
+ this.obj.voteMoreTxt = `${obj[0].label}${obj[1].label}`;
+ this.obj.voteMore = obj[1].value;
+ },
+ submitData() {
+ uni.showLoading({
+ title: '发布中'
+ });
+ if (this.formVerify()) {
+ this.obj.creatUserInfo = uni.getStorageSync('userInfo');
+ this.obj.openid = uni.getStorageSync('userInfo').openid;
+ //判断开始时间是否小于结束时间 小于只改为进行中状态2
+ if (this.compare(this.obj.startTime, this.getTime()) == true) {
+ this.obj.status = 2;
+ }
+ let app = this;
+ uniCloud.callFunction({
+ name: 'add_vote',
+ data: this.obj,
+ success(res) {
+ uni.hideLoading();
+ if (res.result.code == 200) {
+ uni.showToast({
+ title: res.result.msg,
+ duration: 2000
+ });
+ setTimeout(() => {
+ app.clearData();
+ uni.switchTab({
+ url: '/pages/index/index'
+ });
+ }, 500);
+ } else {
+ app.$refs.uToast.show({
+ title: res.result.msg,
+ type: 'error',
+ position: 'top'
+ });
+ }
+ },
+ fail(error) {
+ uni.hideLoading();
+ app.$refs.uToast.show({
+ title: '发布失败,请稍后重试!',
+ type: 'error',
+ position: 'top'
+ });
+ }
+ });
+ } else {
+ uni.hideLoading();
+ }
+ },
+ formVerify() {
+ for (let i = 0; i < this.obj.voteItemlist.length; i++) {
+ if (this.obj.voteItemlist[i].content == '') {
+ this.$refs.uToast.show({
+ title: `请填写第${i + 1}个投票选项`,
+ type: 'error',
+ position: 'top'
+ });
+ return false;
+ }
+ }
+ if (this.obj.activityTitle == '') {
+ this.$refs.uToast.show({
+ title: `请填写活动标题`,
+ type: 'error',
+ position: 'top'
+ });
+ return false;
+ } else if (this.obj.voteIntroduce == '') {
+ this.$refs.uToast.show({
+ title: `请填写投票介绍`,
+ type: 'error',
+ position: 'top'
+ });
+ return false;
+ } else if (this.compare(this.obj.startTime, this.obj.endTime) == false) {
+ this.$refs.uToast.show({
+ title: `投票开始时间不能大于结束时间`,
+ type: 'error',
+ position: 'top'
+ });
+ return false;
+ }
+ return true;
+ },
+ compare(date1, date2) {
+ var oDate1 = new Date(date1);
+ var oDate2 = new Date(date2);
+ if (oDate1.getTime() > oDate2.getTime()) {
+ return false; //1d
+ } else {
+ return true; //2d
+ }
+ },
+ clearData() {
+ this.obj = {
+ pageview: 0,
+ activityTitle: '',
+ voteIntroduce: '',
+ voteItemlist: [{
+ index: 1,
+ vote: 0, //票数
+ content: ''
+ },
+ {
+ index: 2,
+ vote: 0, //票数
+ content: ''
+ }
+ ],
+ startTime: this.getTime(),
+ endTime: this.getTomorrow(),
+ voteMoreTxt: '总共1次',
+ voteMore: '1',
+ updateInfo: [], //更新用户信息
+ switchVal: true,
+ status: 1,
+ openid: '',
+ creatUserInfo: '',
+ voteType: 'textVote'
+ };
+ },
+ // 获取当前时间
+ getTime() {
+ let date = new Date();
+ let y = date.getFullYear();
+ let m = date.getMonth() + 1;
+ let d = date.getDate();
+ let h = date.getHours();
+ let min = date.getMinutes();
+ // let s = date.getSeconds()
+ if (m >= 1 && m <= 9) {
+ m = `0${m}`;
+ }
+ if (d >= 1 && d <= 9) {
+ d = `0${d}`;
+ }
+ if (h >= 0 && h <= 9) {
+ h = `0${h}`;
+ }
+ if (min >= 0 && min <= 9) {
+ min = `0${min}`;
+ }
+ // if (s >= 0 && s <= 9) { min = `0${s}` }
+ return `${y}-${m}-${d} ${h}:${min}`;
+ },
+ // 获取当前时间的明天
+ getTomorrow() {
+ let date = new Date();
+ let y = date.getFullYear();
+ let m = date.getMonth() + 1;
+ let d = date.getDate() + 1;
+ let h = date.getHours();
+ let min = date.getMinutes();
+ // let s = date.getSeconds()
+ if (m >= 1 && m <= 9) {
+ m = `0${m}`;
+ }
+ if (d >= 1 && d <= 9) {
+ d = `0${d}`;
+ }
+ if (h >= 0 && h <= 9) {
+ h = `0${h}`;
+ }
+ if (min >= 0 && min <= 9) {
+ min = `0${min}`;
+ }
+ // if (s >= 0 && s <= 9) { min = `0${s}` }
+ return `${y}-${m}-${d} ${h}:${min}`;
+ }
+ }
+ };
+</script>
+
+<style lang="scss">
+ page {
+ background: #f7f7f7;
+ }
+
+ .content_1 {
+ margin: 40rpx 30rpx 40rpx 30rpx;
+ background: #ffffff;
+ padding: 10rpx 20rpx 10rpx 20rpx;
+ border-radius: 20rpx;
+ }
+
+ .titleOption {
+ padding: 36rpx 16rpx;
+ display: flex;
+ align-items: center;
+ font-size: 32rpx;
+ font-family: Source Han Sans CN;
+ font-weight: 500;
+ color: #000000;
+
+ &::before {
+ content
+ : "";
+ display: block;
+ width: 5rpx;
+ height: 36rpx;
+ margin-right: 10rpx;
+ background: #103289;
+ }
+ }
+
+ .voteOptionContent {
+ .voteOptionContentTit {
+ padding: 0;
+ }
+
+ .u-input {
+ width: 98%;
+ margin-left: 10rpx;
+ }
+
+ .addItem {
+ margin-left: 20rpx;
+ }
+ }
+
+ .uToast {
+ /deep/.u-text {
+ min-width: 300rpx;
+ }
+ }
+
+ .voteRule {
+ /deep/.u-form-item--left {
+ width: auto !important;
+ flex: none !important;
+ }
+ }
+
+ .custom-style {
+ background: #103289 !important;
+ color: #ffffff !important;
+
+ /deep/ .u-btn--default {
+ background: #103289 !important;
+ color: #ffffff !important;
+ }
+ }
+
+ .custom-style {
+ margin: 30rpx 85rpx 50rpx;
+ border: none;
+ width: 572rpx;
+ height: 86rpx;
+ line-height: 86rpx;
+ box-sizing: border-box;
+ border-radius: 15rpx;
+ background-color: #103289;
+ color: #ffffff;
+ }
+</style>
diff --git a/pages/voting/voteDetail.vue b/pages/voting/voteDetail.vue
new file mode 100644
index 0000000..b6aee4d
--- /dev/null
+++ b/pages/voting/voteDetail.vue
@@ -0,0 +1,407 @@
+<template>
+ <view>
+ <view class="initiatorInfo">
+ <view class="Info1">
+ <u-avatar :src="src" class="uavatar"></u-avatar>
+ <view class="infotxt">
+ <view class="name">{{ creatName }}</view>
+ <view class="fqr_txt">投票发起人</view>
+ </view>
+ </view>
+ <view class="Info2">
+ <view class="tp_status">
+ <u-tag text="待开始" v-if="data.status == 1" type="warning" mode="light" size="mini" />
+ <u-tag text="投票中" v-if="data.status == 2" type="success" mode="light" size="mini" />
+ <u-tag text="已结束" v-if="data.status == 3" type="info" mode="light" size="mini" />
+ </view>
+ <view class="enddate" v-if="data.status != 1">{{ data.endTime }} 结束</view>
+ <view class="enddate" v-else>{{ data.startTime }} 开始</view>
+ </view>
+ </view>
+
+ <view class="titInfo1">
+ <view class="tit">{{ data.activityTitle }}</view>
+ <view class="sharer_">
+ <u-button size="mini" @click="rankingBtn">
+ 票数排名<u-icon name="arrow-right"></u-icon>
+ </u-button>
+ </view>
+ </view>
+
+
+ <view class="hd_rule">
+ <view class="">
+ <u-tag text="投票规则" type="warning" mode="dark" bg-color="#103289" />
+ </view>
+ <view class="item_rule">
+ <view class="startTit">开始时间</view>
+ <view class="">{{ data.startTime }}</view>
+ </view>
+ <view class="item_rule">
+ <view class="startTit">结束时间</view>
+ <view class="">{{ data.endTime }}</view>
+ </view>
+ <view class="item_rule">
+ <view class="startTit">投票规则</view>
+ <view class="">每人{{ data.voteMoreTxt }}</view>
+ </view>
+ </view>
+ <view class="hd_rule">
+ <view class="">
+ <u-tag text="投票详情" type="warning" mode="dark" bg-color="#103289" />
+ </view>
+ <view class="item_rule">
+ <view>{{ data.voteIntroduce }}</view>
+ </view>
+ </view>
+
+ <view class="hdOption" :style="data.voteType=='videoTextVote'?'flex-wrap:wrap;':'flex-wrap:nowrap;'"
+ v-for="(item, index) in data.voteItemlist" :key="index">
+ <view class="imgOption" v-if="data.voteType=='ImageTextVote'">
+ <image @click="selectImage(item.imgList)" :src="item.imgList[0]"
+ style="width:110rpx;height:110rpx;overflow:hidden;border-radius: 10rpx;"></image>
+ </view>
+ <view class="videoOption" v-if="data.voteType=='videoTextVote'">
+ <video :src="item.video" style="width:100%;height:100%;"></video>
+ </view>
+ <view :class="activeItem == index ? 'hdOptionBtn active-bgc' : 'hdOptionBtn'"
+ @click="selectItme(index, item)">
+ <text>{{ item.content }}</text>
+ <u-count-to :start-val="0" font-size="40" :end-val="item.vote+''" class="voteNum"></u-count-to>
+ <!-- <u-icon name="checkbox-mark" color="#2979ff" size="28"></u-icon> -->
+ </view>
+ </view>
+
+ <view class="zwf_"></view>
+ <!-- <view class="content_1">
+ <u-button shape="circle" class="custom-style" @click="submitData" :ripple="true">投票</u-button>
+ </view> -->
+
+ <view class="but">
+ <u-button class="custom-style" type="primary" @click="submitData" :ripple="true">投票</u-button>
+ </view>
+
+ </view>
+</template>
+
+<script>
+ export default {
+ data() {
+ return {
+ banner: '',
+ src: '',
+ creatName: '',
+ data: '',
+ activeItem: '*',
+ activeobj: {},
+ }
+ },
+ onLoad(event) {
+ // TODO 后面把参数名替换成 payload
+ const payload = event.detailDate || event.payload;
+ // 目前在某些平台参数会被主动 decode,暂时这样处理。
+ try {
+ this.banner = JSON.parse(decodeURIComponent(payload));
+ } catch (error) {
+ this.banner = JSON.parse(payload);
+ }
+ console.log(this.banner);
+ uni.setNavigationBarTitle({
+ title: this.banner.title
+ });
+ this.getDetail();
+ console.log(this.getUrl());
+ },
+ //分享给朋友
+ onShareAppMessage(res) {
+ return {
+ title: this.banner.title,
+ path: this.getUrl(),
+ success: res => {
+ console.info(res)
+ }
+ }
+ },
+ //分享到朋友圈
+ onShareTimeline(res) {
+ return {
+ title: "迅投,快来投票吧!",
+ query: this.getUrl(),
+ }
+ },
+ filters: {
+ total(data) {
+ let num = 0;
+ for (let i = 0; i < data.length; i++) {
+ num = num + data[i].vote;
+ }
+ return num;
+ }
+ },
+ methods: {
+ getUrl() {
+ let pages = getCurrentPages() //获取加载的页面
+ let currentPage = pages[pages.length - 1] //获取当前页面的对象
+ let url = currentPage.route //当前页面url
+ let options = currentPage.options //如果要获取url中所带的参数可以查看options 参数多时通过&拼接url的参数
+ let urlWithArgs = url + '?'
+ for (let key in options) {
+ let value = options[key]
+ urlWithArgs += key + '=' + value + '&'
+ }
+ urlWithArgs = urlWithArgs.substring(0, urlWithArgs.length - 1)
+ return urlWithArgs;
+ },
+ // 进入排名
+ rankingBtn() {
+ let detail = this.banner;
+ uni.navigateTo({
+ url: "../rankinglist/rankinglist?detailDate=" +
+ encodeURIComponent(JSON.stringify(detail)),
+ });
+ },
+ getDetail() {
+ uni.showLoading({
+ title: '加载中...',
+ mask: true
+ });
+ let that = this;
+ console.log(that.banner.type);
+ uniCloud.callFunction({
+ name: 'getDetail',
+ data: {
+ _id: that.banner._id,
+ type: that.banner.type
+ },
+ success(res) {
+ uni.hideLoading();
+ console.log(res);
+ if (res.result.data) {
+ that.data = res.result.data[0];
+ that.src = that.data.creatUserInfo.avatarUrl;
+ that.creatName = that.data.creatUserInfo.nickName;
+ that.updateView();
+ }
+ },
+ fail(error) {
+ uni.hideLoading();
+ that.$operate.toast({
+ title: '网络请求错误!'
+ });
+ }
+ });
+ },
+ updateView() {
+ let that = this;
+ uniCloud.callFunction({
+ name: 'updatePageView',
+ data: {
+ name: that.banner.type,
+ _id: that.banner._id,
+ hot_id: that.data.hot_id,
+ voteType: that.data.voteType,
+ switchVal: that.data.switchVal
+ },
+ success(res) {
+ console.log(res);
+ if (res.result.data) {
+ that.data = res.result.data[0];
+ that.src = that.data.creatUserInfo.avatarUrl;
+ that.creatName = that.data.creatUserInfo.nickName;
+ }
+ },
+ fail(error) {
+ that.$operate.toast({
+ title: '网络请求错误!'
+ });
+ }
+ });
+ },
+ selectItme(index, item) {
+ this.activeItem = index;
+ this.activeobj = item;
+ console.log(index, item);
+ },
+ selectImage(url) {
+ uni.previewImage({
+ urls: url,
+ current: 0
+ });
+ },
+ submitData() {
+ if (JSON.stringify(this.activeobj) != '{}') {
+ let that = this;
+ uni.showLoading({
+ title: '提交中...',
+ mask: true
+ });
+ // uniCloud.callFunction({
+ // name: 'update_vote',
+ // data: {
+ // name: that.banner.type,
+ // voteType:that.data.voteType,
+ // hot_id:that.data.hot_id,
+ // _id: that.banner._id,
+ // voteData: that.activeobj,
+ // userInfo: uni.getStorageSync('userInfo'),
+ // switchVal: that.data.switchVal,
+ // vcs:{
+ // voteMoreTxt: that.data.voteMoreTxt,
+ // voteMore: that.data.voteMore,
+ // }
+ // },
+ // success(res) {
+ // uni.hideLoading();
+ // console.log(res);
+ // if (res.result.updated) {
+ // that.data.voteItemlist[that.activeItem].vote++;
+ // that.activeItem = '*';
+ // that.activeobj = {};
+ // uni.showToast({
+ // title: "投票成功",
+ // duration: 2000
+ // });
+ // } else {
+ // that.$operate.toast({
+ // title: res.result.msg
+ // })
+ // }
+ // },
+ // fail(error) {
+ // console.log(error);
+ // uni.hideLoading();
+ // that.$operate.toast({
+ // title: '网络请求错误!'
+ // });
+ // }
+ // });
+ } else {
+ this.$operate.toast({
+ title: '请选择投票项!'
+ });
+ }
+ }
+ }
+ };
+</script>
+
+<style lang="scss">
+ page {
+ background: #ffffff;
+ }
+
+ .initiatorInfo {
+ background: #ffffff;
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ padding: 30rpx;
+
+ .Info1 {
+ display: flex;
+ align-items: center;
+
+ .uavatar {
+ margin-right: 20rpx;
+ }
+ }
+
+ .name,
+ .tp_status {
+ line-height: 60rpx;
+ }
+
+ .tp_status {
+ text-align: right;
+ }
+
+ .fqr_txt,
+ .enddate {
+ color: #bababa;
+ // line-height: 40rpx;
+ }
+ }
+
+ .titInfo1 {
+ padding: 0 30rpx;
+ margin-top: 40rpx;
+ display: flex;
+
+ .tit {
+ // text-align: center;
+ font-size: 36rpx;
+ width: 85%;
+ margin-right: 20rpx;
+ }
+
+ .sharer_ {}
+ }
+
+ .hd_rule {
+ padding: 30rpx;
+ font-size: 32rpx;
+
+ .item_rule {
+ margin: 36rpx 0;
+ display: flex;
+
+ .startTit {
+ width: 200rpx;
+ font-weight: 600;
+ }
+ }
+ }
+
+ .hdOption {
+ margin-bottom: 40rpx;
+ display: flex;
+ padding: 0 15px;
+
+ .imgOption {
+ width: 110rpx;
+ height: 110rpx;
+ margin-right: 40rpx;
+ flex-grow: 0;
+ felx-shrink: 0;
+ }
+
+ .videoOption {
+ width: 100%;
+ height: 400rpx;
+ }
+
+ .hdOptionBtn {
+ border: 1px solid #dcdcdc;
+ padding: 36rpx;
+ width: 100%;
+ border-radius: 10rpx;
+ font-size: 40rpx;
+ }
+
+ .voteNum {
+ margin-left: 20rpx;
+ float: right;
+ }
+ }
+
+ .custom-style {
+ margin: 30rpx 85rpx 50rpx;
+ border: none;
+ width: 572rpx;
+ height: 86rpx;
+ line-height: 86rpx;
+ box-sizing: border-box;
+ border-radius: 15rpx;
+ background-color: #103289;
+ color: #ffffff;
+ }
+
+ .zwf_ {
+ height: 140rpx;
+ }
+
+ .active-bgc {
+ border-color: #103289 !important;
+ background-color: #fbeadc;
+ }
+</style>
diff --git a/pages/voting/voteManage.vue b/pages/voting/voteManage.vue
new file mode 100644
index 0000000..8183fd0
--- /dev/null
+++ b/pages/voting/voteManage.vue
@@ -0,0 +1,22 @@
+<template>
+ <view>
+
+ </view>
+</template>
+
+<script>
+ export default {
+ data() {
+ return {
+
+ }
+ },
+ methods: {
+
+ }
+ }
+</script>
+
+<style>
+
+</style>
--
Gitblit v1.9.3