gain_task.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. <template>
  2. <view class="total-page page-box gain-task">
  3. <Nav :title="'领取任务'" :genre="1" is_fixed></Nav>
  4. <view class="m-lr20 r-20">
  5. <k-tabs-swiper class="r-20" v-model="current" :tabs="tabs" :field="'name'" bgColor="#fff" color="#444444"
  6. activeColor="#10B261" fontSize="28rpx" :bold="true" :scroll="true" height="100rpx" lineHeight="10rpx"
  7. @change="changeTab" paddingItem="0 50rpx">
  8. </k-tabs-swiper>
  9. </view>
  10. <EnScroll ref="scroll" :navHeight="110" class="main" @onRefresh="onRefresh" @onScrollBottom="onScrollBottom">
  11. <TaskItem :type="2" :task-list="taskList" is_bottom @takeTask="setTakeTask"></TaskItem>
  12. </EnScroll>
  13. </view>
  14. </template>
  15. <script>
  16. import TaskItem from "@/common/task/task-item.vue"
  17. import {
  18. getTaskReceiving,
  19. takeTask
  20. } from "@/api/task"
  21. import tools from "@/service/tools"
  22. export default {
  23. components: {
  24. TaskItem
  25. },
  26. data() {
  27. return {
  28. current: 0,
  29. tabs: [{
  30. name: '新闻',
  31. icon: '/static/img/statistics/task-four.png'
  32. }, {
  33. name: '新闻新闻',
  34. icon: '/static/img/logo.png'
  35. }, {
  36. name: '新闻新',
  37. icon: '/static/img/logo.png'
  38. }, {
  39. name: '新闻新闻',
  40. icon: '/static/img/logo.png'
  41. }, {
  42. name: '新闻新闻',
  43. icon: '/static/img/logo.png'
  44. }, {
  45. name: '新闻',
  46. icon: '/static/img/logo.png'
  47. }, {
  48. name: '新闻新闻',
  49. icon: '/static/img/logo.png'
  50. }, {
  51. name: '新闻',
  52. icon: '/static/img/logo.png'
  53. }, ],
  54. taskList: [],
  55. page: 1,
  56. totalNum: 9999,
  57. isAjax: false,
  58. productId: 0
  59. }
  60. },
  61. mounted() {
  62. this.getTaskReceiving()
  63. },
  64. methods: {
  65. changeTab(index) {
  66. this.current = index
  67. },
  68. setProductId(productId) {
  69. console.log('productId:' + productId)
  70. this.productId = productId
  71. this.startList()
  72. },
  73. // 下拉刷新
  74. startList() {
  75. this.taskList = [];
  76. this.page = 1
  77. this.totalNum = 99999
  78. this.getTaskReceiving()
  79. },
  80. async getTaskReceiving() {
  81. if (this.totalNum <= this.taskList.length) {
  82. return;
  83. }
  84. const res = await getTaskReceiving({
  85. 'page': this.page,
  86. 'productId': this.productId
  87. })
  88. if (res.code === 1) {
  89. this.totalNum = res.data.totalNum
  90. this.taskList.push(...res.data.items)
  91. ++this.page
  92. }
  93. },
  94. setTakeTask(index) {
  95. console.log('index:' + index)
  96. this.taskList.splice(index, 1)
  97. uni.$emit('updateMemberInfo')
  98. },
  99. onRefresh() {
  100. uni.showLoading({
  101. title: '数据加载中'
  102. })
  103. setTimeout(() => {
  104. uni.showToast({
  105. title: '加载完成',
  106. icon: 'none'
  107. })
  108. this.$refs.scroll.onEndPulling()
  109. this.startList()
  110. }, 1000)
  111. console.log("下拉刷新");
  112. },
  113. // 滚动到底部
  114. onScrollBottom() {
  115. uni.showLoading({
  116. title: '数据加载中'
  117. })
  118. this.getTaskReceiving()
  119. setTimeout(() => {
  120. uni.showToast({
  121. title: '加载完成',
  122. icon: 'none'
  123. })
  124. }, 1000)
  125. console.log("到底部了");
  126. },
  127. }
  128. }
  129. </script>
  130. <style lang="scss" scoped>
  131. .gain-task {
  132. display: flex;
  133. flex-direction: column;
  134. min-height: 100%;
  135. background-image: url('https://wealfavor-1257406827.cos.ap-beijing.myqcloud.com/new-xcx/task/task-nav-bg.png');
  136. background-repeat: no-repeat;
  137. background-size: 100% auto;
  138. }
  139. </style>