gain_task.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  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. // import TaskImgTab from "@/common/task/task_ima_tab.vue"
  26. import {
  27. getTaskReceiving,
  28. takeTask
  29. } from "@/api/task";
  30. import tools from "@/service/tools";
  31. export default {
  32. components: {
  33. // TaskImgTab,
  34. TaskItem
  35. },
  36. data() {
  37. return {
  38. current: 0,
  39. tabs: [{
  40. name: '新闻',
  41. icon: '/static/img/statistics/task-four.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. name: '新闻新闻',
  59. icon: '/static/img/logo.png'
  60. }, {
  61. name: '新闻',
  62. icon: '/static/img/logo.png'
  63. }, ],
  64. taskList: [],
  65. page: 1,
  66. totalNum: 9999,
  67. isAjax: false,
  68. productId: 0
  69. }
  70. },
  71. mounted() {
  72. this.getTaskReceiving()
  73. },
  74. methods: {
  75. changeTab(index) {
  76. this.current = index
  77. },
  78. setProductId(productId) {
  79. console.log('productId:' + productId)
  80. this.productId = productId
  81. this.startList()
  82. },
  83. // 下拉刷新
  84. startList() {
  85. this.taskList = [];
  86. this.page = 1
  87. this.totalNum = 99999
  88. this.getTaskReceiving()
  89. },
  90. async getTaskReceiving() {
  91. if (this.totalNum <= this.taskList.length) {
  92. return;
  93. }
  94. const res = await getTaskReceiving({
  95. 'page': this.page,
  96. 'productId': this.productId
  97. })
  98. if (res.code === 1) {
  99. this.totalNum = res.data.totalNum
  100. this.taskList.push(...res.data.items)
  101. ++this.page
  102. }
  103. },
  104. setTakeTask(index) {
  105. console.log('index:' + index)
  106. this.taskList.splice(index, 1)
  107. uni.$emit('updateMemberInfo')
  108. },
  109. onRefresh() {
  110. uni.showLoading({
  111. title: '数据加载中'
  112. })
  113. setTimeout(() => {
  114. uni.showToast({
  115. title: '加载完成',
  116. icon: 'none'
  117. })
  118. this.$refs.scroll.onEndPulling()
  119. this.startList()
  120. }, 1000)
  121. console.log("下拉刷新");
  122. },
  123. // 滚动到底部
  124. onScrollBottom() {
  125. uni.showLoading({
  126. title: '数据加载中'
  127. })
  128. this.getTaskReceiving()
  129. setTimeout(() => {
  130. uni.showToast({
  131. title: '加载完成',
  132. icon: 'none'
  133. })
  134. }, 1000)
  135. console.log("到底部了");
  136. },
  137. }
  138. }
  139. </script>
  140. <style lang="scss" scoped>
  141. .gain-task {
  142. display: flex;
  143. flex-direction: column;
  144. min-height: 100%;
  145. /* 高度占满整个屏幕 */
  146. background-image: url('https://wealfavor-1257406827.cos.ap-beijing.myqcloud.com/new-xcx/task/task-nav-bg.png');
  147. background-repeat: no-repeat;
  148. background-size: 100% auto;
  149. }
  150. </style>