小程序产品页面优化,及添加忽略文件
This commit is contained in:
@@ -67,21 +67,6 @@ Component({
|
||||
this.triggerEvent('click', { goods: this.data.goods });
|
||||
},
|
||||
|
||||
clickThumbHandle() {
|
||||
this.triggerEvent('thumb', { goods: this.data.goods });
|
||||
},
|
||||
|
||||
addCartHandle(e) {
|
||||
const { id } = e.currentTarget;
|
||||
const { id: cardID } = e.currentTarget.dataset;
|
||||
this.triggerEvent('add-cart', {
|
||||
...e.detail,
|
||||
id,
|
||||
cardID,
|
||||
goods: this.data.goods,
|
||||
});
|
||||
},
|
||||
|
||||
genIndependentID(id) {
|
||||
let independentID;
|
||||
if (id) {
|
||||
|
||||
@@ -1,24 +1,25 @@
|
||||
<view id="{{independentID}}" class="goods-card" bind:tap="clickHandle" data-goods="{{ goods }}">
|
||||
<view
|
||||
id="{{independentID}}"
|
||||
class="goods-card"
|
||||
hover-class="goods-card--hover"
|
||||
hover-stay-time="80"
|
||||
bind:tap="clickHandle"
|
||||
data-goods="{{ goods }}"
|
||||
>
|
||||
<view class="goods-card__main">
|
||||
<view class="goods-card__thumb" bind:tap="clickThumbHandle">
|
||||
<view class="goods-card__thumb">
|
||||
<t-image wx:if="{{ !!goods.thumb }}" t-class="goods-card__img" src="{{ goods.thumb }}" mode="aspectFill" lazy-load />
|
||||
<view wx:else class="goods-card__img goods-card__img--empty" />
|
||||
</view>
|
||||
<view class="goods-card__body">
|
||||
<view class="goods-card__upper">
|
||||
<view wx:if="{{ goods.title }}" class="goods-card__title">
|
||||
{{ goods.title }}
|
||||
</view>
|
||||
<view wx:if="{{ goods.tags && !!goods.tags.length }}" class="goods-card__tags">
|
||||
<view wx:for="{{ goods.tags }}" wx:key="index" wx:for-item="tag" class="goods-card__tag" data-index="{{index}}">
|
||||
{{tag}}
|
||||
</view>
|
||||
</view>
|
||||
<view wx:if="{{ goods.title }}" class="goods-card__title">{{ goods.title }}</view>
|
||||
<view wx:if="{{ goods.tags && !!goods.tags.length }}" class="goods-card__tags">
|
||||
<view wx:for="{{ goods.tags }}" wx:key="index" wx:for-item="tag" class="goods-card__tag">{{ tag }}</view>
|
||||
</view>
|
||||
<view class="goods-card__down">
|
||||
<price wx:if="{{ goods.price }}" wr-class="spec-for-price" symbol-class="spec-for-symbol" symbol="{{currency}}" price="{{goods.price}}" />
|
||||
<price wx:if="{{ goods.originPrice && isValidityLinePrice }}" wr-class="goods-card__origin-price" symbol="{{currency}}" price="{{goods.originPrice}}" type="delthrough" />
|
||||
<t-icon class="goods-card__add-cart" prefix="wr" name="cart" id="{{independentID}}-cart" data-id="{{independentID}}" catchtap="addCartHandle" size="48rpx" color="#FA550F" />
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@@ -1,34 +1,40 @@
|
||||
.goods-card {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
box-sizing: border-box;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
font-size: 24rpx;
|
||||
border-radius: var(--radius-lg);
|
||||
border-bottom: none;
|
||||
background: var(--bg-card);
|
||||
border-radius: var(--radius-lg);
|
||||
box-shadow: var(--shadow-card);
|
||||
overflow: hidden;
|
||||
transition: transform 0.16s ease, box-shadow 0.16s ease;
|
||||
}
|
||||
|
||||
.goods-card--hover {
|
||||
transform: scale(0.98);
|
||||
box-shadow: 0 2rpx 8rpx rgba(29, 33, 41, 0.06);
|
||||
}
|
||||
|
||||
.goods-card__main {
|
||||
position: relative;
|
||||
display: flex;
|
||||
line-height: 1;
|
||||
padding: 0;
|
||||
background: var(--bg-card);
|
||||
width: 342rpx;
|
||||
border-radius: var(--radius-lg);
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
margin-bottom: 20rpx;
|
||||
flex: 1 1 auto;
|
||||
flex-direction: column;
|
||||
box-shadow: var(--shadow-card);
|
||||
width: 100%;
|
||||
background: var(--bg-card);
|
||||
border-radius: var(--radius-lg);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.goods-card__thumb {
|
||||
flex-shrink: 0;
|
||||
position: relative;
|
||||
width: 340rpx;
|
||||
flex-shrink: 0;
|
||||
width: 100%;
|
||||
height: 340rpx;
|
||||
background: var(--bg-grey);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.goods-card__thumb:empty {
|
||||
@@ -40,98 +46,88 @@
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
border-radius: var(--radius-lg) var(--radius-lg) 0 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.goods-card__img--empty {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.goods-card__body {
|
||||
display: flex;
|
||||
flex: 1 1 auto;
|
||||
background: var(--bg-card);
|
||||
border-radius: 0 0 var(--radius-lg) var(--radius-lg);
|
||||
flex-direction: column;
|
||||
padding: 20rpx 24rpx 24rpx;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.goods-card__upper {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
flex: 1 1 auto;
|
||||
background: var(--bg-card);
|
||||
}
|
||||
|
||||
.goods-card__title {
|
||||
flex-shrink: 0;
|
||||
font-size: 28rpx;
|
||||
color: var(--text-primary);
|
||||
font-weight: 500;
|
||||
display: -webkit-box;
|
||||
height: 72rpx;
|
||||
height: 80rpx;
|
||||
-webkit-box-orient: vertical;
|
||||
-webkit-line-clamp: 2;
|
||||
overflow: hidden;
|
||||
font-size: 28rpx;
|
||||
font-weight: 500;
|
||||
line-height: 40rpx;
|
||||
color: var(--text-primary);
|
||||
word-break: break-word;
|
||||
line-height: 36rpx;
|
||||
}
|
||||
|
||||
.goods-card__tags {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
flex-wrap: wrap;
|
||||
margin: 8rpx 0 0 0;
|
||||
flex-wrap: nowrap;
|
||||
margin: 10rpx 0 0 0;
|
||||
overflow: hidden;
|
||||
height: 36rpx;
|
||||
}
|
||||
|
||||
.goods-card__tag {
|
||||
color: var(--brand);
|
||||
background: var(--brand-light);
|
||||
font-size: 20rpx;
|
||||
border: none;
|
||||
padding: 2rpx 12rpx;
|
||||
border-radius: var(--radius-round);
|
||||
line-height: 30rpx;
|
||||
margin: 0 8rpx 8rpx 0;
|
||||
display: block;
|
||||
max-width: 200rpx;
|
||||
margin: 0 8rpx 0 0;
|
||||
padding: 2rpx 12rpx;
|
||||
overflow: hidden;
|
||||
font-size: 20rpx;
|
||||
line-height: 30rpx;
|
||||
color: var(--brand);
|
||||
white-space: nowrap;
|
||||
word-break: keep-all;
|
||||
text-overflow: ellipsis;
|
||||
background: var(--brand-light);
|
||||
border-radius: var(--radius-round);
|
||||
}
|
||||
|
||||
.goods-card__down {
|
||||
display: flex;
|
||||
position: relative;
|
||||
flex-direction: row;
|
||||
justify-content: flex-start;
|
||||
align-items: baseline;
|
||||
line-height: 32rpx;
|
||||
margin: 8rpx 0 0 0;
|
||||
justify-content: flex-start;
|
||||
margin: auto 0 0 0;
|
||||
padding-top: 10rpx;
|
||||
line-height: 44rpx;
|
||||
}
|
||||
|
||||
.goods-card__origin-price {
|
||||
white-space: nowrap;
|
||||
font-weight: 400;
|
||||
order: 2;
|
||||
margin: 0 0 0 12rpx;
|
||||
font-size: 22rpx;
|
||||
font-weight: 400;
|
||||
color: var(--text-placeholder);
|
||||
font-size: 24rpx;
|
||||
margin: 0 0 0 8rpx;
|
||||
text-decoration: line-through;
|
||||
}
|
||||
|
||||
.goods-card__add-cart {
|
||||
order: 3;
|
||||
margin: auto 0 0 auto;
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
right: 0;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.spec-for-price {
|
||||
font-size: 36rpx;
|
||||
white-space: nowrap;
|
||||
font-weight: 700;
|
||||
order: 1;
|
||||
color: var(--brand);
|
||||
margin: 0;
|
||||
font-size: 38rpx;
|
||||
font-weight: 700;
|
||||
color: var(--brand);
|
||||
white-space: nowrap;
|
||||
font-family: 'DIN Alternate', -apple-system, sans-serif;
|
||||
}
|
||||
|
||||
|
||||
@@ -35,16 +35,6 @@ Component({
|
||||
this.triggerEvent('click', { ...e.detail, index });
|
||||
},
|
||||
|
||||
onAddCart(e) {
|
||||
const { index } = e.currentTarget.dataset;
|
||||
this.triggerEvent('addcart', { ...e.detail, index });
|
||||
},
|
||||
|
||||
onClickGoodsThumb(e) {
|
||||
const { index } = e.currentTarget.dataset;
|
||||
this.triggerEvent('thumb', { ...e.detail, index });
|
||||
},
|
||||
|
||||
init() {
|
||||
this.genIndependentID(this.id || '');
|
||||
},
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<view class="goods-list-wrap wr-class" id="{{independentID}}">
|
||||
<block wx:for="{{goodsList}}" wx:for-item="item" wx:key="index">
|
||||
<goods-card id="{{independentID}}-gd-{{index}}" data="{{item}}" currency="{{item.currency || '¥'}}" thresholds="{{thresholds}}" class="goods-card-inside" data-index="{{index}}" bind:thumb="onClickGoodsThumb" bind:click="onClickGoods" bind:add-cart="onAddCart" />
|
||||
<goods-card id="{{independentID}}-gd-{{index}}" data="{{item}}" currency="{{item.currency || '¥'}}" thresholds="{{thresholds}}" class="goods-card-inside" data-index="{{index}}" bind:click="onClickGoods" />
|
||||
</block>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@@ -1,7 +1,14 @@
|
||||
.goods-list-wrap {
|
||||
display: flex;
|
||||
flex-flow: row wrap;
|
||||
align-content: flex-start;
|
||||
justify-content: space-between;
|
||||
padding: 0;
|
||||
background: #fff;
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
.goods-list-wrap goods-card {
|
||||
display: block;
|
||||
width: calc(50% - 10rpx);
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user