guhongwei 2 年之前
父节点
当前提交
51241c6431
共有 1 个文件被更改,包括 58 次插入31 次删除
  1. 58 31
      pagesMy/collection/shop.vue

+ 58 - 31
pagesMy/collection/shop.vue

@@ -4,19 +4,19 @@
 			<view class="one">
 				<scroll-view scroll-y="true" class="scroll-view" @scrolltolower="toPage">
 					<view class="list-scroll-view">
-						<view class="list" v-for="(item, index) in list" :key="index" @click="toView(item)">
-							<image class="image" :src="item.file" mode=""></image>
+						<view class="list" v-for="(item, index) in list" :key="index" @tap="toView(item)">
+							<image class="image" :src="item.shop.file&&item.shop.file.length>0?item.shop.file[0].url:''" mode=""></image>
 							<view class="other">
-								<view class="name">{{item.name}}</view>
+								<view class="name">{{item.shop.name}}</view>
 								<view class="other_1">
-									关注人数 <text>{{item.num}}</text>
+									店铺地址 <text>{{item.shop.address}}</text>
 								</view>
 								<view class="other_1">
 									关注时间 <text>{{item.time}}</text>
 								</view>
 							</view>
 							<view class="btn">
-								<text @click="toDel(item)" class="iconfont icon-del"></text>
+								<text @tap.stop="toDel(item)" class="iconfont icon-del"></text>
 							</view>
 						</view>
 					</view>
@@ -36,25 +36,6 @@
 				skip: 0,
 				limit: 5,
 				page: 0
-				// list: [{
-				// 		file: require('@/static/test.png'),
-				// 		name: '官方自营店',
-				// 		num: 2,
-				// 		time: '2022-09-27'
-				// 	},
-				// 	{
-				// 		file: require('@/static/test.png'),
-				// 		name: '官方自营店',
-				// 		num: 2,
-				// 		time: '2022-09-27'
-				// 	},
-				// 	{
-				// 		file: require('@/static/test.png'),
-				// 		name: '官方自营店',
-				// 		num: 2,
-				// 		time: '2022-09-27'
-				// 	}
-				// ]
 			};
 		},
 		onShow: function() {
@@ -97,20 +78,66 @@
 					that.$set(that, `total`, res.total)
 				}
 			},
+			// 分页
+			toPage() {
+				const that = this;
+				let list = that.list;
+				let limit = that.limit;
+				if (that.total > list.length) {
+					uni.showLoading({
+						title: '加载中',
+						mask: true
+					})
+					let page = that.page + 1;
+					that.$set(that, `page`, page)
+					let skip = page * limit;
+					that.$set(that, `skip`, skip)
+					that.search();
+					uni.hideLoading();
+				} else uni.showToast({
+					title: '没有更多数据了'
+				});
+			},
 			// 详细信息
 			toView(e) {
 				const that = this;
-				console.log(e);
+				that.clearPage();
+				uni.navigateTo({
+					url: `/pagesHome/shop/index?id=${e.shop._id}`
+				})
 			},
 			// 删除
-			toDel(e) {
+			async toDel(e) {
 				const that = this;
-				console.log(e);
-			},
-			// 分页
-			toPage(e) {
-
+				let user = that.user;
+				if (user && user._id && e && e.shop._id) {
+					let res = await that.$api(`/storeShop`, `POST`, {
+						customer: user._id,
+						shop: e.shop._id
+					});
+					if (res.errcode == '0') {
+						uni.showToast({
+							title: res.data.msg,
+							icon: 'none'
+						})
+						that.clearPage();
+						that.search()
+					}
+				} else {
+					uni.showToast({
+						title: '缺少必要信息,无法收藏',
+						icon: 'none'
+					})
+				}
 			},
+			// 清空列表
+			clearPage() {
+				const that = this;
+				that.$set(that, `list`, [])
+				that.$set(that, `skip`, 0)
+				that.$set(that, `limit`, 5)
+				that.$set(that, `page`, 0)
+			}
 		}
 	}
 </script>