Kudos.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. <template>
  2. <view class="kudos">
  3. <!-- 点赞列表 -->
  4. <view class="msg-null" v-if="List.length == 0 ">
  5. <image src="https://t9.9026.com/imgs/dataNull.png" style="width: 394rpx;height: 396rpx;" mode=""></image>
  6. <view class="msg-null-text">
  7. <text>暂无数据</text>
  8. </view>
  9. </view>
  10. <view class="List" style="background-color: #f9f9f9a;" v-if="List.length > 0">
  11. <view class="ListItem" v-for="(item,index) in List" :key="index" @click="goVoteDetail(item.id)">
  12. <image :src="item.cover_img" style="width: 640rpx;height:420rpx;border-radius: 12rpx;"></image>
  13. <view class="kudosicon">
  14. <image src="/static/icon/Kudos.png" v-if="item.is_like!=1" @click.stop="clickKudos(item.id,index)"></image>
  15. <image src="/static/icon/Kudos(1).png" v-if="item.is_like==1" @click.stop="clickKudos(item.id,index)"></image>
  16. </view>
  17. <view class="nav">
  18. <view class="events">
  19. <text>{{item.title}}</text>
  20. </view>
  21. <view class="voteStatus" style="width: 100rpx;">
  22. <text style="font-size: 30rpx;color: #999;" v-if="item.activity_status==1">未开始</text>
  23. <text style="font-size: 30rpx;color: #FF6503;" v-if="item.activity_status==2">进行中</text>
  24. <text style="font-size: 30rpx;color: #999;" v-if="item.activity_status==3">已结束</text>
  25. </view>
  26. </view>
  27. <view class="foot">
  28. <image src="/static/icon/data.png"></image>
  29. <text>{{item.end_time}} 结束</text>
  30. </view>
  31. </view>
  32. </view>
  33. <!-- 已经到底啦 -->
  34. <!-- 触底 -->
  35. <view class="home-bottom" style="padding-bottom: 60rpx;" v-if="List.length > 0">
  36. <uni-load-more :status="status" color="#CCCCCC" :content-text="contentText"/>
  37. </view>
  38. </view>
  39. </template>
  40. <script>
  41. export default{
  42. data(){
  43. return{
  44. contentText: {
  45. contentdown: '查看更多',
  46. contentrefresh: '加载中',
  47. contentnomore: '—— 已经到底啦 ——'
  48. },
  49. // 点赞列表
  50. List:[],
  51. // 分页
  52. page: 1,
  53. pagesize: 15,
  54. totalElements: '',
  55. allListItem: '',
  56. // 组件uni-load-more
  57. status: 'noMore',
  58. }
  59. },
  60. onLoad() {
  61. this.getList()
  62. },
  63. onUnload() {
  64. uni.$emit('refreshActivityList')
  65. },
  66. // 触底加载
  67. onReachBottom() {
  68. // 触底的时候请求数据,即为上拉加载更多
  69. var allTotal = this.page * this.pagesize
  70. console.log(allTotal, '----allTotal');
  71. //this.page为加载次数,this.pagesize为每一次加载的数据条数
  72. if (allTotal < this.totalElements) {
  73. //this.totalElements为请求数据的总条数。只要现有条数小于总条数就就执行一下代码
  74. this.allListItem = false;
  75. this.page++;
  76. //加载次数递加
  77. this.status = "loading"
  78. this.$api.active.getActiveList({ //请求更多数据列表
  79. page: this.page,
  80. is_my_like:1
  81. }).then(res => {
  82. let ret = [...this.List, ...res.data.data]
  83. this.List = ret
  84. console.log(ret)
  85. })
  86. } else {
  87. this.allListItem = true;
  88. console.log('已加载全部数据')
  89. this.status = "noMore"
  90. }
  91. },
  92. methods:{
  93. // 获取点赞列表
  94. getList(){
  95. this.$api.active.getActiveList({
  96. page:1,
  97. is_my_like:1
  98. }).then(res=>{
  99. console.log(res,"点赞列表")
  100. if(res.code==0){
  101. this.List=res.data.data
  102. this.totalElements = res.data.total
  103. this.pagesize = res.data.per_page
  104. }else{
  105. uni.showToast({
  106. title:res.msg,
  107. icon:'none'
  108. })
  109. }
  110. })
  111. },
  112. // 跳转投票详情
  113. goVoteDetail(id){
  114. uni.navigateTo({
  115. url:'/pages/index/active-detail/index?id='+id
  116. })
  117. },
  118. // 点赞
  119. clickKudos(id,index){
  120. let beforeLike=this.List[index].is_like
  121. this.$api.active.kudos({
  122. activity_id:id
  123. }).then(res=>{
  124. if(res.code==0){
  125. if(beforeLike==1){
  126. this.List[index].is_like=0
  127. uni.showToast({
  128. icon: 'none',
  129. title: '取消点赞'
  130. })
  131. setTimeout(()=>{
  132. this.getList()
  133. },500)
  134. }else{
  135. this.List[index].is_like=1
  136. }
  137. }
  138. })
  139. },
  140. }
  141. }
  142. </script>
  143. <style lang="scss" scoped>
  144. $pageColor:#F9F9F9;
  145. $bgColor:#FFFFFF;
  146. @mixin flexlayout {
  147. display: flex;
  148. align-items: center;
  149. justify-content: center;
  150. }
  151. .kudos {
  152. height: 100%;
  153. background: $pageColor;
  154. }
  155. .home-bottom {
  156. // background-color: #f9f9f9;
  157. padding-top: 120rpx;
  158. }
  159. .msg-null{
  160. padding-top: 60rpx;
  161. display: flex;
  162. flex-direction: column;
  163. align-items: center;
  164. justify-content: center;
  165. .msg-null-text{
  166. margin-top: 40rpx;
  167. font-size: 28rpx;
  168. color: #333;
  169. }
  170. }
  171. .List {
  172. padding: 0 30rpx;
  173. box-sizing: border-box;
  174. padding-top: 24rpx;
  175. .ListItem {
  176. position: relative;
  177. margin-bottom: 24rpx;
  178. width: 690rpx;
  179. height: 562rpx;
  180. background: $bgColor;
  181. box-shadow: 0rpx 12rpx 40rpx 0rpx rgba(220, 222, 229, 0.4);
  182. border-radius: 24rpx;
  183. padding: 20rpx 26rpx 26rpx 24rpx;
  184. .kudosicon {
  185. width: 48rpx;
  186. position: absolute;
  187. top: 52rpx;
  188. right: 58rpx;
  189. border-radius: 50%;
  190. height: 48rpx;
  191. background: #FFFFFF;
  192. opacity: 0.84;
  193. @include flexlayout()
  194. image{
  195. width: 29rpx;
  196. height: 26rpx;
  197. }
  198. }
  199. .nav {
  200. display: flex;
  201. align-items: center;
  202. justify-content: space-between;
  203. .events {
  204. text {
  205. font-size: 30rpx;
  206. font-family: PingFang-SC-Bold, PingFang-SC;
  207. font-weight: bold;
  208. color: #333333;
  209. }
  210. }
  211. .voteStatus {
  212. font-size: 30rpx;
  213. font-family: PingFang-SC-Medium, PingFang-SC;
  214. font-weight: 500;
  215. color: #999999;
  216. }
  217. }
  218. .foot {
  219. margin-top: 10rpx;
  220. display: flex;
  221. align-items: center;
  222. image {
  223. width: 28rpx;
  224. height: 28rpx;
  225. margin-right: 8rpx;
  226. }
  227. text {
  228. font-size: 24rpx;
  229. font-weight: 500;
  230. color: #999999;
  231. display: block;
  232. }
  233. }
  234. }
  235. }
  236. </style>