gain_task.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <template>
  2. <view class="total-page page-box">
  3. <Nav :title="'领取任务'" :genre="1" :fixedHeight="110"></Nav>
  4. <view class="task-tabs m-t30">
  5. <TaskImgTab @setProductId="setProductId"></TaskImgTab>
  6. </view>
  7. <!-- <EnButton is_both></EnButton> -->
  8. <EnScroll ref="scroll" :navHeight="110" class="main" @onRefresh="onRefresh" @onScrollBottom="onScrollBottom">
  9. <TaskItem :type="2" :task-list="taskList" is_bottom @takeTask="setTakeTask"></TaskItem>
  10. </EnScroll>
  11. </view>
  12. </template>
  13. <script>
  14. import TaskItem from "@/common/task/task-item.vue"
  15. import TaskImgTab from "@/common/task/task_ima_tab.vue"
  16. import {getTaskReceiving, takeTask} from "@/api/task";
  17. import tools from "@/service/tools";
  18. export default {
  19. components: {
  20. TaskImgTab,
  21. TaskItem
  22. },
  23. data() {
  24. return {
  25. taskList: [],
  26. page: 1,
  27. totalNum: 9999,
  28. isAjax: false,
  29. productId:0
  30. }
  31. },
  32. mounted() {
  33. this.getTaskReceiving()
  34. },
  35. methods: {
  36. setProductId(productId){
  37. console.log('productId:'+productId)
  38. this.productId=productId
  39. this.startList()
  40. },
  41. // 下拉刷新
  42. startList() {
  43. this.taskList = [];
  44. this.page = 1
  45. this.totalNum = 99999
  46. this.getTaskReceiving()
  47. },
  48. async getTaskReceiving() {
  49. if (this.totalNum <= this.taskList.length) {
  50. return;
  51. }
  52. const res = await getTaskReceiving({'page':this.page,'productId':this.productId})
  53. if (res.code === 1) {
  54. this.totalNum=res.data.totalNum
  55. this.taskList.push(...res.data.items)
  56. ++this.page
  57. }
  58. },
  59. setTakeTask(index){
  60. console.log('index:'+index)
  61. this.taskList.splice(index, 1)
  62. uni.$emit('updateMemberInfo')
  63. },
  64. onRefresh() {
  65. uni.showLoading({
  66. title: '数据加载中'
  67. })
  68. setTimeout(() => {
  69. uni.showToast({
  70. title: '加载完成',
  71. icon: 'none'
  72. })
  73. this.$refs.scroll.onEndPulling()
  74. this.startList()
  75. }, 1000)
  76. console.log("下拉刷新");
  77. },
  78. // 滚动到底部
  79. onScrollBottom() {
  80. uni.showLoading({
  81. title: '数据加载中'
  82. })
  83. this.getTaskReceiving()
  84. setTimeout(() => {
  85. uni.showToast({
  86. title: '加载完成',
  87. icon: 'none'
  88. })
  89. }, 1000)
  90. console.log("到底部了");
  91. },
  92. }
  93. }
  94. </script>
  95. <style>
  96. </style>