123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152 |
- const Parse = getApp().Parse
- const dateF = require('../../../../../utils/date')
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- id: null,
- foodorder: null,
- time: null,
- show: false
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- this.setData({
- activeColor:getApp().globalData.activeColor || '#229293'
- })
- let id = options.id
- console.log(id);
- this.setData({ id: id })
- console.log(this.data.id);
- this.foodorder()
- },
- async foodorder() {
- let FoodOrder = new Parse.Query("FoodOrder")
- FoodOrder.include("store")
- FoodOrder.include("table")
- FoodOrder.include("foods")
- let foodorder = await FoodOrder.get(this.data.id)
- console.log(foodorder.toJSON());
- let time = dateF.formatTime("YYYY-mm-dd HH:MM:SS", foodorder.toJSON().createdAt)
- this.setData({
- foodorder: foodorder.toJSON(),
- time: time
- })
- },
- submit() {
- let userLogin = wx.getStorageSync("userLogin");
- if (userLogin == "") {
- login.loginNow();
- return;
- }
- this.setData({
- show: true
- })
- },
- async acceptResult(e) {
- let { activeOrder } = this.data
- let that = this
- let {
- params,
- no
- } = e.detail;
- that.setData({
- show: false
- })
- try {
- if (params == "ok") {
- // activeOrder.set("status", 200)
- // activeOrder.set("isPay", true)
- await that.getorder()
- // await activeOrder.save()
- wx.showToast({
- title: '购买成功',
- icon: 'none',
- image: '',
- duration: 1500,
- mask: false,
- });
- wx.navigateBack({
- delta: 1,
- })
- } else {
- wx.showToast({
- title: '支付失败,取消订单',
- icon: 'none',
- image: '',
- duration: 1500,
- mask: false,
- });
- }
- } catch (error) {
- console.log(error)
- wx.showToast({
- title: "支付失败",
- icon: "error",
- duration: 1500,
- });
- wx.hideLoading()
- }
- },
- async getorder() {
- let FoodOrder = new Parse.Query("FoodOrder")
- let foodorder = await FoodOrder.get(this.data.id)
- foodorder.set("state", "200")
- foodorder.save().then(res => {
- console.log(res)
- })
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- }
- })
|