用微信小程序写一个点餐首页,头部为搜素框,下面为轮播图,轮播图是动态的,在下面分为五个模块包含火锅,麻辣烫,米饭,鸡蛋,水果,底部为图片
时间: 2024-05-05 19:21:15 浏览: 5
好的,下面是一个简单的点餐首页的微信小程序代码:
```
<!--index.wxml-->
<view class="container">
<view class="search-bar">
<input class="search-input" placeholder="搜索菜品" />
</view>
<swiper class="swiper" indicator-dots="true" autoplay="true">
<block wx:for="{{swiperList}}" wx:key="index">
<swiper-item>
<image class="swiper-image" src="{{item}}" />
</swiper-item>
</block>
</swiper>
<view class="menu">
<view class="menu-item">
<image class="menu-image" src="火锅图片链接" />
<text class="menu-text">火锅</text>
</view>
<view class="menu-item">
<image class="menu-image" src="麻辣烫图片链接" />
<text class="menu-text">麻辣烫</text>
</view>
<view class="menu-item">
<image class="menu-image" src="米饭图片链接" />
<text class="menu-text">米饭</text>
</view>
<view class="menu-item">
<image class="menu-image" src="鸡蛋图片链接" />
<text class="menu-text">鸡蛋</text>
</view>
<view class="menu-item">
<image class="menu-image" src="水果图片链接" />
<text class="menu-text">水果</text>
</view>
</view>
<image class="bottom-image" src="底部图片链接" />
</view>
```
```
/* index.wxss */
.container {
display: flex;
flex-direction: column;
align-items: center;
width: 100%;
height: 100%;
background-color: #f5f5f5;
}
.search-bar {
display: flex;
justify-content: center;
align-items: center;
width: 100%;
height: 80rpx;
background-color: #ffffff;
}
.search-input {
width: 90%;
height: 60rpx;
padding: 0 20rpx;
border: none;
border-radius: 30rpx;
background-color: #f5f5f5;
font-size: 32rpx;
}
.swiper {
width: 100%;
height: 400rpx;
}
.swiper-image {
width: 100%;
height: 100%;
}
.menu {
display: flex;
justify-content: space-around;
align-items: center;
flex-wrap: wrap;
width: 100%;
height: 350rpx;
background-color: #ffffff;
}
.menu-item {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
width: 150rpx;
height: 150rpx;
}
.menu-image {
width: 80rpx;
height: 80rpx;
margin-bottom: 20rpx;
}
.menu-text {
font-size: 28rpx;
}
.bottom-image {
width: 100%;
height: 200rpx;
}
```
```
// index.js
Page({
data: {
swiperList: [
'轮播图1链接',
'轮播图2链接',
'轮播图3链接'
]
}
})
```
注意,上述代码中的图片链接需要替换为实际的图片链接。另外,还需要在 app.json 中配置首页路径。