Feat;旅居评价列表
This commit is contained in:
@@ -35,6 +35,7 @@
|
||||
<script>
|
||||
import UserEvaluation from "@/components/UserEvaluation";
|
||||
import { getReplyConfig, getReplyList } from "@/api/store";
|
||||
import { getJiaLouProductReply, getJiaLouProductReplyCount } from "@/api/qianxian";
|
||||
import Loading from "@/components/Loading";
|
||||
|
||||
export default {
|
||||
@@ -47,6 +48,7 @@ export default {
|
||||
data: function() {
|
||||
return {
|
||||
product_id: 0,
|
||||
isTravelGroup: false,
|
||||
replyData: {},
|
||||
navList: [
|
||||
{ evaluate: "全部", num: 0 },
|
||||
@@ -65,6 +67,7 @@ export default {
|
||||
},
|
||||
mounted: function() {
|
||||
this.product_id = this.$yroute.query.id;
|
||||
this.isTravelGroup = String(this.$yroute.query.isTravelGroup || '') === '1';
|
||||
this.getProductReplyCount();
|
||||
this.getProductReplyList();
|
||||
},
|
||||
@@ -74,27 +77,74 @@ export default {
|
||||
methods: {
|
||||
getProductReplyCount: function() {
|
||||
let that = this;
|
||||
getReplyConfig(that.product_id).then(res => {
|
||||
that.$set(that, "replyData", res.data);
|
||||
that.navList[0].num = res.data.sumCount;
|
||||
that.navList[1].num = res.data.goodCount;
|
||||
that.navList[2].num = res.data.inCount;
|
||||
that.navList[3].num = res.data.poorCount;
|
||||
});
|
||||
if (that.isTravelGroup) {
|
||||
getJiaLouProductReplyCount({
|
||||
travelGroupProductId: that.product_id
|
||||
}).then(res => {
|
||||
const data = res.data || {};
|
||||
that.$set(that, "replyData", data);
|
||||
that.navList[0].num = data.sumCount || 0;
|
||||
that.navList[1].num = data.goodCount || 0;
|
||||
that.navList[2].num = data.inCount || 0;
|
||||
that.navList[3].num = data.poorCount || 0;
|
||||
});
|
||||
} else {
|
||||
getReplyConfig(that.product_id).then(res => {
|
||||
const data = res.data || {};
|
||||
that.$set(that, "replyData", data);
|
||||
that.navList[0].num = data.sumCount || 0;
|
||||
that.navList[1].num = data.goodCount || 0;
|
||||
that.navList[2].num = data.inCount || 0;
|
||||
that.navList[3].num = data.poorCount || 0;
|
||||
});
|
||||
}
|
||||
},
|
||||
getProductReplyList: function() {
|
||||
let that = this;
|
||||
if (that.loading) return; //阻止下次请求(false可以进行请求);
|
||||
if (that.loadend) return; //阻止结束当前请求(false可以进行请求);
|
||||
if (that.loading) return;
|
||||
if (that.loadend) return;
|
||||
that.loading = true;
|
||||
let q = { page: that.page, limit: that.limit, type: that.currentActive };
|
||||
getReplyList(that.product_id, q).then(res => {
|
||||
that.loading = false;
|
||||
//apply();js将一个数组插入另一个数组;
|
||||
that.reply.push.apply(that.reply, res.data);
|
||||
that.loadend = res.data.length < that.limit; //判断所有数据是否加载完成;
|
||||
that.page = that.page + 1;
|
||||
});
|
||||
if (that.isTravelGroup) {
|
||||
getJiaLouProductReply({
|
||||
travelGroupProductId: that.product_id,
|
||||
type: q.type,
|
||||
page: q.page,
|
||||
limit: q.limit
|
||||
}).then(res => {
|
||||
that.loading = false;
|
||||
const pageData = res.data || {};
|
||||
const rawList = Array.isArray(pageData.records) ? pageData.records : [];
|
||||
const list = rawList.map(item => {
|
||||
const productScore = Number(item.productScore) || 0;
|
||||
const serviceScore = Number(item.serviceScore) || 0;
|
||||
let star = productScore || serviceScore || 5;
|
||||
const skuText = '默认';
|
||||
const picturesArr = Array.isArray(item.pics) ? item.pics : [];
|
||||
return {
|
||||
...item,
|
||||
star,
|
||||
sku: skuText,
|
||||
picturesArr
|
||||
};
|
||||
});
|
||||
that.reply.push.apply(that.reply, list);
|
||||
that.loadend = list.length < that.limit || !pageData.pages || that.page >= pageData.pages;
|
||||
that.page = that.page + 1;
|
||||
}).catch(() => {
|
||||
that.loading = false;
|
||||
});
|
||||
} else {
|
||||
getReplyList(that.product_id, q).then(res => {
|
||||
that.loading = false;
|
||||
const data = res.data || [];
|
||||
that.reply.push.apply(that.reply, data);
|
||||
that.loadend = data.length < that.limit;
|
||||
that.page = that.page + 1;
|
||||
}).catch(() => {
|
||||
that.loading = false;
|
||||
});
|
||||
}
|
||||
},
|
||||
changeType: function(index) {
|
||||
let that = this;
|
||||
|
||||
Reference in New Issue
Block a user