From e7e2a77a824a0e6a80a3bc7f221c83db8223bf0c Mon Sep 17 00:00:00 2001
From: MrShi <1878285526@qq.com>
Date: 星期四, 12 二月 2026 09:42:40 +0800
Subject: [PATCH] 提交

---
 mini-program/pages/mall/mall.vue |  294 ++++++++++++++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 250 insertions(+), 44 deletions(-)

diff --git a/mini-program/pages/mall/mall.vue b/mini-program/pages/mall/mall.vue
index c4f0dd4..5b43004 100644
--- a/mini-program/pages/mall/mall.vue
+++ b/mini-program/pages/mall/mall.vue
@@ -1,5 +1,6 @@
 <template>
 	<view class="mall">
+		<view class="mall-zz" v-show="show"></view>
 		<view class="head" :style="{ height: 'calc(' + (navHeight + statusbarHeight + 'px + 188rpx)') }">
 			<view class="head-box">
 				<view :style="{ width: '100%', height: statusbarHeight + 'px' }"></view>
@@ -7,70 +8,77 @@
 					<text>鍟嗗煄</text>
 					<view class="head-search-input">
 						<u-search placeholder="鎼滅储鍟嗗搧" height="30" searchIconColor="#999999" borderColor="#eeeeee"
-							bgColor="rgba(255,255,255,0.9)" :showAction="false" v-model="keyword" />	
+							bgColor="rgba(255,255,255,0.9)" @custom="search" :showAction="false" v-model="form.goodsName" @search="search" />	
 					</view>
 				</view>
 				<view class="head-tabs">
-					<u-tabs lineColor="#E4001D" :list="list"></u-tabs>
+					<u-tabs lineColor="#E4001D" :list="list" @click="clickCate"></u-tabs>
 				</view>
 			</view>
 			
 			<view class="head-list">
 				<view class="head-list-item" @click="openSearch(1)">
-					<text style="color: #222222; font-weight: 500;">缁煎悎鎺掑簭</text>
-					<u-icon name="arrow-down" color="#222222" size="13"></u-icon>
+					<text :style="form.sortInfo ? 'color: #222222; font-weight: 500;' : ''">{{form.sortName}}</text>
+					<u-icon name="arrow-down" color="#222222" size="13" v-if="form.sortInfo && !show"></u-icon>
+					<u-icon name="arrow-up" color="#222222" size="13" v-else-if="form.sortInfo && show === 1"></u-icon>
+					<u-icon name="arrow-down" color="#777777" size="13" v-else></u-icon>
 				</view>
 				<view class="head-list-item" @click="openSearch(2)">
-					<text>閫傜敤鍝佺墝</text>
-					<u-icon name="arrow-down" color="#777777" size="13"></u-icon>
+					<text :style="form.applicableBrandId ? 'color: #222222; font-weight: 500;' : ''">{{form.applicableBrandId ? form.applicableBrandName : '閫傜敤鍝佺墝'}}</text>
+					<u-icon name="arrow-down" color="#222222" size="13" v-if="form.applicableBrandId && !show"></u-icon>
+					<u-icon name="arrow-up" color="#222222" size="13" v-else-if="form.applicableBrandId && show === 2"></u-icon>
+					<u-icon name="arrow-down" color="#777777" size="13" v-else></u-icon>
 				</view>
-				<view class="head-list-item">
-					<text>绯诲垪</text>
-					<u-icon name="arrow-down" color="#777777" size="13"></u-icon>
+				<view class="head-list-item" @click="openSearch(3)">
+					<text :style="form.seriesBrandId ? 'color: #222222; font-weight: 500;' : ''">{{form.seriesBrandId ? form.seriesBrandName : '绯诲垪'}}</text>
+					<u-icon name="arrow-down" color="#222222" size="13" v-if="form.seriesBrandId && !show"></u-icon>
+					<u-icon name="arrow-up" color="#222222" size="13" v-else-if="form.seriesBrandId && show === 3"></u-icon>
+					<u-icon name="arrow-down" color="#777777" size="13" v-else></u-icon>
 				</view>
 			</view>
