Kudos.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. <template>
  2. <view class="kudos">
  3. <!-- 点赞列表 -->
  4. <view class="List">
  5. <view class="ListItem" v-for="(item,index) in List" :key="index" @click="goVoteDetail(item.id)">
  6. <image :src="item.cover_img" style="width: 640rpx;height:420rpx;border-radius: 12rpx;"></image>
  7. <view class="kudosicon">
  8. <image src="/static/icon/Kudos.png" v-if="item.is_like!=1" @click.stop="clickKudos(item.id,index)"></image>
  9. <image src="/static/icon/Kudos(1).png" v-if="item.is_like==1" @click.stop="clickKudos(item.id,index)"></image>
  10. </view>
  11. <view class="nav">
  12. <view class="events">
  13. <text>{{item.title}}</text>
  14. </view>
  15. <view class="voteStatus">
  16. <text v-if="false">未开始</text>
  17. <text style="color:#FF6503 ;">投票中</text>
  18. </view>
  19. </view>
  20. <view class="foot">
  21. <image src="/static/icon/data.png"></image>
  22. <text>{{item.end_time}} 结束</text>
  23. </view>
  24. </view>
  25. </view>
  26. <!-- 已经到底啦 -->
  27. <uni-load-more :status="status" color="#CCCCCC" :content-text="contentText"/>
  28. </view>
  29. </template>
  30. <script>
  31. export default{
  32. data(){
  33. return{
  34. //组件uni-load-more
  35. status: 'noMore',
  36. contentText: {
  37. contentdown: '查看更多',
  38. contentrefresh: '加载中',
  39. contentnomore: '—— 已经到底啦 ——'
  40. },
  41. // 点赞列表
  42. List:[],
  43. }
  44. },
  45. onLoad() {
  46. this.getList()
  47. },
  48. methods:{
  49. // 获取点赞列表
  50. getList(){
  51. this.$api.active.getActiveList({
  52. page:1,
  53. is_my_like:1
  54. }).then(res=>{
  55. console.log(res,"点赞列表")
  56. if(res.code==0){
  57. this.List=res.data.data
  58. }else{
  59. uni.showToast({
  60. title:res.msg,
  61. icon:'none'
  62. })
  63. }
  64. })
  65. },
  66. // 跳转投票详情
  67. goVoteDetail(id){
  68. uni.navigateTo({
  69. url:'/pages/index/active-detail/index?id='+id
  70. })
  71. },
  72. // 点赞
  73. clickKudos(id,index){
  74. let beforeLike=this.List[index].is_like
  75. this.$api.active.kudos({
  76. activity_id:id
  77. }).then(res=>{
  78. console.log(res,'点赞')
  79. if(res.code==0){
  80. if(beforeLike==1){
  81. this.List[index].is_like=0
  82. }else{
  83. this.List[index].is_like=1
  84. }
  85. }
  86. })
  87. },
  88. }
  89. }
  90. </script>
  91. <style lang="scss" scoped>
  92. $pageColor:#F9F9F9;
  93. $bgColor:#FFFFFF;
  94. @mixin flexlayout {
  95. display: flex;
  96. align-items: center;
  97. justify-content: center;
  98. }
  99. .kudos {
  100. height: 100%;
  101. background: $pageColor;
  102. }
  103. .List {
  104. padding: 0 30rpx;
  105. box-sizing: border-box;
  106. padding-top: 24rpx;
  107. .ListItem {
  108. position: relative;
  109. margin-bottom: 24rpx;
  110. width: 690rpx;
  111. height: 562rpx;
  112. background: $bgColor;
  113. box-shadow: 0rpx 12rpx 40rpx 0rpx rgba(220, 222, 229, 0.4);
  114. border-radius: 24rpx;
  115. padding: 20rpx 26rpx 26rpx 24rpx;
  116. .kudosicon {
  117. width: 48rpx;
  118. position: absolute;
  119. top: 52rpx;
  120. right: 58rpx;
  121. border-radius: 50%;
  122. height: 48rpx;
  123. background: #FFFFFF;
  124. opacity: 0.84;
  125. @include flexlayout()
  126. image{
  127. width: 29rpx;
  128. height: 26rpx;
  129. }
  130. }
  131. .nav {
  132. display: flex;
  133. align-items: center;
  134. justify-content: space-between;
  135. .events {
  136. text {
  137. font-size: 30rpx;
  138. font-family: PingFang-SC-Bold, PingFang-SC;
  139. font-weight: bold;
  140. color: #333333;
  141. }
  142. }
  143. .voteStatus {
  144. font-size: 30rpx;
  145. font-family: PingFang-SC-Medium, PingFang-SC;
  146. font-weight: 500;
  147. color: #999999;
  148. }
  149. }
  150. .foot {
  151. margin-top: 10rpx;
  152. display: flex;
  153. align-items: center;
  154. image {
  155. width: 28rpx;
  156. height: 28rpx;
  157. margin-right: 8rpx;
  158. }
  159. text {
  160. font-size: 24rpx;
  161. font-weight: 500;
  162. color: #999999;
  163. display: block;
  164. }
  165. }
  166. }
  167. }
  168. </style>