feat: 支持商品列表样式切换
This commit is contained in:
@@ -64,7 +64,7 @@
|
|||||||
<view class="category-title" style="font-size: 28rpx;padding-bottom: 0;">{{ category.category_name }}</view>
|
<view class="category-title" style="font-size: 28rpx;padding-bottom: 0;">{{ category.category_name }}</view>
|
||||||
|
|
||||||
<!--一级-->
|
<!--一级-->
|
||||||
<view class="goods-list double-column show" :data-template="value.template">
|
<view class="goods-list" :class="{ 'double-column': !isList, 'single-column': isList, 'show': true }" :data-template="value.template">
|
||||||
<block v-if="goodsList.length">
|
<block v-if="goodsList.length">
|
||||||
<view class="goods-item" v-for="(item, index) in goodsList" :key="index" >
|
<view class="goods-item" v-for="(item, index) in goodsList" :key="index" >
|
||||||
<view class="goods-img" @click="toDetail(item)">
|
<view class="goods-img" @click="toDetail(item)">
|
||||||
@@ -150,7 +150,7 @@
|
|||||||
</view>
|
</view>
|
||||||
|
|
||||||
<block v-if="loadType == 'all' && goodsList.length">
|
<block v-if="loadType == 'all' && goodsList.length">
|
||||||
<view class="goods-list" :data-template="value.template">
|
<view class="goods-list" :class="{ 'double-column': !isList, 'single-column': isList }" :data-template="value.template">
|
||||||
<view class="goods-item" v-for="(item, index) in goodsList" :key="index">
|
<view class="goods-item" v-for="(item, index) in goodsList" :key="index">
|
||||||
<view class="goods-img" @click="toDetail(item)">
|
<view class="goods-img" @click="toDetail(item)">
|
||||||
<image :src="goodsImg(item.goods_image)" mode="widthFix" @error="imgError(index)" :lazy-load="true"/>
|
<image :src="goodsImg(item.goods_image)" mode="widthFix" @error="imgError(index)" :lazy-load="true"/>
|
||||||
@@ -253,6 +253,10 @@
|
|||||||
last: {
|
last: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false
|
default: false
|
||||||
|
},
|
||||||
|
isList: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
@@ -807,14 +811,10 @@
|
|||||||
.goods-item {
|
.goods-item {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
width: calc(50% - 10rpx);
|
|
||||||
border-radius: $border-radius;
|
border-radius: $border-radius;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
background-color: #fff;
|
background-color: #fff;
|
||||||
margin-bottom: 20rpx;
|
margin-bottom: 20rpx;
|
||||||
&:nth-child(2n + 2) {
|
|
||||||
margin-right: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.goods-img {
|
.goods-img {
|
||||||
position: relative;
|
position: relative;
|
||||||
@@ -948,6 +948,44 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* 双列布局 */
|
||||||
|
&.double-column {
|
||||||
|
.goods-item {
|
||||||
|
width: calc(50% - 10rpx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 单列布局 */
|
||||||
|
&.single-column {
|
||||||
|
flex-direction: column;
|
||||||
|
.goods-item {
|
||||||
|
width: 100%;
|
||||||
|
flex-direction: row;
|
||||||
|
align-items: center;
|
||||||
|
|
||||||
|
.goods-img {
|
||||||
|
width: 180rpx;
|
||||||
|
height: 180rpx;
|
||||||
|
padding-top: 0;
|
||||||
|
margin-right: 14rpx;
|
||||||
|
border-radius: $border-radius;
|
||||||
|
|
||||||
|
image {
|
||||||
|
border-radius: $border-radius;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.goods-name {
|
||||||
|
white-space: normal;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
display: -webkit-box;
|
||||||
|
-webkit-line-clamp: 2;
|
||||||
|
-webkit-box-orient: vertical;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
/**/
|
/**/
|
||||||
/*.goods-item {
|
/*.goods-item {
|
||||||
padding: 0 0 26rpx 0;
|
padding: 0 0 26rpx 0;
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
<input type="text" class="uni-input" maxlength="50" :placeholder="$lang('search')" confirm-type="search" disabled="true" />
|
<input type="text" class="uni-input" maxlength="50" :placeholder="$lang('search')" confirm-type="search" disabled="true" />
|
||||||
<text class="iconfont icon-sousuo3"></text>
|
<text class="iconfont icon-sousuo3"></text>
|
||||||
</view>
|
</view>
|
||||||
|
<view class="iconfont" :class="{ 'icon-apps': !isList, 'icon-list': isList }" @click="changeListStyle()"></view>
|
||||||
</view>
|
</view>
|
||||||
</block>
|
</block>
|
||||||
<!-- #endif -->
|
<!-- #endif -->
|
||||||
@@ -27,6 +28,7 @@
|
|||||||
<input type="text" class="uni-input" maxlength="50" :placeholder="$lang('search')" confirm-type="search" disabled="true" />
|
<input type="text" class="uni-input" maxlength="50" :placeholder="$lang('search')" confirm-type="search" disabled="true" />
|
||||||
<text class="iconfont icon-sousuo3"></text>
|
<text class="iconfont icon-sousuo3"></text>
|
||||||
</view>
|
</view>
|
||||||
|
<view class="iconfont" :class="{ 'icon-apps': !isList, 'icon-list': isList }" @click="changeListStyle()"></view>
|
||||||
</view>
|
</view>
|
||||||
<!-- #endif -->
|
<!-- #endif -->
|
||||||
<view class="template-four wx" v-if="value.template == 4">
|
<view class="template-four wx" v-if="value.template == 4">
|
||||||
@@ -84,7 +86,7 @@
|
|||||||
@refresherrestore="onRestore">
|
@refresherrestore="onRestore">
|
||||||
<view class="child-category" v-for="(item, index) in categoryTree" :key="index" :id="'category-' + index">
|
<view class="child-category" v-for="(item, index) in categoryTree" :key="index" :id="'category-' + index">
|
||||||
<diy-category-item :category="item" :value="value" ref="categoryItem" :index="index"
|
<diy-category-item :category="item" :value="value" ref="categoryItem" :index="index"
|
||||||
:select="select" :oneCategorySelect="oneCategorySelect" @tologin="toLogin"
|
:select="select" :oneCategorySelect="oneCategorySelect" :isList="isList" @tologin="toLogin"
|
||||||
@selectsku="selectSku($event, index)" @addCart="addCartPoint"
|
@selectsku="selectSku($event, index)" @addCart="addCartPoint"
|
||||||
@loadfinish="getHeightArea"></diy-category-item>
|
@loadfinish="getHeightArea"></diy-category-item>
|
||||||
</view>
|
</view>
|
||||||
@@ -97,7 +99,7 @@
|
|||||||
:id="'category-' + index" :style="{ display: select == index ? 'block' : 'none' }">
|
:id="'category-' + index" :style="{ display: select == index ? 'block' : 'none' }">
|
||||||
<diy-category-item :category="item" :value="value" ref="categoryItem" :index="index"
|
<diy-category-item :category="item" :value="value" ref="categoryItem" :index="index"
|
||||||
:last="index == categoryTree.length - 1 ? true : false" :select="select"
|
:last="index == categoryTree.length - 1 ? true : false" :select="select"
|
||||||
:oneCategorySelect="oneCategorySelect" @tologin="toLogin"
|
:oneCategorySelect="oneCategorySelect" :isList="isList" @tologin="toLogin"
|
||||||
@selectsku="selectSku($event, index)" @addCart="addCartPoint"
|
@selectsku="selectSku($event, index)" @addCart="addCartPoint"
|
||||||
@switch="switchOneCategory"></diy-category-item>
|
@switch="switchOneCategory"></diy-category-item>
|
||||||
</view>
|
</view>
|
||||||
@@ -176,6 +178,7 @@
|
|||||||
cartAnimation: {},
|
cartAnimation: {},
|
||||||
loadType: '',
|
loadType: '',
|
||||||
templateFourData: [],
|
templateFourData: [],
|
||||||
|
isList: false,
|
||||||
lang:uni.getStorageSync("lang")//en-us 英文
|
lang:uni.getStorageSync("lang")//en-us 英文
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
@@ -521,7 +524,10 @@
|
|||||||
// 操作多规格商品弹框后,刷新商品数据
|
// 操作多规格商品弹框后,刷新商品数据
|
||||||
refreshData() {
|
refreshData() {
|
||||||
this.$refs.categoryItem[this.select].loadGoodsCartNum(true);
|
this.$refs.categoryItem[this.select].loadGoodsCartNum(true);
|
||||||
}
|
},
|
||||||
|
changeListStyle() {
|
||||||
|
this.isList = !this.isList;
|
||||||
|
},
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
@@ -662,6 +668,12 @@
|
|||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 切换列表图标
|
||||||
|
.iconfont {
|
||||||
|
font-size: 36rpx;
|
||||||
|
margin: 0 0rpx 0 20rpx;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.cart-box {
|
.cart-box {
|
||||||
|
|||||||
Reference in New Issue
Block a user