123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250 |
- const Parse = getApp().Parse;
- const company = getApp().globalData.company
- let navigationBarHeight = getApp().globalData.statusBarHeight + 44;
- const dateF = require('../../../../utils/date');
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- active: 0,
- list: [],
- totalPrice: 0,
- stickytop: navigationBarHeight,
- },
- async acceptResult(e) {
- let { activeOrder } = this.data
- let that = this
- let {
- params,
- no
- } = e.detail;
- that.setData({
- showPayment: false
- })
- try {
- if (params == "ok") {
- // activeOrder.set("status", 200)
- // activeOrder.set("isPay", true)
- await that.getorder()
- // await activeOrder.save()
- wx.showToast({
- title: '支付成功',
- icon: 'none',
- duration: 1500,
- mask: false,
- });
- wx.navigateBack({
- delta: 1,
- })
- } else {
- wx.showToast({
- title: '支付失败,取消订单',
- icon: 'none',
- duration: 1500,
- mask: false,
- });
- }
- } catch (error) {
- console.log(error)
- wx.showToast({
- title: "支付失败",
- icon: "error",
- duration: 1500,
- });
- wx.hideLoading()
- }
- },
- async getorder() {
- let id = this.data.id
- console.log(id);
- let shopOrder
- let ShopOrder = new Parse.Query("FoodOrder")
- shopOrder = await ShopOrder.get(id)
- shopOrder.set("state", "400")
- shopOrder.save().then(res => {
- console.log(res)
- })
- },
- onChange(event) {
- let active = event.detail.name
- this.setData({
- active: active
- })
- console.log(active);
- this.getFoodOrder()
- },
- storepackage(e) {
- let userLogin = wx.getStorageSync("userLogin");
- if (userLogin == "") {
- login.loginNow();
- return;
- }
- let totalPrice = e.currentTarget.dataset.item.totalPrice
- let id = e.currentTarget.dataset.item.objectId
- console.log(totalPrice);
- this.setData({
- show: true,
- totalPrice: totalPrice,
- id: id
- })
- },
- //删除
- delOrder(e) {
- console.log(e);
- let {
- index
- } = e.currentTarget.dataset
- let {
- list
- } = this.data
- let _this = this
- wx.showModal({
- title: '',
- content: '你确定删除该订单吗?',
- showCancel: true,
- cancelText: '取消',
- cancelColor: '#000000',
- confirmText: '确定',
- confirmColor: '#3CC51F',
- success: async(result) => {
- if (result.confirm) {
- await this.upDel(list[index].objectId)
- list.splice(index, 1)
- _this.setData({
- list
- })
- wx.showToast({
- title: '已取消',
- icon: 'none',
- image: '',
- duration: 1500,
- });
- }
- },
- fail: () => {},
- complete: () => {}
- });
- },
- async upDel(id) {
- let FoodOrder = new Parse.Query('FoodOrder')
- let order = await FoodOrder.get(id)
- if (order && order.id) {
- console.log(order);
- await order.destroy()
- }
- },
- foodevaluation(e) {
- let id = e.currentTarget.dataset.item.objectId
- console.log(id);
- wx.navigateTo({
- url: '/nova-tourism/pages/my/order-details/foodevaluation/index?id=' + id
- });
- },
- foodpay(e) {
- let id = e.currentTarget.dataset.item.objectId
- console.log(id);
- wx.navigateTo({
- url: '/nova-tourism/pages/my/order-details/food-pay/index?id=' + id
- });
- },
- refund(e) {
- let id = e.currentTarget.dataset.item.objectId
- console.log(id);
- wx.navigateTo({
- url: '/nova-tourism/pages/my/refund/reply-refund/index?id=' + id
- });
- },
- async getFoodOrder() {
- let FoodOrder = new Parse.Query('FoodOrder')
- FoodOrder.equalTo('company', company)
- FoodOrder.equalTo('user', Parse.User.current().id)
- if (this.data.active == 1) {
- FoodOrder.equalTo('state', "100")
- }
- // if (this.data.active == 2) {
- // FoodOrder.equalTo('status', "200")
- // }
- if (this.data.active == 2) {
- console.log(this.data.active)
- FoodOrder.equalTo('state', "400")
- }
- FoodOrder.include('foods')
- FoodOrder.include('table')
- let foodOrder = await FoodOrder.find()
- let listJSON = []
- if (foodOrder && foodOrder.length > 0) {
- foodOrder.forEach(c => {
- let order = c.toJSON()
- order.Time = dateF.formatTime('YYYY-mm-dd HH:MM:SS', order.createdAt);
- listJSON.push(order)
- })
- }
- this.setData({
- list: listJSON
- })
- console.log(this.data.list);
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function(options) {
- this.getFoodOrder()
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function() {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function() {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function() {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function() {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function() {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function() {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function() {
- }
- })
|