var app = getApp()
Page({
data: {
hidden:false,
curNav:1,
curIndex:0,
cart:[],
cartTotal:0,
navList:[
{
id:1,
name:'热销菜品'
},
{
id:2,
name:'热菜'
},
{
id:3,
name:'凉菜'
},
{
id:4,
name:'套餐'
}
],
dishesList:[
[
{
name:"红烧肉",
price:38,
num:1,
id:1
},
{
name:"宫保鸡丁",
price:58,
num:1,
id:29
},
{
name:"水煮鱼",
price:88,
num:1,
id:2
}
],
[
{
name:"小炒日本豆腐",
price:18,
num:1,
id:3
},
{
name:"烤鱼",
price:58,
num:1,
id:4
}
],
[
{
name:"大拌菜",
price:18,
num:1,
id:5
},
{
name:"川北凉粉",
price:8,
num:1,
id:6
}
],
[]
],
dishes:[]
},
loadingChange () {
setTimeout(() => {
this.setData({
hidden:true
})
},2000)
},
selectNav (event) {
let id = event.target.dataset.id,
index = parseInt(event.target.dataset.index);
self = this;
this.setData({
curNav:id,
curIndex:index
})
},
// 选择菜品
selectDish (event) {
let dish = event.currentTarget.dataset.dish;
let flag = true;
let cart = this.data.cart;
if(cart.length > 0){
cart.forEach(function(item,index){
if(item == dish){
cart.splice(index,1);
flag = false;
}
})
}
if(flag) cart.push(dish);
this.setData({
cartTotal:cart.length
})
this.setStatus(dish)
},
setStatus (dishId) {
let dishes = this.data.dishesList;
for (let dish of dishes){
dish.forEach((item) => {
if(item.id == dishId){
item.status = !item.status || false
}
})
}
this.setData({
dishesList:this.data.dishesList
})
},
onLoad () {
this.loadingChange()
}
})
wechat-weapp-demo.zip
版权申诉
30 浏览量
2023-01-10
13:04:09
上传
评论
收藏 9KB ZIP 举报
甜辣uu
- 粉丝: 8596
- 资源: 1103
最新资源
- Pytorch-pytorch深度学习教程之逻辑回归.zip
- Pytorch-pytorch深度学习教程之双向循环网络.zip
- Pytorch-pytorch深度学习教程之卷积神经网络.zip
- Pytorch-pytorch深度学习教程之前馈神经网络.zip
- Pytorch-pytorch深度学习教程之线性回归.zip
- Pytorch-pytorch深度学习教程之基本操作.zip
- 基于QT的地图可视化桌面系统后台数据库为MySQL5.7源码.zip
- 基于simulink的PLL锁相环系统仿真【包括模型,文档,参考文献,操作步骤】
- 基于EM-GMM模型的目标跟踪和异常行为检测matlab仿真【包括程序,注释,参考文献,操作步骤,说明文档】
- 2109010044_胡晨燕_选课管理数据库设计与实现.prj
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