微信小程序---点餐小程序

wxml:

<!-- 幻灯片滚动效果 -->

<swiper indicator-dots autoplay interval="3000" duration="500">

  <block wx:for="{{lbt}}" wx:key="*this">

    <swiper-item>

      <image src="{{item}}" class="slide-image" />

    </swiper-item>

  </block>

</swiper>

<view class="title-list">

  <view wx:for="{{titles}}" wx:key="*this" bindtap="onTitleTap" 

  data-title="{{item}}" class="title-item">

    {{item}}

  </view>

</view>

wxss:

.slide-image {

  width: 100%;

}

.title-list{

  display: flex;

  flex-wrap: wrap;

  justify-content: space-between;

}

.title-item{

  width: calc(33.33% - 2px);

  height: 100px;

  text-align: center;

  display: flex;

  align-items: center;

  justify-content: center;

  border:1px solid #cfcdcd

}

//index.js

Page({

    data: {

      lbt:[

        '/images/1.jpg',

        '/images/2.jpg',

        '/images/3.jpg'

      ],

      titles: ['堂食 ', '外卖', '外带', '订单', '账单', '报表']

      

    },

  

    onTitleTap: function(e) {

      const title = e.currentTarget.dataset.title;

      wx.navigateTo({

        url: `/pages/dishes/dishes?title=${encodeURIComponent(title)}`

      });

    }

})

<!--pages/dishes/dishes.wxml-->

<view class="a">

  <!-- 侧边栏导航 -->

  <view class="aside">

    <block wx:for="{{zuoxx}}" wx:key="id">

      <text class="type nav {{fcurNav == item.id ? 'selected' : ''}}" bindtap="selectNav" data-id="{{item.id}}">{{item.name}}</text>

    </block>

  </view>

  <!-- 菜品列表 -->

  <view class="content">

  <block wx:for="{{dishesList[curIndex]}}" wx:key="id">

    <view class="dish flex-wrap flex-direction-row" bindtap="selectDish" data-dish="{{item.id}}">

      <view class="flex-item">

        <text class="title">{{item.name}}</text>

        <text class="q">¥{{item.price}}</text>

      </view>

      <view class="add-btn">

        <icon type="{{item.status ? 'success' : 'circle'}}" color="orange" size="30"/>

      </view>

    </view>

  </block>

</view>

</view>

  <!-- 底部购物车 -->

  <view class="cart">

    <text class="cart-text">购物车:{{cartCount}}</text>

  </view>

  <loading hidden="{{hidden}}">玩命加载中...</loading>

/* dishes.wxss */

.a {

  display: flex;

  width: 100%;

  height: 100%;

}

.aside {

  display: flex;

  flex-direction: column;

  background-color: rgb(238, 238, 238);

}

.type {

  padding: 10px;

  text-align: center;

  border-bottom: 1px solid #ddd;

}

.nav {

  cursor: pointer;

}

.selected {

  background-color: #fff;

}

.content {

  padding: 10px;

  background-color: #fff;

  width: 285px;

}

.dish {

  display: flex;

  justify-content: space-between;

  align-items: center;

  margin-bottom: 10px;

  padding: 10px;

  border-bottom: 2px solid rgb(231, 231, 231);

}

.flex-item {

  display: flex;

  flex-direction: column;

}

.title {

  font-size: 16px;

  color: #333;

}

.q{

  padding: 2px;

  font-size: 13px;

  color: rgb(245, 200, 1);

}

.add-btn {

  display: flex;

  align-items: center;

  width: 50px;

  height: 50px;

}

.cart {

  position: fixed;

  bottom: 0;

  width: 95%;

  height: 50px;

  background-color: rgb(233, 232, 232);

  align-items: center;

  font-size: 16px;

  color: #333;

  display: flex;

  margin: 10px;

}

.cart-text {

  font-size: 16px;

  color: #333;

  padding: 20px;

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

不知名小君

你的鼓励 将是我的动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值