From b0712811a0421dd3d4bc6ea03c54b7b39096439e Mon Sep 17 00:00:00 2001
From: MrShi <1878285526@qq.com>
Date: 星期六, 28 二月 2026 18:27:42 +0800
Subject: [PATCH] 提交

---
 mini-program/pages/index/index.vue |  127 +++++++++++++++++++++++++++++-------------
 1 files changed, 87 insertions(+), 40 deletions(-)

diff --git a/mini-program/pages/index/index.vue b/mini-program/pages/index/index.vue
index cba0450..c127892 100644
--- a/mini-program/pages/index/index.vue
+++ b/mini-program/pages/index/index.vue
@@ -1,12 +1,11 @@
 <template>
 	<view class="index">
 		<view class="head" :style="{ height: 'calc(' + (navHeight + statusbarHeight + 'px + 248rpx)') }">
-			<view :style="{ width: '100%', height: navHeight + statusbarHeight + 'px' }"></view>
 			<view class="head-bar" :style="{ height: navHeight + statusbarHeight + 'px' }">
 				<view :style="{ width: '100%', height: statusbarHeight + 'px' }"></view>
 				<view class="head-bar-nav" :style="{ height: navHeight + 'px' }" @click="openLoacing">
 					<image src="/static/icon/home_ic_location@2x.png" mode="widthFix"></image>
-					<text>鑾茶姳绉戞妧鍒涙柊浜т笟鍥璅搴�</text>
+					<text>{{position.formatted_addresses.recommend || '鐐瑰嚮瀹氫綅'}}</text>
 					<u-icon name="arrow-right" color="#222222" size="13"></u-icon>
 				</view>
 			</view>
@@ -15,12 +14,12 @@
 					bgColor="rgba(255,255,255,0.9)" :showAction="false" />
 			</view>
 			<view class="banner">
-				<u-swiper :list="list" keyName="imgurl" height="150"></u-swiper>
+				<u-swiper :list="list" keyName="imgurl" height="150" indicator indicatorMode="dot"></u-swiper>
 			</view>
 			<u-scroll-list indicatorActiveColor="#004096">
 				<view class="scroll-list">
 					<view class="scroll-list__line" v-for="(item, index) in labels" :key="index">
-						<view class="cate-item" v-for="(child, index) in item" :key="index">
+						<view class="cate-item" v-for="(child, a) in item" :key="a" @click="jumpSearch1(child, 1)">
 							<view class="cate-item-image">
 								<image :src="child.imgUrl" mode="widthFix"></image>
 							</view>
@@ -35,7 +34,7 @@
 			<u-scroll-list indicatorActiveColor="#004096">
 				<view class="scroll-list" style="padding: 0;">
 					<view class="scroll-list__line" v-for="(item, index) in brand" :key="index">
-						<view class="cate-item1" v-for="(child, index) in item" :key="index">
+						<view class="cate-item1" v-for="(child, a) in item" :key="a" @click="jumpSearch1(child, 2)">
 							<image :src="child.imgUrl" mode="widthFix"></image>
 							<text>{{child.name}}</text>
 						</view>
@@ -44,22 +43,22 @@
 			</u-scroll-list>
 			<view class="title">
 				<view class="title-left">鍝佽川涓撳尯</view>
-				<view class="title-right">
+				<view class="title-right" @click="toZhuanqu">
 					<text>鏇村</text>
 					<u-icon name="arrow-right" color="#AAAAAA" size="10"></u-icon>
 				</view>
 			</view>
 			<view class="quality">
 				<view class="quality-item" @click="jumpShopZ(specialZone[0])">
-					<image class="quality-item-image" :src="specialZone[0].imgUrl" mode="widthFix"></image>
+					<image class="quality-item-image" :src="specialZone[0].imgUrl || '/static/icon/default2.png'" mode="widthFix"></image>
 				</view>
 				<view style="width: 22rpx; height: 100%;"></view>
 				<view class="quality-item">
 					<view class="quality-item-row" @click="jumpShopZ(specialZone[1])">
