zs 2 年之前
父节点
当前提交
39db75cad7
共有 3 个文件被更改,包括 479 次插入30 次删除
  1. 214 19
      pages/market/index.vue
  2. 235 8
      pagesHome/order/detail.vue
  3. 30 3
      pagesHome/order/order.vue

+ 214 - 19
pages/market/index.vue

@@ -26,8 +26,45 @@
 				<scroll-view scroll-y="true" class="scroll-view">
 					<view class="list-scroll-view">
 						<checkbox-group name="checkbox" @change="marketChange">
-							<view class="lists" v-for="(item, index) in list" :key="index">
-								<view class="list">
+							<view class="list" v-for="(item, index) in list" :key="index">
+								<view class="list_1" v-if="item.is_set=='0'">
+									<view class="title">
+										<checkbox :value="item._id" :checked="item.check">
+											优惠套装---{{item.name||'暂无名称'}}</checkbox>
+									</view>
+									<checkbox-group name="checkbox" @change="goodsChange">
+										<view class="content" v-for="gs in item.goods" :key="gs.goodsSpec_id">
+											<view class="img">
+												<image :src="getFile(gs)"></image>
+											</view>
+											<view class="one_1" @click="toCommon('/pagesHome/order/detail',gs)">
+												<view class="name"><text class="set">套装</text> {{gs.goods_name}}
+												</view>
+												<view class="info">
+													<view class="title_1" v-if="gs.spec_name">
+														<text>规格:{{gs.spec_name}}</text>
+													</view>
+												</view>
+											</view>
+											<view class="money">
+												<view>{{gs.set_num}}件/套x{{gs.set_num}}</view>
+											</view>
+										</view>
+										<view class="total">
+											<view class="total_1"> <text>套装价</text>¥{{item.sell_money||0}} </view>
+											<view class="total_2">
+												<view class="num">
+													<uni-number-box @change="changeValue(item)" name="num" value="item"
+														:min="1" v-model="item.num" />
+												</view>
+												<view class="del">
+													<text class="iconfont icon-del-copy" @click="toDel(item)"></text>
+												</view>
+											</view>
+										</view>
+									</checkbox-group>
+								</view>
+								<view class="list_2" v-else>
 									<view class="title">
 										<checkbox :value="item.shop" :checked="item.check">
 											<text class="iconfont icon-shangdian"></text>
