罗世杰:feat:完成Dropdown组件的封装 fix:更改了pubulishSlide的样式bug

This commit is contained in:
LuoShijie
2023-11-09 21:32:48 +08:00
parent fb0f606ffc
commit 10802093b5
6 changed files with 159 additions and 28 deletions

View File

@@ -1,14 +1,15 @@
<template>
<view class="container">
<view class="tabs-bg"/>
<view class="tabs">
<view
class="title-view"
v-for="(item, index) in title"
:key="item"
@click="changeActiveIndex(index)"
:class="{isActive: activeIndex === index}"
>
<text>{{item}}</text>
<!-- <text>{{index}}</text> -->
<view class="arrow" v-if="activeIndex !== index">
<u-image src="/static/dropdown/dp_icon_lxia.png" width="14rpx" height="11rpx"/>
</view>
@@ -18,27 +19,51 @@
</view>
</view>
<view class="item-border">
<DropDownItem v-if="activeIndex !== -1" :list="tablist"/>
</view>
</view>
</template>
<script>
/**
* @property {Array} postlist 传递一个二维数组
*/
import DropDownItem from "./DropDownItem.vue"
export default {
name:"DropDown",
components: {
DropDownItem
},
props: {
postlist: {
type:Array,
default(){
return [['全部', '餐饮美食', '百货超市', '美容美发'],['区域1', '区域2', '区域3', '区域4'],['100m2','200m2','300m2'],['附近的', '最新发布的', '其他']]
}
}
},
data() {
return {
title: ['行业','区域','面积','筛选'],
activeIndex: -1
activeIndex: -1,
// postlist: [['全部', '餐饮美食', '百货超市', '美容美发'],['区域1', '区域2', '区域3', '区域4'],['100m2','200m2','300m2'],['附近的', '最新发布的', '其他']]
};
},
computed: {
tablist: function() {
return this.postlist[this.activeIndex]
}
},
methods: {
changeActiveIndex(index){
if(this.activeIndex === index){
this.activeIndex = -1;
}
this.activeIndex = index
}else
this.activeIndex = index
}
}
},
}
</script>
@@ -47,12 +72,23 @@
color: #CC3333;
}
.container{
margin-top: 10px;
position: relative;
.tabs-bg {
position: absolute;
background-color: $uni-bg-color-grey;
height: 120rpx;
width: 100%;
transform: translateY(-20rpx);
z-index: 2;
}
.tabs{
background-color: #fff;
height: 100rpx;
display: flex;
justify-content: space-around;
position: relative;
z-index: 3;
}
.title-view {
display: flex;
@@ -70,5 +106,9 @@
justify-content: center;
}
}
.item-border{
position: absolute;
width: 100%;
height: 100%;
}
</style>

View File

@@ -1,18 +1,69 @@
<template>
<view class="root">
<view class="mask"/>
<view class="list-container">
<view
class="item"
v-for="(item,index) in list"
>
<view></view>
<text class="list-text">{{item}}</text>
</view>
</view>
</view>
</template>
<script>
export default {
props: {
list: {
type: Array,
default(){
return []
}
}
}
}
</script>
<style lang="scss" scoped>
.mask{
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: #000;
-webkit-backdrop-filter:saturate(150%) blur(8px);
background-color:rgba(0,0,0,.3);
z-index: 20;
}
.root {
width: 100%;
height: calc(100% - 300rpx);
background-color: magenta;
position: absolute;
z-index: 4;
top: 0;
width: 100%;
font-size: 28rpx;
background-color: #fff;
position: absolute;
z-index: 1;
.list-container {
position: relative;
background-color: #fff;
width: 100%;
z-index: 21;
border-radius: 0px 0px 20px 20px;
.item {
border-top: 1px solid #EEEEEE;
font-weight: 500;
padding-left: 61rpx;
height: 80rpx;
display: flex;
flex-direction: column;
justify-content: center;
}
}
}
</style>

View File

@@ -1,5 +1,5 @@
<template>
<view>
<view class="input-and-swiper-root">
<view class="search-box">
<view class="search-box-input">
<u-input placeholder="热门搜索" placeholder-style="color: #969696" prefixIcon="search"
@@ -133,6 +133,10 @@
</script>
<style lang="scss">
.input-and-swiper-root {
position: relative;
z-index: 2;
}
.search-box {
position: absolute;
z-index: 1;

View File

@@ -60,7 +60,7 @@
}
</script>
<style lang="scss">
<style lang="scss" scoped>
.mask{
position: fixed;
top: 0;

View File

@@ -1,12 +1,17 @@
<template>
<view class="root">
<InputAndSwiper></InputAndSwiper>
<view class="content">
<view style="margin-top: 10px;">
<view>
<view class="dropdown-bug">
</view>
<view class="marginLR10">
<DropDown></DropDown>
</view>
<SearchShopList :showStyle="1"></SearchShopList>
<view class="marginLR10">
<SearchShopList :showStyle="1"/>
</view>
</view>
<TabBar :current-page="3"></TabBar>
@@ -14,7 +19,11 @@
</template>
<script>
import DropDownItem from "@/components/DropDown/DropDownItem.vue"
export default {
components: {
DropDownItem
},
data() {
return {
@@ -26,11 +35,23 @@
}
</script>
<style lang="scss">
<style lang="scss" scoped>
page {
background-color: $uni-bg-color-grey;
}
.content{
.root{
position: relative;
}
.dropdown-bug {
position: absolute;
background-color: $uni-bg-color-grey;
height: 120rpx;
width: 100%;
transform: translateY(-20rpx);
z-index: 2;
}
.marginLR10{
margin: 0 10px;
}
</style>

View File

@@ -2,14 +2,18 @@
<view class="root">
<InputAndSwiper></InputAndSwiper>
<view class="content">
<view style="margin-top: 10px;">
<view>
<view class="dropdown-bug">
</view>
<view class="marginLR10">
<DropDown></DropDown>
</view>
<ShowShopList :showStyle="1"></ShowShopList>
<view class="marginLR10">
<ShowShopList :showStyle="1"></ShowShopList>
</view>
</view>
<DropDownItem></DropDownItem>
<TabBar :current-page="1"></TabBar>
</view>
</template>
@@ -31,11 +35,22 @@
}
</script>
<style lang="scss">
<style lang="scss" scoped>
page {
background-color: $uni-bg-color-grey;
}
.content{
.root{
position: relative;
}
.dropdown-bug {
position: absolute;
background-color: $uni-bg-color-grey;
height: 120rpx;
width: 100%;
transform: translateY(-20rpx);
z-index: 2;
}
.marginLR10{
margin: 0 10px;
}