2022-10-12 17:45:22 +08:00
|
|
|
<template>
|
2022-10-13 10:37:47 +08:00
|
|
|
<view class="app">
|
|
|
|
|
<view class="productlist">
|
2022-10-20 19:39:57 +08:00
|
|
|
<view class="item" @tap='goCommodityDetails(item)' v-for="(item,index) in goodsList" :key="index">
|
2022-10-24 14:42:03 +08:00
|
|
|
<image :src="baseurl+item.goodsPictureUrl" mode=""></image>
|
2022-10-13 10:37:47 +08:00
|
|
|
<view class="title">
|
2022-10-24 14:42:03 +08:00
|
|
|
{{item.goodsName}}
|
2022-10-13 10:37:47 +08:00
|
|
|
</view>
|
|
|
|
|
<view class="price">
|
2022-10-18 18:41:28 +08:00
|
|
|
¥{{item.goodsPrice}}
|
2022-10-13 10:37:47 +08:00
|
|
|
</view>
|
|
|
|
|
</view>
|
2022-10-24 14:42:03 +08:00
|
|
|
<view class="item" v-if="goodsList.length%2!=0">
|
|
|
|
|
</view>
|
2022-10-13 10:37:47 +08:00
|
|
|
</view>
|
2022-10-12 17:45:22 +08:00
|
|
|
</view>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
2022-10-18 18:41:28 +08:00
|
|
|
import {
|
|
|
|
|
goodsList
|
|
|
|
|
} from '@/api/ProductList/ProductList.js';
|
|
|
|
|
import baseurl from '@/api/baseurl.js'
|
2022-10-12 17:45:22 +08:00
|
|
|
export default {
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
2022-10-24 14:42:03 +08:00
|
|
|
baseurl: '',
|
2022-10-13 16:02:25 +08:00
|
|
|
title: '医路优品', //导航栏标题
|
2022-10-18 18:41:28 +08:00
|
|
|
pageNum: 1,
|
2022-10-24 14:42:03 +08:00
|
|
|
pageSize: 10,
|
|
|
|
|
goodsCategoryId: '', //请求值
|
|
|
|
|
goodsList: [], //商品列表list
|
|
|
|
|
total: 0, //list总长度
|
2022-10-12 17:45:22 +08:00
|
|
|
};
|
|
|
|
|
},
|
2022-10-24 14:42:03 +08:00
|
|
|
onLoad(options) { //获取传值
|
|
|
|
|
this.title = options.title //导航栏标题
|
|
|
|
|
this.goodsCategoryId = options.goodsCategoryId //请求id
|
|
|
|
|
this.baseurl = baseurl;
|
|
|
|
|
this.goodsListinfo(this.pageSize, this.pageNum, options.goodsCategoryId)
|
2022-10-13 10:37:47 +08:00
|
|
|
},
|
2022-10-12 17:45:22 +08:00
|
|
|
methods: {
|
2022-10-20 19:39:57 +08:00
|
|
|
// 查询商品列表
|
2022-10-24 14:42:03 +08:00
|
|
|
goodsListinfo(pageSize, pageNum, goodsCategoryId) {
|
|
|
|
|
goodsList(pageSize, pageNum, goodsCategoryId).then(res => {
|
|
|
|
|
res.rows.forEach(e => {
|
|
|
|
|
this.goodsList.push(e)
|
2022-10-20 19:39:57 +08:00
|
|
|
})
|
2022-10-24 14:42:03 +08:00
|
|
|
this.total = res.total
|
2022-10-18 18:41:28 +08:00
|
|
|
})
|
|
|
|
|
},
|
2022-10-13 16:02:25 +08:00
|
|
|
//跳转详情页
|
2022-10-24 14:42:03 +08:00
|
|
|
goCommodityDetails(item) {
|
2022-10-13 16:02:25 +08:00
|
|
|
uni.navigateTo({
|
2022-10-31 09:04:45 +08:00
|
|
|
url: `/pages/CommodityDetails/CommodityDetails?goodsPrice=${item.goodsPrice}&goodsInfoId=${item.goodsInfoId}&buySource=${'SHOPPING_MALL'}`
|
2022-10-13 16:02:25 +08:00
|
|
|
})
|
|
|
|
|
},
|
2022-10-12 17:45:22 +08:00
|
|
|
},
|
2022-10-24 14:42:03 +08:00
|
|
|
onReady() { //更改导航栏文字
|
|
|
|
|
uni.setNavigationBarTitle({
|
|
|
|
|
title: this.title,
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
onReachBottom() { //下滑加载
|
|
|
|
|
if (this.goodsList.length >= this.total) {} else {
|
|
|
|
|
this.pageNum++;
|
|
|
|
|
this.goodsListinfo(this.pageSize, this.pageNum, this.goodsCategoryId)
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
onPullDownRefresh() { //下拉刷新
|
|
|
|
|
this.pageNum = 1;
|
|
|
|
|
goodsList(this.pageSize, this.pageNum, this.goodsCategoryId).then(res => {
|
|
|
|
|
this.goodsList = res.rows
|
|
|
|
|
this.total = res.total
|
|
|
|
|
})
|
|
|
|
|
setTimeout(function() {
|
|
|
|
|
uni.stopPullDownRefresh();
|
|
|
|
|
}, 1000);
|
|
|
|
|
}
|
2022-10-12 17:45:22 +08:00
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style lang="scss">
|
2022-10-13 10:37:47 +08:00
|
|
|
.app {
|
2022-10-31 09:04:45 +08:00
|
|
|
padding: 0;
|
2022-11-01 16:26:34 +08:00
|
|
|
|
2022-10-13 10:37:47 +08:00
|
|
|
.productlist {
|
|
|
|
|
width: 100%;
|
|
|
|
|
margin: 0 auto;
|
|
|
|
|
padding: 40rpx 0 0 0;
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-wrap: wrap;
|
|
|
|
|
justify-content: space-evenly;
|
|
|
|
|
|
|
|
|
|
.item {
|
|
|
|
|
width: 45%;
|
|
|
|
|
background: #FFFFFF;
|
|
|
|
|
border-radius: 25rpx;
|
|
|
|
|
padding-bottom: 10rpx;
|
|
|
|
|
box-shadow: 0px 4rpx 8rpx 4rpx rgba(199, 200, 202, 0.8);
|
|
|
|
|
margin-bottom: 40rpx;
|
|
|
|
|
|
|
|
|
|
.price {
|
|
|
|
|
font-size: 42rpx;
|
|
|
|
|
color: #D43953;
|
|
|
|
|
line-height: 79rpx;
|
|
|
|
|
padding-left: 20rpx;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.title {
|
|
|
|
|
font-size: 39rpx;
|
|
|
|
|
color: #000000;
|
|
|
|
|
line-height: 69rpx;
|
|
|
|
|
padding-left: 20rpx;
|
2022-10-24 14:42:03 +08:00
|
|
|
text-overflow: ellipsis;
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
white-space: nowrap;
|
2022-10-13 10:37:47 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
image {
|
|
|
|
|
width: 100%;
|
|
|
|
|
height: 340rpx;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-10-12 17:45:22 +08:00
|
|
|
</style>
|