This commit is contained in:
Gdpao 2020-08-21 16:05:09 +08:00
parent 4b0cbcf814
commit e0aafebcdc
3 changed files with 44 additions and 22 deletions

View File

@ -29,7 +29,7 @@
<text>评论</text> <text>评论</text>
<u-icon name="close" color="#333" size="28" @click="is_comment=false"></u-icon> <u-icon name="close" color="#333" size="28" @click="is_comment=false"></u-icon>
</view> </view>
<scroll-view class="scroll-box" scroll-y="true" lower-threshold="50" @scroll="changeComment" @scrolltolower="scrollBottom"> <scroll-view class="scroll-box" scroll-y="true" lower-threshold="50" @scrolltolower="scrollBottom">
<block v-for="(item,index) in commentList" :key="index"> <block v-for="(item,index) in commentList" :key="index">
<view class="box"> <view class="box">
<image :src="item.member_avatar" mode="aspectFill"></image> <image :src="item.member_avatar" mode="aspectFill"></image>
@ -52,7 +52,10 @@
</view> </view>
<view class="child_content">{{ child.content }}</view> <view class="child_content">{{ child.content }}</view>
</view> </view>
<view class="more-reply" v-if="item.reply_count" @click="getReplyList(item.id)">展开更多回复<u-icon name="arrow-down"></u-icon></view> <view class="more-reply" v-if="item.reply_count" @click="getReplyList(item.id)">
{{ child_end[item.id] ? "暂无更多回复" : "展开更多回复" }}
<u-icon name="arrow-down" v-if="!child_end[item.id]"></u-icon>
</view>
</view> </view>
</block> </block>
<view class="no-data" v-if="!commentList.length">还没有评论快来评论吧</view> <view class="no-data" v-if="!commentList.length">还没有评论快来评论吧</view>
@ -442,6 +445,7 @@ export default {
edit_text_other: "有爱评论,说点好听的 ~", edit_text_other: "有爱评论,说点好听的 ~",
commentList: [], // commentList: [], //
allList: {}, // allList: {}, //
child_end: {},
status: 'loadmore', status: 'loadmore',
iconType: 'circle', iconType: 'circle',
loadText: { loadText: {
@ -519,6 +523,8 @@ export default {
// console.log(item); // console.log(item);
item.page = 0; item.page = 0;
item.commentList = []; item.commentList = [];
this.page_[item.id] = 0;
this.child_end[item.id] = false;
}) })
this.commentList = list; this.commentList = list;
} }
@ -572,14 +578,14 @@ export default {
// console.log(p_id); // console.log(p_id);
if (res.data.data.pid) { if (res.data.data.pid) {
this.commentList[this.comment_id].reply_count = true; this.commentList[this.comment_id].reply_count = true;
console.log(this.allList[p_id]); // console.log(this.allList[p_id]);
if (this.allList[p_id]) { if (this.allList[p_id]) {
this.allList[p_id].push(res.data.data); this.allList[p_id].push(res.data.data);
} else { } else {
this.allList[p_id] = []; this.allList[p_id] = [];
this.allList[p_id].push(res.data.data); this.allList[p_id].push(res.data.data);
} }
console.log(this.allList); // console.log(this.allList);
} else { } else {
this.commentList.unshift(res.data.data); this.commentList.unshift(res.data.data);
} }
@ -593,18 +599,20 @@ export default {
uni.showLoading({ uni.showLoading({
title: "loading..." title: "loading..."
}) })
if (!this.page_[id] === 0) {
}
this.$u.post("article/articleReplyList", {id: id, page: this.page_[id]}).then(res => { this.$u.post("article/articleReplyList", {id: id, page: this.page_[id]}).then(res => {
uni.hideLoading(); uni.hideLoading();
if (res.errCode == 0) { if (res.errCode == 0) {
// if (res.data.length < 10) { if (this.page_[id] == 0) {
// this.is_more = false; this.allList[id] = res.data;
// } } else {
this.allList[id] = this.allList[id].concat(res.data);
}
this.page_[id]++; this.page_[id]++;
this.allList[id] = res.data;
this.$forceUpdate(); this.$forceUpdate();
console.log(this.allList); // console.log(this.allList);
} else if (res.errCode == 1) {
this.child_end[id] = true;
this.$forceUpdate();
} }
}) })
}, },
@ -623,9 +631,6 @@ export default {
scrollBottom(e) { scrollBottom(e) {
console.log(1); console.log(1);
this.getComment(); this.getComment();
},
changeComment(e) {
console.log(e);
}, },
// //
gotoInfo(id) { gotoInfo(id) {

View File

@ -72,7 +72,9 @@
<text class="child_content">{{ child.content }}</text> <text class="child_content">{{ child.content }}</text>
</view> </view>
<view> <view>
<text class="more-comment" @click="getReplyList(item.id)" v-if="item.reply_count">展开更多回复</text> <text class="more-comment" @click="getReplyList(item.id)" v-if="item.reply_count">
{{ child_end[item.id] ? "暂无更多回复" : "展开更多回复" }}
</text>
<text></text> <text></text>
</view> </view>
</view> </view>
@ -167,6 +169,7 @@
time_count: 0, time_count: 0,
linear: null, linear: null,
loadinging: false, loadinging: false,
child_end: {},
}; };
}, },
onLoad(option) { onLoad(option) {
@ -246,6 +249,16 @@
// console.log(res.data); // console.log(res.data);
this.commentList = res.data.data; this.commentList = res.data.data;
} }
let list = this.commentList;
list.forEach((item,index) => {
console.log(item);
item.page = 0;
item.commentList = [];
this.page_[item.id] = 0;
this.child_end[item.id] = false;
})
console.log(list);
this.commentList = list;
} }
}) })
}, },
@ -317,7 +330,6 @@
uni.showLoading({ uni.showLoading({
title: "loading..." title: "loading..."
}) })
if (!this.page_[id] === 0) {}
uni.request({ uni.request({
url: temp_url + "article/articleReplyList", url: temp_url + "article/articleReplyList",
method: "POST", method: "POST",
@ -332,14 +344,18 @@
uni.hideLoading(); uni.hideLoading();
console.log(this.page_); console.log(this.page_);
if (res.data.errCode == 0) { if (res.data.errCode == 0) {
if (res.data.data.length < 10) { if (this.page_[id] == 0) {
this.is_more = false; this.allList[id] = res.data.data;
} else {
this.allList[id] = this.allList[id].concat(res.data.data);
} }
this.page_[id]++; this.page_[id]++;
console.log(this.page_); this.$forceUpdate();
this.allList[id] = res.data.data; } else if (res.data.errCode == 1) {
this.child_end[id] = true;
this.$forceUpdate(); this.$forceUpdate();
} }
console.log(this.allList);
} }
}) })
}, },

View File

@ -177,9 +177,10 @@ export default {
uni.navigateTo({ uni.navigateTo({
url: "../../pageA/login/login" url: "../../pageA/login/login"
}) })
} } else {
this.getOrderNumber();
}
this.getUserInfo(); this.getUserInfo();
this.getOrderNumber();
}, },
onNavigationBarButtonTap(e) { onNavigationBarButtonTap(e) {
// console.log(e); // console.log(e);