| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231 |
- <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-34 fw-600">{{item.name}}</view>
- <view class="menu-list flex-justify-space" v-for="(info,k) in item.list" :key="k">
- <image src="@/static/img/my/bg.png" mode="scaleToFill"></image>
- <view class="menu-list-right">
- <view class="mb-40 text-overflow-ellipsis fs-34 fw-600">[畅销款]奥尔1良烤肉 牛油拌饭[畅销款]奥尔1良烤肉 牛油拌饭[畅销款]奥尔1良烤肉 牛油拌饭[畅销款]奥尔1良烤肉 牛油拌饭</view>
-
- <view class="flex-justify-space align-items-flex-end">
- <view class="">
- <span class="fs-24 fw-400 fc-FB3D03">¥</span>
- <span class="fs-40 fw-b fc-FB3D03">3.9</span>
- <span class="fs-24 fc-9 fw-400 text-line-through">¥12</span>
- </view>
- <view class="display-flex align-items-center">
- <view v-show="info.num > 0" class="right-only-right-red fw-500 text-align-center fs-36 fc-f" @click="addred(1,i,k,item)">-</view>
- <view v-show="info.num > 0" class="right-only-right-2 text-align-center fs-28 fw-400">{{info.num}}</view>
- <view class="right-only-right-add fw-500 text-align-center fs-36 fc-f" @click="addred(2,i,k,item)">+</view>
- </view>
- </view>
- </view>
- </view>
- </view>
- </view>
- </scroll-view>
-
-
-
-
- </view>
- </template>
- <script>
- import tools from "@/service/tools";
- export default {
- name:'menu-box',
- data(){
- return{
- idMark:'',//滚动自适应参数
-
- type:1,//分类标识
- typeList:[],
-
- menuList:[],
-
-
- }
- },
- mounted() {
- this.getTypeList();
- },
- methods:{
- getTypeList(){
- this.typeList = [
- {
- "category_id": 1,
- "name": "爆品推荐",
- "type": 1,
- },
- {
- "category_id": 2,
- "name": "必点口味",
- "type": 2
- },
- ]
- this.type = this.typeList[0].type;
- this.idMark = 'scroll'+ this.type;
- this.typeList.forEach((v)=>{
- v.num = 0
- })
-
- this.menuList = [
- {
- name:'分类1',
- type:1,
- list:[
- {name:1,num:0,spec:1},{name:2,num:0},{name:3,num:0},{name:4,num:0},
- ]
- },
- {
- name:'分类2',
- type:2,
- list:[
- {name:1,num:0},{name:2,num:0,spec:1},{name:3,num:0},{name:4,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 < 329&&v.top>0){
- _this.idMark = v.id;
- let arr = v.id.split('scroll');
- _this.type = Number(arr[1]);
- }
- })
- }).exec();
- },
- addred(type,i,k,item){
- if(type === 1){
- // 减
- this.menuList[i].list[k].num -= 1;
- this.setSub(item);
- }else if(type === 2){
- // 加
- this.menuList[i].list[k].num += 1;
- this.setSub(item);
- }
- },
- setSub(item){
- let num = 0;
- item.list.forEach((n)=>{
- num += n.num
- })
- this.typeList.forEach((v)=>{
- if(v.type == item.type){
- v.num = num
- }
- })
- },
-
-
- },
- }
- </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;
- image{
- width: 200rpx;
- height: 200rpx;
- border-radius: 12rpx;
- margin-right: 16rpx;
- }
- .menu-list-right{
- flex: 1;
- .right-only-right{
- width: 100rpx;
- height: 44rpx;
- background: linear-gradient( 117deg, #57CAFF 0%, #41ABF5 100%);
- border-radius: 12rpx;
- line-height: 44rpx;
- }
- .right-only-right-red{
- width: 44rpx;
- height: 44rpx;
- line-height: 40rpx;
- border-radius: 12rpx;
- border: 1rpx solid #41ABF5;
- color: #41ABF5;
- }
- .right-only-right-add{
- width: 44rpx;
- height: 44rpx;
- line-height: 40rpx;
- background: linear-gradient( 117deg, #57CAFF 0%, #41ABF5 100%);
- border-radius: 12rpx;
- }
- .right-only-right-2{
- min-width: 50rpx;
- }
- }
- }
- }
- }
- </style>
|