-			
+			<!-- 鎺掑簭 -->
 			<view class="list" v-if="show === 1">
-				<view class="list-item">
-					<text>缁煎悎鎺掑簭</text>
-					<image src="/static/icon/ic_selete@2x.png" mode="widthFix"></image>
-				</view>
-				<view class="list-item">
-					<text>閿�閲忕敱楂樺埌浣�</text>
-				</view>
-				<view class="list-item">
-					<text>浠锋牸鐢变綆鍒伴珮</text>
+				<view :class="item.active ? 'list-item red' : 'list-item'" v-for="(item, index) in paixu" :key="index" @click="clickpx(index)">
+					<text>{{item.name}}</text>
+					<image src="/static/icon/ic_selete@2x.png" mode="widthFix" v-show="item.active"></image>
 				</view>
 			</view>
-			
-			<view class="list" v-if="show === 2">
-				<view class="list-cate active" v-for="(item, index) in 6" :key="index">鑷惀鍝佺墝</view>
+			<!-- 鍝佺墝 -->
+			<view class="list" style="padding-top: 30rpx; box-sizing: border-box; justify-content: flex-start;" v-if="show === 2">
+				<view :class="item.active ? 'list-cate active' : 'list-cate'" v-for="(item, index) in pingpai" :key="index" @click="getXiLie(item.id, index)">{{item.name}}</view>
+			</view>
+			<!-- 绯诲垪 -->
+			<view class="list" v-if="show === 3">
+				<view :class="item.active ? 'list-item red' : 'list-item'" v-for="(item, index) in xilie" :key="index" @click="clickxl(index)">
+					<text>{{item.name}}</text>
+					<image src="/static/icon/ic_selete@2x.png" mode="widthFix" v-show="item.active"></image>
+				</view>
 			</view>
 		</view>
 		<view class="commodity">
-			<!-- <view class="commodity-wu">
+			<view class="commodity-wu" v-if="goodsList.length === 0">
 				<image src="/static/images/default_search@2x.png" mode="widthFix"></image>
-			</view> -->
-			<view class="commodity-item" v-for="(item, i) in 16" :key="i" @click="jump()">
+			</view>
+			<view class="commodity-item" v-else v-for="(item, i) in goodsList" :key="i" @click="jumpDetails(item.id)">
 				<view class="commodity-item-image">
-					<image src="/static/logo.png" mode="widthFix"></image>
+					<image :src="item.imgurl" mode="widthFix"></image>
 				</view>
 				<view class="commodity-item-box">
 					<view class="commodity-item-box-title">
-						鏇茶酱鍑忛渿鍣ㄧ毊甯﹁疆A12
+						{{item.name}}
 					</view>
 					<view class="commodity-item-box-price">
 						<view class="commodity-item-box-price-a">
-							<text>499</text>
-							<text>.00</text>
+							<text>{{item.minPrice[0]}}</text>
+							<text>.{{item.minPrice[1]}}</text>
 						</view>
 						<view class="commodity-item-box-price-b">
-							楼699.00
+							楼{{item.price}}
 						</view>
 					</view>
 					<view class="commodity-item-shou">
-						<text>宸插敭299</text>
-						<view class="commodity-item-shou-add">+</view>
+						<text>宸插敭{{item.saleNum + item.realSaleNum}}</text>
+						<view class="commodity-item-shou-add" @click.stop="addCard(item)">+</view>
 					</view>
 				</view>
 			</view>
@@ -79,7 +87,7 @@
 			<view class="cart-box">
 				<image src="/static/icon/ic_cart@2x.png" mode="widthFix"></image>
 				<text>璐墿杞�</text>
