actionList.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. <template>
  2. <view class="content">
  3. <empty v-if="loaded && list.length == 0"></empty>
  4. <view class="action" v-for="item in list" @click="goAction(item)">
  5. <image :src="item.image_input[0]" mode="" class="action-img"></image>
  6. <view class="action-tit">
  7. {{item.title}}
  8. </view>
  9. <view class=" time">
  10. <view class="">
  11. 活动时间:{{getTime(item.start_time)}} - {{getTime(item.end_time)}}
  12. </view>
  13. </view>
  14. </view>
  15. <uni-load-more :status="loadingType"></uni-load-more>
  16. </view>
  17. </template>
  18. <script>
  19. import { getTime } from '@/utils/rocessor.js'
  20. import {
  21. articleList,
  22. record,
  23. } from '@/api/index.js'
  24. export default {
  25. data() {
  26. return {
  27. page: 1,
  28. limit: 10,
  29. list: [],
  30. loadingType: 'more',
  31. loaded: false,
  32. type: 0,
  33. };
  34. },
  35. onLoad(opt) {
  36. if(opt.type) {
  37. this.type = opt.type
  38. }
  39. },
  40. onShow() {
  41. this.getActionList()
  42. },
  43. onReachBottom() {
  44. },
  45. methods: {
  46. getTime,
  47. goAction(item) {
  48. if(this.type == 0) {
  49. let time = new Date().getTime()
  50. console.log(time);
  51. if(time < item.start_time*1000) {
  52. return this.$api.msg('活动未开始,请耐心等待')
  53. }
  54. if(time > item.end_time*1000) {
  55. return this.$api.msg('活动已结束')
  56. }
  57. uni.navigateTo({
  58. url: '/pages/index/action?id=' + item.id
  59. })
  60. }
  61. },
  62. getActionList() {
  63. if (this.loadingType == 'loading' || this.loadingType == 'noMore') {
  64. return
  65. }
  66. this.loadingType = 'more'
  67. articleList({
  68. page: this.page,
  69. limit: this.limit
  70. },2).then(res => {
  71. this.list = this.list.concat(res.data.data)
  72. this.page++
  73. if (res.data.lengt == this.limit) {
  74. this.loadingType = 'more'
  75. } else {
  76. this.loadingType = 'noMore'
  77. }
  78. this.loaded = true
  79. })
  80. }
  81. }
  82. };
  83. </script>
  84. <style lang="scss" scoped>
  85. page {
  86. background-color: #f2f2f2;
  87. height: auto;
  88. min-height: 100%;
  89. }
  90. .action {
  91. width: 700rpx;
  92. margin: 25rpx auto;
  93. border-radius: 35rpx;
  94. overflow: hidden;
  95. background-color: #fff;
  96. .action-img {
  97. width: 700rpx;
  98. height: 300rpx;
  99. background-color: #333;
  100. }
  101. .action-tit {
  102. min-height: 100rpx;
  103. font-size: 34rpx;
  104. font-weight: 500;
  105. color: #0E0E0E;
  106. display: flex;
  107. align-items: center;
  108. padding: 15rpx;
  109. padding-left: 30rpx;
  110. }
  111. .time {
  112. font-size: 12rpx;
  113. padding: 20rpx;
  114. padding-top: 0;
  115. }
  116. }
  117. </style>