diff --git a/scr/food/images/test1.jpg b/scr/food/images/test1.jpg new file mode 100644 index 0000000..3d05fbb Binary files /dev/null and b/scr/food/images/test1.jpg differ diff --git a/scr/food/images/test2.jpg b/scr/food/images/test2.jpg new file mode 100644 index 0000000..e538276 Binary files /dev/null and b/scr/food/images/test2.jpg differ diff --git a/scr/food/images/test3.jpg b/scr/food/images/test3.jpg new file mode 100644 index 0000000..bb3413f Binary files /dev/null and b/scr/food/images/test3.jpg differ diff --git a/scr/food/images/test4.jpg b/scr/food/images/test4.jpg new file mode 100644 index 0000000..17bba03 Binary files /dev/null and b/scr/food/images/test4.jpg differ diff --git a/scr/food/images/test6.jpg b/scr/food/images/test6.jpg new file mode 100644 index 0000000..6eb7176 Binary files /dev/null and b/scr/food/images/test6.jpg differ diff --git a/scr/food/pages/cart/cart.js b/scr/food/pages/cart/cart.js index 2c4ab5b..4ba3488 100644 --- a/scr/food/pages/cart/cart.js +++ b/scr/food/pages/cart/cart.js @@ -8,35 +8,33 @@ Page({ data: { cartlistsee:[] }, - async f() { - const res = await db.collection('user').doc('eda7dd506371adb300c89bc66afc4601').get(); - console.log(res); - - - }, /** * 生命周期函数--监听页面加载 */ onLoad:function(options) { - var _this = this; + const db = wx.cloud.database({ //这个是环境ID不是环境名称 env: 'cloud1-8g5wmepxce8a3b8a' }) //2、开始查询数据了 news对应的是集合的名称 - db.collection('user').doc('eda7dd506371adb300c89bc66afc4601').get({ - //如果查询成功的话 - success: res => { - console.log(res.data) - //这一步很重要,给ne赋值,没有这一步的话,前台就不会显示值 - this.setData({ - cartlist: res.data - }) - } - }) - }, - + db.collection("user") + .doc("eda7dd506371adb300c89bc66afc4601") + .get() + .then(res => { + console.log("列表页", res.data); + console.log(res.data.cartlist) + //再次显示数据 + this.setData({ + cartlistsee:res.data.cartlist + }) + }) + .catch(err => { + console.log("加载失败", err); + }) + + }, /** * 生命周期函数--监听页面初次渲染完成 */ diff --git a/scr/food/pages/cart/cart.wxml b/scr/food/pages/cart/cart.wxml index af7cf47..265f26c 100644 --- a/scr/food/pages/cart/cart.wxml +++ b/scr/food/pages/cart/cart.wxml @@ -1,2 +1,44 @@ -测试 \ No newline at end of file + + + + + + + + + + {{item.food_name}} + + ¥{{item.price}} + + + + + + + + + + 删除 + + + + + + + + + 全选 + + 合计:¥{{total_all_price}} + + 结算 + + + + + 购物车中没有商品 + + + diff --git a/scr/food/pages/cart/cart.wxss b/scr/food/pages/cart/cart.wxss index b58f5e9..3847c27 100644 --- a/scr/food/pages/cart/cart.wxss +++ b/scr/food/pages/cart/cart.wxss @@ -1 +1,239 @@ -/* pages/cart/cart.wxss */ \ No newline at end of file +/* pages/cart/cart.wxss */ + + +/*list样式*/ + +.scrol_view_style { + background: #f5f5f5; +} + +.carts_box { + display: flex; + align-items: center; + height: 100%; +} + +/*item*/ +.list_item_style { + height: 180rpx; + background: white; + padding-bottom: 20rpx; + padding-left: 20rpx; + padding-right: 20rpx; +} + +/*商品主图*/ + +.good_main_image { + width: 180rpx; + height: 180rpx; + margin-left: 10rpx; + border: 1rpx solid #bbb; +} + +/*商品名称*/ + +.item_good_title { + text-align: left; + font-size: 32rpx; + height: auto; + white-space: nowrap; + word-break: keep-all; + overflow: hidden; + text-overflow: ellipsis; + width: 90%; +} + +.cart_content_right { + display: flex; + flex-direction: column; + height: 100%; + margin-left: 20rpx; +} + +.btn_wrap { + display: flex; + flex-direction: row; + align-items: center; + width: 200rpx; +} + +.btn_wrap input { + background: #f8f8f8; + color: #666; + font-size: 26rpx; + right: 10rpx; + width: 50rpx; + text-align: center; +} + +.btn_wrap input:nth-child(2) { + margin: 0 10rpx; +} + +/*+号按钮*/ + +.add_image_style { + width: 20rpx; + height: 20rpx; + position: relative; + top: 60rpx; + right: 10rpx; + float: right; +} + +/*——号按钮*/ + +.reduce_image_style { + width: 20rpx; + height: 20rpx; + position: relative; + top: 60rpx; + right: 10rpx; + float: right; +} + +/*购买数量*/ + +.good_buy_number { + height: 25rpx; + position: relative; + top: 57rpx; + background: #f8f8f8; + color: #666; + font-size: 22rpx; + right: 10rpx; + width: 50rpx; + text-align: center; + float: right; + margin-right: 5rpx; + margin-left: 5rpx; + border-radius: 5rpx; +} + +/*价钱的背景试图*/ + +.price_back_view { + display: flex; + align-items: center; + justify-content: space-between; + width: 460rpx; + padding-top: 20rpx; +} + +.cart_content_bottom { + display: flex; + align-items: center; + justify-content: space-between; + width: 460rpx; + padding-top: 25rpx; +} + +.cart_content_bottom .delete { + font-size: 28rpx; +} + +/*售价*/ + +.right_list_item_price { + color: #ff5d08; + font-size: 32rpx; +} + +/* 没有商品时的购物车样式 */ + +.no_shop { + text-align: center; + font-size: 50rpx; + color: #bbb; + margin-top: 100px; +} + +/*规格的样式*/ + +.guige { + font-size: 28rpx; +} + +/* 未选中的 背景样式 */ + +checkbox .wx-checkbox-input { + border-radius: 50%; /* 圆角 */ + width: 35rpx; /* 背景的宽 */ + height: 35rpx; /* 背景的高 */ +} + +/* 选中后的 背景样式 (红色背景 无边框 可根据UI需求自己修改) */ + +checkbox .wx-checkbox-input.wx-checkbox-input-checked { + border-color: red; + background: red; +} + +/* 选中后的 对勾样式 (白色对勾 可根据UI需求自己修改) */ + +checkbox .wx-checkbox-input.wx-checkbox-input-checked::before { + border-radius: 50%; /* 圆角 */ + width: 35rpx; /* 选中后对勾大小,不要超过背景的尺寸 */ + height: 35rpx; /* 选中后对勾大小,不要超过背景的尺寸 */ + line-height: 35rpx; + text-align: center; + font-size: 25rpx; /* 对勾大小 30rpx */ + color: #fff; /* 对勾颜色 白色 */ + background: transparent; + transform: translate(-50%, -50%) scale(1); + -webkit-transform: translate(-50%, -50%) scale(1); +} + +/*合计样式*/ + +.heji { + /* margin-left: 140px; */ + float: right; + margin-right: 75px; +} + +/*合计价格的样式*/ + +.all_shop_price { + color: #ff6261; +} + +/*结算的样式*/ + +.jiesuan { + position: absolute; + height: 100%; + border-radius: 5rpx; + line-height: 80rpx; + padding: 0 30rpx; + color: white; + font-size: 28rpx; + background: #ff5d08; + bottom: 0rpx; + right: 0rpx; +} + +/*全选的样式*/ + +.buy_shop { + width: 100%; + height: 80rpx; + background-color: white; + line-height: 80rpx; + position: fixed; + bottom: 0; + font-size: 28rpx; + z-index: 999; + box-shadow: 0 0 10rpx rgba(155, 143, 143, 0.6); + display: flex; + align-items: center; +} +.select_allbox{ + display: flex; + align-items: center; + width: 57%; +} +.select_allbox text{ + padding-left: 10rpx; +} \ No newline at end of file diff --git a/scr/food/pages/detail/detail.js b/scr/food/pages/detail/detail.js index 660513f..961cdc0 100644 --- a/scr/food/pages/detail/detail.js +++ b/scr/food/pages/detail/detail.js @@ -11,6 +11,7 @@ Page({ detailObj: {}, list:[], clockresult:[], + userid:null }, @@ -20,26 +21,33 @@ Page({ onLoad: function (options) { let foodid =options.id + var userid=options.aid + console.log('1111wb'); + cont.doc(foodid).get({ success: res => { console.log(res.data) - //这一步很重要,给ne赋值,没有这一步的话,前台就不会显示值 + //这一步很重要,给ne赋值,没有这一步的话,前台就不会显示值 + this.setData({ - detailObj: res.data + detailObj: res.data, }) } - }) - + }, // 渲染数据 async addCar(event) { var detailObj= event.currentTarget.dataset.item; + var userid=event.currentTarget.dataset.userid; db.collection('user').doc('eda7dd506371adb300c89bc66afc4601').update({ data:{ cartlist:db.command.push(detailObj) } }) + + + wx.showToast({ title: '加入购物车成功', icon: 'success', diff --git a/scr/food/pages/detail/detail.wxml b/scr/food/pages/detail/detail.wxml index 2ec6541..ef1b89e 100644 --- a/scr/food/pages/detail/detail.wxml +++ b/scr/food/pages/detail/detail.wxml @@ -15,6 +15,6 @@ 东西还可以,好评~ - + \ No newline at end of file diff --git a/scr/food/pages/usercenter/usercenter.wxml b/scr/food/pages/usercenter/usercenter.wxml index 9883d91..d9c7606 100644 --- a/scr/food/pages/usercenter/usercenter.wxml +++ b/scr/food/pages/usercenter/usercenter.wxml @@ -2,26 +2,26 @@ - + 张三 - + 待付款 - + 待发货 - + 待收货 - + 待评价 @@ -29,29 +29,29 @@ - + 我的收藏 - + - + 我的评价 - + - + 售后记录 - + - + 分享邀请 - + diff --git a/scr/food/project.private.config.json b/scr/food/project.private.config.json index 86ff34f..deaa9c2 100644 --- a/scr/food/project.private.config.json +++ b/scr/food/project.private.config.json @@ -51,6 +51,20 @@ "pathName": "pages/updateRecordSuccess/index", "query": "", "scene": null + }, + { + "name": "", + "pathName": "pages/usercenter/usercenter", + "query": "", + "launchMode": "default", + "scene": null + }, + { + "name": "", + "pathName": "pages/cart/cart", + "query": "", + "launchMode": "default", + "scene": null } ] }