我的收藏布局修改

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