2023-09-22 11:08:14 +08:00
|
|
|
|
<template>
|
|
|
|
|
|
<view class="app">
|
2023-09-26 15:39:25 +08:00
|
|
|
|
<u-tabs :list="GoodsCategorychildrenlist" :current="tabIndex" @change="toggleTab" active-color='#26A888'
|
2023-09-22 11:08:14 +08:00
|
|
|
|
v-if="GoodsCategorychildrenlist.length>=2"></u-tabs>
|
|
|
|
|
|
<view class="fenlei" @tap='toggleTab(1111111111111)' v-if="GoodsCategorychildrenlist.length>=2">
|
2023-09-22 11:30:57 +08:00
|
|
|
|
<image src="../../static/pagesB/fenlei.png" mode=""></image>
|
2023-09-22 11:08:14 +08:00
|
|
|
|
<view class="">
|
|
|
|
|
|
分类
|
|
|
|
|
|
</view>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
<view class="inputs">
|
|
|
|
|
|
<i class="icon"></i>
|
|
|
|
|
|
<input v-model="goodsName" type="text" name="" id="" class="input" placeholder="请输入商品名称">
|
|
|
|
|
|
</view>
|
|
|
|
|
|
<view class="productlist" v-if='goodsList.length>0'>
|
|
|
|
|
|
<view class="item" @tap='goCommodityDetails(item)' v-for="(item,index) in goodsList" :key="index">
|
|
|
|
|
|
<image :src="baseurl+item.goodsPictureUrl" mode=""></image>
|
|
|
|
|
|
<view class="title">
|
|
|
|
|
|
{{item.goodsName}}
|
|
|
|
|
|
</view>
|
|
|
|
|
|
<view class="text">
|
|
|
|
|
|
{{item.attributeDetailsName}}
|
|
|
|
|
|
</view>
|
|
|
|
|
|
<view class="price">
|
|
|
|
|
|
¥{{item.goodsPrice}}
|
|
|
|
|
|
</view>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
<view style="width: 45%;" v-if="goodsList.length%2!=0">
|
|
|
|
|
|
</view>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
<view style='margin-top:90rpx' v-else>
|
|
|
|
|
|
<u-empty mode="list" icon-size='220' text='暂无商品'></u-empty>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
<u-back-top :scroll-top="scrollTop"></u-back-top>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
|
import {
|
|
|
|
|
|
goodsList,
|
|
|
|
|
|
getGoodsCategoryNameList
|
2023-09-22 11:30:57 +08:00
|
|
|
|
} from '@/api/pagesB/ProductList/ProductList.js';
|
2023-09-22 11:08:14 +08:00
|
|
|
|
import baseurl from '@/api/baseurl.js'
|
|
|
|
|
|
export default {
|
|
|
|
|
|
components: {},
|
|
|
|
|
|
data() {
|
|
|
|
|
|
return {
|
|
|
|
|
|
//将选中标签的索引绑定为tabIndex,以便后续的调用
|
|
|
|
|
|
tabIndex: 0,
|
|
|
|
|
|
baseurl: '',
|
|
|
|
|
|
title: '医路优品', //导航栏标题
|
|
|
|
|
|
pageNum: 1,
|
|
|
|
|
|
pageSize: 10,
|
|
|
|
|
|
goodsCategoryId: '', //请求值
|
|
|
|
|
|
goodsList: [], //商品列表list
|
|
|
|
|
|
total: 0, //list总长度
|
|
|
|
|
|
goodsName: '',
|
|
|
|
|
|
GoodsCategorychildrenlist: [], //子分类list
|
|
|
|
|
|
GoodsCategorychildrenid: null,
|
|
|
|
|
|
scrollTop: 0,
|
|
|
|
|
|
};
|
|
|
|
|
|
},
|
|
|
|
|
|
watch: { //监听
|
|
|
|
|
|
goodsName() {
|
|
|
|
|
|
this.pageNum = 1;
|
|
|
|
|
|
goodsList(this.pageSize, this.pageNum, this.GoodsCategorychildrenid, this.goodsName).then(res => {
|
|
|
|
|
|
this.goodsList = res.rows
|
|
|
|
|
|
this.total = res.total
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
|
|
|
|
|
onShow() {
|
|
|
|
|
|
var that = this
|
|
|
|
|
|
const value3 = uni.getStorageSync('Refresh');
|
|
|
|
|
|
if (value3) {
|
|
|
|
|
|
that.goodsListinfo();
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
onLoad(options) { //获取传值
|
|
|
|
|
|
this.GoodsCategorychildrenid = null
|
|
|
|
|
|
this.tabIndex = 0
|
|
|
|
|
|
if (options.title) {
|
|
|
|
|
|
this.title = options.title //导航栏标题
|
|
|
|
|
|
}
|
|
|
|
|
|
this.goodsCategoryId = options.goodsCategoryId //请求id
|
|
|
|
|
|
this.GoodsCategorychildrenid = options.goodsCategoryId //请求id
|
|
|
|
|
|
this.baseurl = baseurl;
|
|
|
|
|
|
this.goodsListinfo()
|
|
|
|
|
|
this.GoodsCategorychildren(this.goodsCategoryId);
|
|
|
|
|
|
},
|
|
|
|
|
|
methods: {
|
|
|
|
|
|
onPageScroll(e) {
|
|
|
|
|
|
this.scrollTop = e.scrollTop;
|
|
|
|
|
|
},
|
|
|
|
|
|
//点击导航栏标签改变当前索引
|
|
|
|
|
|
toggleTab(index) {
|
|
|
|
|
|
if (index == 1111111111111) {
|
|
|
|
|
|
uni.navigateTo({
|
2023-09-22 16:01:48 +08:00
|
|
|
|
url: `/pagesB/classification/classification?goodsCategoryId=${this.goodsCategoryId}&index=${this.tabIndex}&GoodsCategorychildrenid=${this.GoodsCategorychildrenid}`
|
2023-09-22 11:08:14 +08:00
|
|
|
|
})
|
|
|
|
|
|
} else if (index == 0) {
|
|
|
|
|
|
this.GoodsCategorychildrenid = this.goodsCategoryId
|
|
|
|
|
|
this.tabIndex = index
|
|
|
|
|
|
this.pageNum = 1
|
|
|
|
|
|
goodsList(this.pageSize, this.pageNum, this.goodsCategoryId, this.goodsName).then(
|
|
|
|
|
|
res => {
|
|
|
|
|
|
if (res.code == 200) {
|
|
|
|
|
|
this.goodsList = res.rows
|
|
|
|
|
|
this.total = res.total
|
|
|
|
|
|
}
|
|
|
|
|
|
uni.removeStorageSync('Refresh');
|
|
|
|
|
|
})
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.GoodsCategorychildrenid = this.GoodsCategorychildrenlist[index].id
|
|
|
|
|
|
this.tabIndex = index
|
|
|
|
|
|
this.pageNum = 1
|
|
|
|
|
|
goodsList(this.pageSize, this.pageNum, this.GoodsCategorychildrenid, this.goodsName).then(
|
|
|
|
|
|
res => {
|
|
|
|
|
|
if (res.code == 200) {
|
|
|
|
|
|
this.goodsList = res.rows
|
|
|
|
|
|
this.total = res.total
|
|
|
|
|
|
}
|
|
|
|
|
|
uni.removeStorageSync('Refresh');
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
//根据父级分类id获取子分类
|
|
|
|
|
|
GoodsCategorychildren(value) {
|
|
|
|
|
|
getGoodsCategoryNameList(value).then(res => {
|
|
|
|
|
|
this.GoodsCategorychildrenlist = [{
|
|
|
|
|
|
name: '全部',
|
|
|
|
|
|
id: 99999999999999999,
|
|
|
|
|
|
}]
|
|
|
|
|
|
res.data.forEach(e => {
|
|
|
|
|
|
e.name = e.goodsCategoryName
|
|
|
|
|
|
this.GoodsCategorychildrenlist.push(e)
|
|
|
|
|
|
})
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
// 查询商品列表
|
|
|
|
|
|
goodsListinfo() {
|
|
|
|
|
|
this.pageNum = 1;
|
|
|
|
|
|
goodsList(this.pageSize, this.pageNum, this.GoodsCategorychildrenid, this.goodsName).then(res => {
|
|
|
|
|
|
if (res.code == 200) {
|
|
|
|
|
|
res.rows.forEach(e => {
|
|
|
|
|
|
this.goodsList.push(e)
|
|
|
|
|
|
})
|
|
|
|
|
|
this.total = res.total
|
|
|
|
|
|
}
|
|
|
|
|
|
uni.removeStorageSync('Refresh');
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
//跳转详情页
|
|
|
|
|
|
goCommodityDetails(item) {
|
|
|
|
|
|
uni.navigateTo({
|
2023-09-22 16:01:48 +08:00
|
|
|
|
url: `/pagesB/CommodityDetails/CommodityDetails?goodsPrice=${item.goodsPrice}&goodsInfoId=${item.goodsInfoId}&buySource=${'SHOPPING_MALL'}&goodsAttributeId=${item.goodsAttributeId}`
|
2023-09-22 11:08:14 +08:00
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
|
|
|
|
|
onReady() { //更改导航栏文字
|
|
|
|
|
|
uni.setNavigationBarTitle({
|
|
|
|
|
|
title: this.title,
|
|
|
|
|
|
});
|
|
|
|
|
|
},
|
|
|
|
|
|
onReachBottom() { //下滑加载
|
|
|
|
|
|
if (this.goodsList.length >= this.total) {} else {
|
|
|
|
|
|
this.pageNum++;
|
|
|
|
|
|
goodsList(this.pageSize, this.pageNum, this.GoodsCategorychildrenid, this.goodsName).then(res => {
|
|
|
|
|
|
if (res.code == 200) {
|
|
|
|
|
|
res.rows.forEach(e => {
|
|
|
|
|
|
this.goodsList.push(e)
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
onPullDownRefresh() { //下拉刷新
|
|
|
|
|
|
this.pageNum = 1;
|
|
|
|
|
|
goodsList(this.pageSize, this.pageNum, this.GoodsCategorychildrenid, this.goodsName).then(res => {
|
|
|
|
|
|
this.goodsList = res.rows
|
|
|
|
|
|
this.total = res.total
|
|
|
|
|
|
})
|
|
|
|
|
|
setTimeout(function() {
|
|
|
|
|
|
uni.stopPullDownRefresh();
|
|
|
|
|
|
}, 1000);
|
|
|
|
|
|
},
|
|
|
|
|
|
//1.分享给朋友
|
|
|
|
|
|
onShareAppMessage(res) {
|
|
|
|
|
|
let pages = getCurrentPages();
|
|
|
|
|
|
let url = pages[pages.length - 1].$page.fullPath
|
|
|
|
|
|
url = decodeURIComponent(url)
|
|
|
|
|
|
return {
|
2023-09-22 11:45:09 +08:00
|
|
|
|
title: '新医路健康服务平台',
|
2023-09-22 11:08:14 +08:00
|
|
|
|
path: url,
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
//2.分享到朋友圈
|
|
|
|
|
|
onShareTimeline(res) {
|
|
|
|
|
|
let pages = getCurrentPages();
|
|
|
|
|
|
let url = pages[pages.length - 1].$page.fullPath
|
|
|
|
|
|
url = decodeURIComponent(url)
|
|
|
|
|
|
return {
|
2023-09-22 11:45:09 +08:00
|
|
|
|
title: '新医路健康服务平台',
|
2023-09-22 11:08:14 +08:00
|
|
|
|
path: url,
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
}
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<style lang="scss">
|
|
|
|
|
|
::v-deep .u-tabs {
|
|
|
|
|
|
width: 80%;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.app {
|
|
|
|
|
|
padding: 0;
|
|
|
|
|
|
|
|
|
|
|
|
.fenlei {
|
|
|
|
|
|
width: 20%;
|
|
|
|
|
|
display: inline-block;
|
|
|
|
|
|
background-color: #fff;
|
|
|
|
|
|
line-height: 86rpx;
|
|
|
|
|
|
font-weight: normal;
|
|
|
|
|
|
height: 86rpx;
|
|
|
|
|
|
text-align: center;
|
|
|
|
|
|
color: #000000;
|
|
|
|
|
|
position: absolute;
|
|
|
|
|
|
right: 0;
|
|
|
|
|
|
top: 0;
|
|
|
|
|
|
font-size: 32rpx;
|
|
|
|
|
|
|
|
|
|
|
|
view {
|
|
|
|
|
|
position: absolute;
|
|
|
|
|
|
right: 20%;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
image {
|
|
|
|
|
|
width: 45rpx;
|
|
|
|
|
|
height: 45rpx;
|
|
|
|
|
|
position: absolute;
|
|
|
|
|
|
left: 10%;
|
|
|
|
|
|
top: 50%;
|
|
|
|
|
|
transform: translateY(-50%);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.inputs {
|
|
|
|
|
|
box-shadow: 0rpx 9rpx 31rpx 9rpx rgba(0, 0, 0, 0.03);
|
|
|
|
|
|
border: 1px solid #f0f0f0;
|
|
|
|
|
|
width: 90%;
|
|
|
|
|
|
height: 65rpx;
|
|
|
|
|
|
margin: 10rpx 0 10rpx 50%;
|
|
|
|
|
|
transform: translateX(-50%);
|
|
|
|
|
|
border-radius: 20rpx;
|
|
|
|
|
|
background-color: #Ffffff;
|
|
|
|
|
|
z-index: 999;
|
|
|
|
|
|
|
|
|
|
|
|
.input {
|
|
|
|
|
|
margin: 0 auto;
|
|
|
|
|
|
position: absolute;
|
|
|
|
|
|
height: 65rpx;
|
|
|
|
|
|
// top: 8%;
|
|
|
|
|
|
left: 10%;
|
|
|
|
|
|
width: 90%;
|
|
|
|
|
|
font-size: 26rpx;
|
|
|
|
|
|
color: #000000;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.icon {
|
2023-09-22 11:49:36 +08:00
|
|
|
|
background: url(@/static/pagesB/sousuo.png) no-repeat;
|
2023-09-22 11:08:14 +08:00
|
|
|
|
width: 30rpx;
|
|
|
|
|
|
height: 28rpx;
|
|
|
|
|
|
background-size: cover;
|
|
|
|
|
|
position: absolute;
|
|
|
|
|
|
top: 30%;
|
|
|
|
|
|
left: 3%;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.productlist {
|
|
|
|
|
|
width: 100%;
|
|
|
|
|
|
margin: 0 auto;
|
|
|
|
|
|
padding: 20rpx 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: 36rpx;
|
2023-10-08 16:16:18 +08:00
|
|
|
|
color: #26A888;
|
2023-09-22 11:08:14 +08:00
|
|
|
|
line-height: 79rpx;
|
|
|
|
|
|
padding-left: 15rpx;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.text {
|
|
|
|
|
|
font-size: 24rpx;
|
|
|
|
|
|
padding: 0 15rpx;
|
|
|
|
|
|
// text-overflow: ellipsis;
|
|
|
|
|
|
// overflow: hidden;
|
|
|
|
|
|
// white-space: nowrap;
|
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
|
|
display: -webkit-box;
|
|
|
|
|
|
-webkit-box-orient: vertical;
|
|
|
|
|
|
-webkit-line-clamp: 2;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.title {
|
|
|
|
|
|
font-size: 36rpx;
|
|
|
|
|
|
color: #000000;
|
|
|
|
|
|
line-height: 69rpx;
|
|
|
|
|
|
padding-left: 15rpx;
|
|
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
|
white-space: nowrap;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
image {
|
|
|
|
|
|
border-radius: 25rpx 25rpx 0 0;
|
|
|
|
|
|
width: 100%;
|
|
|
|
|
|
height: 340rpx;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2023-09-22 11:49:36 +08:00
|
|
|
|
</style>
|