vote-card.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. <template>
  2. <view class="vote-card" @click="$emit('on-click',vote)">
  3. <view class="vote-card-head flex">
  4. <view class="left flex flex-center w-full">
  5. <view class="flex-shrink">
  6. <tm-tags color="light-blue" :shadow="0" rounded size="s" model="fill">{{ vote.spec._uh_type}}</tm-tags>
  7. </view>
  8. <view class="title text-overflow">
  9. {{ vote.spec.title }}
  10. </view>
  11. </view>
  12. </view>
  13. <view class="vote-card-body w-full">
  14. <view v-if="vote.spec.remark" class="remark text-overflow-2 text-size-s">
  15. {{vote.spec.remark}}
  16. </view>
  17. </view>
  18. <view class="vote-card-foot flex flex-between">
  19. <view class="left flex">
  20. <tm-tags :color="vote.spec._uh_state.color" size="s" rounded :shadow="0"
  21. model="text">{{vote.spec._uh_state.state}}</tm-tags>
  22. <tm-tags v-if="vote.spec.isVoted" color="blue" rounded size="s" model="text">已投票</tm-tags>
  23. <tm-tags v-if="vote.spec.timeLimit==='permanent'" color="grey-darken-2" rounded size="s"
  24. model="text">结束时间:永久有效 </tm-tags>
  25. <tm-tags v-else color="grey-darken-2" rounded size="s" model="text">
  26. <template
  27. v-if="vote.spec._uh_state.state=='未开始'">开始时间:{{ {d: vote.spec.startDate, f: 'yyyy-MM-dd HH:mm'} | formatTime }}
  28. </template>
  29. <template v-else>结束时间:{{ {d: vote.spec.endDate, f: 'yyyy-MM-dd HH:mm'} | formatTime }}
  30. </template>
  31. </tm-tags>
  32. </view>
  33. <view v-if="false" class="right flex flex-end">
  34. <tm-tags v-if="false" color="grey-darken-2" rounded size="s" model="text">{{ vote.stats.voteCount }}
  35. 人已参与</tm-tags>
  36. </view>
  37. </view>
  38. </view>
  39. </template>
  40. <script>
  41. import tmGroupradio from '@/tm-vuetify/components/tm-groupradio/tm-groupradio.vue';
  42. import tmRadio from '@/tm-vuetify/components/tm-radio/tm-radio.vue';
  43. import tmGroupcheckbox from '@/tm-vuetify/components/tm-groupcheckbox/tm-groupcheckbox.vue';
  44. import tmCheckbox from '@/tm-vuetify/components/tm-checkbox/tm-checkbox.vue';
  45. import tmButton from '@/tm-vuetify/components/tm-button/tm-button.vue';
  46. import tmTags from '@/tm-vuetify/components/tm-tags/tm-tags.vue';
  47. export default {
  48. name: "VoteCard",
  49. options: {
  50. virtualHost: true,
  51. styleIsolation: 'shared'
  52. },
  53. components: {
  54. tmGroupradio,
  55. tmRadio,
  56. tmGroupcheckbox,
  57. tmCheckbox,
  58. tmButton,
  59. tmTags
  60. },
  61. props: {
  62. vote: {
  63. type: Object,
  64. default: () => ({})
  65. },
  66. index: {
  67. type: Number,
  68. default: 0
  69. },
  70. showOptions: {
  71. type: Boolean,
  72. default: false
  73. }
  74. }
  75. }
  76. </script>
  77. <style lang="scss" scoped>
  78. .w-full {
  79. width: 100%;
  80. }
  81. .wp-50 {
  82. width: 50%;
  83. }
  84. .vote-card {
  85. display: flex;
  86. flex-direction: column;
  87. box-sizing: border-box;
  88. margin: 0 24rpx;
  89. padding: 24rpx;
  90. border-radius: 12rpx;
  91. background-color: #ffff;
  92. box-shadow: 0rpx 2rpx 12rpx rgba(0, 0, 0, 0.035);
  93. overflow: hidden;
  94. margin-bottom: 24rpx;
  95. // border: 1px solid #eee;
  96. }
  97. .vote-card-head {
  98. margin-bottom: 12rpx;
  99. display: flex;
  100. align-items: center;
  101. justify-content: space-between;
  102. .left {
  103. .title {
  104. font-size: 28rpx;
  105. font-weight: bold;
  106. }
  107. }
  108. }
  109. .vote-card-body {
  110. .remark {
  111. box-sizing: border-box;
  112. padding-top: 0;
  113. color: rgba(0, 0, 0, 0.75);
  114. margin-bottom: 12rpx;
  115. }
  116. }
  117. .vote-card-foot {
  118. box-sizing: border-box;
  119. padding-top: 6px;
  120. margin-top: 6px;
  121. border-top: 2rpx solid #F7F7F7;
  122. .left {}
  123. }
  124. .single {
  125. ::v-deep {
  126. .tm-groupradio {
  127. width: 100%;
  128. box-sizing: border-box;
  129. display: flex;
  130. flex-wrap: wrap;
  131. gap: 12rpx 0;
  132. }
  133. .tm-checkbox {
  134. box-sizing: border-box;
  135. display: block;
  136. padding: 0 12rpx;
  137. width: 50%;
  138. }
  139. .tm-button-label {
  140. width: 100%;
  141. }
  142. }
  143. }
  144. .multiple {
  145. ::v-deep {
  146. .tm-groupcheckbox {
  147. width: 100%;
  148. box-sizing: border-box;
  149. display: flex;
  150. flex-wrap: wrap;
  151. gap: 12rpx 0;
  152. }
  153. .tm-checkbox {
  154. box-sizing: border-box;
  155. display: block;
  156. padding: 0 12rpx;
  157. width: 50%;
  158. }
  159. .tm-button-label {
  160. width: 100%;
  161. }
  162. }
  163. }
  164. .pk {
  165. box-sizing: border-box;
  166. width: 100%;
  167. padding: 0 12rpx;
  168. ::v-deep {
  169. .tm-groupradio {
  170. display: flex;
  171. width: 100%;
  172. }
  173. .tm-checkbox {
  174. flex-grow: 1;
  175. min-width: 30% !important;
  176. max-width: 70% !important;
  177. }
  178. .radio-item {
  179. position: relative;
  180. .selected {
  181. z-index: 10;
  182. }
  183. }
  184. .radio-left {}
  185. .radio-right {}
  186. .option-item {
  187. width: 100%;
  188. padding: 12rpx 24rpx;
  189. border-radius: 12rpx;
  190. }
  191. .option-item-left {
  192. background: linear-gradient(90deg, #3B82F6, #60A5FA);
  193. color: white;
  194. clip-path: polygon(0 0, calc(100% - 40rpx) 0, 100% 100%, 0 100%);
  195. }
  196. .option-item-right {
  197. background: linear-gradient(90deg, #F87171, #EF4444);
  198. color: white;
  199. clip-path: polygon(0 0, 100% 0, 100% 100%, 40rpx 100%);
  200. text-align: right;
  201. }
  202. .option-foot {
  203. width: 100%;
  204. margin-top: 6rpx;
  205. font-size: 24rpx;
  206. color: #666;
  207. .left {
  208. box-sizing: border-box;
  209. padding-right: 24rpx;
  210. }
  211. .right {
  212. box-sizing: border-box;
  213. padding-left: 24rpx;
  214. }
  215. }
  216. }
  217. }
  218. </style>