我的订单
获取历史订单数据
// pages/my-order/my-order.vue
// 省略部分代码
const db = wx.cloud.database()
const _ = db.command
const good_collect = db.collection('order-data')
const Price = require('e-commerce_price')
export default {
data () {return {
Price,
res_data: {}
}},
methods: {
async get_menu () {
try {
let field_obj = {
transac_status: true,
table_number: true,
order_time: true,
sett_amount: true
}
let res = await good_collect.where({}).orderBy('order_time', 'desc').field(field_obj).get()
this.res_data = res.data
} catch (e) {
console.log(e)
}
}
},
onLoad () {
this.get_menu()
}
}
选择人数页面
扫描二维码获取桌号
// pages/index/index.vue
// 省略部分代码
onLoad (e) {
this.table_number = e.number
wx.setStorageSync('table_num', e.number)
}
查询当前桌号结账状态
当前桌号历史订单已结束,即开始新订单
当前桌号存在历史订单未结账,则跳转到订单详情页
// pages/index/index.vue
// 省略部分代码
methods: {
async query_order () {
try{
let query = await good_collect.where({table_number:this.table_number, transac_status: 'unsettled'}).get()
if (query.data.length > 0) {
wx.reLaunch({
url: '/pages/order-details/details'
})
}
}catch(e){
//TODO handle the exception
}
}
},
onLoad (e) {
this.table_number = e.number
wx.setStorageSync('table_num', e.number)
this.query_order()
}
选择人数
通过 wx.setStorageSync('number_of_diners', item)
接口保存选择人数
点击开始跳转点单页面
通过 x.getStorageSync('number_of_diners')
和 wx.getStorageSync('table_num')
接口获取桌号和人数