我的收藏布局修改

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,56 +1,53 @@
<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>
</view>
<view class="swiper-box"> <view class="swiper-box">
<!-- 显示商品栏 --> <!-- 显示商品栏 -->
<view v-if="tabCurrentIndex == 0" class="tab-content"> <view v-if="tabCurrentIndex == 0" class="tab-content">
<scroll-view class="list-scroll-content" scroll-y @scrolltolower="loadMore"> <scroll-view class="list-scroll-content" scroll-y>
<!-- 空白页 --> <!-- 空白页 -->
<u-empty style="margin-top:40rpx;" text="暂无收藏商品数据" mode="favor" v-if="goodsEmpty"></u-empty> <u-empty style="margin-top: 40rpx" text="暂无收藏商品数据" mode="favor" v-if="goodsEmpty"></u-empty>
<!-- 商品展示数据 --> <!-- 商品展示数据 -->
<u-swipe-action @open="openLeftChange(item,index,'goods')" :show="item.selected" btn-width="180" <u-swipe-action @open="openLeftChange(item, index, 'goods')" :show="item.selected" btn-width="180"
:options="LeftOptions" v-else v-for="(item,index) in goodList" @click="clickGoodsSwiperAction(item,index)" :options="LeftOptions" v-else v-for="(item, index) in goodList"
:index="index" :key="index"> @click="clickGoodsSwiperAction(item, index)" :index="index" :key="index">
<view class="goods" @click="goGoodsDetail(item)"> <view class="goods" @click="goGoodsDetail(item)">
<u-image width="131rpx" height="131rpx" :src="item.image" mode="aspectFit"> <u-image width="131rpx" height="131rpx" :src="item.image" mode="aspectFit">
<u-loading slot="loading"></u-loading> <u-loading slot="loading"></u-loading>
</u-image> </u-image>
<view class="goods-intro"> <view class="goods-intro">
<view>{{item.goodsName}}</view> <view>{{ item.goodsName }}</view>
<view class="goods-sn">{{item.goods_sn}}</view> <view class="goods-sn">{{ item.goods_sn }}</view>
<view>{{item.price | unitPrice}}</view> <view>{{ item.price | unitPrice }}</view>
</view> </view>
</view> </view>
</u-swipe-action> </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 @scrolltolower="loadMore"> <scroll-view class="list-scroll-content" scroll-y>
<!-- 空白页 --> <!-- 空白页 -->
<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" mode="aspectFit"> <u-image width="102rpx" height="102rpx" :src="item.storeLogo" :alt="item.storeName"
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>
@ -58,7 +55,6 @@
</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>
@ -66,45 +62,43 @@
</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
{ {
text: "商品(0)", name: "商品(0)",
loadingType: "more",
params: { params: {
pageNumber: 1, pageNumber: 1,
pageSize: 10, pageSize: 10,
}, },
}, },
{ {
text: "店铺(0)", name: "店铺(0)",
loadingType: "more",
params: { params: {
pageNumber: 1, pageNumber: 1,
pageSize: 10, pageSize: 10,
}, },
}, },
], ],
goodsLoad: "more", //
storeLoad: "more", //
goodsEmpty: false, // goodsEmpty: false, //
storeEmpty: false, // storeEmpty: false, //
goodList: [], // goodList: [], //
@ -115,13 +109,25 @@ export default {
this.getGoodList(); this.getGoodList();
this.getStoreList(); this.getStoreList();
}, },
onReachBottom() {
if (this.tabCurrentIndex == 0) {
this.navList[0].params.pageNumber++;
this.getGoodList();
} else {
this.navList[1].params.pageNumber++;
this.getStoreList();
}
},
methods: { methods: {
/** /**
* 打开商品左侧取消收藏 * 打开商品左侧取消收藏
*/ */
openLeftChange(val, type) { openLeftChange(val, type) {
const { goodList, storeList } = this; const {
goodList,
storeList
} = this;
let way; let way;
type == "goods" ? (way = goodList) : (way = storeList); type == "goods" ? (way = goodList) : (way = storeList);
way.forEach((item) => { way.forEach((item) => {
@ -147,7 +153,7 @@ export default {
/** /**
* 点击店铺左侧取消收藏 * 点击店铺左侧取消收藏
*/ */
clickstoreSwiperAction(val) { clickStoreSwiperAction(val) {
deleteStoreCollection(val.storeId).then((res) => { deleteStoreCollection(val.storeId).then((res) => {
if (res.statusCode == 200) { if (res.statusCode == 200) {
this.storeList = []; this.storeList = [];
@ -176,7 +182,7 @@ export default {
/** /**
* 查看店铺详情 * 查看店铺详情
*/ */
gostoreMainPage(id) { goStoreMainPage(id) {
// //
uni.navigateTo({ uni.navigateTo({
url: "/pages/product/shopPage?id=" + id, url: "/pages/product/shopPage?id=" + id,
@ -196,7 +202,8 @@ export default {
if (res.data.success) { if (res.data.success) {
let data = res.data.result; let data = res.data.result;
data.selected = false; data.selected = false;
this.navList[0].text = `商品(${data.total})`; this.navList[0].name = `商品(${data.total})`;
if (data.total == 0) { if (data.total == 0) {
this.goodsEmpty = true; this.goodsEmpty = true;
} else if (data.total < 10) { } else if (data.total < 10) {
@ -223,32 +230,16 @@ export default {
if (res.data.success) { if (res.data.success) {
let data = res.data.result; let data = res.data.result;
data.selected = false; data.selected = false;
this.navList[1].text = `店铺(${data.total})`; this.navList[1].name = `店铺(${data.total})`;
if (data.total == 0) { if (data.total == 0) {
this.storeEmpty = true; this.storeEmpty = true;
} else if (data.total < 10) { } else if (data.total < 10) {
this.storeLoad = "noMore";
this.storeList.push(...data.records); this.storeList.push(...data.records);
} else {
this.storeList.push(...data.records);
if (data.total.length < 10) this.storeLoad = "noMore";
} }
} }
}); });
}, },
/**
* 底部加载更多
*/
loadMore() {
if (this.tabCurrentIndex == 0) {
this.navList[0].params.pageNumber++;
this.getGoodList();
} else {
this.navList[1].params.pageNumber++;
this.getStoreList();
}
},
}, },
/** /**
@ -265,32 +256,41 @@ export default {
this.getStoreList(); 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{
flex: 1;
display: flex;
justify-content: center;
padding-right: 72rpx;
}
.content {
width: 100%;
}
.swiper-box {
overflow-y: auto;
}
.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;
@ -298,11 +298,13 @@ page,
align-items: center; align-items: center;
padding: 30rpx 20rpx; padding: 30rpx 20rpx;
margin-top: 20rpx; margin-top: 20rpx;
image { image {
width: 131rpx; width: 131rpx;
height: 131rpx; height: 131rpx;
border-radius: 10rpx; border-radius: 10rpx;
} }
.goods-intro { .goods-intro {
flex: 1; flex: 1;
font-size: $font-base; font-size: $font-base;
@ -316,14 +318,17 @@ page,
overflow: hidden; overflow: hidden;
color: #666; color: #666;
} }
view:nth-child(2) { view:nth-child(2) {
color: #cccccc; color: #cccccc;
font-size: 24rpx; font-size: 24rpx;
} }
view:nth-child(3) { view:nth-child(3) {
color: $light-color; color: $light-color;
} }
} }
button { button {
color: $main-color; color: $main-color;
height: 50rpx; height: 50rpx;
@ -333,16 +338,19 @@ page,
line-height: 50rpx; line-height: 50rpx;
background-color: #ffffff; background-color: #ffffff;
margin-top: 80rpx; margin-top: 80rpx;
&::after { &::after {
border-color: $main-color; border-color: $main-color;
} }
} }
} }
.store {
.store {
background-color: #fff; background-color: #fff;
border: 1px solid $border-color-light; border: 1px solid $border-color-light;
border-radius: 16rpx; border-radius: 16rpx;
margin: 20rpx 10rpx; margin: 20rpx 10rpx;
.intro { .intro {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
@ -355,36 +363,43 @@ page,
height: 102rpx; height: 102rpx;
border-radius: 50%; border-radius: 50%;
overflow: hidden; overflow: hidden;
image { image {
width: 100%; width: 100%;
height: 100%; height: 100%;
border-radius: 50%; border-radius: 50%;
} }
} }
.store-name { .store-name {
flex: 1; flex: 1;
margin-left: 30rpx; margin-left: 30rpx;
line-height: 2em; line-height: 2em;
:first-child { :first-child {
font-size: $font-base; font-size: $font-base;
} }
:last-child { :last-child {
font-size: $font-sm; font-size: $font-sm;
color: #999; color: #999;
} }
} }
.store-collect { .store-collect {
border-left: 1px solid $border-color-light; border-left: 1px solid $border-color-light;
padding-left: 20rpx; padding-left: 20rpx;
text-align: center; text-align: center;
:last-child { :last-child {
color: #999; color: #999;
font-size: $font-sm; font-size: $font-sm;
} }
} }
} }
} }
.navbar {
.navbar {
display: flex; display: flex;
height: 40px; height: 40px;
padding: 0 5px; padding: 0 5px;
@ -392,6 +407,7 @@ page,
box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06); box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
position: relative; position: relative;
z-index: 10; z-index: 10;
.nav-item { .nav-item {
flex: 1; flex: 1;
display: flex; display: flex;
@ -403,10 +419,12 @@ page,
text { text {
position: relative; position: relative;
} }
text.current { text.current {
color: $light-color; color: $light-color;
font-weight: bold; font-weight: bold;
font-size: 28rpx; font-size: 28rpx;
&::after { &::after {
content: ""; content: "";
position: absolute; position: absolute;
@ -418,5 +436,5 @@ page,
} }
} }
} }
} }
</style> </style>