-						<image class="quality-item-row-image" :src="specialZone[1].imgUrl" mode="widthFix"></image>
+						<image class="quality-item-row-image" :src="specialZone[1].imgUrl || '/static/icon/default2.png'" mode="widthFix"></image>
 					</view>
 					<view class="quality-item-row" @click="jumpShopZ(specialZone[2])">
-						<image class="quality-item-row-image" :src="specialZone[2].imgUrl" mode="widthFix"></image>
+						<image class="quality-item-row-image" :src="specialZone[2].imgUrl || '/static/icon/default2.png'" mode="widthFix"></image>
 					</view>
 				</view>
 			</view>
@@ -67,9 +66,9 @@
 				<view class="title-left">绮鹃�夊晢鍝�</view>
 			</view>
 			<view class="commodity">
-				<view class="commodity-item" v-for="(item, i) in goodsList" :key="i">
+				<view class="commodity-item" v-for="(item, i) in goodsList" :key="i" @click="jumpDetails(item.id)">
 					<view class="commodity-item-image">
-						<image :src="item.imgurl" mode="widthFix"></image>
+						<image :src="item.imgurl || '/static/icon/default2.png'" mode="widthFix"></image>
 					</view>
 					<view class="commodity-item-box">
 						<view class="commodity-item-box-title">
@@ -86,13 +85,13 @@
 						</view>
 						<view class="commodity-item-shou">
 							<text>宸插敭{{item.saleNum + item.realSaleNum}}</text>
-							<view class="commodity-item-shou-add">+</view>
+							<view class="commodity-item-shou-add" @click.stop="addCard(item)">+</view>
 						</view>
 					</view>
 				</view>
 			</view>
 		</view>
-		<view class="dingwei" v-if="!position">
+		<view class="dingwei" v-if="isShow">
 			<view class="dingwei-left">
 				<text>鏈巿鏉冨畾浣�</text>
 				<text>鎴戜滑鏃犳硶鑾峰緱鎮ㄥ綋鍓嶄綅缃俊鎭负鎮ㄦ帹鑽愰檮杩戠粡閿�鍟�</text>
@@ -114,7 +113,7 @@
 			Login
 		},
 		computed: {
-			...mapState(['navHeight', 'statusbarHeight', 'position'])
+			...mapState(['navHeight', 'statusbarHeight', 'position', 'userInfo'])
 		},
 		data() {
 			return {
@@ -130,14 +129,15 @@
 				specialZone: [],
 				goodsList: [],
 				page: 1,
-				next: true
+				next: true,
+				isShow: false
 			}
 		},
 		async onLoad() {
 			await this.$onLaunched;
-			// this.$nextTick(() => {
-			// 	this.$refs.loginRef.open()
-			// })
+			if (!this.position) {
+				this.isShow = true
+			}
 			this.getBanner()
 			this.getLabels()
 			this.getGoodsList()
@@ -146,6 +146,31 @@
 			this.getGoodsList()
 		},
 		methods: {
+			toZhuanqu() {
+				uni.navigateTo({
+					url: '/pages/zhuanqu/zhuanqu'
+				})
+			},
+			addCard(e) {
+				if (!this.userInfo) {
+					this.$refs.loginRef.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' })
+					}
+				})
+			},
+			jumpDetails(id) {
+				uni.navigateTo({
+					url: '/pages/details/details?id=' + id
+				})
+			},
 			jumpShopZ(item) {
 				uni.navigateTo({
 					url: '/pages/special-zone/special-zone?qualityId=' + item.id
@@ -177,7 +202,7 @@
 				this.$u.api.getGoodsLabelsByType({ type: 12 })
 					.then(res => {
 						if (res.code === 200) {
-							this.specialZone = res.data
+							this.specialZone = res.data.length > 0 ? res.data.slice(0, 3) : []
 						}
 					})
 			},
@@ -226,8 +251,12 @@
 						countInCurrentChunk = 0; // 閲嶇疆璁℃暟鍣�
 					}
 				}
