|
|
@@ -0,0 +1,186 @@
|
|
|
+<template>
|
|
|
+ <view class="menu-box flex-justify-space">
|
|
|
+ <scroll-view scroll-y="true" class="menu-box-left" :scroll-into-view="idMark" :scroll-with-animation='true'>
|
|
|
+ <view class="menu-type-list-f">
|
|
|
+ <view class="menu-type-list fs-28 fc-6 text-align-center" v-for="(item,i) in typeList" :key="i" @click="selectType(item)"
|
|
|
+ :class="type === item.type?'bgc-BCEAFF':''" :id="'scroll'+ item.type">
|
|
|
+ {{item.name}}
|
|
|
+ <view class="menu-type-num fc-f" v-show="item.num > 0">{{item.num > 99?'99+':item.num}}</view>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+
|
|
|
+ </scroll-view>
|
|
|
+
|
|
|
+ <scroll-view scroll-y="true" :scroll-with-animation='true' :scroll-into-view="idMark" @scroll="menuScroll">
|
|
|
+ <view class="menu-box-right">
|
|
|
+ <view class="menu-box-only" v-for="(item,i) in menuList" :key="i" :id="'scroll'+ item.type">
|
|
|
+ <view class="mb-18 fs-24">{{item.name}}</view>
|
|
|
+ <view class="menu-list" v-for="(info,k) in item.list" :key="k">
|
|
|
+ {{info.name}}
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+ </scroll-view>
|
|
|
+ </view>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+
|
|
|
+ export default {
|
|
|
+ name:'menu-box',
|
|
|
+ data(){
|
|
|
+ return{
|
|
|
+ idMark:'',//滚动自适应参数
|
|
|
+
|
|
|
+ type:1,//分类标识
|
|
|
+ typeList:[],
|
|
|
+
|
|
|
+ menuList:[
|
|
|
+ {
|
|
|
+ name:'分类1',
|
|
|
+ type:1,
|
|
|
+ list:[
|
|
|
+ {name:1,},{name:2,},{name:3,},{name:4,},
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name:'分类2',
|
|
|
+ type:2,
|
|
|
+ list:[
|
|
|
+ {name:1,},{name:2,},{name:3,},{name:4,},
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name:'分类3',
|
|
|
+ type:3,
|
|
|
+ list:[
|
|
|
+ {name:1,},{name:2,},{name:3,},{name:4,},
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name:'分类4',
|
|
|
+ type:4,
|
|
|
+ list:[
|
|
|
+ {name:1,},{name:2,},{name:3,},{name:4,},
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name:'分类5',
|
|
|
+ type:5,
|
|
|
+ list:[
|
|
|
+ {name:1,},{name:2,},{name:3,},{name:4,},
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ }
|
|
|
+ },
|
|
|
+ mounted() {
|
|
|
+ this.getTypeList();
|
|
|
+ },
|
|
|
+ methods:{
|
|
|
+ getTypeList(){
|
|
|
+ this.typeList = [
|
|
|
+ {
|
|
|
+ "category_id": 1,
|
|
|
+ "name": "爆品推荐爆爆品推荐爆爆品推荐爆",
|
|
|
+ "type": 1,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "category_id": 2,
|
|
|
+ "name": "必点口味必点口味必点口味必点口味必点口味",
|
|
|
+ "type": 2
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "category_id": 3,
|
|
|
+ "name": "爆品推荐爆爆品推荐爆爆品推荐爆",
|
|
|
+ "type": 3,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "category_id": 4,
|
|
|
+ "name": "必点口味必点口味必点口味必点口味必点口味",
|
|
|
+ "type": 4
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "category_id": 5,
|
|
|
+ "name": "必点口味必点口味必点口味必点口味必点口味",
|
|
|
+ "type": 5
|
|
|
+ },
|
|
|
+ ]
|
|
|
+ this.type = this.typeList[0].type;
|
|
|
+ this.idMark = 'scroll'+ this.type;
|
|
|
+ this.typeList.forEach((v)=>{
|
|
|
+ v.num = 0
|
|
|
+ })
|
|
|
+ },
|
|
|
+
|
|
|
+ selectType(item){
|
|
|
+ if(this.type != item.type){
|
|
|
+ this.type = item.type;
|
|
|
+ this.idMark = 'scroll'+ item.type
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ menuScroll(){
|
|
|
+ let _this = this;
|
|
|
+ let query = uni.createSelectorQuery().in(this);
|
|
|
+ query.selectAll(".menu-box-only").boundingClientRect(data=>{
|
|
|
+ data.forEach((v)=>{
|
|
|
+ if(v.top < 297&&v.top>0){
|
|
|
+ _this.idMark = v.id;
|
|
|
+ let arr = v.id.split('scroll');
|
|
|
+ _this.type = Number(arr[1]);
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }).exec();
|
|
|
+ },
|
|
|
+ },
|
|
|
+ }
|
|
|
+</script>
|
|
|
+
|
|
|
+<style scoped lang="scss">
|
|
|
+ .menu-box{
|
|
|
+ height: 100%;
|
|
|
+ .menu-box-left{
|
|
|
+ width: 176rpx;
|
|
|
+ height: 100%;
|
|
|
+ background-color: #F7F8FA;
|
|
|
+ border-radius: 0rpx 20rpx 0 0rpx;
|
|
|
+ .menu-type-list-f{
|
|
|
+ width: 176rpx;
|
|
|
+ height: 100%;
|
|
|
+ .menu-type-list{
|
|
|
+ width: 176rpx;
|
|
|
+ min-height: 10rpx;
|
|
|
+ box-sizing: border-box;
|
|
|
+ padding: 14rpx 32rpx;
|
|
|
+ position: relative;
|
|
|
+ .menu-type-num{
|
|
|
+ position: absolute;
|
|
|
+ top: 2rpx;
|
|
|
+ right: 8rpx;
|
|
|
+ padding: 0 6rpx;
|
|
|
+ min-width: 20rpx;
|
|
|
+ height: 32rpx;
|
|
|
+ text-align: center;
|
|
|
+ line-height: 32rpx;
|
|
|
+ background: #FB3D03;
|
|
|
+ border-radius: 50%;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ .menu-box-right{
|
|
|
+ flex: 1;
|
|
|
+ height: 100%;
|
|
|
+ box-sizing: border-box;
|
|
|
+ padding: 0 16rpx;
|
|
|
+ .menu-list{
|
|
|
+ width: 100%;
|
|
|
+ height: 200rpx;
|
|
|
+ margin-bottom: 40rpx;
|
|
|
+ background-color: skyblue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+</style>
|