zs преди 2 години
родител
ревизия
6bd2961f9e
променени са 1 файла, в които са добавени 308 реда и са изтрити 11 реда
  1. 308 11
      pagesHome/group/index.vue

+ 308 - 11
pagesHome/group/index.vue

@@ -2,6 +2,7 @@
 	<mobile-frame>
 		<view class="main">
 			<view class="one">
+	<!-- 			<view class="one_1">参团商品</view> -->
 				<view class="list" @tap="toView">
 					<image class="image" :src="goodsInfo.file&&goodsInfo.file.length>0?goodsInfo.file[0].url:''"
 						mode="">
@@ -14,16 +15,43 @@
 							<text>¥</text>
 							<text>{{specsInfo.sell_money}}</text>
 						</view>
+					</view>
+				</view>
+			</view>
+			<view class="two">
+				<button type="default" size="default" @click="toGroup()">我要开团</button>
+			</view>
+			<view class="thr">
+				<!-- 	<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">
+					<image class="image" :src="item.file&&item.file.length>0?item.file[0].url:''" mode="">
+					</image>
+					<view class="list_1">
+						<view class="name">
+							{{item.name||'暂无'}}
+						</view>
+						<view class="some">
+							<text>店铺名称</text>
+							<text>{{item.name||'暂无'}}</text>
+						</view>
+						<view class="some">
+							<text>规格名称</text>
+							<text>{{item.name||'暂无'}}</text>
+						</view>
 						<view class="other">
 							<view class="other_1">
-								{{goodsInfo.view_num||0}}人浏览
+								<text>¥</text>
+								<text>{{item.sell_money||0}}</text>
 							</view>
 							<view class="other_2">
-								<text @tap.stop="toDel" class="iconfont icon-del"></text>
+								<view class="btn" @click="toJoin(item)"><text>已参团{{item.num||'5'}}人</text>立即参团</view>
 							</view>
 						</view>
 					</view>
 				</view>
+				<!-- 		</view>
+				</scroll-view> -->
 			</view>
 		</view>
 	</mobile-frame>
@@ -39,6 +67,98 @@
 				goodsInfo: {},
 				// 规格详情
 				specsInfo: {},
