更新记录

1.0.0(2022-08-25)

1、仿美团外卖商品列表。


平台兼容性

Vue2 Vue3
×
App 快应用 微信小程序 支付宝小程序 百度小程序 字节小程序 QQ小程序
× × × × × × ×
钉钉小程序 快手小程序 飞书小程序 京东小程序
× × × ×
H5-Safari Android Browser 微信浏览器(Android) QQ浏览器(Android) Chrome IE Edge Firefox PC-Safari
× × × × × × × × ×

仿美团外卖商品列表

简易实现美团外卖商品列表,没什么技术难点,简单来说就是两个scroll-view协作,并且两个scroll-view不会滑动冲突。

简介

左右两个scroll-view简易实现美团外卖商品列表功能。rightBar属性仅为示例,可根据实际数据结构二次开发

属性介绍

属性名 类型 默认值 必填 说明
shopOptions Object 商品列表整体数据。
shopList Array shopOptions下属性,不能单独使用
leftBar Object shopOptions下属性,不能单独使用
rightBar Object shopOptions下属性,不能单独使用

1、shopList

属性名 类型 默认值 必填 说明
shopList Array 商品列表数据。本文仅为示例,数据结构不同,可根据数据结构二次开发本插件。

2、leftBar

属性名 类型 默认值 必填 说明
leftBarWidth String 左部导航栏长度,例:25%、100px
leftBarBgColor String 左部导航栏背景色,例:red、#fff
leftBarItemHeight String 左部导航栏Item宽度,例:25px
leftBarItemFontSize String 左部导航栏Item字体大小,例:12px
leftBarItemSelectFontSize String 左部导航栏Item选择时字体大小,例:12px
leftBarItemFontWeight String 左部导航栏Item字体粗细,例:400
leftBarItemSelectFontWeight String 左部导航栏Item选择时字体粗细,例:400
leftBarItemFontColor String 左部导航栏Item字体颜色,例:red#fff
leftBarItemSelectFontColor String 左部导航栏Item选择时字体颜色,例:red#fff
leftBarItemBgColor String 左部导航栏Item背景颜色,例:red#fff
leftBarItemSelectBgColor String 左部导航栏Item选择时背景颜色,例:red#fff

3、rightBar

属性名 类型 默认值 必填 说明
rightBarWidth String 右部导航栏长度,例:75%、650px
rightBarBgColor String 右部导航栏背景色,例:red、#fff
rightBarItemImgWidth String 右部商品列表Item图片长宽,例:40px
rightBarItemTitleFontSize String 右部商品列表Item标题字体大小,例:12px
rightBarItemTitleFontWeight String 右部商品列表Item标题字体粗细,例:500
rightBarItemTitleFontColor String 右部商品列表Item标题字体颜色,例:red#fff
rightBarItemDesFontSize String 右部商品列表Item描述信息字体大小,例:12px
rightBarItemDesFontWeight String 右部商品列表Item描述信息字体粗细,例:500
rightBarItemDesFontColor String 右部商品列表Item描述信息字体颜色,例:red#fff
rightBarItemPriceFontSize String 右部商品列表Item价格字体大小,例:12px
rightBarItemPriceFontWeight String 右部商品列表Item价格字体粗细,例:500
rightBarItemPriceFontColor String 右部商品列表Item价格字体颜色,例:red#fff

事件介绍

事件名 说明
@rightBarItemClick 右部商品列表item点击事件。返回值event:{superIndex: 2, index: 0}superIndex:左部导航栏当前选择的下标,index:右部商品列表当前点击的下标。

使用示例

<view class="container">
        <bugking7-shop-view 
        :shopOptions="shopOptions" 
        @rightBarItemClick="handleRightClick"></bugking7-shop-view>
</view>

import tabbarItem from '@/pages/index/data.js'

