gain_task.vue 3.5 KB

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