2021-05-13 11:03:32 +08:00
|
|
|
|
<template>
|
2021-08-09 18:40:06 +08:00
|
|
|
|
<div>
|
|
|
|
|
<u-navbar :title="title"></u-navbar>
|
|
|
|
|
<!-- 商品 -->
|
|
|
|
|
<div class="contant">
|
|
|
|
|
<view v-if="!goodsList.length" class="empty">暂无商品信息</view>
|
|
|
|
|
<view v-else class="item" v-for="(item,index) in goodsList" :key="index" @click="navigateToGoodsDetail(item)">
|
|
|
|
|
<u-image width="100%" height="324rpx" :src="item.thumbnail">
|
|
|
|
|
<u-loading slot="loading"></u-loading>
|
|
|
|
|
</u-image>
|
|
|
|
|
<div class="name">{{ item.goodsName }}</div>
|
|
|
|
|
<div class="price">
|
|
|
|
|
<div>¥{{ item.price | unitPrice }}</div>
|
|
|
|
|
</div>
|
|
|
|
|
<view class="buyCount">
|
|
|
|
|
<div>已售 {{ item.buyCount || "0" }}</div>
|
2021-05-13 11:03:32 +08:00
|
|
|
|
</view>
|
|
|
|
|
</view>
|
2021-08-09 18:40:06 +08:00
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2021-05-13 11:03:32 +08:00
|
|
|
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
import { getGoodsList } from "@/api/goods.js";
|
|
|
|
|
export default {
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
2021-08-09 18:40:06 +08:00
|
|
|
|
title: "",
|
|
|
|
|
routerVal: "",
|
|
|
|
|
goodsList: [],
|
2021-05-13 11:03:32 +08:00
|
|
|
|
params: {
|
|
|
|
|
pageNumber: 1,
|
|
|
|
|
pageSize: 10,
|
|
|
|
|
|
2021-08-09 18:40:06 +08:00
|
|
|
|
order: "desc",
|
|
|
|
|
keyword: "",
|
|
|
|
|
storeCatId: "",
|
|
|
|
|
storeId: "",
|
|
|
|
|
},
|
2021-05-13 11:03:32 +08:00
|
|
|
|
};
|
|
|
|
|
},
|
2021-08-09 18:40:06 +08:00
|
|
|
|
onLoad(options) {
|
|
|
|
|
this.routerVal = options;
|
|
|
|
|
this.params.storeId = options.storeId;
|
|
|
|
|
this.params.storeCatId = options.id;
|
|
|
|
|
this.title = options.title;
|
2021-05-13 11:03:32 +08:00
|
|
|
|
},
|
2021-08-09 18:40:06 +08:00
|
|
|
|
onShow() {
|
|
|
|
|
this.goodsList =[]
|
|
|
|
|
this.params.pageNumber = 1;
|
|
|
|
|
this.getGoodsData();
|
2021-05-13 11:03:32 +08:00
|
|
|
|
},
|
|
|
|
|
methods: {
|
2021-08-09 18:40:06 +08:00
|
|
|
|
/**
|
|
|
|
|
* 跳转到商品详情
|
|
|
|
|
*/
|
|
|
|
|
navigateToGoodsDetail(val) {
|
2021-05-13 11:03:32 +08:00
|
|
|
|
uni.navigateTo({
|
|
|
|
|
url: `/pages/product/goods?id=${val.id}&goodsId=${val.goodsId}`,
|
|
|
|
|
});
|
|
|
|
|
},
|
2021-08-09 18:40:06 +08:00
|
|
|
|
|
|
|
|
|
async getGoodsData() {
|
|
|
|
|
let goodsList = await getGoodsList(this.params);
|
|
|
|
|
if (goodsList.data.success) {
|
|
|
|
|
this.goodsList.push(...goodsList.data.result.content);
|
|
|
|
|
}
|
2021-05-13 11:03:32 +08:00
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
2021-08-09 18:40:06 +08:00
|
|
|
|
.contant {
|
|
|
|
|
margin-top: 20rpx;
|
2021-05-13 11:03:32 +08:00
|
|
|
|
display: flex;
|
2021-08-09 18:40:06 +08:00
|
|
|
|
flex-wrap: wrap;
|
2021-05-13 11:03:32 +08:00
|
|
|
|
justify-content: space-between;
|
2021-08-09 18:40:06 +08:00
|
|
|
|
> .empty {
|
|
|
|
|
width: 100%;
|
|
|
|
|
display: flex;
|
|
|
|
|
justify-content: center;
|
|
|
|
|
margin-top: 40rpx;
|
2021-05-13 11:03:32 +08:00
|
|
|
|
}
|
2021-08-09 18:40:06 +08:00
|
|
|
|
.item {
|
|
|
|
|
overflow: hidden;
|
2021-05-13 11:03:32 +08:00
|
|
|
|
|
2021-08-09 18:40:06 +08:00
|
|
|
|
background: #fff;
|
|
|
|
|
width: 49%;
|
|
|
|
|
height: 484rpx;
|
|
|
|
|
font-size: 26rpx;
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
border: 1px solid #f8f8f8;
|
|
|
|
|
margin-bottom: 20rpx;
|
2021-05-13 11:03:32 +08:00
|
|
|
|
|
2021-08-09 18:40:06 +08:00
|
|
|
|
.name {
|
|
|
|
|
text-align: left !important;
|
|
|
|
|
color: #333;
|
|
|
|
|
padding: 0 20rpx;
|
|
|
|
|
margin-top: 20rpx;
|
|
|
|
|
line-height: 1.4em;
|
|
|
|
|
max-height: 2.8em; //height是line-height的整数倍,防止文字显示不全
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
}
|
|
|
|
|
.price {
|
|
|
|
|
font-weight: 500;
|
|
|
|
|
color: $main-color;
|
|
|
|
|
font-size: 30rpx;
|
|
|
|
|
padding: 0 20rpx;
|
|
|
|
|
margin-top: 20rpx;
|
|
|
|
|
white-space: nowrap;
|
|
|
|
|
}
|
|
|
|
|
.buyCount {
|
|
|
|
|
display: flex;
|
|
|
|
|
padding: 0 20rpx;
|
|
|
|
|
font-size: 24upx;
|
|
|
|
|
justify-content: space-between;
|
|
|
|
|
color: #999;
|
|
|
|
|
}
|
2021-05-13 11:03:32 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2021-08-09 18:40:06 +08:00
|
|
|
|
</style>
|