<template>
|
<view class="box">
|
<view class="head" :style="{ height: 'calc(' + (navHeight + statusbarHeight + 'px + 148rpx)') }">
|
<view :style="{ width: '100%', height: navHeight + statusbarHeight + 'px' }"></view>
|
<view class="head-bar" :style="{ height: navHeight + statusbarHeight + 'px' }">
|
<view :style="{ width: '100%', height: statusbarHeight + 'px' }"></view>
|
<view class="head-bar-nav" :style="{ height: navHeight + 'px' }">
|
<image src="/static/icon/nav_ic_bac@2x.png" mode="widthFix" @click="fanhui"></image>
|
<text>商品专区</text>
|
<image src="/static/icon/nav_ic_bac@2x.png" style="opacity: 0;" mode="widthFix"></image>
|
</view>
|
</view>
|
<view class="search">
|
<u-search placeholder="请输入商品名称搜索" height="36" searchIconColor="#999999" borderColor="#eeeeee"
|
bgColor="rgba(255,255,255,0.9)" :showAction="false" v-model="goodsName" @search="search" />
|
</view>
|
</view>
|
<view class="list">
|
<image class="list-notfund" src="/static/images/default_search@2x.png" mode="widthFix" v-if="goodsList.length === 0"></image>
|
<view class="commodity-item" v-for="(item, i) in goodsList" :key="i" v-else @click="jumpDetails(item)">
|
<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" @click.stop="addCard(item)">+</view>
|
</view>
|
</view>
|
</view>
|
</view>
|
<view class="cart">
|
<view class="cart-box" @click="jumpCard">
|
<image src="/static/icon/ic_cart@2x.png" mode="widthFix"></image>
|
<text>购物车</text>
|
<view class="cart-num" v-if="cardObj && cardObj.cartTypeNum > 0">{{cardObj.cartTypeNum}}</view>
|
</view>
|
</view>
|
</view>
|
</template>
|
|
<script>
|
import {
|
mapState
|
} from 'vuex'
|
export default {
|
computed: {
|
...mapState(['navHeight', 'statusbarHeight'])
|
},
|
data() {
|
return {
|
goodsName: '',
|
next: true,
|
page: 1,
|
goodsList: [],
|
qualityId: null,
|
cardObj: null
|
};
|
},
|
onLoad(options) {
|
this.qualityId = options.qualityId
|
this.getGoodsList()
|
this.cardNum()
|
},
|
onReachBottom() {
|
this.getGoodsList()
|
},
|
methods: {
|
jumpDetails(item) {
|
uni.navigateTo({
|
url: '/pages/details/details?id=' + item.id
|
})
|
},
|
addCard(e) {
|
this.$u.api.addCart({
|
goodsId: e.id,
|
goodsSkuId: e.skuResponsesList[0].id,
|
num: 1
|
}).then(res => {
|
if (res.code === 200) {
|
this.cardNum()
|
uni.showToast({ title: '添加成功', icon: 'none' })
|
}
|
})
|
},
|
jumpCard() {
|
uni.navigateTo({
|
url: '/pages/shopping-cart/shopping-cart'
|
})
|
},
|
cardNum() {
|
this.$u.api.myInfo({})
|
.then(res => {
|
if (res.code === 200) {
|
this.cardObj = res.data
|
}
|
})
|
},
|
fanhui() {
|
uni.navigateBack({ delta: 1 });
|
},
|
search() {
|
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,
|
qualityId: this.qualityId
|
}
|
}).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>
|
page {
|
background-color: #F9F9FB;
|
}
|
</style>
|
<style lang="scss" scoped>
|
.box {
|
width: 100%;
|
|
.cart {
|
position: fixed;
|
right: 30rpx;
|
bottom: 100rpx;
|
z-index: 999;
|
.cart-box {
|
width: 88rpx;
|
height: 88rpx;
|
border-radius: 50%;
|
display: flex;
|
flex-direction: column;
|
align-items: center;
|
justify-content: center;
|
background: rgba(255,255,255,0.96);
|
box-shadow: 0rpx 4rpx 12rpx 0rpx rgba(0,0,0,0.16);
|
position: relative;
|
image {
|
width: 35rpx;
|
height: 35rpx;
|
}
|
text {
|
font-weight: 400;
|
font-size: 20rpx;
|
color: #333333;
|
}
|
.cart-num {
|
position: absolute;
|
top: -15rpx;
|
right: -15rpx;
|
border-radius: 50%;
|
width: 40rpx;
|
height: 40rpx;
|
line-height: 40rpx;
|
font-weight: 400;
|
font-size: 22rpx;
|
color: #FFFFFF;
|
text-align: center;
|
background: #E4001D;
|
}
|
}
|
}
|
|
.head {
|
width: 100%;
|
height: 424rpx;
|
padding: 0 30rpx;
|
box-sizing: border-box;
|
background: linear-gradient(180deg, #C8F3FF 0%, #F8F9FB 100%);
|
position: sticky;
|
top: 0;
|
left: 0;
|
z-index: 9;
|
|
.head-bar {
|
width: 100%;
|
position: fixed;
|
padding: 0 30rpx;
|
box-sizing: border-box;
|
top: 0;
|
left: 0;
|
z-index: 999;
|
|
.head-bar-nav {
|
width: 100%;
|
display: flex;
|
align-items: center;
|
justify-content: space-between;
|
|
image {
|
width: 48rpx;
|
height: 48rpx;
|
}
|
|
text {
|
font-weight: 500;
|
font-size: 32rpx;
|
color: #111111;
|
}
|
}
|
}
|
|
.search {
|
width: 100%;
|
margin-top: 20rpx;
|
}
|
}
|
|
.list {
|
width: 100%;
|
padding: 0 30rpx 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: 300rpx auto;
|
}
|
|
.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>
|