task-list.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. <template>
  2. <view class="">
  3. <navbar :config="config" backColor="#999999"></navbar>
  4. <view class="page-content">
  5. <view class="task-record">
  6. <view class="record-item" @click.stop="$u.route('/pages/task/ranking')">
  7. <image class="record-item-icon" src="./static/task-rank.png" mode="aspectFit"></image>
  8. </view>
  9. <view class="record-item" @click.stop="$u.route('/pages/task/my-task')">
  10. <image class="record-item-icon" src="./static/my-task.png" mode="aspectFit"></image>
  11. </view>
  12. </view>
  13. <view class="task-list">
  14. <task-list-item :dataList="dataList" ref="taskListRef"/>
  15. <!-- <u-waterfall v-model="dataList"> -->
  16. <!-- <template v-slot:left="{leftList}">
  17. <block v-for="(item, index) in leftList" :key="`left_${index}`">
  18. <task-list-item :task-obj="item" class="task-item-left" />
  19. </block>
  20. </template>
  21. <template v-slot:right="{rightList}">
  22. <block v-for="(item, index) in rightList" :key="`right_${index}`">
  23. <task-list-item :task-obj="item" class="task-item-left" />
  24. </block>
  25. </template>
  26. </u-waterfall> -->
  27. </view>
  28. <loadMore v-if="dataList.length > 0 || loadingStatus === 'loading' " :status="loadingStatus" />
  29. <view class="empty-data" v-if="(!dataList || dataList.length===0) && loadingStatus=== 'noMore' ">
  30. <EmptyDate />
  31. </view>
  32. </view>
  33. </view>
  34. </template>
  35. <script>
  36. import taskListItem from "./components/task-list-item.vue"
  37. import {
  38. getTaskList_Api
  39. } from "@/api/task.js"
  40. export default {
  41. components: {
  42. taskListItem
  43. },
  44. data() {
  45. return {
  46. config: {
  47. back: true,
  48. title: '任务中心',
  49. color: 'black',
  50. backgroundColor: [1, '#fff'],
  51. statusBarFontColor: 'black'
  52. },
  53. dataList: [],
  54. pageNum: 0,
  55. pageSize: 10,
  56. loadingStatus: ''
  57. }
  58. },
  59. onShow() {
  60. // if(this.dataList && this.dataList.length > 0){
  61. // try{
  62. // this.$refs.taskListRef.refresh()
  63. // }catch(e){
  64. // //TODO handle the exception
  65. // }
  66. // }
  67. },
  68. onLoad() {
  69. this.dataList = [];
  70. this.init()
  71. },
  72. onReachBottom() {
  73. if (this.loadingStatus === "more") {
  74. this.getTaskList();
  75. }
  76. },
  77. onPullDownRefresh() {
  78. this.init();
  79. },
  80. methods: {
  81. // getTaskList(){
  82. // getTaskList_Api().then(res => {})
  83. // }
  84. init() {
  85. this.dataList = [];
  86. this.pageNum = 0;
  87. this.pageSize = 10;
  88. this.loadingStatus = '';
  89. this.getTaskList();
  90. },
  91. getTaskList() {
  92. if (this.loadingStatus === 'noMore' || this.loadingStatus === 'loading') return
  93. this.loadingStatus = 'loading';
  94. this.pageNum++;
  95. getTaskList_Api({
  96. pageNum: this.pageNum,
  97. pageSize: this.pageSize,
  98. taskStatus: 2
  99. }).then(res => {
  100. if (res.code === 200) {
  101. this.dataList = this.dataList.concat(res.rows || []);
  102. };
  103. this.setLoadingStatus(this.$mUtil.pagination(res.total, this.pageNum, this.pageSize))
  104. }).catch(err => {
  105. this.setLoadingStatus("noMore")
  106. })
  107. },
  108. setLoadingStatus(status) {
  109. setTimeout(() => {
  110. this.loadingStatus = status
  111. }, 300)
  112. }
  113. }
  114. }
  115. </script>
  116. <style>
  117. page {
  118. background-color: #f9f9f9;
  119. }
  120. </style>
  121. <style lang="scss" scoped>
  122. @import "./common.scss";
  123. $padd_: 30rpx;
  124. .page-content {
  125. width: 100%;
  126. padding: 30rpx;
  127. .task-record {
  128. width: 100%;
  129. display: flex;
  130. justify-content: space-between;
  131. align-items: stretch;
  132. .record-item {
  133. width: 320rpx;
  134. height: 135rpx;
  135. image {
  136. width: 100%;
  137. height: 100%;
  138. }
  139. }
  140. }
  141. .task-list {
  142. padding: 30rpx 0 0;
  143. }
  144. }
  145. </style>