// pages/cart/cart.js
var postData = require("../../data/post-data.js");
Page({
data: {
cartListShow: true,
showModal: false,
postList: postData.postList
},
onLoad: function (options) {
//this.setData({
// postList: postData.postList
//});
if (this.data.postList.length < 1) {
this.setData({
showModal: true
});
}
},
plus: function (e) {
var that = this;
var index = e.currentTarget.dataset.index;
var num = that.data.postList[index].num;
if (num > 1) {
num--;
} else {
wx.showModal({
title: '',
content: '是否删除此菜品?',
success: function (res) {
if (res.confirm) {
carts.splice(index, 1);
that.setData({
postList: carts
});
if (that.data.postList.length < 1) {
that.setData({
cartListShow: false,
showModal: true
});
}
} else if (res.cancel) {
return;
}
}
})
}
var carts = that.data.postList;
carts[index].num = num;
that.setData({
postList: carts
});
//this.data.postList[index].num;
},
add: function (e) {
var index = e.currentTarget.dataset.index;
var num = this.data.postList[index].num;
num++;
var carts = this.data.postList;
carts[index].num = num;
this.setData({
postList: carts
});
},
delThisFood: function (e) {
var that = this;
var index = e.currentTarget.dataset.index;
var carts = that.data.postList;
wx.showModal({
title: '',
content: '是否删除此菜品?',
success: function (res) {
if (res.confirm) {
carts.splice(index, 1);
that.setData({
postList: carts
});
if (that.data.postList.length < 1) {
that.setData({
cartListShow: false,
showModal: true
});
}
} else if (res.cancel) {
return;
}
}
})
}
})
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
微信小程序开发-十二路外卖点餐案例源码.zip (50个子文件)
十二路外卖点餐
临时资源.zip 1.27MB
weixin-order
pages
cart
cart.wxml 1KB
cart.wxss 3KB
cart.js 2KB
cart.json 2B
index
index.wxml 6KB
index.js 1KB
index.json 63B
index.wxss 2KB
user
user.wxml 1KB
user.js 1KB
user.wxss 2KB
user.json 2B
nopay
nopay.wxml 4KB
nopay.json 28B
nopay.js 333B
nopay.wxss 3KB
logs
logs.json 54B
logs.js 187B
logs.wxml 188B
logs.wxss 106B
app.json 958B
app.js 772B
image
2.jpg 75KB
1.jpg 112KB
3.jpg 101KB
4.jpg 115KB
data
post-data.js 888B
utils
util.js 460B
app.wxss 222B
images
footer_btn_1.png 4KB
search_cart.png 4KB
search_none.png 6KB
footer_btn_3_active.png 5KB
1.jpg 53KB
plus_gray.png 2KB
footer_btn_2.png 4KB
add.png 626B
del.png 3KB
footer_btn_2_active.png 4KB
footer_btn_1_active.png 4KB
cart_none.png 6KB
add_gray.png 2KB
xq_nrrow_right.png 827B
search_ico_small.png 602B
footer_btn_3.png 5KB
food.jpg 11KB
xq_nrrow_left.png 661B
close_btn.png 2KB
search_ico.png 1KB
共 50 条
- 1
资源评论
小小姑娘很大
- 粉丝: 4113
- 资源: 2348
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功