110 lines
3.0 KiB
Vue
Raw Normal View History

2023-08-04 11:32:51 +08:00
<template>
2023-08-04 18:11:49 +08:00
<view class="c_task_index">
<u-sticky bgColor="#f5f5f5" offsetTop="44px">
2023-08-05 10:22:22 +08:00
<!-- <u-tabs :list="tabLists" @click="changeCurrent" lineColor='#3274F9' :scrollable="false"
inactiveStyle='color:#666' activeStyle="color:#3274F9"></u-tabs> -->
2023-08-16 16:16:53 +08:00
<uni-segmented-control :current="current" :values="['全部','已完成']" styleType="text"
2023-08-15 18:27:07 +08:00
@clickItem="changeCurrent" activeColor="#3274F9"></uni-segmented-control>
2023-08-04 18:11:49 +08:00
</u-sticky>
<view class="c_task_index_list">
2023-08-15 18:27:07 +08:00
<view v-for="item in list" :key="item.id">
<taskItem :datas="item"></taskItem>
2023-08-05 10:22:22 +08:00
</view>
2023-08-04 18:11:49 +08:00
</view>
2023-08-15 18:27:07 +08:00
<u-loadmore :status="loadConfig.status" :loading-text="loadConfig.loadingText"
:loadmore-text="loadConfig.loadmoreText" :nomore-text="loadConfig.nomoreText" />
<!-- <u-empty icon="/static/img/empty/data.png" text="没有数据"></u-empty> -->
2023-08-04 11:32:51 +08:00
</view>
</template>
<script>
2023-08-05 10:22:22 +08:00
import { Toast } from "../../libs/uniApi";
2023-08-15 18:27:07 +08:00
import taskItem from "./taskItem.vue";
import { taskLists } from "@/api/task.js";
2023-08-04 11:32:51 +08:00
export default {
2023-08-04 18:11:49 +08:00
name: "task",
components: { taskItem },
2023-08-04 11:32:51 +08:00
data() {
return {
2023-08-04 18:11:49 +08:00
current: 0,
2023-08-15 18:27:07 +08:00
status: 0,
2023-08-05 10:22:22 +08:00
// tabLists: [{
// name: '全部',
// }, {
// name: '已完成'
// }, {
// name: '未完成'
// }],
2023-08-04 18:11:49 +08:00
loadConfig: {
page: 1,
2023-08-15 18:27:07 +08:00
limit: 25,
2023-08-04 18:11:49 +08:00
loadingText: '努力加载中',
loadmoreText: '轻轻上拉',
nomoreText: '我也是有底线的~~',
status: 'loadmore'
},
list: []
2023-08-04 11:32:51 +08:00
};
2023-08-04 18:11:49 +08:00
},
2023-08-15 18:27:07 +08:00
created() {
this.initLoadConfig();
},
2023-08-04 18:11:49 +08:00
methods: {
2023-08-10 14:13:35 +08:00
navTo(url) {
2023-08-05 10:22:22 +08:00
url ?
uni.navigateTo({
url: url
}) : Toast('暂未开放')
},
2023-08-04 18:11:49 +08:00
changeCurrent(e) {
2023-08-15 18:27:07 +08:00
if (this.current !== e.currentIndex) {
this.current = +e.currentIndex;
switch (this.current) {
case 1:
this.status = 3;
break;
case 2:
this.status = 5;
break;
default:
this.status = 0;
}
this.initLoadConfig();
}
},
initLoadConfig() {
this.loadConfig.page = 1;
this.loadConfig.status = 'loadmore';
this.list = [];
this.loadList();
},
async loadList() {
if (this.loadConfig.status == "nomore") return;
this.loadConfig.status = "loading";
let res = await taskLists({
page: this.loadConfig.page,
status: this.status,
limit: this.loadConfig.limit
});
this.loadConfig.status = "loadmore"
if (res.data.length < this.loadConfig.limit) {
this.loadConfig.status = "nomore"
} else {
this.loadConfig.page++;
2023-08-05 10:22:22 +08:00
}
2023-08-15 18:27:07 +08:00
this.list = [...this.list, ...res.data];
2023-08-04 18:11:49 +08:00
}
2023-08-04 11:32:51 +08:00
}
}
</script>
<style lang="scss">
2023-08-04 18:11:49 +08:00
.c_task_index {
padding-bottom: 100rpx;
.c_task_index_list {
padding-top: 28rpx;
}
}
2023-08-04 11:32:51 +08:00
</style>