voteList.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356
  1. <template>
  2. <div class="bigbox">
  3. <!-- 顶部图片 -->
  4. <div class="topimg">
  5. <img :src="'./api/file/pub/'+ voteImg" alt="">
  6. </div>
  7. <!-- 投票简介部分 -->
  8. <div class="voteIntro">
  9. <div v-html="activityDesc"></div>
  10. </div>
  11. <!-- 投票列表排行部分 -->
  12. <div>
  13. <!-- 按钮 -->
  14. <div class="voteButton">
  15. <!-- 用户投票数据 -->
  16. <div class="uservote" v-if="startflag">
  17. <div class="addupVote">累计已投: <span>{{totalVotes}}</span> 票</div>
  18. <div class="todayVote">今日已投: <span>{{nowDayTotalVotes}}</span> 票</div>
  19. <div class="maxdayVote" v-if="!maxVoteflag">今日可投: <span>{{maxNumOneday - nowDayTotalVotes}}</span> 票</div>
  20. <div class="maxVote" v-if="maxVoteflag">投票数已达上限</div>
  21. </div>
  22. <div class="votestart" v-if="!startflag" v-text="endflag?'投票已结束':'投票未开始'"></div>
  23. <!-- 排序按钮 -->
  24. <div class="buttonB" @click="sortVotenum(newlist,'numOfVote')"><img src="./huangguan.png" alt="">即时排行榜</div>
  25. <div class="buttonA" @click="getLocaleZh(newlist,'itemName')">按字母排序</div>
  26. </div>
  27. <!-- 文章分类按钮 -->
  28. <div style="margin-bottom:10px;">
  29. <div
  30. class="classify"
  31. v-for="(item,index) in voteItemTypeDicts" :key="index"
  32. :style="{backgroundColor: sign == index ? '#1d5edb': '#fff',color: sign == index ? '#fff': '#333'}"
  33. @click="select(index)"
  34. >{{item.label}}</div>
  35. </div>
  36. <!-- 投票列表 -->
  37. <div class="votebox">
  38. <div class="votelist" v-for="(item,index) in newlist" :key="index" @click="toView('vote', item, activityInfos)">
  39. <!-- <div class="voteName">
  40. <span :style="{ backgroundColor:colorGroup[index] }" class="span">{{number[index]}}</span>{{ item.itemName }}
  41. </div> -->
  42. <span :style="{ backgroundColor:colorGroup[index] }" class="span">{{number[index]}}</span>
  43. <div class="voteName">{{ item.itemName }}</div>
  44. <div class="voteCompetitor">{{ item.competitorName }}</div>
  45. <div class="voteCount" :style="{backgroundColor:item.votecolor}">{{ item.numOfVote ? item.numOfVote : 0 }}</div>
  46. <div class="tested" v-if="Number(item.totalVotesForOneItem)"></div>
  47. </div>
  48. </div>
  49. </div>
  50. <!-- 返回按钮 -->
  51. <div class="backButton" @click="toHome">返回首页</div>
  52. </div>
  53. </template>
  54. <script>
  55. import {getActivityForVotes,getItemForVotes,getVoteParams} from "@/api/vote/vote";
  56. import { getDicts } from '@/api/dict'
  57. export default {
  58. name: 'voteList',
  59. data() {
  60. return {
  61. newlist:[],
  62. colorGroup:[ '#e02020','#fa6400','#f7b500' ],
  63. sign:0,
  64. number:[1,2,3],
  65. startflag:true,//用户投票数据是否显示flag
  66. endflag:false,//投票是否结束
  67. maxVoteflag:false,
  68. activityDesc:'',//投票描述
  69. voteImg:'',//投票宣传图
  70. voteId:'',//
  71. activityInfos:'',
  72. maxNumOneday:'',//账号最多投票数
  73. //--当前账号投票情况--
  74. totalVotes: '', //账号在投票期间投票总数
  75. nowDayTotalVotes: '',//账号当天投票总数
  76. nowDayTotalVotesForOneItem: '',//账号对单个参投项当天投票总数
  77. isVoteForOneItem: '',//账号在投票期间对单个参投项是否投过票
  78. //----------------------------------------------------------
  79. // votecolor:'',
  80. voteItemTypeDicts:[],
  81. voteItemTypeDict:'academic_papers',//论文类型
  82. };
  83. },
  84. mounted() {
  85. getDicts('VOTE_ITEM_TYPE_DICT').then(result => {
  86. var data = result.data;
  87. if(data){
  88. this.voteItemTypeDicts = result.data[0];
  89. console.log('xxxxxxxx',this.voteItemTypeDicts)
  90. }
  91. });
  92. this.getActivityForVote()
  93. },
  94. methods: {
  95. getActivityForVote(){
  96. getActivityForVotes().then(res => {
  97. this.activityInfos = res.data.activityForVotes[0];
  98. this.activityDesc = res.data.activityForVotes[0].activityDesc;
  99. this.voteImg = res.data.activityForVotes[0].coverPictureUrl;
  100. this.activityId = res.data.activityForVotes[0].id;
  101. this.maxNumOneday = res.data.activityForVotes[0].maxNumOneday;
  102. // console.log('=================',this.voteId)
  103. var nowtime = Date.parse(new Date());
  104. if( Date.parse(this.activityInfos.voteStartDate) > nowtime||Date.parse(this.activityInfos.voteEndDate) < nowtime ){ this.startflag = false }
  105. if( Date.parse(this.activityInfos.voteStartDate) < nowtime ){ this.endflag = true }
  106. getItemForVotes({activityId:this.activityId,voteItemTypeDict:this.voteItemTypeDict}).then(res => {
  107. this.newlist = res.data.itemForVotes;
  108. this.sortVotenum(this.newlist,'numOfVote');
  109. this.nowDayTotalVotes = res.data.itemForVotes[0].nowDayTotalVotes;
  110. this.totalVotes = res.data.itemForVotes[0].totalVotes;
  111. this.newlist.forEach((item,index)=>{
  112. // console.log('xxxxxxxxxxx',this.activityInfos.isRevoteOneitem)
  113. if((this.activityInfos.isRevoteOneitem=='No' && item.totalVotesForOneItem>0)||item.nowDayTotalVotesForOneItem == this.activityInfos.maxNumOneitemOneday||this.activityInfos.maxNumTotal==this.totalVotes){
  114. this.$set(item,'votecolor','#949494')
  115. }
  116. });
  117. if(this.activityInfos.maxNumTotal==this.totalVotes){ this.maxVoteflag = true }
  118. // console.log('xxxxxxx',this.newlist)
  119. });
  120. })
  121. },
  122. toView(router, items, activityInfos) {
  123. items = JSON.stringify(items);
  124. activityInfos = JSON.stringify(activityInfos)
  125. // localStorage.setItem('conferenceId', id);
  126. this.$router.push({ path: router , query: { items,activityInfos } });
  127. },
  128. toHome(){
  129. this.$router.push({ path: 'home' });
  130. },
  131. //tab栏
  132. select(index){
  133. this.sign = index;
  134. this.voteItemTypeDict = this.voteItemTypeDicts[index].value;
  135. this.getActivityForVote()
  136. },
  137. //按字母排序
  138. getLocaleZh(array,property){
  139. array.sort(function (a,b){
  140. return a[property].localeCompare(b[property], 'zh');
  141. })
  142. },
  143. //按票数排序
  144. sortVotenum(array,property){
  145. array.sort(function (a,b){
  146. return b[property]-a[property];
  147. })
  148. },
  149. }
  150. }
  151. </script>
  152. <style scoped>
  153. *{
  154. padding: 0;
  155. margin: 0;
  156. box-sizing: border-box;
  157. /* vertical-align: text-top; */
  158. }
  159. html,body,#app {
  160. width: 100%;
  161. height: 100%;
  162. }
  163. .bigbox{
  164. width: 1080px;
  165. margin: auto;
  166. padding-bottom: 65px;
  167. }
  168. .topimg{
  169. width: 1080px;
  170. /* height: 450px; */
  171. }
  172. .topimg > img{
  173. width: 100%;
  174. }
  175. .voteIntro{
  176. width: 1080px;
  177. /* height: 300px; */
  178. border-left: 2px dotted #cccccc;
  179. border-right: 2px dotted #cccccc;
  180. border-bottom: 2px dotted #cccccc;
  181. margin-top: 45px;
  182. padding: 0px 20px
  183. }
  184. .voteButton{
  185. width: 100%;
  186. height: 115px;
  187. padding: 50px 0px 20px 0px;
  188. }
  189. .uservote{
  190. width: 50%;
  191. float: left;
  192. }
  193. .addupVote{
  194. display: inline-block;
  195. margin-left: 20px;
  196. }
  197. .addupVote > span{
  198. display: inline-block;
  199. margin-bottom: 8px;
  200. font-size: 26px;
  201. color: #468ff7;
  202. }
  203. .todayVote{
  204. display: inline-block;
  205. margin-left: 40px;
  206. }
  207. .todayVote > span{
  208. display: inline-block;
  209. margin-bottom: 8px;
  210. font-size: 26px;
  211. color: #e56d2c;
  212. }
  213. .maxdayVote{
  214. display: inline-block;
  215. margin-left: 40px;
  216. }
  217. .maxdayVote > span{
  218. display: inline-block;
  219. margin-bottom: 8px;
  220. font-size: 26px;
  221. color: #71b96c;
  222. }
  223. .maxVote{
  224. display: inline-block;
  225. margin-left: 40px;
  226. font-size: 26px;
  227. margin-bottom: 13px;
  228. color: red;
  229. }
  230. .votestart{
  231. width: 50%;
  232. height: 100%;
  233. float: left;
  234. font-size: 30px;
  235. padding-top: 24px;
  236. }
  237. .buttonA{
  238. width: 166px;
  239. height: 40px;
  240. float: right;
  241. /* margin-top: 25px; */
  242. border-radius: 10px;
  243. background-color: #f7b500;
  244. text-align: center;
  245. line-height: 40px;
  246. margin-right: 25px;
  247. color: white;
  248. cursor: pointer;
  249. }
  250. .buttonB{
  251. position: relative;
  252. width: 166px;
  253. height: 40px;
  254. float: right;
  255. /* margin-top: 25px; */
  256. border-radius: 10px;
  257. background-color: #44d7b6;
  258. text-align: center;
  259. line-height: 40px;
  260. color: white;
  261. cursor: pointer;
  262. }
  263. .buttonB > img{
  264. position: absolute;
  265. top: 10px;
  266. left: 20px;
  267. width: 20px;
  268. height: 20px;
  269. }
  270. .votebox{
  271. border-top: 2px dotted #cccccc;
  272. }
  273. .classify{
  274. display:inline-block;
  275. width:140px;
  276. height: 40px;
  277. line-height: 40px;
  278. text-align: center;
  279. border: 1px dotted black;
  280. cursor: pointer;
  281. }
  282. .votelist{
  283. position: relative;
  284. display: inline-block;
  285. width: 50%;
  286. height: 90px;
  287. border-bottom: 2px dotted #cccccc;
  288. padding-top: 10px;
  289. cursor: pointer;
  290. vertical-align: top;
  291. }
  292. .span{
  293. width:18px;
  294. height:18px;
  295. display:inline-block;
  296. border-radius: 5px;
  297. text-align: center;
  298. color: white;
  299. font-size: 10px;
  300. margin: 3px 8px 0px 0px;
  301. vertical-align: top;
  302. }
  303. .voteName{
  304. display: -webkit-inline-box;
  305. font-weight: bold;
  306. color:#666666;
  307. width: 70%;
  308. overflow: hidden;
  309. -webkit-box-orient: vertical;
  310. -webkit-line-clamp: 2;
  311. text-overflow:ellipsis;
  312. }
  313. .voteCompetitor{
  314. padding-left:26px;
  315. padding-top:8px;
  316. font-size:14px;
  317. color:#7c8086
  318. }
  319. .voteCount{
  320. position: absolute;
  321. top: 23%;
  322. right: 25px;
  323. width: 100px;
  324. height: 40px;
  325. background-color: #7aacff;
  326. border-radius: 10px;
  327. text-align: center;
  328. line-height: 40px;
  329. color: #FFF;
  330. }
  331. .tested{
  332. position: absolute;
  333. top: 6px;
  334. right: 141px;
  335. width: 60px;
  336. height: 60px;
  337. background-image: url('./zvoted.png');
  338. background-size: cover;
  339. }
  340. .backButton{
  341. width: 100px;
  342. height: 30px;
  343. background-color: #B4D5FF;
  344. position: fixed;
  345. top: 0px;
  346. right: 2%;
  347. border-radius: 8px;
  348. text-align: center;
  349. line-height: 30px;
  350. cursor: pointer;
  351. }
  352. </style>