data() {
    return {
        shopOptions: {
            shopList: tabbarItem.tabbarItem,
            leftBar:{
                leftBarWidth:'25%',
                leftBarBgColor:'',
                leftBarItemHeight:'40px',
                leftBarItemFontSize:'13px',
                leftBarItemSelectFontSize:'14px',
                leftBarItemFontWeight:'400',
                leftBarItemSelectFontWeight:'500',
                leftBarItemFontColor:'black',
                leftBarItemSelectFontColor:'#fff',
                leftBarItemBgColor:'#f5f5f5',
                leftBarItemSelectBgColor:'#2979ff'
            },
            rightBar:{
                rightBarWidth:'75%',
                rightBarBgColor:'white',
                rightBarItemImgWidth:'40px',
                rightBarItemTitleFontSize:'15px',
                rightBarItemTitleFontWeight:'500',
                rightBarItemTitleFontColor:'black',
                rightBarItemDesFontSize:'13px',
                rightBarItemDesFontWeight:'300',
                rightBarItemDesFontColor:'gray',
                rightBarItemPriceFontSize:'15px',
                rightBarItemPriceFontWeight:'600',
                rightBarItemPriceFontColor:'red',
            }
        }
    }
},
methods: {
    handleRightClick(e){
        console.log(e)
    }
}

数据结构示例(shopList)

本组件仅为示例,商品列表数据只为测试使用。如果要在项目中使用本组件,请根据数据结构二次开发注:shopList数据结构须与二次开发组件中右部商品列表v-for时一致。

export default {
    "tabbarItem": [
        {
            "name": "京东",
            "id": "jd",
            "list": [
                {
                    "title": "京东plus年卡",
                    "subTitle": "限时优惠",
                    "desc": "详情请点击>>>",
                    "price": "¥99",
                    "avatar": "https://vkceyugu.cdn.bspapp.com/VKCEYUGU-7c798a00-b51f-42a8-bcad-d38005229108/621c6953-882d-4bbc-9afa-9adcfcc99c9f.jpeg",
                    "link": "https://hulumengke.suyur.com/detail?tid=500507660&mid=600309072&categoryId=262&groupId=296&productId=8980413150410",
                    "type": "link",
                    "imgPath": ""
                },
                {
                    "title": "1号店年卡",
                    "subTitle": "领取12个月鸡蛋",
                    "desc": "详情请点击>>>",
                    "price": "¥188",
                    "avatar": "https://vkceyugu.cdn.bspapp.com/VKCEYUGU-7c798a00-b51f-42a8-bcad-d38005229108/57ce3357-2c6d-4c13-bd4f-ab851a6de4bd.jpeg",
                    "link": "https://hulumengke.suyur.com/detail?tid=500507660&mid=600309072&categoryId=262&groupId=296&productId=2380704173252",
                    "type": "link",
                    "imgPath": ""
                }
            ]
        },
        {
            "name": "腾讯视频",
            "id": "txsp",
            "list": [
                {
                    "title": "月卡",
                    "subTitle": "限时优惠",
                    "desc": "详情请点击>>>",
                    "price": "¥18",
                    "avatar": "https://vkceyugu.cdn.bspapp.com/VKCEYUGU-7c798a00-b51f-42a8-bcad-d38005229108/4bc77267-4982-44c3-8af9-19b2543329f2.jpeg",
                    "link": "https://hulumengke.suyur.com/detail?tid=500507660&mid=600309072&categoryId=157&groupId=106&productId=200309073",
                    "type": "link",
                    "imgPath": ""
                },
                {
                    "title": "季卡",
                    "subTitle": "限时优惠",
                    "desc": "详情请点击>>>",
                    "price": "¥50",
                    "avatar": "https://vkceyugu.cdn.bspapp.com/VKCEYUGU-7c798a00-b51f-42a8-bcad-d38005229108/4bc77267-4982-44c3-8af9-19b2543329f2.jpeg",
                    "link": "https://hulumengke.suyur.com/detail?tid=500507660&mid=600309072&categoryId=157&groupId=106&productId=200309074",
                    "type": "link",
                    "imgPath": ""
                }
            ]
        }
    ]
}

存在问题

1、右部商品列表滑动时,左部导航栏暂未实现实时定位

uniappscroll-view的滑动事件监听,暂未实现根据计算滑动距离改变左部导航栏实时定位。如果有好的实现方式,欢迎评论留言。

友情链接

二次元、动漫、游戏、cos、美女等壁纸免费下载,欢迎扫码体验
短视频免费去水印、藏头诗生成、星座运势、星座配对等,欢迎扫码体验
每日精选星座推文、在线客服,欢迎扫码关注

隐私、权限声明

1. 本插件需要申请的系统权限列表:

2. 本插件采集的数据、发送的服务器地址、以及数据用途说明:

插件不采集任何数据

3. 本插件是否包含广告,如包含需详细说明广告表达方式、展示频率:

许可协议

MIT协议

使用中有什么不明白的地方,就向插件作者提问吧~ 我要提问