-				<view class="cart-num">12</view>
+				<view class="cart-num">{{cardTotal}}</view>
 			</view>
 		</view>
 	</view>
@@ -93,32 +101,211 @@
 		computed: {
 			...mapState(['navHeight', 'statusbarHeight'])
 		},
+		watch: {
+			paixu: {
+				immediate: true,
+				deep: true,
+				handler(news, olds) {
+					let obj = news.filter(item => item.active)
+					this.form.sortInfo = obj[0].id
+					this.form.sortName = obj[0].name
+				}
+			},
+			pingpai: {
+				immediate: true,
+				deep: true,
+				handler(news, olds) {
+					if (news.length === 0) return;
+					let obj = news.filter(item => item.active)
+					this.form.applicableBrandId = obj[0].id
+					this.form.applicableBrandName = obj[0].name
+				}
+			},
+			xilie: {
+				immediate: true,
+				deep: true,
+				handler(news, olds) {
+					if (news.length === 0) return;
+					let obj = news.filter(item => item.active)
+					this.form.seriesBrandId = obj[0].id
+					this.form.seriesBrandName = obj[0].name
+				}
+			}
+		},
 		data() {
 			return {
 				keyword: '',
 				show: null,
-				list: [
-					{ name: '鍏ㄩ儴' },
-					{ name: '鏀噸杞�' },
-					{ name: '鎵樿疆' },
-					{ name: '骞宠 杞�' },
-					{ name: '瀵艰建' },
-					{ name: '瀵煎悜杞�' },
-				]
+				list: [],
+				paixu: [
+					{ name: '榛樿鎺掑簭', id: '', active: true },
+					{ name: '缁煎悎鎺掑簭', id: 0, active: false },
+					{ name: '閿�閲忕敱浣庡埌楂�', id: 1, active: false },
+					{ name: '浠锋牸鐢变綆鍒伴珮', id: 2, active: false },
+					{ name: '閿�閲忕敱楂樺埌浣�', id: 3, active: false },
+					{ name: '浠锋牸鐢遍珮鍒颁綆', id: 4, active: false },
+				],
+				pingpai: [],
+				xilie: [],
+				form: {
+					sortInfo: '',
+					sortName: '',
+					categoryId: '',
+					type: 1,
+					goodsName: '',
+					seriesBrandId: '',
+					seriesBrandName: '',
+					applicableBrandId: '',
+					applicableBrandName: ''
+				},
+				next: true,
+				page: 1,
+				goodsList: [],
+				cardTotal: 0
 			};
 		},
