From 0e4b49f4bee160790b1830e6a8606e739b32fc3b Mon Sep 17 00:00:00 2001
From: rk <94314517@qq.com>
Date: 星期三, 11 三月 2026 09:09:45 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 mini-program/pages/search/search.vue |   39 ++++++++++++++++++++++++++++++++++-----
 1 files changed, 34 insertions(+), 5 deletions(-)

diff --git a/mini-program/pages/search/search.vue b/mini-program/pages/search/search.vue
index 6ec5f00..aa9b722 100644
--- a/mini-program/pages/search/search.vue
+++ b/mini-program/pages/search/search.vue
@@ -2,7 +2,7 @@
 	<view class="box">
 		<view class="search">
 			<u-search placeholder="璇疯緭鍏ュ晢鍝佸悕绉版悳绱�" height="36" searchIconColor="#999999" borderColor="#EEEEEE"
-				bgColor="#F9F9FB" :showAction="false" v-model="goodsName" @search="search" />
+				bgColor="#F9F9FB" :showAction="false" v-model="goodsName" @search="search" @clear="goodsList = []" />
 		</view>
 		<view class="history" v-if="historyList && historyList.length > 0">
 			<view class="history-title">鍘嗗彶鎼滅储</view>
@@ -12,8 +12,8 @@
 		</view>
 		<template v-if="isSearch">
 			<view class="list">
-				<image class="list-notfund" v-if="goodsList.length === 0" src="/static/images/default_search@2x.png" mode="widthFix"></image>
-				<view class="commodity-item" v-for="(item, i) in goodsList" :key="i" v-else>
+				<image class="list-notfund" v-if="goodsList.length === 0" src="/static/images/default_nodata_grey.png" mode="widthFix"></image>
+				<view class="commodity-item" v-for="(item, i) in goodsList" :key="i" v-else @click="jumpDetails(item.id)">
 					<view class="commodity-item-image">
 						<image :src="item.imgurl" mode="widthFix"></image>
 					</view>
@@ -31,19 +31,22 @@
 							</view>
 						</view>
 						<view class="commodity-item-shou">
-							<text>宸插敭{{item.saleNum + item.realSaleNum}}</text>
-							<view class="commodity-item-shou-add">+</view>
+							<text>宸插敭{{item.shou}}</text>
+							<view class="commodity-item-shou-add" @click.stop="addCard(item)">+</view>
 						</view>
 					</view>
 				</view>
 			</view>
 		</template>
+		<Login ref="login" />
 	</view>
 </template>
 
 <script>
 	import { mapState } from 'vuex'
+	import Login from '@/components/login/login.vue'
 	export default {
+		components: { Login },
 		computed: {
 			...mapState(['userInfo'])
 		},
@@ -76,6 +79,26 @@
 			this.getGoodsList()
 		},
 		methods: {
+			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 })
+					}
+				})
+			},
+			jumpDetails(id) {
+				uni.navigateTo({
+					url: '/pages/details/details?id=' + id
+				})
+			},
 			seleContent(val) {
 				this.goodsName = val
 				this.search()
@@ -91,6 +114,10 @@
 				})
 			},
 			search() {
+				if (!this.goodsName) {
+					this.goodsList = []
+					return
+				};
 				if (!this.isSearch) {
 					this.isSearch = true
 				}
@@ -117,6 +144,7 @@
 						this.gethistary()
 						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++
@@ -204,6 +232,7 @@
 				.commodity-item-image {
 					width: 100%;
 					height: 336rpx;
+					overflow: hidden;
 					display: flex;
 					align-items: center;
 					justify-content: center;

--
Gitblit v1.9.3