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)">
|
2021-09-02 16:08:35 +08:00
|
|
|
|
<u-image width="100%" mode="aspectFit" height="324rpx" :src="item.content.thumbnail">
|
2021-08-09 18:40:06 +08:00
|
|
|
|
<u-loading slot="loading"></u-loading>
|
|
|
|
|
</u-image>
|
2021-09-02 16:08:35 +08:00
|
|
|
|
<div class="name">{{ item.content.goodsName }}</div>
|
2021-08-09 18:40:06 +08:00
|
|
|
|
<div class="price">
|
2021-09-02 16:08:35 +08:00
|
|
|
|
<div>¥{{ item.content.price | unitPrice }}</div>
|
2021-08-09 18:40:06 +08:00
|
|
|
|
</div>
|
|
|
|
|
<view class="buyCount">
|
2021-09-18 09:59:47 +08:00
|
|
|
|
<div>已售 {{ item.content.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
|
|
|
|
},
|
2021-08-09 18:44:03 +08:00
|
|
|
|
onReachBottom(){
|
|
|
|
|
this.params.pageNumber ++;
|
|
|
|
|
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({
|
2021-09-02 16:08:35 +08:00
|
|
|
|
url: `/pages/product/goods?id=${val.content.id}&goodsId=${val.content.goodsId}`,
|
2021-05-13 11:03:32 +08:00
|
|
|
|
});
|
|
|
|
|
},
|
2021-08-09 18:40:06 +08:00
|
|
|
|
|
|
|
|
|
async getGoodsData() {
|
2021-09-02 16:08:35 +08:00
|
|
|
|
// #TODO
|
2021-08-09 18:40:06 +08:00
|
|
|
|
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>
|