Преглед изворни кода

Merge branch 'master' of http://git.cc-lotus.info/pointToNetwork/point-app

zs пре 2 година
родитељ
комит
a160fb65db
1 измењених фајлова са 19 додато и 20 уклоњено
  1. 19 20
      pagesHome/shop/index.vue

+ 19 - 20
pagesHome/shop/index.vue

@@ -227,7 +227,13 @@
 					// 查询店铺信息
 					const res = await that.$api(`/shop/${that.id}`, 'GET');
 					if (res.errcode == '0') that.$set(that, `info`, res.data);
-
+					let arr = await that.$api(`/storeGoods/check`, `GET`, {
+						customer: that.user._id,
+						shop: that.id
+					});
+					if (arr.errcode == '0') {
+						that.$set(that, `collection`, arr.data)
+					}
 					// 查询店铺商品
 					that.searchShopMarket();
 					// 查询全部商品
@@ -339,31 +345,24 @@
 			// 收藏
 			async toCollect() {
 				const that = this;
-				that.collection = !that.collection;
-				if (that.collection == true) {
-					var params = {};
-					params = {
-						shop: that.info.id,
-						customer: that.user.id
-					}
-					const arr = await that.$api(`/storeShop`, 'POST', params)
-					if (arr.errcode == '0') {
-						const aee = await that.$api(`/storeShop/check`, 'POST', params)
-						if (aee.errcode == '0') {
-							console.log(aee.data);
-						}
+				var params = {};
+				params = {
+					shop: that.id,
+					customer: that.user.id
+				}
+				if (that.user) {
+					let res = await that.$api(`/storeShop`, `POST`, params);
+					if (res.errcode == '0') {
+						console.log(res);
 						uni.showToast({
-							title: `收藏成功`,
+							title: res.data.msg,
 							icon: 'none'
 						})
-					} else {
-						uni.showToast({
-							title: arr.errmsg,
-						})
+						that.$set(that, `collection`, res.data.result)
 					}
 				} else {
 					uni.showToast({
-						title: `取消成功`,
+						title: '无用户登录无法收藏店铺',
 						icon: 'none'
 					})
 				}