1.(1)这是目录结构。、
2.(2)只写了一个index页面。
3.——这个页面的布局分为上下两部分。上面一部分是一个view,里面嵌套了3个view,用来切换tab的。
4.——下面是内容区域。用了小程序的swiper控件,swiper控件里面放置的是scroll-view控件。这里面设置的高度用的是百分比,这存在一定的问题。不如css3可以混用百分比和数值来的方便,虽然这种方式存在兼容性问题。
5.——index.wxml。
viewclass="recipe_tabs"viewclass="recipe_tab{{currentTab==0?'recipe_tab_active':''}}"data-current="0"bindtap="swipeContent"早餐/viewviewclass="recipe_tab{{currentTab==1?'recipe_tab_active':''}}"data-current="1"bindtap="swipeContent"午餐/viewviewclass="recipe_tab{{currentTab==2?'recipe_tab_active':''}}"data-current="2"bindtap="swipeContent"咖吧/view/viewswipercurrent="{{currentTab}}"class="swiper_container"bindchange="swiperChange"swiper-itemscroll-viewscroll-ystyle="height:100%"viewclass="recipe_cell"wx:for="{{breakfests}}"imageclass="recipe_img"src="{{item.RECIPE_IMG}}"/imageviewclass="recipe_name"{{item.RECIPE_NAME}}/view/view/scroll-view/swiper-itemswiper-itemscroll-viewscroll-ystyle="height:100%"viewclass="recipe_cell"wx:for="{{lunches}}"imageclass="recipe_img"src="{{item.RECIPE_IMG}}"/imageviewclass="recipe_name"{{item.RECIPE_NAME}}/view/view/scroll-view/swiper-itemswiper-itemscroll-viewscroll-ystyle="height:100%"viewclass="recipe_cell"wx:for="{{desserts}}"imageclass="recipe_img"src="{{item.RECIPE_IMG}}"/imageviewclass="recipe_name"{{item.RECIPE_NAME}}/view/view/scroll-view/swiper-item/swiper6.(3)样式没什么好说的,index.wxss。
/**index.wxss**/page{background-color:#EEEEEE;height:100%;}/*recipe_tab*/.recipe_tabs{background-color:#FFFFFF;height:7%;}.recipe_tab{display:inline-block;width:20%;height:80rpx;line-height:80rpx;text-align:center;margin-left:10%;}.recipe_tab_active{color:red;font-weight:700;border-bottom:4rpxsolidred;}/*content*/.swiper_container{height:93%;overflow:hidden;}.recipe_cell{background-color:#FFFFFF;width:100%;padding-bottom:20rpx;margin-top:14rpx;}.recipe_img{width:94%;height:400rpx;padding:3%;}.recipe_name{padding-left:3%;line-height:60rpx;}/*app_tab*/.app_tab{height:9%;background-color:red;}7.(4)微信小程序除了布局之外,基本都是js的内容。其实小程序的开发和AngularJS十分相似。
8.——这里面用到了微信自带的util.js文件里的格式化日期,但是和服务器要求的日期格式还是有点差别,所以我们在此基础上再格式化了一下。
//index.js//获取应用实例varapp=getApp();varutil=require('../../utils/util.js');Page({data:{//初始化数据breakfests:[],lunches:[],desserts:[],currentTab:0,currentDate:''},//点击切换swipeContent:function(e){var_this=this;if(this.data.currentTab!=e.target.dataset.current){_this.setData({currentTab:e.target.dataset.current,});}},swiperChange:function(e){var_this=this;_this.setData({currentTab:e.detail.current,});},//页面加载的时候执行onLoad:function(){var_this=this;//获取当前日期varcurrD=util.formatTime(newDate());_this.setData({//2017/07/1412:12:12currentDate:currD.substr(0,4)+"-"+currD.substr(5,2)+"-"+currD.substr(8,2),});//发送请求wx.request({url:'http://xxx',method:'POST',data:{userId:'xxx',date:this.data.currentDate,mealId:0,pageIndex:1,pageSize:100},success:function(res){_this.setData({breakfests:res.data.data});}});//发送请求wx.request({url:'http://xxx',method:'POST',data:{userId:'xxx',date:this.data.currentDate,mealId:1,pageIndex:1,pageSize:100},success:function(res){_this.setData({lunches:res.data.data});}});//发送请求wx.request({url:'http://xxx',method:'POST',data:{userId:'xxx',date:this.data.currentDate,mealId:2,pageIndex:1,pageSize:100},success:function(res){_this.setData({desserts:res.data.data});}});}})
微信小程序餐饮案例-微信小程序快速开发-食堂菜单案例-微信小程序实例
浏览量:2741
时间:
来源:喂-不吃素的熊宝宝
版权声明
即速应用倡导尊重与保护知识产权。如发现本站文章存在版权问题,烦请提供版权疑问、身份证明、版权证明、联系方式等发邮件至197452366@qq.com ,我们将及时处理。本站文章仅作分享交流用途,作者观点不等同于即速应用观点。用户与作者的任何交易与本站无关,请知悉。
最新资讯
-

即速应用,赋能企业玩转微信小程序智慧经营
作为国内领军的智慧商业经营服务商,即速应用始终秉承“让每个企业都拥有自己的智慧店铺”的愿景,持续赋能更多企业玩转智慧经营。即速应用旗下拥有“小程序搭建工具-即速应用”、“私域流量专家-即客云”等产品,帮助商家打通互联网全生态营销闭环。 -

即客云2.0重磅更新,让微信小程序运营更简单!
即客云作为一款基于企业微信的第三方工具,现从多维度提供超过30种功能,自上线以来,已服务多家企业,受到一致好评。近期,我们根据客户反馈和市场调研正式推出升级版 即客云2.0!更新了私域运营SOP,群日历功能,批量拓客,客户雷达,消息推送,个人欢迎语,帮助企业更好运用企业微信;同时提升了社群运营工作标准化,提升运营效率,帮助企业实现客户增长,玩转私域流量。 -

零代码 + AI 双轮驱动|即速应用解锁人工智能小程序开发新范式
无需代码、无需 AI 算法功底,普通人也能快速搭建智能小程序。即速应用将人工智能与零代码开发深度融合,推出 AI 智能生成能力,用户通过自然语言描述需求,AI 自动生成小程序页面、功能模块与后台配置,覆盖商城、预约、同城、社区团购等全场景。平台内置 AI 智能推荐、智能客服、用户画像分析等能力,一键对接微信生态,打通视频号、企业微信、短信跳转,帮企业快速落地 AI 应用,抢占智慧经营先机,让每家企业都拥有 AI 驱动的智慧店铺。












