list.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. <template>
  2. <view :style="vuex_skin">
  3. <!-- #ifdef MP-WEIXIN -->
  4. <view class="navbar">
  5. <u-navbar title-color="#000000" :is-back="true" title="活动列表"></u-navbar>
  6. </view>
  7. <!-- #endif -->
  8. <mescroll-body ref="mescrollRef" @init="mescrollInit" :down="downOption" :up="upOption" @down="downCallback"
  9. @up="upCallback">
  10. <view class="card" style="position: relative;" @click="jump(item)" v-for="(item,index) in list" :key="index">
  11. <view class="center">
  12. <image :src="item.imgUrl" mode="aspectFill"></image>
  13. </view>
  14. <view class="content" style="padding: 6rpx 0;">
  15. <view class="">
  16. <view class="text-bold text-cut-2" style="font-size: 28rpx;">{{content(item.content)}}</view>
  17. </view>
  18. <view class="" >
  19. <view style="margin-top: 8rpx;color: #828282;font-weight: 300;font-size: 26rpx;margin-bottom: 15rpx;">
  20. 参赛时间:
  21. <text>{{formatTime(item.startTime)}} 至 {{formatTime(item.endTime)}}</text>
  22. </view>
  23. <view class="flex">
  24. <text class="cuIcon-hotfill padding-lr-xs text-base" style="margin-right: 4rpx;"></text>
  25. <text style="margin-left: -6rpx;">{{numberNull(item.viewCount)}}</text>
  26. </view>
  27. </view>
  28. </view>
  29. <image :src="getIcon(item)" mode="" style="width: 80rpx;height: 80rpx;position: absolute;right: 0rpx;bottom: 0rpx;"></image>
  30. </view>
  31. </mescroll-body>
  32. </view>
  33. </template>
  34. <script>
  35. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  36. export default {
  37. mixins: [MescrollMixin],
  38. data() {
  39. return {
  40. now:null,
  41. list: [],
  42. downOption:{
  43. auto:false
  44. },
  45. upOption:{
  46. auto:true
  47. }
  48. }
  49. },
  50. onLoad() {
  51. this.now=new Date().getTime()
  52. },
  53. computed:{
  54. content(){
  55. return data=>{
  56. return this.$util.formatHtml(data)
  57. }
  58. },
  59. getIcon(){
  60. return data=>{
  61. let startTime=this.$dateTime.getTime(data.startTime)
  62. let endTime=this.$dateTime.getTime(data.endTime)
  63. if (this.now<startTime) {
  64. return "/static/icon/waiting.png"
  65. }
  66. if (this.now>endTime) {
  67. return "/static/icon/end.png"
  68. }
  69. return "/static/icon/ongoing.png"
  70. }
  71. }
  72. },
  73. methods: {
  74. jump(item){
  75. uni.reLaunch({
  76. url:"/pages/index/home?activeId="+item.id
  77. })
  78. },
  79. downCallback() {
  80. setTimeout(() => {
  81. this.mescroll.resetUpScroll();
  82. }, 800)
  83. },
  84. upCallback(mescroll) {
  85. let params = {
  86. current:mescroll.num,
  87. size:mescroll.size,
  88. }
  89. try {
  90. this.$api.activerecord.list(params).then(res => {
  91. let data = res.data.data.records
  92. let total = res.data.data.total
  93. mescroll.endBySize(data.length, total);
  94. if (mescroll.num == 1) this.list = []; //如果是第一页需手动制空列表
  95. this.list = this.list.concat(data); //追加新数据
  96. })
  97. } catch (e) {
  98. this.mescroll.endErr()
  99. }
  100. },
  101. }
  102. }
  103. </script>
  104. <style lang="scss">
  105. .card{
  106. margin: 20rpx;
  107. padding: 20rpx;
  108. border-radius: 12rpx;
  109. background-color: #FFFFFF;
  110. display: flex;
  111. image{
  112. width: 200rpx;
  113. height: 200rpx;
  114. margin-right: 20rpx;
  115. border-radius: 8rpx;
  116. }
  117. .content{
  118. display: flex;
  119. flex-direction: column;
  120. justify-content: space-between;
  121. }
  122. }
  123. </style>