+		onLoad() {
+			this.getCartNum()
+			this.getLabels()
+			this.getGoodsList()
+		},
+		onReachBottom() {
+			this.getGoodsList()
+		},
 		methods: {
+			getCartNum() {
+				this.$u.api.cartGoodsTypeNum()
+					.then(res => {
+						if (res.code === 200) {
+							this.cardTotal = res.data
+						}
+					})
+			},
+			search() {
+				this.page = 1
+				this.goodsList = []
+				this.next = true
+				this.getGoodsList()
+			},
+			addCard(e) {
+				this.$u.api.addCart({
+					goodsId: e.id,
+					goodsSkuId: e.skuResponsesList[0].id,
+					num: 1
+				}).then(res => {
+					if (res.code === 200) {
+						uni.showToast({ title: '娣诲姞鎴愬姛', icon: 'success' })
+						this.getCartNum()
+					}
+				})
+			},
+			jumpDetails(id) {
+				uni.navigateTo({
+					url: '/pages/details/details?id=' + id
+				})
+			},
+			// 鍟嗗搧
+			getGoodsList() {
+				if (!this.next) return;
+				this.$u.api.goodsPage({
+					capacity: 10,
+					page: this.page,
+					model: this.form
+				}).then(res => {
+					if (res.code === 200) {
+						res.data.records.forEach(item => {
+							item.minPrice = item.minPrice.toFixed(2).split('.')
+						})
+						this.goodsList.push(...res.data.records)
+						this.page++
+						if (this.goodsList.length === res.data.total) {
+							this.next = false
+						}
+					}
+				})
+			},
+			// 鑾峰彇鍒嗙被
+			getLabels() {
+				this.$u.api.getGoodsLabelsByType({ type: 0 })
+					.then(res => {
+						if (res.code === 200) {
+							res.data.unshift({ name: '鍏ㄩ儴', id: '' })
+							this.list = res.data
+						}
+					})
+				this.$u.api.getGoodsLabelsByType({ type: 14 })
+					.then(res => {
+						if (res.code === 200) {
+							res.data.forEach(item => {
+								item.active = false
+							})
+							res.data.unshift({ name: '鍏ㄩ儴', id: '', active: true })
+							this.pingpai = res.data
+						}
+					})
+			},
+			// 绯诲垪
+			getXiLie(parentId, i) {
+				this.xilie = []
+				this.pingpai.forEach((item, index) => {
+					item.active = index === i
+				})
+				if (!parentId) {
+					this.show = null
+					this.form.seriesBrandId = ''
+					this.form.seriesBrandName = ''
+					this.search()
+					return;
+				}
+				this.$u.api.getGoodsLabelsByType({ type: 15, parentId })
+					.then(res => {
+						if (res.code === 200) {
+							this.show = null
+							this.search()
+							if (res.data.length === 0) return uni.showToast({
+								title: '褰撳墠鍝佺墝涓嬫殏鏃犵郴鍒�',
+								icon: 'none'
+							})
+							res.data.forEach(item => {
+								item.active = false
+							})
+							res.data.unshift({ name: '鍏ㄩ儴', id: '', active: true })
+							this.xilie = res.data
+						}
+					})
+			},
+			// 鎵撳紑鎼滅储
 			openSearch(type) {
+				if (type === 3 && this.xilie.length === 0) return uni.showToast({
+					title: '褰撳墠鏆傛棤绯诲垪鏁版嵁',
+					icon: 'none'
+				})
 				if (type === this.show) {
 					this.show = null
 				} else {
 					this.show = type
 				}
 			},
-			jump() {
-				uni.navigateTo({
-					url: '/pages/details/details'
+			// 閫夋嫨鎺掑簭
+			clickpx(i) {
+				this.paixu.forEach((item, index) => {
+					item.active = index === i
 				})
+				this.show = null
+				this.search()
+			},
+			// 閫夋嫨绯诲垪
+			clickxl(i) {
+				this.xilie.forEach((item, index) => {
+					item.active = index === i
+				})
+				this.show = null
+				this.search()
+			},
+			// 鍒囨崲鍒嗙被
+			clickCate(e) {
+				this.form.categoryId = e.id
+				this.search()
 			}
 		}
 	}
@@ -132,6 +319,15 @@
 <style lang="scss" scoped>
 	.mall {
 		width: 100%;
+		.mall-zz {
+			width: 100vw;
+			height: 100vh;
+			background-color: rgba(0,0,0,.5);
+			position: fixed;
+			top: 0;
+			left: 0;
+			z-index: 2;
+		}
 		.cart {
 			position: fixed;
 			right: 30rpx;
@@ -315,6 +511,7 @@
 				align-items: center;
 				justify-content: space-between;
 				flex-wrap: wrap;
+				border-radius: 0rpx 0rpx 24rpx 24rpx;
 				.active {
 					background: rgba(0,64,150,0.1) !important;
 					color: #004096 !important;
@@ -331,6 +528,15 @@
 					font-size: 28rpx;
 					color: #333333;
 					margin-bottom: 24rpx;
+					margin-right: 20rpx;
+					&:last-child {
+						margin-right: 0 !important;
+					}
+				}
+				.red {
+					text {
+						color: #E4001D !important;
+					}
 				}
 				.list-item {
 					width: 100%;

--
Gitblit v1.9.3