const app = getApp() import { default as productApi } from "../../api/product" import { default as storeApi } from "../../api/store" import { default as orderApi } from "../../api/order" Page({ data: { is_confirms:true, cartList:[], totalNum:0, totalPrice:0.00, }, onShow:function(){ this.setData({ is_confirms:true }) }, // 获取购物车 getCart: async function(){ let self = this; let data = { tableId: this.data.tableId, storeId: this.data.storeId } const rs = await productApi.getCart(data) self.setData({ cartId:rs.id, cartList:rs.list, totalNum:rs.totalNum, totalPrice:rs.totalPrice }) }, onLoad : async function (options) { this.setData({ tableId:options.tableId, storeId:options.storeId, }) const rs = await storeApi.getStoreById(options.storeId) this.setData({ storeInfo: rs.info }) this.getCart(); wx.showLoading({ title: 'loading', mask:true }); }, showMoreHandle:function(){ this.setData({ showMore:!this.data.showMore }) }, confirms:async function(){ wx.showLoading({ title: 'loading', mask:true }); this.setData({ is_confirms:false }) let self = this; let data = { cartId : self.data.cartId, tableId : self.data.tableId } const rs = await orderApi.createFoodOrder(data) let orderId = rs.orderId; wx.requestPayment({ timeStamp: rs.timeStamp, nonceStr: rs.nonceStr, package: rs.package, signType: rs.signType, paySign: rs.paySign, success (res) { setTimeout(()=>{ wx.reLaunch({ url: '../order/order?id=' + orderId, }) },2000) }, fail (res) { wx.reLaunch({ url: '../order/order?id=' + orderId, }) } }) }, goMenu(){ wx.navigateBack({ delta: 1 }) } })