Browse Source

发现评论相关优化

master
Enzo 4 years ago
parent
commit
92d404c3e6
  1. 54
      pages/discover/discover.vue
  2. 14
      pages/discover/discoverdetails.vue
  3. 88
      pages/user/my/my.vue

54
pages/discover/discover.vue

@ -78,9 +78,9 @@
}
return {
tab_list: [
{name: '最新',type: 'created_at',list:[]},
{name: '最热',type: 'view_count',list:[]},
{name: '已关注',type: 'view_count',list:[]}
{name: '最新',type: 'created_at',list:[],..._public},
{name: '最热',type: 'view_count',list:[],..._public},
{name: '已关注',type: 'view_count',list:[],..._public}
],
tab_current: 0,
scrollH: 0,
@ -140,7 +140,7 @@
});
});
},
getMyAttention() {
getMyAttention(options = {}) {
let tab_item = this.tab_list[this.tab_current];
this.$http
.get({
@ -150,31 +150,22 @@
},
})
.then(res => {
console.log(res)
if (res.data.code == 200) {
if (res.data.status) {
let isPage = res.data.next_page_url == null?false:true;
tab_item.isPage = isPage;
if(!isPage) {
tab_item.loadingClass = false;
tab_item.loadingText = '没有更多数据啦~';
}
if(options.type == 'pageRefresh') {
uni.stopPullDownRefresh();
}else if(options.type == 'scrollRefresh') {
this.isRefresher = false;
}
if(tab_item.page == 1) {
tab_item.list = res.data.data.data;
}else {
tab_item.list.push(...res.data.data.data);
}
console.log('发现列表',tab_item.list)
} else {
wx.showModal({
content: res.data.message || '请下拉页面刷新重试',
showCancel: false
});
let isPage = res.data.data.next_page_url == null?false:true;
tab_item.isPage = isPage;
if(!isPage) {
tab_item.loadingClass = false;
tab_item.loadingText = '没有更多数据啦~';
}
if(options.type == 'pageRefresh') {
uni.stopPullDownRefresh();
}else if(options.type == 'scrollRefresh') {
this.isRefresher = false;
}
if(tab_item.page == 1) {
tab_item.list = res.data.data.data;
}else {
tab_item.list.push(...res.data.data.data);
}
} else {
wx.showModal({
@ -186,10 +177,7 @@
})
.catch(() => {
wx.hideLoading();
wx.showModal({
content: '请求失败',
showCancel: false
});
});
},
//
@ -256,7 +244,7 @@
page_size: this.pageSize,
data:{
order: discover_type,
user_id: 1
user_id: this.$cookieStorage.get('user_info').id
}
})
.then(res => {

14
pages/discover/discoverdetails.vue

@ -3,7 +3,7 @@
<lf-nav :spreadOut="true" :showIcon="true" title="详情"></lf-nav>
<view class="lf-p-32">
<view class="lf-flex">
<view class="tag-father">
<view class="tag-father" @click="$url('/pages/user/my/my?user_id='+discover_details.user_id)">
<image :src="discover_details.user.avatar" mode="aspectFill" class="head-img"></image>
<view class="head-tag">V</view>
</view>
@ -40,10 +40,10 @@
<self-line/>
<!-- 评论 -->
<view class="comment" v-if="commentList.length != 0">
<view class="lf-color-555 lf-font-24"> {{commentList.total}}条评论</view>
<view class="lf-color-555 lf-font-24"> {{discover_details.comments_count}}条评论</view>
<!-- 评论开始 -->
<view v-for="(commentitem,commentindex) of commentList" :key="commentindex">
<view class="lf-m-t-20" @click="applyComment(commentitem.user.id,commentitem.id)">
<view class="lf-m-t-20" @click="applySub(commentitem.user.id,commentitem.id)">
<view class="lf-flex">
<view>
<image class="comment-img" :src="commentitem.user.avatar" mode="aspectFill"></image>
@ -104,7 +104,7 @@
<input class="rom-search" type="text" v-else @confirm="sendComment(discover_details.id)" :cursor-spacing="8" v-model="comment" placeholder="说点什么" />
</view>
<view class="lf-row-center">
<view class="lf-row-center lf-m-r-35" @click="addLike(discover_details.id)">
<view class="lf-row-center lf-m-r-35" @click.stop="addLike(discover_details.id)">
<text class="lf-iconfont icon-xihuanlike lf-color-price" v-if="discover_details.is_like"></text>
<text class="lf-iconfont icon-xihuan" v-else></text>
<text class="lf-font-24 lf-color-777 lf-m-l-10">{{discover_details.likes_count}}</text>
@ -195,7 +195,7 @@
api: 'api/discover/comment/list',
data: {
discover_id: this.discover_id,
user_id: 6
user_id: this.$cookieStorage.get('user_info').id
},
header: {
Authorization: this.$cookieStorage.get('user_token')
@ -248,6 +248,7 @@
this.$msg('回复成功').then(() => {
console.log('更新回复列表');
this.comment = '';
this.ifApply = false;
this.getCommentList();
})
} else {
@ -331,6 +332,7 @@
if (res.data.code == 200) {
if (res.data.status) {
this.getCommentList();
this.getDiscoverDetails();
} else {
wx.showModal({
content: res.data.message || '请下拉页面刷新重试',
@ -359,7 +361,7 @@
api: 'api/discover/detail',
data: {
id: this.discover_id,
user_id: 6
user_id: this.$cookieStorage.get('user_info').id
},
})
.then(res => {

88
pages/user/my/my.vue

@ -14,8 +14,8 @@
</view>
</view>
<view>
<button class="head-btn" v-if="discover_info.is_follow == true">已关注</button>
<button class="head-btn" v-if="discover_info.is_follow == false">关注</button>
<button class="head-btn" v-if="discover_info.is_follow == true" @click="payAttention()">已关注</button>
<button class="head-btn" v-if="discover_info.is_follow == false" @click="payAttention()">关注</button>
<view v-if="discover_info.is_follow == -1"></view>
</view>
</view>
@ -31,7 +31,7 @@
<image v-for="(picture,index2) in item.attachs" :key="index2" class="qzone-img" :src="picture.url" mode="aspectFill"></image>
</view>
<view class="lf-m-t-30 lf-row-between lf-p-l-50 lf-p-r-50">
<view class="lf-row-center">
<view class="lf-row-center" @click.stop="addLike(item.id)">
<text class="lf-iconfont icon-xihuanlike lf-color-price" v-if="item.is_like"></text>
<text class="lf-iconfont icon-xihuan" v-else></text>
<text class="lf-font-24 lf-color-777 lf-m-l-10">{{item.likes_count}}</text>
@ -70,6 +70,88 @@
}
},
methods: {
//
payAttention() {
this.$http
.post({
api: 'api/discover/add_follow',
data: {
user_id: this.user_id
},
header: {
Authorization: this.$cookieStorage.get('user_token')
},
})
.then(res => {
if (res.data.code == 200) {
if (res.data.status) {
this.$msg(res.data.data);
this.loginList();
} else {
wx.showModal({
content: res.data.message,
showCancel: false
});
}
} else {
wx.showModal({
content: res.data.message,
showCancel: false
});
}
wx.hideLoading();
})
.catch(() => {
wx.hideLoading();
wx.showModal({
content: '请求失败',
showCancel: false
});
});
},
//
addLike(id) {
let user_info = this.$cookieStorage.get('user_token');
if(user_info) {
this.$http
.post({
api: 'api/discover/like',
data: {
discover_id: id
},
header: {
Authorization: this.$cookieStorage.get('user_token')
},
})
.then(res => {
if (res.data.code == 200) {
if (res.data.status) {
this.loginList();
} else {
wx.showModal({
content: res.data.message || '请下拉页面刷新重试',
showCancel: false
});
}
} else {
wx.showModal({
content: res.data.message || '请下拉页面刷新重试',
showCancel: false
});
}
wx.hideLoading();
})
.catch(() => {
wx.hideLoading();
wx.showModal({
content: '请求失败',
showCancel: false
});
});
}else {
this.$msg('你还未登录,请前往登录!');
}
},
goDetails(id) {
this.$url('/pages/discover/discoverdetails?discover_id='+id)
},

Loading…
Cancel
Save