|
@@ -182,35 +182,37 @@ Page({
|
|
|
// this.menuNumOpera(mw, onum, data._id)
|
|
|
},
|
|
|
// 提交
|
|
|
- onSubmit: function () {
|
|
|
+ onSubmit: async function () {
|
|
|
const data = JSON.parse(JSON.stringify(this.data.form))
|
|
|
if (app.globalData.wxInfo) data.openid = app.globalData.wxInfo.openid;
|
|
|
if (this.data.today) data.date = this.data.today;
|
|
|
let url;
|
|
|
if (data._id) url = `${app.globalData.publicUrl}/api/st/dining/order/update/${data._id}`
|
|
|
else url = `${app.globalData.publicUrl}/api/st/dining/order`;
|
|
|
- wx.request({
|
|
|
- url,
|
|
|
- method: "post",
|
|
|
- header: {
|
|
|
- 'x-tenant': app.globalData.tenant
|
|
|
- },
|
|
|
- data,
|
|
|
- success: res => {
|
|
|
- if (res.data.errcode == 0) {
|
|
|
- wx.showToast({
|
|
|
- title: '完成点餐',
|
|
|
- })
|
|
|
- }
|
|
|
+ const res = await app.$post(uri, data);
|
|
|
+ console.log(res);
|
|
|
+ // wx.request({
|
|
|
+ // url,
|
|
|
+ // method: "post",
|
|
|
+ // header: {
|
|
|
+ // 'x-tenant': app.globalData.tenant
|
|
|
+ // },
|
|
|
+ // data,
|
|
|
+ // success: res => {
|
|
|
+ // if (res.data.errcode == 0) {
|
|
|
+ // wx.showToast({
|
|
|
+ // title: '完成点餐',
|
|
|
+ // })
|
|
|
+ // }
|
|
|
|
|
|
- },
|
|
|
- error: err => {
|
|
|
- wx.showToast({
|
|
|
- title: err.msg,
|
|
|
- icon: 'error'
|
|
|
- })
|
|
|
- }
|
|
|
- })
|
|
|
+ // },
|
|
|
+ // error: err => {
|
|
|
+ // wx.showToast({
|
|
|
+ // title: err.msg,
|
|
|
+ // icon: 'error'
|
|
|
+ // })
|
|
|
+ // }
|
|
|
+ // })
|
|
|
|
|
|
},
|
|
|
/**
|
|
@@ -225,34 +227,47 @@ Page({
|
|
|
this.searchOrder();
|
|
|
},
|
|
|
// 查询时间
|
|
|
- searchDate: function () {
|
|
|
+ searchDate: async function () {
|
|
|
let today = this.data.today;
|
|
|
- wx.request({
|
|
|
- url: `${app.globalData.publicUrl}/api/st/dining/arrange/getByDate?date=` + today,
|
|
|
- method: "get",
|
|
|
- header: {
|
|
|
- 'x-tenant': app.globalData.tenant
|
|
|
- },
|
|
|
- success: res => {
|
|
|
- const { arrange } = res.data.data;
|
|
|
- if (!arrange) return;
|
|
|
- let { breakfast, lunch, dinner } = arrange
|
|
|
- breakfast = this.dealImg(breakfast)
|
|
|
- lunch = this.dealImg(lunch)
|
|
|
- dinner = this.dealImg(dinner)
|
|
|
- this.setData({
|
|
|
- breakfastList: breakfast,
|
|
|
- lunchList: lunch,
|
|
|
- dinnerList: dinner
|
|
|
- })
|
|
|
- },
|
|
|
- error: err => {
|
|
|
- wx.showToast({
|
|
|
- title: err.msg,
|
|
|
- icon: 'error'
|
|
|
- })
|
|
|
- }
|
|
|
+ const res = await app.$get(`${app.globalData.publicUrl}/api/st/dining/arrange/getByDate?date=${today}`)
|
|
|
+ console.log(res);
|
|
|
+ const { arrange } = res.data;
|
|
|
+ if (!arrange) return;
|
|
|
+ let { breakfast, lunch, dinner } = arrange
|
|
|
+ breakfast = this.dealImg(breakfast)
|
|
|
+ lunch = this.dealImg(lunch)
|
|
|
+ dinner = this.dealImg(dinner)
|
|
|
+ this.setData({
|
|
|
+ breakfastList: breakfast,
|
|
|
+ lunchList: lunch,
|
|
|
+ dinnerList: dinner
|
|
|
})
|
|
|
+ // wx.request({
|
|
|
+ // url: `${app.globalData.publicUrl}/api/st/dining/arrange/getByDate?date=${today}`,
|
|
|
+ // method: "get",
|
|
|
+ // header: {
|
|
|
+ // 'x-tenant': app.globalData.tenant
|
|
|
+ // },
|
|
|
+ // success: res => {
|
|
|
+ // const { arrange } = res.data.data;
|
|
|
+ // if (!arrange) return;
|
|
|
+ // let { breakfast, lunch, dinner } = arrange
|
|
|
+ // breakfast = this.dealImg(breakfast)
|
|
|
+ // lunch = this.dealImg(lunch)
|
|
|
+ // dinner = this.dealImg(dinner)
|
|
|
+ // this.setData({
|
|
|
+ // breakfastList: breakfast,
|
|
|
+ // lunchList: lunch,
|
|
|
+ // dinnerList: dinner
|
|
|
+ // })
|
|
|
+ // },
|
|
|
+ // error: err => {
|
|
|
+ // wx.showToast({
|
|
|
+ // title: err.msg,
|
|
|
+ // icon: 'error'
|
|
|
+ // })
|
|
|
+ // }
|
|
|
+ // })
|
|
|
},
|
|
|
dealImg(list) {
|
|
|
for (let i of list) {
|
|
@@ -261,7 +276,7 @@ Page({
|
|
|
}
|
|
|
return list;
|
|
|
},
|
|
|
- searchST: function () {
|
|
|
+ searchST: async function () {
|
|
|
wx.request({
|
|
|
url: `${app.globalData.publicUrl}/api/st/system/tenant/getTenant/${app.globalData.tenant}`,
|
|
|
method: "get",
|
|
@@ -281,33 +296,43 @@ Page({
|
|
|
})
|
|
|
},
|
|
|
// 查订单
|
|
|
- searchOrder() {
|
|
|
+ async searchOrder() {
|
|
|
let today = this.data.today;
|
|
|
let openid = app.globalData.wxInfo.openid;
|
|
|
- wx.request({
|
|
|
- url: `${app.globalData.publicUrl}/api/st/dining/order/getByOpenid?date=${today}&openid=${openid}`,
|
|
|
- method: "get",
|
|
|
- header: {
|
|
|
- 'x-tenant': app.globalData.tenant
|
|
|
- },
|
|
|
- success: res => {
|
|
|
- const { data } = res.data
|
|
|
- if (!data) return
|
|
|
- this.setData({
|
|
|
- form: res.data.data,
|
|
|
- })
|
|
|
- const robj = res.data.data
|
|
|
- if (robj.breakfast && robj.breakfast.list && robj.breakfast.list.length > 0) this.dealOrderToMenu('breakfast', robj.breakfast.list)
|
|
|
- if (robj.lunch && robj.lunch.list && robj.lunch.list.length > 0) this.dealOrderToMenu('lunch', robj.lunch.list)
|
|
|
- if (robj.dinner && robj.dinner.list && robj.dinner.list.length > 0) this.dealOrderToMenu('dinner', robj.dinner.list)
|
|
|
- },
|
|
|
- error: err => {
|
|
|
- wx.showToast({
|
|
|
- title: err.msg,
|
|
|
- icon: 'error'
|
|
|
- })
|
|
|
- }
|
|
|
+ const res = await app.$get(`${app.globalData.publicUrl}/api/st/dining/order/getByOpenid?date=${today}&openid=${openid}`)
|
|
|
+ const { data } = res
|
|
|
+ if (!data) return
|
|
|
+ this.setData({
|
|
|
+ form: res.data,
|
|
|
})
|
|
|
+ const robj = res.data
|
|
|
+ if (robj.breakfast && robj.breakfast.list && robj.breakfast.list.length > 0) this.dealOrderToMenu('breakfast', robj.breakfast.list)
|
|
|
+ if (robj.lunch && robj.lunch.list && robj.lunch.list.length > 0) this.dealOrderToMenu('lunch', robj.lunch.list)
|
|
|
+ if (robj.dinner && robj.dinner.list && robj.dinner.list.length > 0) this.dealOrderToMenu('dinner', robj.dinner.list)
|
|
|
+ // wx.request({
|
|
|
+ // url: `${app.globalData.publicUrl}/api/st/dining/order/getByOpenid?date=${today}&openid=${openid}`,
|
|
|
+ // method: "get",
|
|
|
+ // header: {
|
|
|
+ // 'x-tenant': app.globalData.tenant
|
|
|
+ // },
|
|
|
+ // success: res => {
|
|
|
+ // const { data } = res.data
|
|
|
+ // if (!data) return
|
|
|
+ // this.setData({
|
|
|
+ // form: res.data.data,
|
|
|
+ // })
|
|
|
+ // const robj = res.data.data
|
|
|
+ // if (robj.breakfast && robj.breakfast.list && robj.breakfast.list.length > 0) this.dealOrderToMenu('breakfast', robj.breakfast.list)
|
|
|
+ // if (robj.lunch && robj.lunch.list && robj.lunch.list.length > 0) this.dealOrderToMenu('lunch', robj.lunch.list)
|
|
|
+ // if (robj.dinner && robj.dinner.list && robj.dinner.list.length > 0) this.dealOrderToMenu('dinner', robj.dinner.list)
|
|
|
+ // },
|
|
|
+ // error: err => {
|
|
|
+ // wx.showToast({
|
|
|
+ // title: err.msg,
|
|
|
+ // icon: 'error'
|
|
|
+ // })
|
|
|
+ // }
|
|
|
+ // })
|
|
|
},
|
|
|
/**
|
|
|
* 将点过的单还原,继续修改
|