-
-				return result;
+				
+				if (result[1].length === 0) {
+					return [result[0]]
+				} else {
+					return result;
+				}
 			},
 			goToAppSetting() {
 				var that = this;
@@ -247,30 +276,33 @@
 					highAccuracyExpireTime: 3000,
 					isHighAccuracy: true,
 					success: function(addr) {
+						
+					}
+				});
+			},
+			openLoacing() {
+				var that = this;
+				uni.chooseLocation({
+					success(res1) {
 						const locParam = {
-							latitude: addr.latitude,
-							longitude: addr.longitude
+							latitude: res1.latitude,
+							longitude: res1.longitude
 						};
 						const qqmapsdk = new QQMapWX({
-							key: '4PXBZ-JLBC7-LCLXG-P2SZX-C4HYE-LDBLQ'
+							key: 'HEIBZ-QJLLM-SZ36X-6ZBHI-S6Y2J-S6FND'
 						});
 						// 鑵捐鍦板浘閫嗗湴鐞嗙紪鐮�
 						qqmapsdk.reverseGeocoder({
 							locParam,
 							success: function(res) {
-								console.log(res, '==================鑾峰彇鍦板潃');
+								console.log(res,  '==================index鑾峰彇鍦板潃')
+								console.log(locParam)
+								that.$store.commit('setPosition', res.result)
 							},
 							fail: (err) => {
 								console.error('鑾峰彇浣嶇疆澶辫触===========', err);
 							}
 						});
-					}
-				});
-			},
-			openLoacing() {
-				uni.chooseLocation({
-					success(res) {
-						console.log(res)
 					}
 				})
 			},
@@ -278,6 +310,18 @@
 				uni.navigateTo({
 					url: '/pages/search/search'
 				})
+			},
+			jumpSearch1(row, type) {
+				console.log(row)
+				if (type === 1) {
+					uni.navigateTo({
+						url: '/pages/search/search?categoryId=' + row.id
+					})
+				} else {
+					uni.navigateTo({
+						url: '/pages/search/search?applicableBrandId=' + row.id
+					})
+				}
 			}
 		}
 	}
@@ -347,12 +391,6 @@
 
 			.head-bar {
 				width: 100%;
-				position: fixed;
-				padding: 0 30rpx;
-				box-sizing: border-box;
-				top: 0;
-				left: 0;
-				z-index: 999;
 				// background-color: #ffffff;
 
 				.head-bar-nav {
@@ -367,10 +405,14 @@
 					}
 
 					text {
+						max-width: 400rpx;
 						font-weight: 500;
 						font-size: 32rpx;
 						color: #111111;
 						margin-right: 8rpx;
+						white-space: nowrap;
+						overflow: hidden;
+						text-overflow: ellipsis;
 					}
 				}
 			}
@@ -463,6 +505,7 @@
 					.commodity-item-image {
 						width: 100%;
 						height: 336rpx;
+						overflow: hidden;
 						display: flex;
 						align-items: center;
 						justify-content: center;
@@ -586,14 +629,14 @@
 				}
 
 				.cate-item {
-					width: calc(100vw / 4 - 96rpx);
+					width: calc(100vw / 4 - 86rpx);
 					height: auto;
 					display: flex;
 					flex-direction: column;
 					align-items: center;
 					justify-content: center;
 					margin-bottom: 30rpx;
-					margin-right: 96rpx;
+					margin-right: 86rpx;
 
 					&:last-child {
 						margin-right: 0 !important;
@@ -614,6 +657,10 @@
 					}
 
 					text {
+						width: 100%;
+						white-space: nowrap;
+						overflow: hidden;
+						text-overflow: ellipsis;
 						font-weight: 400;
 						font-size: 26rpx;
 						color: #333333;

--
Gitblit v1.9.3