|
@@ -151,30 +151,14 @@
|
|
|
limit: that.limit,
|
|
|
is_use: '0',
|
|
|
status: '1',
|
|
|
- type: that.tabs.active
|
|
|
+ type: that.tabs.active,
|
|
|
}
|
|
|
+ if (that.user._id) info.user = that.user._id
|
|
|
let res;
|
|
|
- res = await that.$api(`/article`, 'GET', {
|
|
|
+ res = await that.$api(`/article/article`, 'GET', {
|
|
|
...info,
|
|
|
});
|
|
|
if (res.errcode == '0') {
|
|
|
- if (that.user._id) {
|
|
|
- for (let val of res.data) {
|
|
|
- const like = await that.$api(`/like`, 'GET', {
|
|
|
- source: val._id,
|
|
|
- user: that.user._id,
|
|
|
- type: '0'
|
|
|
- });
|
|
|
- if (like.errcode == '0' && like.total > 0) val.is_like = true
|
|
|
- else val.is_like = false
|
|
|
- const likenum = await that.$api(`/like`, 'GET', {
|
|
|
- source: val._id,
|
|
|
- type: '0',
|
|
|
- limit: 1
|
|
|
- });
|
|
|
- if (likenum.errcode == '0') val.like_num = likenum.total
|
|
|
- }
|
|
|
- }
|
|
|
let list = [...that.list, ...res.data];
|
|
|
that.$set(that, `list`, list);
|
|
|
that.$set(that, `total`, res.total)
|
|
@@ -212,21 +196,10 @@
|
|
|
create_time: moment().format('YYYY-MM-DD HH:mm:ss'),
|
|
|
}
|
|
|
res = await that.$api(`/like`, 'POST', form);
|
|
|
- if (res.errcode == '0') {
|
|
|
- that.clearPage();
|
|
|
- that.search()
|
|
|
- }
|
|
|
- } else {
|
|
|
- res = await that.$api(`/like`, 'GET', {
|
|
|
- source: item._id,
|
|
|
- user: that.user._id,
|
|
|
- type: '0'
|
|
|
- });
|
|
|
- if (res.errcode == '0' && res.total > 0) {
|
|
|
- await that.$api(`/like/${res.data[0]._id}`, 'DELETE', {})
|
|
|
- that.clearPage();
|
|
|
- that.search()
|
|
|
- }
|
|
|
+ } else res = await that.$api(`/like/${item.like}`, 'DELETE', {})
|
|
|
+ if (res.errcode == '0') {
|
|
|
+ that.clearPage();
|
|
|
+ that.search()
|
|
|
}
|
|
|
},
|
|
|
// 查询其他信息
|