2023-01-29 13:27:02 +08:00
|
|
|
|
<template>
|
|
|
|
|
|
<view class="app">
|
2023-01-29 15:52:42 +08:00
|
|
|
|
<view class="inputs">
|
|
|
|
|
|
<i class="icon"></i>
|
|
|
|
|
|
<input v-model="goodsName" type="text" name="" id="" class="input" placeholder="请输入商品名称">
|
|
|
|
|
|
</view>
|
2023-01-29 13:27:02 +08:00
|
|
|
|
<view class="lefttabbar">
|
|
|
|
|
|
<scroll-view :scroll-top="scrollTop" scroll-y="true" class="scroll-Y" @scrolltoupper="upper"
|
|
|
|
|
|
@scrolltolower="lower" @scroll="scroll">
|
|
|
|
|
|
<view class="scroll-view-item" v-for="(item,index) in GoodsCategorychildrenlist" :key='item.id'
|
|
|
|
|
|
@tap='tapscroll(item,index)'>
|
2023-01-29 15:47:31 +08:00
|
|
|
|
<view :class="tabIndex==index?'actives':'active'">
|
2023-01-29 13:27:02 +08:00
|
|
|
|
{{item.goodsCategoryName}}
|
|
|
|
|
|
</view>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
</scroll-view>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
<view class="" style="display: inline-block;width: 80%;padding-top: 20rpx;position: absolute;right: 0%;">
|
|
|
|
|
|
<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 class="noorder" v-if='goodsList.length==0'>
|
|
|
|
|
|
<image src="../../static/noorder.png" mode=""></image>
|
|
|
|
|
|
<view class="">
|
|
|
|
|
|
暂无商品
|
|
|
|
|
|
</view>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
|
import {
|
|
|
|
|
|
goodsList,
|
|
|
|
|
|
getGoodsCategoryNameList
|
|
|
|
|
|
} from '@/api/ProductList/ProductList.js';
|
|
|
|
|
|
import baseurl from '@/api/baseurl.js'
|
|
|
|
|
|
export default {
|
|
|
|
|
|
data() {
|
|
|
|
|
|
return {
|
|
|
|
|
|
//将选中标签的索引绑定为tabIndex,以便后续的调用
|
|
|
|
|
|
baseurl: '',
|
|
|
|
|
|
pageNum: 1,
|
|
|
|
|
|
pageSize: 20,
|
|
|
|
|
|
goodsCategoryId: '', //请求值
|
|
|
|
|
|
goodsList: [], //商品列表list
|
|
|
|
|
|
total: 0, //list总长度
|
|
|
|
|
|
goodsName: '',
|
|
|
|
|
|
tabIndex: 0,
|
|
|
|
|
|
GoodsCategorychildrenlist: [], //子分类list
|
|
|
|
|
|
GoodsCategorychildrenid: null,
|
|
|
|
|
|
scrollTop: 0,
|
|
|
|
|
|
old: {
|
|
|
|
|
|
scrollTop: 0
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
},
|
2023-01-29 15:52:42 +08:00
|
|
|
|
watch: { //监听
|
|
|
|
|
|
goodsName() {
|
|
|
|
|
|
this.pageNum = 1;
|
|
|
|
|
|
goodsList(this.pageSize, this.pageNum, this.GoodsCategorychildrenid, this.goodsName).then(res => {
|
|
|
|
|
|
this.goodsList = res.rows
|
|
|
|
|
|
this.total = res.total
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
2023-01-29 13:27:02 +08:00
|
|
|
|
onShow() {
|
|
|
|
|
|
var that = this
|
|
|
|
|
|
try {
|
|
|
|
|
|
const value = uni.getStorageSync('openid');
|
|
|
|
|
|
const value3 = uni.getStorageSync('Refresh');
|
|
|
|
|
|
if (value) {} else {
|
|
|
|
|
|
uni.navigateTo({
|
|
|
|
|
|
url: '/pages/login/login'
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
if (value3) {
|
|
|
|
|
|
that.goodsListinfo();
|
|
|
|
|
|
}
|
|
|
|
|
|
} catch (e) {}
|
|
|
|
|
|
},
|
|
|
|
|
|
onLoad(options) { //获取传值
|
|
|
|
|
|
this.goodsCategoryId = options.goodsCategoryId //请求id
|
2023-01-29 15:47:31 +08:00
|
|
|
|
this.GoodsCategorychildrenid = options.GoodsCategorychildrenid //请求id
|
|
|
|
|
|
this.tabIndex = options.index
|
2023-01-29 13:27:02 +08:00
|
|
|
|
this.baseurl = baseurl;
|
|
|
|
|
|
this.goodsListinfo()
|
|
|
|
|
|
this.GoodsCategorychildren(this.goodsCategoryId);
|
|
|
|
|
|
},
|
|
|
|
|
|
methods: {
|
|
|
|
|
|
tapscroll(item, index) {
|
|
|
|
|
|
this.tabIndex = index
|
|
|
|
|
|
if (index == 0) {
|
|
|
|
|
|
this.GoodsCategorychildrenid = this.goodsCategoryId
|
|
|
|
|
|
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');
|
|
|
|
|
|
})
|
|
|
|
|
|
} 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');
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
upper: function(e) {},
|
|
|
|
|
|
lower: function(e) {},
|
|
|
|
|
|
scroll: function(e) {
|
|
|
|
|
|
this.old.scrollTop = e.detail.scrollTop
|
|
|
|
|
|
},
|
|
|
|
|
|
//根据父级分类id获取子分类
|
|
|
|
|
|
GoodsCategorychildren(value) {
|
|
|
|
|
|
getGoodsCategoryNameList(value).then(res => {
|
|
|
|
|
|
this.GoodsCategorychildrenlist = [{
|
|
|
|
|
|
goodsCategoryName: '全部',
|
|
|
|
|
|
id: 99999999999999999,
|
|
|
|
|
|
}]
|
|
|
|
|
|
res.data.forEach(e => {
|
|
|
|
|
|
this.GoodsCategorychildrenlist.push(e)
|
|
|
|
|
|
})
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
// 查询商品列表
|
|
|
|
|
|
goodsListinfo() {
|
|
|
|
|
|
this.pageNum = 1;
|
2023-01-29 15:47:31 +08:00
|
|
|
|
goodsList(this.pageSize, this.pageNum, this.GoodsCategorychildrenid, this.goodsName).then(res => {
|
2023-01-29 13:27:02 +08:00
|
|
|
|
if (res.code == 200) {
|
|
|
|
|
|
res.rows.forEach(e => {
|
|
|
|
|
|
this.goodsList.push(e)
|
|
|
|
|
|
})
|
|
|
|
|
|
this.total = res.total
|
|
|
|
|
|
}
|
|
|
|
|
|
uni.removeStorageSync('Refresh');
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
//跳转详情页
|
|
|
|
|
|
goCommodityDetails(item) {
|
|
|
|
|
|
uni.navigateTo({
|
|
|
|
|
|
url: `/pages/CommodityDetails/CommodityDetails?goodsPrice=${item.goodsPrice}&goodsInfoId=${item.goodsInfoId}&buySource=${'SHOPPING_MALL'}&goodsAttributeId=${item.goodsAttributeId}`
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
|
|
|
|
|
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 {
|
|
|
|
|
|
title: '泉医到家',
|
|
|
|
|
|
path: url,
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
//2.分享到朋友圈
|
|
|
|
|
|
onShareTimeline(res) {
|
|
|
|
|
|
let pages = getCurrentPages();
|
|
|
|
|
|
let url = pages[pages.length - 1].$page.fullPath
|
|
|
|
|
|
url = decodeURIComponent(url)
|
|
|
|
|
|
return {
|
|
|
|
|
|
title: '泉医到家',
|
|
|
|
|
|
path: url,
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
}
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<style lang="scss">
|
|
|
|
|
|
.app {
|
|
|
|
|
|
padding: 0;
|
|
|
|
|
|
width: 100%;
|
|
|
|
|
|
height: 100%;
|
|
|
|
|
|
|
2023-01-29 15:52:42 +08:00
|
|
|
|
.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 {
|
|
|
|
|
|
background: url(@/static/sousuo.png) no-repeat;
|
|
|
|
|
|
width: 30rpx;
|
|
|
|
|
|
height: 28rpx;
|
|
|
|
|
|
background-size: cover;
|
|
|
|
|
|
position: absolute;
|
|
|
|
|
|
top: 30%;
|
|
|
|
|
|
left: 3%;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-01-29 13:27:02 +08:00
|
|
|
|
.lefttabbar {
|
2023-01-29 15:47:31 +08:00
|
|
|
|
position: fixed;
|
2023-01-29 13:27:02 +08:00
|
|
|
|
width: 20%;
|
|
|
|
|
|
height: 100%;
|
|
|
|
|
|
display: inline-block;
|
|
|
|
|
|
|
|
|
|
|
|
.scroll-Y {
|
|
|
|
|
|
height: 100%;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-29 15:47:31 +08:00
|
|
|
|
|
|
|
|
|
|
.actives {
|
2023-01-29 13:27:02 +08:00
|
|
|
|
color: red;
|
|
|
|
|
|
font-size: 34rpx;
|
2023-01-29 15:47:31 +08:00
|
|
|
|
overflow: hidden;
|
|
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
|
|
white-space: nowrap;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.active {
|
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
|
|
white-space: nowrap;
|
2023-01-29 13:27:02 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.scroll-view-item {
|
|
|
|
|
|
color: #7d7e80;
|
|
|
|
|
|
height: 100rpx;
|
|
|
|
|
|
line-height: 100rpx;
|
|
|
|
|
|
text-align: center;
|
|
|
|
|
|
font-size: 30rpx;
|
2023-01-29 15:47:31 +08:00
|
|
|
|
padding: 0 10rpx;
|
2023-01-29 13:27:02 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.noorder {
|
|
|
|
|
|
view {
|
|
|
|
|
|
text-align: center;
|
|
|
|
|
|
font-size: 40rpx;
|
|
|
|
|
|
color: #BFBFBF;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
image {
|
|
|
|
|
|
display: block;
|
|
|
|
|
|
margin: 20% auto 50rpx;
|
|
|
|
|
|
width: 160rpx;
|
|
|
|
|
|
height: 200rpx;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.productlist {
|
|
|
|
|
|
width: 100%;
|
|
|
|
|
|
margin: 0 auto;
|
|
|
|
|
|
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: 30rpx;
|
|
|
|
|
|
|
|
|
|
|
|
.price {
|
|
|
|
|
|
font-size: 28rpx;
|
|
|
|
|
|
color: #D43953;
|
|
|
|
|
|
line-height: 50rpx;
|
|
|
|
|
|
padding-left: 10rpx;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.text {
|
|
|
|
|
|
font-size: 22rpx;
|
|
|
|
|
|
padding: 0 10rpx;
|
|
|
|
|
|
// 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: 28rpx;
|
|
|
|
|
|
color: #000000;
|
|
|
|
|
|
line-height: 50rpx;
|
|
|
|
|
|
padding-left: 10rpx;
|
|
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
|
white-space: nowrap;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
image {
|
|
|
|
|
|
border-radius: 25rpx 25rpx 0 0;
|
|
|
|
|
|
width: 100%;
|
|
|
|
|
|
height: 270rpx;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
</style>
|