我的收藏布局修改

master
lemon橪 2021-12-24 16:22:03 +08:00
parent 3a2202a2e8
commit a8836744f6
2 changed files with 441 additions and 422 deletions

View File

@ -93,6 +93,7 @@
"style": { "style": {
"navigationBarTitleText": "收藏", "navigationBarTitleText": "收藏",
"enablePullDownRefresh": true, // "enablePullDownRefresh": true, //
"navigationStyle": "custom",
"app-plus": { "app-plus": {
"scrollIndicator": "none" "scrollIndicator": "none"
} }

View File

@ -1,422 +1,440 @@
<template> <template>
<view class="content"> <view class="content">
<view class="navbar"> <u-navbar>
<!-- 循环出顶部nav栏 --> <u-tabs :active-color="lightColor" class="slot-wrap" :list="navList" count="count" :is-scroll="true" :current="tabCurrentIndex" @change="tabClick"></u-tabs>
<view v-for="(item, index) in navList" :key="index" class="nav-item" @click="tabClick(index)"> </u-navbar>
<text :class="{current: tabCurrentIndex === index}">{{item.text}}</text> <view class="swiper-box">
</view> <!-- 显示商品栏 -->
</view> <view v-if="tabCurrentIndex == 0" class="tab-content">
<view class="swiper-box"> <scroll-view class="list-scroll-content" scroll-y>
<!-- 显示商品栏 --> <!-- 空白页 -->
<view v-if="tabCurrentIndex == 0" class="tab-content"> <u-empty style="margin-top: 40rpx" text="暂无收藏商品数据" mode="favor" v-if="goodsEmpty"></u-empty>
<scroll-view class="list-scroll-content" scroll-y @scrolltolower="loadMore"> <!-- 商品展示数据 -->
<!-- 空白页 --> <u-swipe-action @open="openLeftChange(item, index, 'goods')" :show="item.selected" btn-width="180"
<u-empty style="margin-top:40rpx;" text="暂无收藏商品数据" mode="favor" v-if="goodsEmpty"></u-empty> :options="LeftOptions" v-else v-for="(item, index) in goodList"
<!-- 商品展示数据 --> @click="clickGoodsSwiperAction(item, index)" :index="index" :key="index">
<u-swipe-action @open="openLeftChange(item,index,'goods')" :show="item.selected" btn-width="180" <view class="goods" @click="goGoodsDetail(item)">
:options="LeftOptions" v-else v-for="(item,index) in goodList" @click="clickGoodsSwiperAction(item,index)" <u-image width="131rpx" height="131rpx" :src="item.image" mode="aspectFit">
:index="index" :key="index"> <u-loading slot="loading"></u-loading>
<view class="goods" @click="goGoodsDetail(item)"> </u-image>
<u-image width="131rpx" height="131rpx" :src="item.image" mode="aspectFit"> <view class="goods-intro">
<u-loading slot="loading"></u-loading> <view>{{ item.goodsName }}</view>
</u-image> <view class="goods-sn">{{ item.goods_sn }}</view>
<view class="goods-intro"> <view>{{ item.price | unitPrice }}</view>
<view>{{item.goodsName}}</view> </view>
<view class="goods-sn">{{item.goods_sn}}</view> </view>
<view>{{item.price | unitPrice}}</view> </u-swipe-action>
</view>
</view>
</u-swipe-action>
<uni-load-more :status="goodsLoad"></uni-load-more> </scroll-view>
</scroll-view> </view>
</view> <!-- 显示收藏的店铺栏 -->
<!-- 显示收藏的店铺栏 --> <view v-else class="tab-content">
<view v-else class="tab-content"> <scroll-view class="list-scroll-content" scroll-y>
<scroll-view class="list-scroll-content" scroll-y @scrolltolower="loadMore"> <!-- 空白页 -->
<!-- 空白页 --> <u-empty style="margin-top: 40rpx" text="暂无收藏店铺数据" mode="favor" v-if="storeEmpty"></u-empty>
<u-empty style="margin-top:40rpx;" text="暂无收藏店铺数据" mode="favor" v-if="storeEmpty"></u-empty> <!-- 店铺展示数据 -->
<!-- 店铺展示数据 --> <u-swipe-action @open="openLeftChange(item, 'store')" :show="item.selected" btn-width="180"
<u-swipe-action @open="openLeftChange(item,'store')" :show="item.selected" btn-width="180" :options="LeftOptions" v-else v-for="(item, index) in storeList" :key="index"
:options="LeftOptions" v-else v-for="(item,index) in storeList" :key="index" @click="clickStoreSwiperAction(item)">
@click="clickstoreSwiperAction(item)"> <view class="store" @click="goStoreMainPage(item.id)">
<view class="store" @click="gostoreMainPage(item.id)"> <view class="intro">
<view class="intro"> <view class="store-logo">
<view class="store-logo"> <u-image width="102rpx" height="102rpx" :src="item.storeLogo" :alt="item.storeName"
<u-image width="102rpx" height="102rpx" :src="item.storeLogo" :alt="item.storeName" mode="aspectFit"> mode="aspectFit">
<u-loading slot="loading"></u-loading> <u-loading slot="loading"></u-loading>
</u-image> </u-image>
</view> </view>
<view class="store-name"> <view class="store-name">
<view>{{item.storeName}}</view> <view>{{ item.storeName }}</view>
<u-tag size="mini" type="error" :color="$mainColor" v-if="item.selfOperated" text="自营" mode="plain" <u-tag size="mini" type="error" :color="$mainColor" v-if="item.selfOperated"
shape="circle" /> text="自营" mode="plain" shape="circle" />
</view> </view>
<view class="store-collect"> <view class="store-collect">
<view>进店逛逛</view> <view>进店逛逛</view>
</view> </view>
</view> </view>
</view> </view>
</u-swipe-action> </u-swipe-action>
<uni-load-more :status="storeLoad"></uni-load-more> </scroll-view>
</scroll-view> </view>
</view> </view>
</view> </view>
</view>
</template> </template>
<script> <script>
import { import {
getGoodsCollection, getGoodsCollection,
deleteGoodsCollection, deleteGoodsCollection,
deleteStoreCollection, deleteStoreCollection,
} from "@/api/members.js"; } from "@/api/members.js";
export default { export default {
data() { data() {
return { return {
// lightColor:this.$lightColor,
LeftOptions: [ //
{ LeftOptions: [{
text: "取消", text: "取消",
style: { style: {
backgroundColor: this.$lightColor, backgroundColor: this.$lightColor,
}, },
}, }, ],
], tabCurrentIndex: 0, //tab0
tabCurrentIndex: 0, //tab0 navList: [
navList: [ //tab
//tab {
{ name: "商品(0)",
text: "商品(0)",
loadingType: "more",
params: {
pageNumber: 1,
pageSize: 10,
},
},
{
text: "店铺(0)",
loadingType: "more",
params: {
pageNumber: 1,
pageSize: 10,
},
},
],
goodsLoad: "more", //
storeLoad: "more", //
goodsEmpty: false, //
storeEmpty: false, //
goodList: [], //
storeList: [], //
};
},
onLoad() {
this.getGoodList();
this.getStoreList();
},
methods: { params: {
/** pageNumber: 1,
* 打开商品左侧取消收藏 pageSize: 10,
*/ },
openLeftChange(val, type) { },
const { goodList, storeList } = this; {
let way; name: "店铺(0)",
type == "goods" ? (way = goodList) : (way = storeList);
way.forEach((item) => {
this.$set(item, "selected", false);
});
this.$set(val, "selected", false);
val.selected = true;
},
/** params: {
* 点击商品左侧取消收藏 pageNumber: 1,
*/ pageSize: 10,
clickGoodsSwiperAction(val) { },
deleteGoodsCollection(val.skuId).then((res) => { },
if (res.statusCode == 200) { ],
this.storeList = [];
this.goodList = [];
this.getGoodList();
}
});
},
/** goodsEmpty: false, //
* 点击店铺左侧取消收藏 storeEmpty: false, //
*/ goodList: [], //
clickstoreSwiperAction(val) { storeList: [], //
deleteStoreCollection(val.storeId).then((res) => { };
if (res.statusCode == 200) { },
this.storeList = []; onLoad() {
this.getStoreList(); this.getGoodList();
} this.getStoreList();
}); },
}, onReachBottom() {
if (this.tabCurrentIndex == 0) {
this.navList[0].params.pageNumber++;
this.getGoodList();
} else {
this.navList[1].params.pageNumber++;
this.getStoreList();
}
},
/** methods: {
* 顶部tab点击 /**
*/ * 打开商品左侧取消收藏
tabClick(index) { */
this.tabCurrentIndex = index; openLeftChange(val, type) {
}, const {
goodList,
storeList
} = this;
let way;
type == "goods" ? (way = goodList) : (way = storeList);
way.forEach((item) => {
this.$set(item, "selected", false);
});
this.$set(val, "selected", false);
val.selected = true;
},
/** /**
* 查看商品详情 * 点击商品左侧取消收藏
*/ */
goGoodsDetail(val) { clickGoodsSwiperAction(val) {
// deleteGoodsCollection(val.skuId).then((res) => {
uni.navigateTo({ if (res.statusCode == 200) {
url: "/pages/product/goods?id=" + val.skuId + "&goodsId=" + val.goodsId, this.storeList = [];
}); this.goodList = [];
}, this.getGoodList();
}
});
},
/** /**
* 查看店铺详情 * 点击店铺左侧取消收藏
*/ */
gostoreMainPage(id) { clickStoreSwiperAction(val) {
// deleteStoreCollection(val.storeId).then((res) => {
uni.navigateTo({ if (res.statusCode == 200) {
url: "/pages/product/shopPage?id=" + id, this.storeList = [];
}); this.getStoreList();
}, }
});
},
/** /**
* 获取商品集合 * 顶部tab点击
*/ */
getGoodList() { tabClick(index) {
uni.showLoading({ this.tabCurrentIndex = index;
title: "加载中", },
});
getGoodsCollection(this.navList[0].params, "GOODS").then((res) => {
uni.hideLoading();
uni.stopPullDownRefresh();
if (res.data.success) {
let data = res.data.result;
data.selected = false;
this.navList[0].text = `商品(${data.total})`;
if (data.total == 0) {
this.goodsEmpty = true;
} else if (data.total < 10) {
this.goodsLoad = "noMore";
this.goodList.push(...data.records);
} else {
this.goodList.push(...data.records);
if (data.total.length < 10) this.goodsLoad = "noMore";
}
}
});
},
/** /**
* 获取店铺集合 * 查看商品详情
*/ */
getStoreList() { goGoodsDetail(val) {
uni.showLoading({ //
title: "加载中", uni.navigateTo({
}); url: "/pages/product/goods?id=" + val.skuId + "&goodsId=" + val.goodsId,
getGoodsCollection(this.navList[1].params, "store").then((res) => { });
uni.hideLoading(); },
uni.stopPullDownRefresh();
if (res.data.success) {
let data = res.data.result;
data.selected = false;
this.navList[1].text = `店铺(${data.total})`;
if (data.total == 0) {
this.storeEmpty = true;
} else if (data.total < 10) {
this.storeLoad = "noMore";
this.storeList.push(...data.records);
} else {
this.storeList.push(...data.records);
if (data.total.length < 10) this.storeLoad = "noMore";
}
}
});
},
/** /**
* 底部加载更多 * 查看店铺详情
*/ */
loadMore() { goStoreMainPage(id) {
if (this.tabCurrentIndex == 0) { //
this.navList[0].params.pageNumber++; uni.navigateTo({
this.getGoodList(); url: "/pages/product/shopPage?id=" + id,
} else { });
this.navList[1].params.pageNumber++; },
this.getStoreList();
}
},
},
/** /**
* 下拉刷新时 * 获取商品集合
*/ */
onPullDownRefresh() { getGoodList() {
if (this.tabCurrentIndex == 0) { uni.showLoading({
this.navList[0].params.pageNumber = 1; title: "加载中",
this.goodList = []; });
this.getGoodList(); getGoodsCollection(this.navList[0].params, "GOODS").then((res) => {
} else { uni.hideLoading();
this.navList[1].params.pageNumber = 1; uni.stopPullDownRefresh();
this.storeList = []; if (res.data.success) {
this.getStoreList(); let data = res.data.result;
} data.selected = false;
}, this.navList[0].name = `商品(${data.total})`;
};
if (data.total == 0) {
this.goodsEmpty = true;
} else if (data.total < 10) {
this.goodsLoad = "noMore";
this.goodList.push(...data.records);
} else {
this.goodList.push(...data.records);
if (data.total.length < 10) this.goodsLoad = "noMore";
}
}
});
},
/**
* 获取店铺集合
*/
getStoreList() {
uni.showLoading({
title: "加载中",
});
getGoodsCollection(this.navList[1].params, "store").then((res) => {
uni.hideLoading();
uni.stopPullDownRefresh();
if (res.data.success) {
let data = res.data.result;
data.selected = false;
this.navList[1].name = `店铺(${data.total})`;
if (data.total == 0) {
this.storeEmpty = true;
} else if (data.total < 10) {
this.storeList.push(...data.records);
}
}
});
},
},
/**
* 下拉刷新时
*/
onPullDownRefresh() {
if (this.tabCurrentIndex == 0) {
this.navList[0].params.pageNumber = 1;
this.goodList = [];
this.getGoodList();
} else {
this.navList[1].params.pageNumber = 1;
this.storeList = [];
this.getStoreList();
}
},
};
</script> </script>
<style lang="scss"> <style lang="scss">
page, page,
.content { .content {
background: $page-color-base; background: $page-color-base;
height: 100%; height: 100%;
} }
.content {
width: 100%;
overflow: hidden;
}
.swiper-box {
overflow-y: auto;
}
.list-scroll-content { .slot-wrap{
height: 100%;
width: 100%;
}
/deep/ .u-swipe-content {
overflow: hidden;
}
.goods {
background-color: #fff;
border-bottom: 1px solid $border-color-light;
height: 190rpx;
display: flex;
align-items: center;
padding: 30rpx 20rpx;
margin-top: 20rpx;
image {
width: 131rpx;
height: 131rpx;
border-radius: 10rpx;
}
.goods-intro {
flex: 1;
font-size: $font-base;
line-height: 48rpx;
margin-left: 30rpx;
view:nth-child(1) {
line-height: 1.4em;
font-size: 24rpx;
max-height: 2.8em; //heightline-height
overflow: hidden;
color: #666;
}
view:nth-child(2) {
color: #cccccc;
font-size: 24rpx;
}
view:nth-child(3) {
color: $light-color;
}
}
button {
color: $main-color;
height: 50rpx;
width: 120rpx;
font-size: $font-sm;
padding: 0;
line-height: 50rpx;
background-color: #ffffff;
margin-top: 80rpx;
&::after {
border-color: $main-color;
}
}
}
.store {
background-color: #fff;
border: 1px solid $border-color-light;
border-radius: 16rpx;
margin: 20rpx 10rpx;
.intro {
display: flex;
justify-content: space-between;
align-items: center;
padding: 0 30rpx 0 40rpx;
height: 170rpx;
.store-logo {
width: 102rpx;
height: 102rpx;
border-radius: 50%;
overflow: hidden;
image {
width: 100%;
height: 100%;
border-radius: 50%;
}
}
.store-name {
flex: 1;
margin-left: 30rpx;
line-height: 2em;
:first-child {
font-size: $font-base;
}
:last-child {
font-size: $font-sm;
color: #999;
}
}
.store-collect {
border-left: 1px solid $border-color-light;
padding-left: 20rpx;
text-align: center;
:last-child {
color: #999;
font-size: $font-sm;
}
}
}
}
.navbar {
display: flex;
height: 40px;
padding: 0 5px;
background: #fff;
box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
position: relative;
z-index: 10;
.nav-item {
flex: 1; flex: 1;
display: flex; display: flex;
justify-content: center; justify-content: center;
align-items: center; padding-right: 72rpx;
height: 100%;
font-size: 26rpx;
text {
position: relative;
}
text.current {
color: $light-color;
font-weight: bold;
font-size: 28rpx;
&::after {
content: "";
position: absolute;
left: 20rpx;
bottom: -10rpx;
width: 30rpx;
height: 0;
border-bottom: 2px solid $light-color;
}
}
} }
}
.content {
width: 100%;
}
.swiper-box {
overflow-y: auto;
}
.list-scroll-content {
height: 100%;
width: 100%;
}
/deep/ .u-swipe-content {
overflow: hidden;
}
.goods {
background-color: #fff;
border-bottom: 1px solid $border-color-light;
height: 190rpx;
display: flex;
align-items: center;
padding: 30rpx 20rpx;
margin-top: 20rpx;
image {
width: 131rpx;
height: 131rpx;
border-radius: 10rpx;
}
.goods-intro {
flex: 1;
font-size: $font-base;
line-height: 48rpx;
margin-left: 30rpx;
view:nth-child(1) {
line-height: 1.4em;
font-size: 24rpx;
max-height: 2.8em; //heightline-height
overflow: hidden;
color: #666;
}
view:nth-child(2) {
color: #cccccc;
font-size: 24rpx;
}
view:nth-child(3) {
color: $light-color;
}
}
button {
color: $main-color;
height: 50rpx;
width: 120rpx;
font-size: $font-sm;
padding: 0;
line-height: 50rpx;
background-color: #ffffff;
margin-top: 80rpx;
&::after {
border-color: $main-color;
}
}
}
.store {
background-color: #fff;
border: 1px solid $border-color-light;
border-radius: 16rpx;
margin: 20rpx 10rpx;
.intro {
display: flex;
justify-content: space-between;
align-items: center;
padding: 0 30rpx 0 40rpx;
height: 170rpx;
.store-logo {
width: 102rpx;
height: 102rpx;
border-radius: 50%;
overflow: hidden;
image {
width: 100%;
height: 100%;
border-radius: 50%;
}
}
.store-name {
flex: 1;
margin-left: 30rpx;
line-height: 2em;
:first-child {
font-size: $font-base;
}
:last-child {
font-size: $font-sm;
color: #999;
}
}
.store-collect {
border-left: 1px solid $border-color-light;
padding-left: 20rpx;
text-align: center;
:last-child {
color: #999;
font-size: $font-sm;
}
}
}
}
.navbar {
display: flex;
height: 40px;
padding: 0 5px;
background: #fff;
box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
position: relative;
z-index: 10;
.nav-item {
flex: 1;
display: flex;
justify-content: center;
align-items: center;
height: 100%;
font-size: 26rpx;
text {
position: relative;
}
text.current {
color: $light-color;
font-weight: bold;
font-size: 28rpx;
&::after {
content: "";
position: absolute;
left: 20rpx;
bottom: -10rpx;
width: 30rpx;
height: 0;
border-bottom: 2px solid $light-color;
}
}
}
}
</style> </style>