<template>
|
<view class="box">
|
<view class="search">
|
<u-search placeholder="请输入商品名称搜索" height="36" searchIconColor="#999999" borderColor="#EEEEEE"
|
bgColor="#F9F9FB" :showAction="false" v-model="goodsName" @search="search" />
|
</view>
|
<view class="history">
|
<view class="history-title">历史搜索</view>
|
<view class="history-list">
|
<view class="history-list-item">支重轮</view>
|
</view>
|
</view>
|
<template v-if="isSearch">
|
<view class="list">
|
<image class="list-notfund" v-if="goodsList.length === 0" src="/static/images/default_search@2x.png" mode="widthFix"></image>
|
<view class="commodity-item" v-for="(item, i) in goodsList" :key="i" v-else>
|
<view class="commodity-item-image">
|
<image :src="item.imgurl" mode="widthFix"></image>
|
</view>
|
<view class="commodity-item-box">
|
<view class="commodity-item-box-title">
|
{{item.name}}
|
</view>
|
<view class="commodity-item-box-price">
|
<view class="commodity-item-box-price-a">
|
<text>{{item.minPrice[0]}}</text>
|
<text>.{{item.minPrice[1]}}</text>
|
</view>
|
<view class="commodity-item-box-price-b">
|
¥{{item.price}}
|
</view>
|
</view>
|
<view class="commodity-item-shou">
|
<text>已售{{item.saleNum + item.realSaleNum}}</text>
|
<view class="commodity-item-shou-add">+</view>
|
</view>
|
</view>
|
</view>
|
</view>
|
</template>
|
</view>
|
</template>
|
|
<script>
|
export default {
|
data() {
|
return {
|
goodsName: '',
|
goodsList: [],
|
page: 1,
|
next: true,
|
isSearch: false
|
};
|
},
|
onReachBottom() {
|
this.getGoodsList()
|
},
|
methods: {
|
search() {
|
if (!this.isSearch) {
|
this.isSearch = true
|
}
|
this.next = true
|
this.page = 1
|
this.goodsList = []
|
this.getGoodsList()
|
},
|
getGoodsList() {
|
if (!this.next) return;
|
this.$u.api.goodsPage({
|
capacity: 10,
|
page: this.page,
|
model: {
|
type: 0,
|
sortInfo: 3,
|
goodsName: this.goodsName
|
}
|
}).then(res => {
|
if (res.code === 200) {
|
res.data.records.forEach(item => {
|
item.minPrice = item.minPrice.toFixed(2).split('.')
|
})
|
this.goodsList.push(...res.data.records)
|
this.page++
|
if (this.goodsList.length === res.data.total) {
|
this.next = false
|
}
|
}
|
})
|
},
|
}
|
}
|
</script>
|
|
<style lang="scss" scoped>
|
.box {
|
width: 100%;
|
.search {
|
width: 100%;
|
padding: 30rpx;
|
box-sizing: border-box;
|
background-color: #ffffff;
|
position: sticky;
|
top: 0;
|
left: 0;
|
z-index: 999;
|
margin-bottom: 14rpx;
|
}
|
.history {
|
width: 100%;
|
padding: 0 30rpx;
|
box-sizing: border-box;
|
.history-title {
|
font-weight: 500;
|
font-size: 30rpx;
|
color: #111111;
|
}
|
.history-list {
|
width: 100%;
|
margin-top: 26rpx;
|
display: flex;
|
align-items: center;
|
flex-wrap: wrap;
|
.history-list-item {
|
padding: 0 28rpx;
|
height: 66rpx;
|
line-height: 66rpx;
|
background: #F7F7F7;
|
border-radius: 34rpx;
|
font-weight: 400;
|
font-size: 26rpx;
|
color: #111111;
|
margin-right: 24rpx;
|
margin-bottom: 24rpx;
|
&:last-child {
|
margin: 0 !important;
|
}
|
}
|
}
|
}
|
.list {
|
width: 100%;
|
padding: 20rpx 30rpx;
|
box-sizing: border-box;
|
display: flex;
|
align-items: center;
|
justify-content: space-between;
|
flex-wrap: wrap;
|
|
.list-notfund {
|
width: 320rpx;
|
height: 320rpx;
|
margin: 0 auto;
|
margin-top: 240rpx;
|
}
|
|
.commodity-item {
|
width: 332rpx;
|
background-color: #ffffff;
|
margin-bottom: 20rpx;
|
.commodity-item-image {
|
width: 100%;
|
height: 336rpx;
|
display: flex;
|
align-items: center;
|
justify-content: center;
|
image {
|
width: 100%;
|
}
|
}
|
.commodity-item-box {
|
width: 100%;
|
padding: 20rpx;
|
box-sizing: border-box;
|
.commodity-item-box-title {
|
font-weight: 600;
|
font-size: 30rpx;
|
color: #222222;
|
}
|
.commodity-item-box-price {
|
width: 100%;
|
display: flex;
|
align-items: baseline;
|
margin-top: 8rpx;
|
.commodity-item-box-price-a {
|
display: flex;
|
align-items: baseline;
|
margin-right: 8rpx;
|
text {
|
&:nth-child(1) {
|
font-weight: bold;
|
font-size: 32rpx;
|
color: #E4001D;
|
&::before {
|
content: '¥';
|
font-weight: 400;
|
font-size: 24rpx;
|
color: #E4001D;
|
}
|
}
|
&:nth-child(2) {
|
font-weight: 400;
|
font-size: 24rpx;
|
color: #E4001D;
|
}
|
}
|
}
|
.commodity-item-box-price-b {
|
font-weight: 400;
|
font-size: 22rpx;
|
color: #999999;
|
}
|
}
|
.commodity-item-shou {
|
width: 100%;
|
display: flex;
|
align-items: center;
|
justify-content: space-between;
|
text {
|
font-weight: 400;
|
font-size: 24rpx;
|
color: #999999;
|
}
|
.commodity-item-shou-add {
|
width: 44rpx;
|
height: 44rpx;
|
background: #004096;
|
border-radius: 50%;
|
line-height: 44rpx;
|
text-align: center;
|
font-size: 30rpx;
|
color: #fff;
|
}
|
}
|
}
|
}
|
}
|
}
|
</style>
|