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.

231 lines
5.2 KiB

4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
3 months ago
4 months ago
4 months ago
3 months ago
4 months ago
3 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
3 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
3 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
3 months ago
4 months ago
3 months ago
4 months ago
3 months ago
4 months ago
4 months ago
4 months ago
4 months ago
3 months ago
4 months ago
3 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" @click="goVote(item)">
  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" >查看结果</view>
  17. <view class="btn" v-else-if="item.voteStatus==0" style="opacity: 0.4;">未开始</view>
  18. <view class="btn" v-else-if="item.voteStatus==1">我要投票</view>
  19. <view class="btn" 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. onShow,
  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. let style = {
  55. // p: 'font-size:32rpx',
  56. // span: 'font-size: 30rpx',
  57. img: 'max-width: 100%'
  58. }
  59. // tab切换
  60. const currentTab = ref(0)
  61. function tabClick(item) {
  62. currentTab.value = item.id
  63. initList()
  64. }
  65. // 类型筛选
  66. let currentTag = ref(-1)
  67. function tagClick(item) {
  68. if(currentTag.value==item.id) return
  69. currentTag.value = item.id
  70. params.value.voteState = item.id
  71. initList()
  72. }
  73. function goVote(item) {
  74. let url = ''
  75. if(currentTab.value==1||item.voted==1) {
  76. url = '/pages/subPage/ballots/vote/voteReslut?voteId='+item.voteId
  77. }else if(item.voteStatus==0) {
  78. return false
  79. }else if(item.voteStatus==1) {
  80. url = '/pages/subPage/ballots/vote/vote?voteId='+item.voteId
  81. }else if(item.voteStatus==2) {
  82. url = '/pages/subPage/ballots/vote/voteReslut?voteId='+item.voteId
  83. }
  84. // console.log(url)
  85. // console.log(item)
  86. uni.navigateTo({
  87. url
  88. })
  89. }
  90. let voteList = ref([])
  91. let total = ref(0)
  92. let params = ref({
  93. "pageNo": 1,
  94. "pageSize": 30,
  95. "voteState": -1
  96. })
  97. async function votePageFn() {
  98. if(params.value.voteState==-1) delete params.value.voteState
  99. console.log(params.value)
  100. let res
  101. if(currentTab.value==0) {
  102. const data = await votePage(params.value)
  103. res = data.data
  104. }else {
  105. const data = await mineVotePage(params.value)
  106. res = data.data
  107. }
  108. voteList.value.push(...res.list)
  109. total.value = res.total
  110. if(voteList.value.length>=total.value) status.value = 'nomore'
  111. console.log(voteList.value)
  112. }
  113. async function initList() {
  114. params.value.pageNo = 1
  115. voteList.value = []
  116. total.value = 0
  117. votePageFn()
  118. }
  119. onPullDownRefresh(async()=>{
  120. await initList()
  121. uni.stopPullDownRefresh()
  122. })
  123. onShow(()=>{
  124. initList()
  125. })
  126. onReachBottom(()=>{
  127. if(total.value > voteList.value.length) {
  128. votePageFn()
  129. }
  130. })
  131. </script>
  132. <style lang="scss" scoped>
  133. image {
  134. display: block;
  135. width: 100%;
  136. height: 100%;
  137. }
  138. .content {
  139. .banner {
  140. width: 100%;
  141. height: 174rpx;
  142. }
  143. .tabs {
  144. padding: 30rpx 0 10rpx 0;
  145. border-bottom: 1px solid #EFEFEF;
  146. }
  147. .tags {
  148. width: 100%;
  149. height: 110rpx;
  150. display: flex;
  151. align-items: center;
  152. border-bottom: 1px solid #EFEFEF;
  153. .tag {
  154. height: 50rpx;
  155. background: #EFEFEF;
  156. border-radius: 25rpx;
  157. border: 1px solid #F4F4F4;
  158. line-height: 50rpx;
  159. padding: 0 20rpx;
  160. font-size: 24rpx;
  161. margin-right: 30rpx;
  162. &.active {
  163. color: $themC;
  164. background: rgba(222,58,38,0.1);
  165. border-radius: 25rpx;
  166. border: 1px solid #DE3A26;
  167. }
  168. }
  169. }
  170. .ul {
  171. width: 100%;
  172. .li {
  173. width: 100%;
  174. padding: 30rpx 0;
  175. border-bottom: 1px solid #EFEFEF;
  176. &:last-child {
  177. border: none;
  178. }
  179. .flex-b {
  180. .name {
  181. font-size: 32rpx;
  182. color: #333333;
  183. flex: 1;
  184. width: 0;
  185. padding-right: 30rpx;
  186. }
  187. .btn {
  188. width: 132rpx;
  189. height: 44rpx;
  190. background: #DE3A26;
  191. border-radius: 22rpx;
  192. font-size: 24rpx;
  193. color: #fff;
  194. text-align: center;
  195. line-height: 44rpx;
  196. &.boder {
  197. border: 1px solid #DE3A26;
  198. color: $themC;
  199. background-color: #fff;
  200. }
  201. &.hui {
  202. opacity: 0.4;
  203. }
  204. }
  205. }
  206. .text {
  207. padding-top: 14rpx;
  208. text {
  209. font-size: 24rpx;
  210. color: #9C9C9C;
  211. margin-right: 40rpx;
  212. }
  213. }
  214. }
  215. }
  216. }
  217. </style>