zs 1 gadu atpakaļ
vecāks
revīzija
71add9d322

+ 7 - 34
pages/home/index.vue

@@ -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()
 				}
 			},
 			// 查询其他信息

+ 2 - 1
pagesMy/article/index.vue

@@ -126,7 +126,8 @@
 					skip: that.skip,
 					limit: that.limit,
 					contact: that.user._id,
-					status: that.tabs.active
+					status: that.tabs.active,
+					user: that.user._id,
 				}
 				const res = await that.$api(`/article/article`, 'GET', {
 					...info,

Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 1 - 1
unpackage/dist/dev/.sourcemap/mp-weixin/pages/home/index.js.map


Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 1 - 1
unpackage/dist/dev/.sourcemap/mp-weixin/pagesMy/article/index.js.map


Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 26 - 90
unpackage/dist/dev/mp-weixin/pages/home/index.js


+ 2 - 1
unpackage/dist/dev/mp-weixin/pagesMy/article/index.js

@@ -328,7 +328,8 @@ var _default = {
                   skip: that.skip,
                   limit: that.limit,
                   contact: that.user._id,
-                  status: that.tabs.active
+                  status: that.tabs.active,
+                  user: that.user._id
                 };
                 _context4.next = 4;
                 return that.$api("/article/article", 'GET', _objectSpread(_objectSpread({}, info), that.searchInfo));