Commit 8284d2f9 authored by 肖健's avatar 肖健

首页商品轮播

parent 7c1670d7
......@@ -18,9 +18,9 @@
</view>
<view class="banner">
<view :class="indexCommodityList.length == 2 ? 'banner-bg' : 'banner-bg banner-bg-1'" v-if="indexCommodityList && indexCommodityList.length <= 2">
<view :class="indexCommodityList.length == 1 ? 'banner-bg' : 'banner-bg banner-bg-1'" v-if="indexCommodityList && indexCommodityList.length == 1">
<image src="http://jdnc-oss.uzosp.com/2022/12/28/b1679b5da1b84fa1827039fe4fadd91c.png"></image>
<view class="item" style="margin-right: 15rpx;" @click="goJdShop(item)" v-for="(item, i) in indexCommodityList" :key="i">
<view class="item" style="margin-right: 15rpx;" @click="goJdShop(item)" v-for="(item, i) in indexCommodityList[0]" :key="i">
<image :src="item.mainImgUrl"></image>
<view class="banner-btn-bg">
<view class="banner-btn">
......@@ -31,19 +31,25 @@
</view>
</view>
<view v-else>
<view scroll-x="true" class="banner-bg">
<view class="banner-bg">
<image src="http://jdnc-oss.uzosp.com/2022/12/28/b1679b5da1b84fa1827039fe4fadd91c.png"></image>
<scroll-view :scroll-x="true" :enable-flex="true" :show-scrollbar="false" :scroll-with-animation="true" style="width:100%;white-space: nowrap;">
<view class="item" style="display: inline-flex;margin-right: 15rpx;" @click="goJdShop(item)" v-for="(item, i) in indexCommodityList" :key="i">
<image :src="item.mainImgUrl"></image>
<view class="banner-btn-bg">
<view class="banner-btn">
<image src="../static/index/ban-btn.png"></image>
<text>立即购买</text>
</view>
</view>
</view>
</scroll-view>
<swiper :indicator-dots="true" :autoplay="true" indicator-color ="rgba(255, 255, 255, 0.35)" indicator-active-color="#FEE83A" style="height: 430rpx;width:100%">
<swiper-item v-for="(item, i) in indexCommodityList" :key="i">
<u-grid align="left" :col="2">
<u-grid-item v-for="(t, tj) in indexCommodityList[i]" :key="tj" @click="goJdShop(t)">
<view class="item" style="display: inline-flex;">
<image :src="t.mainImgUrl"></image>
<view class="banner-btn-bg">
<view class="banner-btn">
<image src="../static/index/ban-btn.png"></image>
<text>立即购买</text>
</view>
</view>
</view>
</u-grid-item>
</u-grid>
</swiper-item>
</swiper>
</view>
</view>
......@@ -333,6 +339,19 @@
}).then(res => {
if(res && res.length > 0) {
this.indexCommodityList = res
let resultArr = []
let indexSize = Math.ceil(res / 2)
let startIdx = 0
res.forEach(function (value, index) {
if(index % 2 == 0) {
resultArr[startIdx] = []
resultArr[startIdx].push(value)
} else {
resultArr[startIdx].push(value)
startIdx++
}
});
this.indexCommodityList = resultArr
} else {
this.indexCommodityList = []
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment