From e4f9739d74323aacf09d139700f22a383910ee97 Mon Sep 17 00:00:00 2001
From: MrShi <1878285526@qq.com>
Date: 星期三, 04 三月 2026 10:38:32 +0800
Subject: [PATCH] 合并

---
 mini-program/pages/mall/mall.vue |  265 ++++++++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 222 insertions(+), 43 deletions(-)

diff --git a/mini-program/pages/mall/mall.vue b/mini-program/pages/mall/mall.vue
index 27e0bb2..6bddcae 100644
--- a/mini-program/pages/mall/mall.vue
+++ b/mini-program/pages/mall/mall.vue
@@ -8,26 +8,32 @@
 					<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)" @clear="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" :itemStyle="{ height: '100rpx' }" :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="String(form.sortInfo) ? 'color: #222222; font-weight: 500;' : ''">{{form.sortName}}</text>
+					<u-icon name="arrow-down" color="#222222" size="13" v-if="String(form.sortInfo) && !show"></u-icon>
+					<u-icon name="arrow-up" color="#222222" size="13" v-else-if="String(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" @click="openSearch(3)">
-					<text>绯诲垪</text>
-					<u-icon name="arrow-down" color="#777777" size="13"></u-icon>
+					<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>
 			<!-- 鎺掑簭 -->
@@ -38,52 +44,58 @@
 				</view>
 			</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)">{{item.name}}</view>
+			<view class="list" style="padding-top: 30rpx; box-sizing: border-box;" 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 style="width: 216rpx; height: 0;"></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="clickpx(index)">
+				<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">
-				<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 class="commodity-wu" v-if="goodsList.length === 0">
+				<image src="/static/images/default_nodata_white.png" mode="widthFix"></image>
+			</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?item.imgurl:'/static/icon/default2.png'" 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>
+<<<<<<< HEAD
+						<text>宸插敭{{item.shou}}</text>
+=======
+						<text>宸插敭{{(item.saleNum ||0)+ (item.realSaleNum||0)}}</text>
+>>>>>>> 7b09a9950f13521190a4aef9bbc2a6163445566c
+						<view class="commodity-item-shou-add" @click.stop="addCard(item)">+</view>
 					</view>
 				</view>
 			</view>
 		</view>
-		<view class="cart">
+		<view class="cart" @click="jumpCart">
 			<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" v-if="cardTotal>0">{{cardTotal}}</view>
 			</view>
 		</view>
+		<Login ref="login" />
 	</view>
 </template>
 
@@ -91,9 +103,42 @@
 	import {
 		mapState
 	} from 'vuex'
+	import Login from '@/components/login/login.vue'
 	export default {
+		components: { Login },
 		computed: {
-			...mapState(['navHeight', 'statusbarHeight'])
+			...mapState(['navHeight', 'statusbarHeight', 'userInfo'])
+		},
+		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 {
@@ -101,6 +146,7 @@
 				show: null,
 				list: [],
 				paixu: [
+					{ name: '榛樿鎺掑簭', id: '', active: true },
 					{ name: '缁煎悎鎺掑簭', id: 0, active: false },
 					{ name: '閿�閲忕敱浣庡埌楂�', id: 1, active: false },
 					{ name: '浠锋牸鐢变綆鍒伴珮', id: 2, active: false },
@@ -108,13 +154,103 @@
 					{ name: '浠锋牸鐢遍珮鍒颁綆', id: 4, active: false },
 				],
 				pingpai: [],
-				xilie: []
+				xilie: [],
+				form: {
+					sortInfo: '',
+					sortName: '',
+					categoryId: '',
+					type: 1,
+					goodsName: '',
+					seriesBrandId: '',
+					seriesBrandName: '',
+					applicableBrandId: '',
+					applicableBrandName: ''
+				},
+				next: true,
+				page: 1,
+				goodsList: [],
+				cardTotal: 0
 			};
 		},
 		onLoad() {
 			this.getLabels()
+			this.getGoodsList()
+		},
+		async onShow() {
+			await this.$onLaunched;
+			if (this.userInfo) {
+				this.getCartNum()
+			}
+		},
+		onReachBottom() {
+			this.getGoodsList()
 		},
 		methods: {
+			jumpCart() {
+				if (!this.userInfo) {
+					this.$refs.login.open()
+					return;
+				}
+				uni.navigateTo({
+					url: '/pages/shopping-cart/shopping-cart'
+				})
+			},
+			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) {
+				if (!this.userInfo) {
+					this.$refs.login.open()
+					return;
+				}
+				this.$u.api.addCart({
+					goodsId: e.id,
+					goodsSkuId: e.goodsSkuResponseList[0].id,
+					num: 1
+				}).then(res => {
+					if (res.code === 200) {
+						uni.showToast({ title: '娣诲姞鎴愬姛', icon: 'success', mask: true })
+						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('.')
+							item.shou = (item.salenum || 0) + (item.realSaleNum || 0)
+						})
+						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 })
@@ -124,47 +260,81 @@
 							this.list = res.data
 						}
 					})
-				this.$u.api.getGoodsLabelsByType({ type: 1 })
+				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 })
+							res.data.unshift({ name: '鍏ㄩ儴', id: '', active: true })
 							this.pingpai = res.data
 						}
 					})
 			},
 			// 绯诲垪
-			getXiLie(parentId) {
+			getXiLie(parentId, i) {
+				this.form.seriesBrandId = ''
+				this.form.seriesBrandName = ''
+				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) {
-							console.log(res)
+							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 })
+							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()
 			}
 		}
 	}
@@ -254,11 +424,13 @@
 				.commodity-item-image {
 					width: 100%;
 					height: 336rpx;
+					overflow: hidden;
 					display: flex;
 					align-items: center;
 					justify-content: center;
 					image {
 						width: 100%;
+						max-height:330rpx;
 					}
 				}
 				.commodity-item-box {
@@ -266,6 +438,11 @@
 					padding: 20rpx;
 					box-sizing: border-box;
 					.commodity-item-box-title {
+						width: 100%;
+						display: -webkit-box;
+						-webkit-box-orient: vertical;
+						-webkit-line-clamp: 2;
+						overflow: hidden;
 						font-weight: 600;
 						font-size: 30rpx;
 						color: #222222;
@@ -356,8 +533,8 @@
 				.head-tabs {
 					width: 100%;
 					height: 100rpx;
-					display: flex;
-					align-items: flex-end;
+					// display: flex;
+					// align-items: flex-end;
 					border-bottom: 1rpx solid #E5E5E5;
 				}
 			}
@@ -387,13 +564,15 @@
 					font-size: 28rpx;
 					color: #333333;
 					margin-bottom: 24rpx;
-					margin-right: 20rpx;
-					&:last-child {
-						margin-right: 0 !important;
-					}
+					// margin-right: 20rpx;
+					// &:last-child {
+					// 	margin-right: 0 !important;
+					// }
 				}
 				.red {
-					color: #E4001D !important;
+					text {
+						color: #E4001D !important;
+					}
 				}
 				.list-item {
 					width: 100%;

--
Gitblit v1.9.3