Explorar el Código

Signed-off-by: 李妹妹 <1639016684@qq.com>

李妹妹 hace 1 mes
padre
commit
358f181765

+ 1 - 1
manifest.json

@@ -52,7 +52,7 @@
     "quickapp" : {},
     /* 小程序特有相关 */
     "mp-weixin" : {
-        "appid" : "wxec95e303998c5515",
+        "appid" : "wxcfd4cd6e2375e42f",
         "setting" : {
             "urlCheck" : false
         },

+ 3 - 3
pages/home/components/GoodsCard.vue

@@ -1,13 +1,13 @@
 <template>
 	<view class="goods-card" @click="showProduct(item)">
 		<view class="img-wrap">
-			<image class="img" :src="item.image || item.imageUrl || defaultImg" mode="aspectFill"></image>
+			<image class="img" :src="item.image" mode="aspectFill"></image>
 			<view class="tag-row" v-if="tagList && tagList.length > 0">
 				<text class="tag-chip" v-for="(t, i) in tagList" :key="i">{{ t }}</text>
 			</view>
 		</view>
 		<view class="info">
-			<view class="title line2">{{ item.productName || item.title || item.name }}</view>
+			<view class="title line2">{{ item.productName }}</view>
 			<view class="x-bc">
 				<view class="price-row">
 					<text class="unit"v-if="showPrice">¥</text>
@@ -16,7 +16,7 @@
 				</view>
 				<view class="meta-row" v-if="item.sales != null || item.positiveRating != null">
 					<text class="sales" v-if="item.sales != null">已售{{ item.sales }}</text>
-					<text>I</text>
+					<text v-if="item.positiveRating">I</text>
 					<text class="good-rate" v-if="item.positiveRating != null">好评{{ item.positiveRating }}%</text>
 				</view>
 			</view>

+ 1 - 1
pages/home/components/GoodsList.vue

@@ -1,7 +1,7 @@
 <template>
 	<view class="goods-list">
 		<view class="list-column" v-if="list && list.length > 0">
-			<view class="list-item" v-for="(item, index) in list" :key="item.productId || index">
+			<view class="list-item" v-for="(item, index) in list" :key="item.productId">
 				<GoodsCard :item="item" :show-price="showPrice" @click="$emit('itemClick', item)" />
 			</view>
 		</view>

+ 18 - 10
pages/home/components/RecommendSection.vue

@@ -45,15 +45,15 @@
 				<view class="block-small">
 					<view class="block-small-head">
 						<image class="w140" src="@/static/images/new.png" mode="widthFix"></image>
-						<view class="more" @click.stop="goMore('green')">
+						<view class="more" @click.stop="goMore('hot')">
 							<text class="green">更多</text>
 							<u-icon name="play-right-fill" color="#FF5B25" size="24rpx"></u-icon>
 						</view>
 					</view>
 					<view class="block-small-body">
-						<view class="small-item" v-for="(item, i) in (green || []).slice(0, 2)" :key="'g' + i"
-							@click.stop="onItemClick(item, 'green')">
-							<image class="small-thumb" :src="item.image || item.imageUrl" mode="aspectFill"></image>
+						<view class="small-item" v-for="(item, i) in hot.slice(0, 2)" :key="i"
+							@click.stop="onItemClick(item, 'hot')">
+							<image class="small-thumb" :src="getFirstImage(item)" mode="aspectFill"></image>
 							<view>
 								<text class="unit">¥</text>
 								<text class="small-price" v-if="item.price != null">{{ Number(item.price).toFixed(2)
@@ -65,15 +65,15 @@
 				<view class="block-small">
 					<view class="block-small-head">
 						<image class="w140" src="@/static/images/hot.png" mode="widthFix"></image>
-						<view class="more" @click.stop="goMore('hot')">
+						<view class="more" @click.stop="goMore('green')">
 							<text class="hot">更多</text>
 							<u-icon name="play-right-fill" color="#FF485D" size="24rpx"></u-icon>
 						</view>
 					</view>
 					<view class="block-small-body">
-						<view class="small-item" v-for="(item, i) in (hot || []).slice(0, 2)" :key="'h' + i"
-							@click.stop="onItemClick(item, 'hot')">
-							<image class="small-thumb" :src="item.image || item.imageUrl" mode="aspectFill"></image>
+						<view class="small-item" v-for="(item, e) in green.slice(0, 2)" :key="e"
+							@click.stop="onItemClick(item, 'green')">
+							<image class="small-thumb" :src="getFirstImage(item)" mode="aspectFill"></image>
 							<view>
 								<text class="unit">¥</text>
 								<text class="small-price" v-if="item.price != null">{{ Number(item.price).toFixed(2)
@@ -139,7 +139,15 @@ export default {
 		},
 		onItemClick(item, type) {
 			//this.$emit('itemClick', { item, section: { type } })
-			this.$emit('itemClick', item)
+			this.$emit('itemClick', item,type)
+		},
+		// 取 sliderImage 逗号拼接的第一张图,没有则用 image
+		getFirstImage(item) {
+			if (!item) return ''
+			const str = item.sliderImage || item.image || ''
+			if (typeof str !== 'string') return item.image || ''
+			const first = str.split(',')[0]
+			return (first && first.trim()) || item.image || ''
 		}
 	}
 }
@@ -243,7 +251,7 @@ export default {
 	background: rgba(0, 0, 0, 0.45);
 	color: #fff;
 	font-size: 26rpx;
-	padding: 16rpx 16rpx 50rpx;
+	padding: 16rpx;
 }
 .block-tit {
 	display: flex;

+ 6 - 5
pages/home/newindex.vue

@@ -290,8 +290,8 @@ export default {
 			//console.log(item)
 			if (item && item.liveId) uni.navigateTo({ url: '/pages_course/living?liveId=' + item.liveId })
 		},
-		onRecommendItemClick(item) {
-			if (item.productId) this.showProduct(item)
+		onRecommendItemClick(item,type) {
+			if (item.productId) this.showProduct(item,type)
 		},
 		getMenu() {
 			getMenu().then(res => {
@@ -386,9 +386,10 @@ export default {
 			//uni.navigateTo({ url: './productSearch' })
 			uni.navigateTo({ url: '../home/productList' })
 		},
-		showProduct(item) {
-			console.log('item',item)
-			uni.navigateTo({ url: '../shopping/productDetails?productId=' + item.productId })
+		showProduct(item,type) {
+			//console.log('item',type)
+			//uni.navigateTo({ url: '../shopping/productDetails?productId=' + item.productId })
+			uni.navigateTo({ url: '/pages/home/recommendList?type='+type})
 		}
 	}
 }

+ 2 - 2
pages/home/recommendList.vue

@@ -77,8 +77,8 @@ export default {
 	mixins: [MescrollMixin],
 	data() {
 		return {
-			type: 'green',
-			titleMap: { green: '热卖有机', hot: '上新推荐' },
+			type: 'hot',
+			titleMap: { hot: '热卖有机', green: '上新推荐' },
 			mescroll: null,
 			keyword:'',
 			downOption: {},