task-list.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. <template>
  2. <view class="">
  3. <nav-bar title="任务中心" goBack />
  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. </view>
  16. <uni-load-more v-if="dataList.length > 0 || loadingStatus === 'loading' " :status="loadingStatus" />
  17. <view class="empty-data" v-if="(!dataList || dataList.length===0) && loadingStatus=== 'noMore' ">
  18. <EmptyDate />
  19. </view>
  20. </view>
  21. </view>
  22. </template>
  23. <script>
  24. import taskListItem from "./components/task-list-item.vue"
  25. import {
  26. getTaskList_Api
  27. } from "@/api/task.js"
  28. export default {
  29. components: {
  30. taskListItem
  31. },
  32. data() {
  33. return {
  34. dataList: [],
  35. pageNum: 0,
  36. pageSize: 10,
  37. loadingStatus: ''
  38. }
  39. },
  40. onShow() {
  41. // if(this.dataList && this.dataList.length > 0){
  42. // try{
  43. // this.$refs.taskListRef.refresh()
  44. // }catch(e){
  45. // //TODO handle the exception
  46. // }
  47. // }
  48. },
  49. onLoad() {
  50. this.init()
  51. },
  52. onReachBottom() {
  53. if (this.loadingStatus === "more") {
  54. this.getTaskList();
  55. }
  56. },
  57. onPullDownRefresh() {
  58. this.init();
  59. },
  60. methods: {
  61. // getTaskList(){
  62. // getTaskList_Api().then(res => {})
  63. // }
  64. init() {
  65. this.dataList = [];
  66. this.pageNum = 0;
  67. this.pageSize = 10;
  68. this.loadingStatus = '';
  69. this.getTaskList();
  70. },
  71. getTaskList() {
  72. if (this.loadingStatus === 'noMore' || this.loadingStatus === 'loading') return
  73. this.loadingStatus = 'loading';
  74. this.pageNum++;
  75. getTaskList_Api({
  76. pageNum: this.pageNum,
  77. pageSize: this.pageSize,
  78. taskStatus: 2
  79. }).then(res => {
  80. const t_o = 300;
  81. setTimeout(() => {
  82. if (res.code === 200) {
  83. this.dataList = this.dataList.concat(res.rows || []);
  84. };
  85. this.setLoadingStatus(this.$mUtil.pagination(res.total, this.pageNum, this
  86. .pageSize))
  87. } , this.dataList.length === 0 ? t_o : 1)
  88. }).catch(err => {
  89. this.setLoadingStatus("noMore")
  90. })
  91. },
  92. setLoadingStatus(status) {
  93. setTimeout(() => {
  94. this.loadingStatus = status
  95. }, 300)
  96. }
  97. }
  98. }
  99. </script>
  100. <style>
  101. page {
  102. background-color: #f9f9f9;
  103. }
  104. </style>
  105. <style lang="scss" scoped>
  106. @import "./common.scss";
  107. $padd_: 30rpx;
  108. .page-content {
  109. width: 100%;
  110. padding: 30rpx;
  111. .task-record {
  112. width: 100%;
  113. display: flex;
  114. justify-content: space-between;
  115. align-items: stretch;
  116. .record-item {
  117. width: 320rpx;
  118. height: 135rpx;
  119. image {
  120. width: 100%;
  121. height: 100%;
  122. }
  123. }
  124. }
  125. .task-list {
  126. padding: 30rpx 0 0;
  127. }
  128. }
  129. </style>