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.

230 lines
4.5 KiB

2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
  1. <template>
  2. <view class="content">
  3. <topInfo :detailInfo="detailInfo"/>
  4. <view class="padding">
  5. <view class="ul">
  6. <view class="li" :class="{active: voteItemId.find(val=>val.voteItemId==item.itemId)}" v-for="(item,index) in detailInfo.voteItems" :key="index" @click="chooseItem(item)">{{ item.itemName }}</view>
  7. </view>
  8. <!-- <view class="ul" >
  9. <view class="li2 flex-b active" v-for="(item,index) in detailInfo.voteItems" :key="index">
  10. <view class="proccess" style="width: 30%;"></view>
  11. <view class="leftTxt flex">
  12. <u-icon name="checkbox-mark" color="#DE3A26" size="20"></u-icon>
  13. <view class="name">{{ item.itemName }}</view>
  14. </view>
  15. <view class="rightTxt">13 <text>(30%)</text></view>
  16. </view>
  17. </view> -->
  18. <view class="btn padding">
  19. <oneBtn text="投 票" :disabled="!voteItemId.length" @oneBtnClick="articleVoteFn"></oneBtn>
  20. </view>
  21. </view>
  22. </view>
  23. </template>
  24. <script setup>
  25. import { ref } from 'vue'
  26. import { voteDetail, articleVote } from '@/config/api.js'
  27. import topInfo from './comp/topInfo.vue'
  28. import {
  29. onLoad,
  30. onPullDownRefresh,
  31. } from '@dcloudio/uni-app'
  32. let voteId = ''
  33. const isCheck = ref(false)
  34. function changeRadio(val) {
  35. isCheck.value = val
  36. }
  37. const detailInfo = ref({})
  38. async function voteDetailFn() {
  39. const {data: res} = await voteDetail({voteId: voteId})
  40. console.log(res)
  41. detailInfo.value = res
  42. }
  43. // 选择投票选项
  44. const voteItemId = ref([])
  45. function chooseItem(item) {
  46. // 如果是单选
  47. if(detailInfo.value.voteType==1) {
  48. voteItemId.value = [{voteItemId: item.itemId, voteId: voteId}]
  49. return
  50. }
  51. // 如果是多选
  52. let index = voteItemId.value.findIndex((val)=>val.voteItemId==item.itemId)
  53. if(index==-1) {
  54. voteItemId.value.push({voteItemId: item.itemId, voteId: voteId})
  55. }else {
  56. voteItemId.value.splice(index, 1)
  57. }
  58. console.log(voteItemId.value)
  59. }
  60. async function articleVoteFn() {
  61. if(!voteItemId.value.length) return
  62. const {data: res} = await articleVote(voteItemId.value)
  63. if(res) uni.$u.toast('投票成功')
  64. setTimeout(()=>{
  65. uni.navigateTo({
  66. url: '/pages/subPage/ballots/vote/voteReslut?voteId='+voteId
  67. })
  68. }, 1500)
  69. }
  70. onLoad((option)=>{
  71. voteId = option.voteId
  72. voteDetailFn()
  73. })
  74. onPullDownRefresh(async()=>{
  75. await voteDetailFn()
  76. uni.stopPullDownRefresh()
  77. })
  78. </script>
  79. <style lang="scss" scoped>
  80. .content {
  81. width: 100%;
  82. .bg {
  83. width: 100%;
  84. background: linear-gradient(0deg, #ffffff 0%, #FFD4D3 100%);
  85. padding: 120rpx 20rpx 20rpx 20rpx;
  86. .tit {
  87. font-size: 36rpx;
  88. padding: 10rpx 0 20rpx 0;
  89. font-weight: 700;
  90. }
  91. .textCon {
  92. display: flex;
  93. .p {
  94. font-size: 24rpx;
  95. color: #9C9C9C;
  96. flex: 1;
  97. width: 0;
  98. .txt {
  99. margin-bottom: 14rpx;
  100. }
  101. }
  102. .status {
  103. width: 110rpx;
  104. font-size: 22rpx;
  105. height: 44rpx;
  106. background: #DE3A26;
  107. border-radius: 22rpx;
  108. line-height: 44rpx;
  109. text-align: center;
  110. color: #fff;
  111. }
  112. }
  113. }
  114. .row {
  115. height: 90rpx;
  116. margin-bottom: 40rpx;
  117. border-bottom: 1px solid #EFEFEF;
  118. .flex {
  119. flex: 1;
  120. width: 0;
  121. .radionItem {
  122. font-size: 28rpx;
  123. margin-right: 30rpx;
  124. color: $themC;
  125. &.hui {
  126. color: #9C9C9C;
  127. }
  128. }
  129. }
  130. .checkboxs {
  131. font-size: 28rpx;
  132. color: $themC;
  133. }
  134. }
  135. .ul {
  136. width: 100%;
  137. .li {
  138. height: 84rpx;
  139. border-radius: 10rpx;
  140. border: 1px solid #CCCCCC;
  141. line-height: 84rpx;
  142. padding: 0 20rpx;
  143. display: flex;
  144. margin-bottom: 20rpx;
  145. font-size: 28rpx;
  146. color: #333;
  147. &.active {
  148. background: #FFD3D3;
  149. border-radius: 10rpx;
  150. color: $themC;
  151. border: 1px solid #DE3A26;
  152. }
  153. }
  154. .li2 {
  155. position: relative;
  156. height: 84rpx;
  157. border-radius: 10rpx;
  158. border: 1px solid #CCCCCC;
  159. line-height: 84rpx;
  160. padding: 0 20rpx;
  161. display: flex;
  162. margin-bottom: 20rpx;
  163. font-size: 28rpx;
  164. color: #333;
  165. &.active {
  166. border-radius: 10rpx;
  167. color: $themC;
  168. .proccess {
  169. background: #FFD3D3;
  170. }
  171. }
  172. .proccess {
  173. width: 100%;
  174. height: 100%;
  175. background-color: #EFEFEF;
  176. position: absolute;
  177. left: 0;
  178. top: 0;
  179. }
  180. .leftTxt {
  181. position: relative;
  182. z-index: 9;
  183. .name {
  184. margin-left: 6rpx;
  185. }
  186. }
  187. .rightTxt {
  188. color: #9C9C9C;
  189. position: relative;
  190. z-index: 9;
  191. text {
  192. margin-left: 4rpx;
  193. }
  194. }
  195. }
  196. }
  197. .btn {
  198. padding-top: 50rpx;
  199. }
  200. }
  201. </style>