The front-end Vue imitates the screen box popup alert on the right side of the Meituan sidebar

With the development of technology, the complexity of development is getting higher and higher. The traditional development method makes a system into a whole application. It often happens that a small change or a small function increase may cause the overall logic to change. Modifications, causing the whole body to be affected by a single hair.

Through component development, separate development and maintenance can be effectively realized, and they can be combined at will. Greatly improve development efficiency and reduce maintenance costs.

Today I will introduce a component that imitates the filter box popup alert on the right side of Meituan; the source code download address is attached : https://ext.dcloud.net.cn/plugin?id=13602

The renderings are as follows:

[External link picture transfer failed, the source site may have an anti-leeching mechanism, it is recommended to save the picture and upload it directly (img-dCgLNhgW-1689509203340)(https://p3-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp /80811c30cb684ed0bbedf7dca0c3337e~tplv-k3u1fbpfcp-zoom-1.image)]

The implementation code is as follows

cc-rightPopup

Instructions


<!-- pop-show:是否显示弹框  color:主题色 classList:分类数组 @sureClick:筛选确认 @hideClick:隐藏事件  -->

<cc-rightPopup :pop-show="popShow" :colors="colors" :classList="classList" @sureClick="sureClick"

@hideClick="hideright"></cc-rightPopup>

// 隐藏处理

hideright() {

this.popShow = false;

},

// 筛选确认

sureClick(paramDict, selArr) {

this.popShow = false;

uni.showModal({

title: '筛选数据',

    content: '筛选价格数据 = ' + JSON.stringify(paramDict) + ' 筛选按钮数据= ' + JSON.stringify(selArr)

})

}

HTML code implementation part


<template>

<view class="content">

<button style="margin: 60px 90px;" @click="showPopClick">点击弹框</button>

<!-- pop-show:是否显示弹框  color:主题色 classList:分类数组 @sureClick:筛选确认 @hideClick:隐藏事件  -->

<cc-rightPopup :pop-show="popShow" :colors="colors" :classList="classList" @sureClick="sureClick"

@hideClick="hideright"></cc-rightPopup>

</view>

</template>

<script>

export default {
     
     

data() {
     
     

return {
     
     

colors: '#fa436a',

popShow: false,

classList: [{
     
     

name: '营业事件',

id: 1,

child: [{
     
     

name: '0-5时',

id: 2

}, {
     
     

name: '5-10时',

id: 3

}, {
     
     

name: '10-14时',

id: 2

}, {
     
     

name: '14-18时',

id: 3

}, {
     
     

name: '18-22时',

id: 2

}, {
     
     

name: '22-24时',

id: 3

}]

}, {
     
     

name: '用餐人数',

id: 2,

child: [{
     
     

name: '单人餐',

id: 1

}, {
     
     

name: '双人餐',

id: 2

}, {
     
     

name: '3-4人餐',

id: 2

},

{
     
     

name: '5-10人餐',

id: 2

}

]

}],

}

},

methods: {
     
     

showPopClick() {
     
     

this.popShow = true;

},

hideright() {
     
     

this.popShow = false;

},

sureClick(paramDict, selArr) {
     
     

this.popShow = false;

uni.showModal({
     
     

title: '筛选数据',

content: '筛选价格数据 = ' + JSON.stringify(paramDict) + ' 筛选按钮数据= ' + JSON.stringify(selArr)

})

}

}

}

</script>

<style>

page {
     
     

background-color: #f2f2f2;

margin-bottom: 50px;

}

</style>

Guess you like

Origin blog.csdn.net/chenchuang0128/article/details/131754284