|
|
|
@ -1,6 +1,7 @@
|
|
|
|
|
// pages/detail/detail.js
|
|
|
|
|
const db = wx.cloud.database({});
|
|
|
|
|
const cont = db.collection('food');
|
|
|
|
|
const get=getApp()
|
|
|
|
|
Page({
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -8,7 +9,6 @@ Page({
|
|
|
|
|
*/
|
|
|
|
|
data: {
|
|
|
|
|
detailObj: {},
|
|
|
|
|
|
|
|
|
|
list:[],
|
|
|
|
|
clockresult:[],
|
|
|
|
|
|
|
|
|
@ -18,7 +18,7 @@ Page({
|
|
|
|
|
* 生命周期函数--监听页面加载
|
|
|
|
|
*/
|
|
|
|
|
onLoad: function (options) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let foodid =options.id
|
|
|
|
|
cont.doc(foodid).get({
|
|
|
|
|
success: res => {
|
|
|
|
@ -28,26 +28,25 @@ Page({
|
|
|
|
|
detailObj: res.data
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
// 渲染数据
|
|
|
|
|
addCar: function (event) {
|
|
|
|
|
// 获取 event 事件对象
|
|
|
|
|
// 获取点击对应的下标
|
|
|
|
|
var index = event.currentTarget.dataset.foodid;
|
|
|
|
|
console.log(index);
|
|
|
|
|
//抓取id进行赋
|
|
|
|
|
//wx.navigateTo 会触发页面隐藏onHide
|
|
|
|
|
console.log('11111')
|
|
|
|
|
|
|
|
|
|
async addCar(event) {
|
|
|
|
|
var detailObj= event.currentTarget.dataset.item;
|
|
|
|
|
db.collection('user').doc('aa9355ef636df7cc004ab37533cb2c96').update({
|
|
|
|
|
data:{
|
|
|
|
|
cartlist:db.command.push(detailObj)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
wx.showToast({
|
|
|
|
|
title: '加入购物车成功',
|
|
|
|
|
icon: 'success',
|
|
|
|
|
duration: 2000
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|