@@ -168,7 +205,9 @@
 					value
 				} = e.detail;
 				for (const p1 of list) {
-					let p2 = value.find((i) => i == p1.shop);
+					let p2;
+					if (p1._id) p2 = value.find((i) => i == p1._id);
+					if (p1.shop) p2 = value.find((i) => i == p1.shop);
 					let a = p2 ? true : false;
 					p1.check = a;
 					for (let s of p1.goods) {
@@ -244,16 +283,30 @@
 			async changeValue(value) {
 				const that = this;
 				this.$nextTick(async () => {
-					const {
-						goodsSpec_id: goodsSpecId,
-						num,
-						cart_id: cartId
-					} = value
-					const res = await that.$api(`/cart/checkGoodsNum`, 'GET', {
-						cartId,
-						goodsSpecId,
-						num
-					});
+					let res;
+					if (value.is_set == '0') {
+						const {
+							_id: set_id,
+							num,
+							cart_id: cartId
+						} = value
+						res = await that.$api(`/cart/checkGoodsNum`, 'GET', {
+							cartId,
+							set_id,
+							num
+						});
+					} else {
+						const {
+							goodsSpec_id: goodsSpecId,
+							num,
+							cart_id: cartId
+						} = value
+						res = await that.$api(`/cart/checkGoodsNum`, 'GET', {
+							cartId,
+							goodsSpecId,
+							num
+						});
+					}
 					if (res.errcode === 0) {
 						const {
 							enough,
@@ -328,11 +381,18 @@
 				// 渲染结束执行下面方法
 				that.$nextTick(() => {
 					for (const val of list) {
-						for (let s of val.goods) {
-							if (s.check == true) {
-								let total = that.$multiply(s.price, s.num);
+						if (val.is_set == '0') {
+							if (val.check == true) {
+								let total = that.$multiply(val.sell_money, val.num);
 								totalMoney += Number(total);
 							}
+						} else {
+							for (let s of val.goods) {
+								if (s.check == true) {
+									let total = that.$multiply(s.price, s.num);
+									totalMoney += Number(total);
+								}
+							}
 						}
 					}
 					that.$set(that, `totalMoney`, totalMoney.toFixed(2))
@@ -346,8 +406,21 @@
 			// 去结算
 			async toSettle() {
 				// 将选中的购物车放到数组中,传回服务端进行检查.然后拿着key去订单页请求数据
-				const goodsList = this.list.map(i => i.goods).flat();
-				const cartIds = goodsList.filter(i => i.check).map(i => i.cart_id)
+				let goodsList = [];
+				let cartIds = [];
+				for (let val of this.list) {
+					if (val.is_set == '0') goodsList.push(val)
+					else goodsList.push(val.goods)
+				}
+				for (let val of goodsList) {
+					if (val.is_set == '0') {
+						if (val.check) cartIds.push(val.cart_id)
+					} else {
+						for (let set of val) {
+							if (set.check) cartIds.push(set.cart_id)
+						}
+					}
+				}
 				const res = await this.$api(`/util/checkCartBuy`, 'POST', {
 					cartIds
 				});
@@ -440,7 +513,129 @@
 			flex-grow: 1;
 			margin: 0 2vw;
 
-			.list {
+			.list_1 {
+				background-color: var(--mainColor);
+				margin: 2vw 0 2vw 0;
+				padding: 2vw 3vw;
+				border-radius: 4px;
+
+				.title {
+					border-bottom: 1px solid var(--fcColor);
+					padding: 0 0 2vw 0;
+					font-size: var(--font18Size);
+
+					text {
+						margin: 0 1vw;
+					}
+				}
+
+				.content {
+					display: flex;
+					flex-direction: row;
+					padding: 2vw 0;
+					font-size: var(--font16Size);
+					border-bottom: 1px dashed var(--fcColor);
+
+					.img {
+						width: 20vw;
+						height: 20vw;
+						border-radius: 2vw;
+						border: 1px solid var(--fcColor);
+
+						image {
+							width: 20vw;
+							height: 20vw;
+						}
+					}
+
+					.one_1 {
+						margin: 0 2.5vw;
+						flex-grow: 1;
+
+						.name {
+							.set {
+								margin: 0 1vw 0 0;
+								font-size: 12px;
+								border-radius: 5px;
+								padding: 0 1vw;
+								color: #ffffff;
+								background-color: #FF6347;
+								border: 1px solid #FFA500;
+							}
+						}
+
+						.info {
+							width: 100%;
+							display: flex;
+							flex-direction: row;
+
+							.title_1 {
+								font-size: 12px;
+								color: #666;
+								margin-top: 10px;
+
+								text {
+									background-color: #eee;
+									padding: 5px;
+								}
+							}
+
+							.gift {
+								margin: 2vw 1vw 0 0;
+								font-size: 12px;
+								color: #FFA500;
+								border: 1px solid #FFA500;
+								border-radius: 5px;
+								padding: 0 1vw;
+							}
+
+							.act {
+								margin: 2vw 0 0 0;
+								font-size: 12px;
+								border-radius: 5px;
+								padding: 0 1vw;
+								border: 1px solid var(--fFB1Color);
+								color: var(--fFB1Color);
+							}
+						}
+					}
+
+					.money {
+						font-size: 14px;
+						margin-top: 2vw;
+						text-align: right;
+						flex-grow: 1;
+					}
+				}
+
+				.total {
+					display: flex;
+					justify-content: space-between;
+					padding: 1vw;
+
+					.total_1 {
+						font-size: 20px;
+						color: var(--fFB1Color);
+
+						text {
+							font-size: 12px;
+
+						}
+					}
+
+					.total_2 {
+						display: flex;
+						justify-content: space-between;
+						align-items: center;
+
+						.del {
+							margin: 0 0 0 3vw;
+						}
+					}
+				}
+			}
+
+			.list_2 {
 				background-color: var(--mainColor);
 				margin: 2vw 0 2vw 0;
 				padding: 2vw 3vw;

+ 235 - 8
pagesHome/order/detail.vue

@@ -74,8 +74,24 @@
 								<text class="iconfont icon-jiantouyou"></text>
 							</view>
 						</view>
-						<view class="one_7">
+						<view class="one_7" v-if="info.sets.length>0" @tap="toSets">
 							<view class="one_7_1">
+								优惠套装<text>({{info.sets.length||0}})</text>
+							</view>
+							<view class="one_7_2">
+								<view class="image" v-for="(set,index) in info.sets[0].set" :key="index">
+									<image class="image" :src="set.file&&set.file.length>0?set.file[0].url:''"
+										mode="aspectFit">
+									</image>
+								</view>
+								<view class="money">
+									<view class="money_1">共{{info.sets[0].goods_total}}件</view>
+									<view class="money_2">¥{{info.sets[0].sell_money}}</view>
+								</view>
+							</view>
+						</view>
+						<view class="one_8">
+							<view class="one_8_1">
 								<view class="shop_1">
 									<image class="image"
 										:src="info.shop.logo&&info.shop.logo.length>0?info.shop.logo[0].url:''"
@@ -86,7 +102,7 @@
 									<view class="num"><text>宝贝数:</text>{{info.shop.goods_num||0}}</view>
 								</view>
 							</view>
-							<view class="one_7_2">
+							<view class="one_8_2">
 								<view class="score_1">
 									<text>商品:</text>
 									<text>{{info.shop.goods_score||5}}</text>
@@ -102,7 +118,7 @@
 									<text>{{info.shop.service_score||5}}</text>
 								</view>
 							</view>
-							<view class="one_7_3">
+							<view class="one_8_3">
 								<view class="btn">
 									<button size="mini" @tap="toShop">进入店铺</button>
 								</view>
@@ -111,7 +127,7 @@
 								</view>
 							</view>
 						</view>
-						<view class="one_8">
+						<view class="one_9">
 							<rich-text :nodes="info.goods.brief"></rich-text>
 						</view>
 					</view>
@@ -247,6 +263,35 @@
 						</view>
 					</scroll-view>
 				</view>
+				<view class="info_4" v-else>
+					<view class="info_4">
+						<scroll-view scroll-y="true" class="scroll-view">
+							<view class="list-scroll-view">
+								<view class="list" v-for="(item,index) in info.sets" :key="index">
+									<view class="name"><text class="set">套装</text>{{item.name}}</view>
+									<view class="set">
+										<view class="set_1" v-for="(tag,indexx) in item.set" :key="indexx"
+											@tap="toDeatil(tag)">
+											<image class="image" :src="tag.file&&tag.file.length>0?tag.file[0].url:''"
+												mode="aspectFit">
+											</image>
+											<view class="goods textOver">{{tag.goods_name}}</view>
+											<view class="spec textOver">{{tag.spec_name}}</view>
+										</view>
+									</view>
+									<view class="bottom">
+										<view class="money">
+											共{{item.goods_total||0}}件,套装价:<text>¥{{item.sell_money||0}}</text>
+										</view>
+										<view class="add">
+											<button size="mini" @tap="toSetMarket(item)">加入购物车</button>
+										</view>
+									</view>
+								</view>
+							</view>
+						</scroll-view>
+					</view>
+				</view>
 			</view>
 		</uni-popup>
 		<view class="dialog" v-if="dialog.show==true" @tap="dialogClose">
@@ -506,6 +551,51 @@
 					that.$refs.specShow.open();
 				}
 			},
+			// 查看套装
+			toSets() {
+				const that = this;
+				if (that.info.sets.length > 0) {
+					that.$set(that, `popupShow`, '3')
+					that.$refs.specShow.open();
+				}
+			},
+			// 套装详情
+			toDeatil(e) {
+				const that = this;
+				uni.navigateTo({
+					url: `/pagesHome/order/detail?id=${e.goods}`
+				})
+			},
+			// 套装加入购物车
+			async toSetMarket(e) {
+				const that = this;
+				let user = that.user;
+				if (user && user._id) {
+					let obj = {
+						customer: user._id,
+						set_id: e._id,
+						is_set: '0',
+						num: 1,
+					}
+					let res = await that.$api(`/cart`, 'POST', obj)
+					if (res.errcode == '0') {
+						uni.showToast({
+							title: `加入购物车成功`,
+							icon: 'none'
+						})
+						that.toClose();
+					} else {
+						uni.showToast({
+							title: res.errmsg,
+							icon: 'none'
+						})
+					}
+				} else {
+					uni.navigateTo({
+						url: `/pages/login/index`
+					})
+				}
+			},
 			// 查看正品详情
 			getDetail(e) {
 				const that = this;
@@ -941,9 +1031,61 @@
 
 			.one_7 {
 				padding: 2vw;
-				border-bottom: 0.5vw solid var(--f9Color);
+				border-bottom: 2vw solid var(--f9Color);
+				border-top: 1vw solid var(--f9Color);
 
 				.one_7_1 {
+					padding: 2vw 0;
+					font-size: 14px;
+
+					text {
+						padding: 0 0 0 1vw;
+						font-size: 12px;
+						color: #858585;
+					}
+				}
+
+				.one_7_2 {
+					display: flex;
+					justify-content: space-between;
+					align-items: center;
+					padding: 2vw;
+					border-radius: 5px;
+					background-color: var(--f9Color);
+
+					.image {
+						width: 20vw;
+						height: 20vw;
+
+						.image {
+							width: 100%;
+							height: 100%;
+							border-radius: 5px;
+							background-color: #fff;
+						}
+					}
+
+					.money {
+						text-align: center;
+
+						.money_1 {
+							font-size: 12px;
+							color: #858585;
+						}
+
+						.money_2 {
+							font-size: 12px;
+							color: #ff0000;
+						}
+					}
+				}
+			}
+
+			.one_8 {
+				padding: 2vw;
+				border-bottom: 0.5vw solid var(--f9Color);
+
+				.one_8_1 {
 					margin: 0 0 1vw 0;
 					display: flex;
 
@@ -978,7 +1120,7 @@
 					}
 				}
 
-				.one_7_2 {
+				.one_8_2 {
 					margin: 0 0 2vw 0;
 					display: flex;
 					justify-content: space-between;
@@ -1000,7 +1142,7 @@
 					}
 				}
 
-				.one_7_3 {
+				.one_8_3 {
 					display: flex;
 					justify-content: space-around;
 
@@ -1016,7 +1158,7 @@
 				}
 			}
 
-			.one_8 {
+			.one_9 {
 				padding: 2vw;
 
 				.rich-img {
@@ -1341,6 +1483,91 @@
 				}
 			}
 		}
+
+		.info_4 {
+			position: relative;
+			display: flex;
+			flex-direction: column;
+			height: 54vh;
+
+			.info_4 {
+				position: relative;
+				flex-grow: 1;
+
+				.list {
+					margin: 0 2vw 2vw 2vw;
+					border-radius: 10px;
+					background-color: var(--f9Color);
+
+					.name {
+						display: flex;
+						padding: 2vw;
+						font-size: 14px;
+
+						.set {
+							margin: 0 1vw 0 0;
+							font-size: 12px;
+							border-radius: 5px;
+							padding: 0 1vw;
+							color: #ffffff;
+							background-color: #FF6347;
+							border: 1px solid #FFA500;
+						}
+					}
+
+					.set {
+						display: flex;
+						justify-content: space-around;
+						flex-wrap: wrap;
+						margin: 0 2vw;
+						padding: 2vw;
+						background-color: #fff;
+						border-radius: 5px;
+
+						.set_1 {
+							width: 25vw;
+							text-align: center;
+							font-size: 14px;
+
+							.spec {
+								font-size: 12px;
+								color: #858585;
+							}
+
+							.image {
+								width: 20vw;
+								height: 20vw;
+								border-radius: 5px;
+								background-color: #fff;
+							}
+						}
+					}
+
+					.bottom {
+						display: flex;
+						justify-content: space-between;
+						align-items: center;
+						padding: 2vw;
+
+						.money {
+							font-size: 12px;
+
+							text {
+								color: #ff0000;
+							}
+						}
+
+						.add {
+							button {
+								background-color: #ff0000;
+								color: #ffffff;
+								border-radius: 5vw;
+							}
+						}
+					}
+				}
+			}
+		}
 	}
 
 	.dialog {

+ 30 - 3
pagesHome/order/order.vue

@@ -20,7 +20,12 @@
 						</view>
 						<view class="one_2">
 							<view class="list" v-for="(item,index) in orderList" :key="index">
-								<view class="list_1">
+								<view class="list_1" v-if="item.is_set=='0'">
+									<view class="r">
+										<text class="set">套装</text> {{item.name}}
+									</view>
+								</view>
+								<view class="list_1" v-else>
 									<view class="l">
 										<text class="iconfont icon-shangdian"></text>
 										<text>{{item.shop_name}}</text>
@@ -36,7 +41,10 @@
 											<view class="name">
 												{{tag.goods_name}}
 											</view>
-											<view class="Spec">
+											<view class="Spec" v-if="item.is_set=='0'">
+												规格:{{tag.spec_name}}
+											</view>
+											<view class="Spec" v-else>
 												规格:{{tag.goodsSpec_name}}
 											</view>
 											<view class="label">
@@ -44,7 +52,10 @@
 												<text v-if="tag.sp_price" class="label_2">特价</text>
 											</view>
 										</view>
-										<view class="r">
+										<view class="r" v-if="item.is_set=='0'">
+											<view>{{tag.set_num}}件/套x{{tag.set_num}}</view>
+										</view>
+										<view class="r" v-else>
 											<view class="price" v-if="type=='0'">
 												¥{{tag.price}}
 											</view>
@@ -81,6 +92,10 @@
 									</view>
 								</view>
 								<view class="list_3">
+									<view class="other" v-if="item.is_set=='0'">
+										<view class="other_1">单价:¥{{item.sell_money}}</view>
+										<view class="other_2">数量:×{{item.num}}</view>
+									</view>
 									<view class="other">
 										<view class="other_1">配送方式</view>
 										<view class="other_2"><text class="iconfont icon-duihao"></text>快递配送</view>
@@ -675,6 +690,18 @@
 						text {
 							padding: 0 0 0 1vw;
 						}
+
+						.r {
+							.set {
+								margin: 0 1vw 0 0;
+								font-size: 12px;
+								border-radius: 5px;
+								padding: 0 1vw;
+								color: #ffffff;
+								background-color: #FF6347;
+								border: 1px solid #FFA500;
+							}
+						}
 					}
 
 					.list_2 {