+				// 店铺详情
+				shopInfo: {},
+				// 参团列表
+				list: [{
+					"_id": "633559dfa4e39d34f49990af",
+					"name": "商品6",
+					"view_num": 54,
+					"sell_money": 1,
+					"file": [{
+						"id": "20221010102439",
+						"name": "ece9214111e760727a166eaac037fdc0.jpg",
+						"uri": "/files/point/goods/20221010102439.jpg",
+						"url": "https://broadcast.waityou24.cn/files/point/goods/20221010102439.jpg",
+						"uid": 1665368678937,
+						"status": "success"
+					}],
+					"time": "2022-10-11 15:50:27"
+				}, {
+					"_id": "63437e3ba163596194c3e830",
+					"name": "王大拿商品1",
+					"view_num": 37,
+					"sell_money": 15,
+					"file": [{
+						"id": "20221010100628",
+						"name": "0e7edbb2f8e99780f253a3604adc32e4.jpg",
+						"uri": "/files/point/goods/20221010100628.jpg",
+						"url": "https://broadcast.waityou24.cn/files/point/goods/20221010100628.jpg",
+						"uid": 1665367588108,
+						"status": "success"
+					}],
+					"time": "2022-10-11 15:08:29"
+				}, {
+					"_id": "6343878989bdcb128d846990",
+					"name": "王大拿商品2",
+					"view_num": 196,
+					"sell_money": 50,
+					"file": [{
+						"id": "20221011092711",
+						"name": "25.png",
+						"uri": "/files/point/goods/20221011092711.png",
+						"url": "https://broadcast.waityou24.cn/files/point/goods/20221011092711.png",
+						"uid": 1665451632365,
+						"status": "success"
+					}],
+					"time": "2022-10-11 15:05:41"
+				}, {
+					"_id": "63353758101f3c01048c4f61",
+					"name": "test",
+					"view_num": 265,
+					"sell_money": 0.1,
+					"file": [{
+						"id": "20220929141236",
+						"name": "f0e22552dddcf494f9720c655a8420a.png",
+						"uri": "/files/point/goods/20220929141236.png",
+						"url": "https://broadcast.waityou24.cn/files/point/goods/20220929141236.png",
+						"uid": 1664431956868,
+						"status": "success"
+					}],
+					"time": "2022-10-11 11:21:01"
+				}, {
+					"_id": "633930162a24745ec0006373",
+					"name": "测试店铺1-商品1",
+					"view_num": 59,
+					"sell_money": 0.1,
+					"file": [{
+						"id": "20220929141236",
+						"name": "f0e22552dddcf494f9720c655a8420a.png",
+						"uri": "/files/point/goods/20220929141236.png",
+						"url": "https://broadcast.waityou24.cn/files/point/goods/20220929141236.png",
+						"uid": 1664431956868,
+						"status": "success"
+					}],
+					"time": "2022-10-11 11:15:36"
+				}, {
+					"_id": "63355854a4e39d34f499904a",
+					"name": "商品2",
+					"view_num": 164,
+					"sell_money": 1,
+					"file": [{
+						"id": "20220929163309",
+						"name": "f0e22552dddcf494f9720c655a8420a.png",
+						"uri": "/files/point/goods/20220929163309.png",
+						"url": "https://broadcast.waityou24.cn/files/point/goods/20220929163309.png",
+						"uid": 1664440389135,
+						"status": "success"
+					}],
+					"time": "2022-10-11 11:13:11"
+				}],
+				total: 0,
+				skip: 0,
+				limit: 6,
+				page: 0
 			};
 		},
 		onLoad: async function(e) {
@@ -54,6 +174,42 @@
 			that.search();
 		},
 		methods: {
+			// 开团
+			async toGroup() {
+				const that = this;
+				let user = that.user;
+				if (user) {
+					let data = {
+						shop: that.shopInfo._id,
+						goods: that.goodsInfo._id,
+						goodsSpec: that.specsInfo._id,
+						leader: user._id
+					}
+					const arr = await that.$api(`/group`, 'POST', data)
+					if (arr.errcode == '0') {
+						uni.showToast({
+							title: '开团成功',
+							icon: 'none'
+						})
+						that.clearPage();
+						that.search()
+					} else {
+						uni.showToast({
+							title: arr.data.errmsg || '下单失败!',
+							icon: 'none'
+						})
+					}
+				} else {
+					uni.showToast({
+						title: '无用户登录无法开团',
+						icon: 'none'
+					})
+				}
+			},
+			// 立即参团
+			toJoin(e) {
+				console.log(e);
+			},
 			// 监听用户是否登录
 			watchLogin() {
 				const that = this;
@@ -70,15 +226,58 @@
 			async search() {
 				const that = this;
 				let res;
-				res = await that.$api(`/goods/${that.query.goods_id}`, 'GET')
+				res = await that.$api(`/viewGoods/goodsDetail`, `POST`, {
+					id: that.query.goods_id
+				});
 				if (res.errcode == '0') {
-					that.$set(that, `goodsInfo`, res.data);
+					that.$set(that, `goodsInfo`, res.data.goods)
+					that.$set(that, `shopInfo`, res.data.shop)
 				}
 				res = await that.$api(`/goodsSpec/${that.query.specs_id}`, 'GET')
 				if (res.errcode == '0') {
 					that.$set(that, `specsInfo`, res.data);
 				}
+				let info = {
+					skip: that.skip,
+					limit: that.limit,
+				}
+				res = await that.$api(`/group`, 'GET', {
+					...info
+				})
+				if (res.errcode == '0') {
+					let list = [...that.list, ...res.data];
+					that.$set(that, `list`, list);
+					that.$set(that, `total`, res.total)
+				}
+			},
+			// 分页
+			toPage(e) {
+				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: '没有更多数据了'
+				});
 			},
