You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

214 lines
4.9 KiB

4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
  1. <template>
  2. <view class="content padding">
  3. <view class="banner">
  4. <image :src="imgUrl+'ballots.png'" mode=""></image>
  5. </view>
  6. <view class="tabs">
  7. <up-tabs :list="tabArr" @click="tabClick" :current="currentTab" lineColor="#DE3A26"> </up-tabs>
  8. </view>
  9. <view class="tags">
  10. <view class="tag" v-for="(item,index) in tagArr" :key="index" :class="{active: currentTag==item.id}" @click="tagClick(item)">{{ item.name }}</view>
  11. </view>
  12. <view class="ul">
  13. <view class="li" v-for="(item,index) in voteList" :key="index">
  14. <view class="flex-b">
  15. <view class="name towRowText">{{ item.title }}</view>
  16. <view class="btn boder" v-if="currentTab==1||item.voted==1" @click="$goPage('/pages/subPage/ballots/vote/voteReslut?voteId='+item.voteId)">查看结果</view>
  17. <view class="btn" v-else-if="item.voteStatus==0" style="opacity: 0.4;">未开始</view>
  18. <view class="btn" @click="$goPage('/pages/subPage/ballots/vote/vote?voteId='+item.voteId)" v-else-if="item.voteStatus==1">我要投票</view>
  19. <view class="btn" @click="$goPage('/pages/subPage/ballots/vote/voteReslut?voteId='+item.voteId)" v-else-if="item.voteStatus==2" style="opacity: 0.4;">已结束</view>
  20. </view>
  21. <view class="text">
  22. <text>发起人{{ item.makerName }}</text>
  23. <text>截止时间{{ item.endTime }}</text>
  24. </view>
  25. </view>
  26. </view>
  27. <view style="padding-bottom: 20rpx;" v-if="voteList.length>30">
  28. <u-loadmore :status="status" />
  29. </view>
  30. <nodata v-if="!voteList.length&&status=='nomore'">暂无投票信息~</nodata>
  31. </view>
  32. </template>
  33. <script setup>
  34. import siteObj from '@/config/site.config.js'
  35. const {imgUrl} = siteObj
  36. import {
  37. onLoad,
  38. onPullDownRefresh,
  39. onReachBottom
  40. } from '@dcloudio/uni-app'
  41. import { reactive, ref } from 'vue';
  42. import { votePage, mineVotePage } from '@/config/api.js'
  43. let status = ref('loading')
  44. const tabArr = reactive([
  45. { name: '投票列表', id: 0 },
  46. { name: '我的投票', id: 1 },
  47. ]);
  48. const tagArr = reactive([
  49. { name: '全部', id: -1 },
  50. { name: '未开始', id: 0 },
  51. { name: '进行中', id: 1 },
  52. { name: '已结束', id: 2 },
  53. ]);
  54. // tab切换
  55. const currentTab = ref(0)
  56. function tabClick(item) {
  57. currentTab.value = item.id
  58. initList()
  59. }
  60. // 类型筛选
  61. let currentTag = ref(-1)
  62. function tagClick(item) {
  63. if(currentTag.value==item.id) return
  64. currentTag.value = item.id
  65. params.value.voteState = item.id
  66. initList()
  67. }
  68. // 去投票
  69. function goVote(item) {
  70. console.log(item)
  71. uni.navigateTo({
  72. url: '/pages/subPage/ballots/vote/vote'
  73. })
  74. }
  75. let voteList = ref([])
  76. let total = ref(0)
  77. let params = ref({
  78. "pageNo": 1,
  79. "pageSize": 30,
  80. "voteState": -1
  81. })
  82. async function votePageFn() {
  83. if(params.value.voteState==-1) delete params.value.voteState
  84. console.log(params.value)
  85. let res
  86. if(currentTab.value==0) {
  87. const data = await votePage(params.value)
  88. res = data.data
  89. }else {
  90. const data = await mineVotePage(params.value)
  91. res = data.data
  92. }
  93. voteList.value.push(...res.list)
  94. total.value = res.total
  95. if(voteList.value.length>=total.value) status.value = 'nomore'
  96. console.log(voteList.value)
  97. }
  98. votePageFn()
  99. async function initList() {
  100. params.value.pageNo = 1
  101. voteList.value = []
  102. total.value = 0
  103. votePageFn()
  104. }
  105. onPullDownRefresh(async()=>{
  106. await initList()
  107. uni.stopPullDownRefresh()
  108. })
  109. onReachBottom(()=>{
  110. if(total.value > voteList.value.length) {
  111. votePageFn()
  112. }
  113. })
  114. </script>
  115. <style lang="scss" scoped>
  116. image {
  117. display: block;
  118. width: 100%;
  119. height: 100%;
  120. }
  121. .content {
  122. .banner {
  123. width: 100%;
  124. height: 174rpx;
  125. }
  126. .tabs {
  127. padding: 30rpx 0 10rpx 0;
  128. border-bottom: 1px solid #EFEFEF;
  129. }
  130. .tags {
  131. width: 100%;
  132. height: 110rpx;
  133. display: flex;
  134. align-items: center;
  135. border-bottom: 1px solid #EFEFEF;
  136. .tag {
  137. height: 50rpx;
  138. background: #EFEFEF;
  139. border-radius: 25rpx;
  140. border: 1px solid #F4F4F4;
  141. line-height: 50rpx;
  142. padding: 0 20rpx;
  143. font-size: 24rpx;
  144. margin-right: 30rpx;
  145. &.active {
  146. color: $themC;
  147. background: rgba(222,58,38,0.1);
  148. border-radius: 25rpx;
  149. border: 1px solid #DE3A26;
  150. }
  151. }
  152. }
  153. .ul {
  154. width: 100%;
  155. .li {
  156. width: 100%;
  157. padding: 30rpx 0;
  158. border-bottom: 1px solid #EFEFEF;
  159. &:last-child {
  160. border: none;
  161. }
  162. .flex-b {
  163. .name {
  164. font-size: 32rpx;
  165. color: #333333;
  166. flex: 1;
  167. width: 0;
  168. padding-right: 30rpx;
  169. }
  170. .btn {
  171. width: 132rpx;
  172. height: 44rpx;
  173. background: #DE3A26;
  174. border-radius: 22rpx;
  175. font-size: 24rpx;
  176. color: #fff;
  177. text-align: center;
  178. line-height: 44rpx;
  179. &.boder {
  180. border: 1px solid #DE3A26;
  181. color: $themC;
  182. background-color: #fff;
  183. }
  184. &.hui {
  185. opacity: 0.4;
  186. }
  187. }
  188. }
  189. .text {
  190. padding-top: 14rpx;
  191. text {
  192. font-size: 24rpx;
  193. color: #9C9C9C;
  194. margin-right: 40rpx;
  195. }
  196. }
  197. }
  198. }
  199. }
  200. </style>