优化评价页面

This commit is contained in:
TOP糯米 2023-03-29 23:39:33 +08:00
parent a38ced69a7
commit c7cf0a33e7
2 changed files with 49 additions and 34 deletions

View File

@ -67,6 +67,9 @@
:cate="appraise.cate" :cate="appraise.cate"
@changeCate="changeAppraiseCate" @changeCate="changeAppraiseCate"
/> />
<view class="loadmore-box">
<app-load-more :hasMore="currentAppraiseCate.more" @loadmore="loadAppraiseData" />
</view>
</view> </view>
</view> </view>
</view> </view>
@ -76,6 +79,7 @@
<script> <script>
import AppLayout from "@/components/layout/layout"; import AppLayout from "@/components/layout/layout";
import AppAppraiseSection from "@/components/appraise/section"; import AppAppraiseSection from "@/components/appraise/section";
import AppLoadMore from "@/components/widgets/loadmore";
export default { export default {
name: "service-detail", name: "service-detail",
data() { data() {
@ -93,7 +97,7 @@ export default {
content: "", content: "",
price: 0, price: 0,
}, },
currentAppraiseCateIndex: 0, currentAppraiseCate: {},
appraise: { appraise: {
total: 0, total: 0,
tags: [], tags: [],
@ -104,6 +108,7 @@ export default {
components: { components: {
AppLayout, AppLayout,
AppAppraiseSection, AppAppraiseSection,
AppLoadMore,
}, },
async onLoad(e) { async onLoad(e) {
this.pageConfig = getApp().globalData.pageConfig; this.pageConfig = getApp().globalData.pageConfig;
@ -152,10 +157,7 @@ export default {
onReady() {}, onReady() {},
onReachBottom() { onReachBottom() {
if (this.tabIndex == 0) return; if (this.tabIndex == 0) return;
let currentCate = this.appraise.cate[this.currentAppraiseCateIndex]; this.loadAppraiseData();
if (currentCate.more) {
this.loadAppraiseData(currentCate);
}
}, },
onPullDownRefresh() {}, onPullDownRefresh() {},
methods: { methods: {
@ -203,29 +205,30 @@ export default {
/** /**
* 切换评价分类 * 切换评价分类
*/ */
changeAppraiseCate(currentCate, index) { changeAppraiseCate(currentAppraiseCate, index) {
this.currentAppraiseCateIndex = index; currentAppraiseCate.list = [];
currentCate.list = []; currentAppraiseCate.more = true;
currentCate.more = true; currentAppraiseCate.page = 1;
currentCate.page = 1; this.currentAppraiseCate = currentAppraiseCate;
this.loadAppraiseData(currentCate); this.loadAppraiseData();
}, },
/** /**
* 加载评价数据 * 加载评价数据
*/ */
loadAppraiseData(currentCate) { loadAppraiseData() {
if (!this.currentAppraiseCate.more) return;
this.$models.appraise.list this.$models.appraise.list
.service({ .service({
id: this.id, id: this.id,
status: currentCate.status, status: this.currentAppraiseCate.status,
page: currentCate.page, page: this.currentAppraiseCate.page,
}) })
.then((list) => { .then((list) => {
if (list.length > 0) { if (list.length > 0) {
currentCate.page++; this.currentAppraiseCate.page++;
currentCate.list = currentCate.list.concat(list); this.currentAppraiseCate.list = this.currentAppraiseCate.list.concat(list);
} else { } else {
currentCate.more = false; this.currentAppraiseCate.more = false;
} }
}); });
}, },
@ -385,5 +388,8 @@ export default {
.reviews { .reviews {
width: 100%; width: 100%;
height: auto; height: auto;
.loadmore-box {
padding: 40rpx 0;
}
} }
</style> </style>

View File

@ -35,6 +35,9 @@
:cate="appraise.cate" :cate="appraise.cate"
@changeCate="changeAppraiseCate" @changeCate="changeAppraiseCate"
/> />
<view class="loadmore-box">
<app-load-more :hasMore="currentAppraiseCate.more" @loadmore="loadAppraiseData" />
</view>
</view> </view>
</app-layout> </app-layout>
</template> </template>
@ -42,6 +45,7 @@
<script> <script>
import AppLayout from "@/components/layout/layout"; import AppLayout from "@/components/layout/layout";
import AppAppraiseSection from "@/components/appraise/section"; import AppAppraiseSection from "@/components/appraise/section";
import AppLoadMore from "@/components/widgets/loadmore";
export default { export default {
name: "worker-detail", name: "worker-detail",
data() { data() {
@ -61,7 +65,7 @@ export default {
avatar: "", avatar: "",
}, },
}, },
currentAppraiseCateIndex: 0, currentAppraiseCate: {},
appraise: { appraise: {
total: 0, total: 0,
tags: [], tags: [],
@ -72,6 +76,7 @@ export default {
components: { components: {
AppLayout, AppLayout,
AppAppraiseSection, AppAppraiseSection,
AppLoadMore,
}, },
async onLoad(e) { async onLoad(e) {
if (!e.id) { if (!e.id) {
@ -110,39 +115,37 @@ export default {
onShow() {}, onShow() {},
onReady() {}, onReady() {},
onReachBottom() { onReachBottom() {
let currentCate = this.appraise.cate[this.currentAppraiseCateIndex]; this.loadAppraiseData();
if (currentCate.more) {
this.loadAppraiseData(currentCate);
}
}, },
onPullDownRefresh() {}, onPullDownRefresh() {},
methods: { methods: {
/** /**
* 切换评价分类 * 切换评价分类
*/ */
changeAppraiseCate(currentCate, index) { changeAppraiseCate(currentAppraiseCate, index) {
this.currentAppraiseCateIndex = index; currentAppraiseCate.list = [];
currentCate.list = []; currentAppraiseCate.more = true;
currentCate.more = true; currentAppraiseCate.page = 1;
currentCate.page = 1; this.currentAppraiseCate = currentAppraiseCate;
this.loadAppraiseData(currentCate); this.loadAppraiseData();
}, },
/** /**
* 加载评价数据 * 加载评价数据
*/ */
loadAppraiseData(currentCate) { loadAppraiseData() {
if (!this.currentAppraiseCate.more) return;
this.$models.appraise.list this.$models.appraise.list
.worker({ .worker({
id: this.id, id: this.id,
status: currentCate.status, status: this.currentAppraiseCate.status,
page: currentCate.page, page: this.currentAppraiseCate.page,
}) })
.then((list) => { .then((list) => {
if (list.length > 0) { if (list.length > 0) {
currentCate.page++; this.currentAppraiseCate.page++;
currentCate.list = currentCate.list.concat(list); this.currentAppraiseCate.list = this.currentAppraiseCate.list.concat(list);
} else { } else {
currentCate.more = false; this.currentAppraiseCate.more = false;
} }
}); });
}, },
@ -205,4 +208,10 @@ export default {
color: #999999; color: #999999;
} }
} }
.appraise-body {
width: 100%;
.loadmore-box {
padding: 40rpx 0;
}
}
</style> </style>