+			// 清空列表
+			clearPage() {
+				const that = this;
+				that.$set(that, `list`, [])
+				that.$set(that, `skip`, 0)
+				that.$set(that, `limit`, 6)
+				that.$set(that, `page`, 0)
+			}
 		}
 	}
 </script>
@@ -91,12 +290,19 @@
 		height: 100vh;
 
 		.one {
+			.one_1 {
+				text-align: center;
+				font-size: var(--font16Size);
+				font-weight: bold;
+				margin: 2vw 0;
+			}
+
 			.list {
 				display: flex;
 				flex-direction: row;
 				justify-content: space-between;
 				width: 91vw;
-				border: 1px solid var(--f1Color);
+				border: 0.5vw dashed var(--ff0Color);
 				margin: 2vw 2vw 0 2vw;
 				padding: 2vw;
 				border-radius: 5px;
@@ -111,6 +317,7 @@
 				.list_1_1 {
 					display: flex;
 					flex-direction: column;
+					justify-content: space-between;
 					flex-grow: 1;
 					padding: 2vw 0;
 
@@ -123,16 +330,75 @@
 						color: var(--fFB1Color);
 						font-size: var(--font14Size);
 						margin: 0 0 1vw 0;
+
+						text:last-child {
+							font-size: var(--font16Size);
+						}
+					}
+				}
+			}
+		}
+
+		.two {
+			margin: 4vw 0;
+			text-align: center;
+
+			button {
+				margin: 0 2vw 2vw 2vw;
+				background-color: #FFA500;
+				color: var(--fffColor);
+			}
+
+		}
+
+		.thr {
+			position: relative;
+			flex-grow: 1;
+
+			.list {
+				display: flex;
+				flex-direction: row;
+				justify-content: space-between;
+				align-items: center;
+				width: 91vw;
+				border: 1px solid var(--f1Color);
+				margin: 2vw 2vw 0 2vw;
+				padding: 0 2vw;
+				border-radius: 5px;
+
+				.image {
+					width: 25vw;
+					height: 25vw;
+					border-radius: 5px;
+					margin: 0 2vw 0 0;
+				}
+
+				.list_1 {
+					display: flex;
+					flex-direction: column;
+					flex-grow: 1;
+					padding: 2vw 0;
+
+					.name {
+						font-size: var(--font16Size);
+						margin: 0 0 1vw 0;
+					}
+
+					.some {
+						color: var(--f85Color);
+						font-size: var(--font14Size);
+						margin: 0 0 1vw 0;
+
+						text:last-child {
+							margin: 0 0 0 1vw;
+							color: var(--f00Color);
+						}
 					}
 
 					.other {
 						display: flex;
 						justify-content: space-between;
-
-						.name {
-							font-size: var(--font16Size);
-							font-weight: bold;
-						}
+						align-items: center;
 
 						.other_1 {
 							font-size: var(--font14Size);
@@ -140,13 +406,44 @@
 
 							text {
 								font-weight: bold;
-								padding: 0 2vw;
+								padding: 0 1vw 0 0;
 								color: var(--ff0Color);
 							}
 						}
+
+						.other_2 {
+							.btn {
+								display: flex;
+								flex-direction: column;
+								align-items: center;
+								margin: 0 2vw;
+								padding: 2vw 3vw;
+								background-color: var(--ff0Color);
+								color: var(--fffColor);
+								border-radius: 2vw;
+								font-size: var(--font14Size);
+
+								text {
+									font-size: var(--font12Size);
+								}
+							}
+						}
 					}
 				}
 			}
 		}
 	}
+
+	.scroll-view {
+		position: absolute;
+		top: 0;
+		left: 0;
+		right: 0;
+		bottom: 0;
+
+		.list-scroll-view {
+			display: flex;
+			flex-direction: column;
+		}
+	}
 </style>