You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
shop-app/components/UiGoodsGroup.vue

194 lines
4.6 KiB

3 years ago
<!--
* @Author: ch
3 years ago
* @Date: 2022-04-07 17:22:44
3 years ago
* @LastEditors: ch
* @LastEditTime: 2022-04-21 16:38:03
3 years ago
* @Description: file content
-->
3 years ago
3 years ago
<template>
3 years ago
<view class="goods">
<view class="goods--column">
<view class="goods-item" v-for="item in goodsLeftData" :key="item.id"
@click="$Router.push(`/goodsDetail?id=${item.id}`)">
<image class="goods-item--img" :src="item.mainPicture" mode="widthFix"></image>
<view class="goods-item--title"><text>{{item.name}}</text></view>
<view class="goods-item--pirce-box">
<UiMoney :money="item.startingPrice" prefix class="goods-item--pirce"/>
<!-- <view>
3 years ago
<text class="goods-item--pirce">{{item.startingPrice}}</text>
<text class="goods-item--original-pirce">50</text>
</view> -->
3 years ago
<!-- <view>
3 years ago
<image class="goods-item--icon" src='@/static/index/bz.png'></image>
3 years ago
</view> -->
3 years ago
</view>
3 years ago
<!-- <view class="goods-item--activity">
3 years ago
<text class="goods-item--activity-title">秒杀</text>
<text class="goods-item--activity-desc">正在抢购中</text>
3 years ago
</view> -->
3 years ago
</view>
</view>
3 years ago
<view class="goods--column">
<view class="goods-item" v-for="item in goodsRightData" :key="item.id"
@click="$Router.push(`/goodsDetail?id=${item.id}`)">
<image class="goods-item--img" :src="item.mainPicture" mode="widthFix"></image>
<view class="goods-item--title"><text>{{item.name}}</text></view>
<view class="goods-item--pirce-box">
<UiMoney :money="item.startingPrice" prefix class="goods-item--pirce"/>
<!-- <view>
3 years ago
<text class="goods-item--pirce">{{item.startingPrice}}</text>
<text class="goods-item--original-pirce">50</text>
</view> -->
3 years ago
<!-- <view>
3 years ago
<image class="goods-item--icon" src='@/static/index/bz.png'></image>
3 years ago
</view> -->
3 years ago
</view>
3 years ago
<!-- <view class="goods-item--activity">
3 years ago
<text class="goods-item--activity-title">秒杀</text>
<text class="goods-item--activity-desc">正在抢购中</text>
3 years ago
</view> -->
3 years ago
</view>
</view>
</view>
</template>
3 years ago
<script>
import UiMoney from './UiMoney.vue';
3 years ago
export default {
components: { UiMoney },
3 years ago
data(){
return {
// goodsLeftData : [],
// goodsRightData : [],
3 years ago
}
},
3 years ago
props: {
listData : {
type : Array,
defalut : []
}
3 years ago
},
computed:{
goodsLeftData (){
return this.listData.filter((item, index) => index % 2 === 0);
},
goodsRightData(){
return this.listData.filter((item, index) => index % 2 !== 0);
}
},
3 years ago
watch : {
lisatData (data){
console.log(data);
3 years ago
// const abs = this.goodsLeftData.length - this.goodsRightData.length;
3 years ago
const newLeftData = [];
const newRightData = [];
3 years ago
// if(abs < 1){
data.forEach((item, index) => {
3 years ago
if(index % 2 === 0){
newLeftData.push(item);
}else{
newRightData.push(item);
}
})
3 years ago
// }else{
// data.forEach((item, index) => {
// if(index % 2 !== 0){
// newLeftData.push(item);
// }else{
// newRightData.push(item);
// }
// })
// }
this.goodsLeftData = newLeftData; // this.goodsLeftData.concat(newLeftData);
this.goodsRightData = newRightData; //this.goodsRightData.concat(newRightData);
3 years ago
}
3 years ago
},
mounted(){
},
methods : {
3 years ago
}
}
</script>
3 years ago
<style lang="scss" scoped>
.goods{
padding: 0 30rpx;
display: flex;
justify-content: space-between;
flex-flow:wrap;
&--column{
width: 335rpx;
}
&-item{
width: 335rpx;
border-radius: 8rpx;
background: $color-grey0;
3 years ago
margin-bottom: 30rpx;
overflow: hidden;
padding-bottom: 20rpx;
&--img{
width: 100%;
}
&--title{
font-size: $font-size-base;
padding: 20rpx 20rpx 24rpx;
line-height: 36rpx;
font-weight: bold;
3 years ago
}
&--pirce-box{
padding:0 20rpx;
display: flex;
justify-content: space-between;
}
&--original-pirce{
color: $color-grey3;
3 years ago
font-size: 20rpx;
text-decoration: line-through;
margin-left: 15rpx;
}
&--icon{
width: 22rpx;
height: 24rpx;
}
&--activity{
height: 40rpx;
line-height: 40rpx;
margin:20rpx 20rpx 0;
background: $color-yellow0;
3 years ago
border-radius: 20rpx;
font-size: 22rpx;
color: $color-yellow4;
3 years ago
display: flex;
&-title{
height: 40rpx;
display: block;
border-radius: 20rpx;
padding: 0 14rpx;
background: $color-yellow4;
color: $color-grey0;
3 years ago
}
&-desc{
flex: 1 1 auto;
text-align: center;
}
}
}
}
/deep/ {
.goods-item--pirce{
text{
font-size: $font-size-lg;
line-height: 32rpx;
color: $color-yellow4;
font-weight: bold;
}
.ui-money--prefix{
font-size: $font-size-sm;
}
}
}
3 years ago
</style>