let Parse = getApp().Parse;
const company = getApp().globalData.company
const dateF = require('../../../../../../utils/date')
Page({
    /**
     * 页面的初始数据
     */
    data: {
        store: null,
        list: null,
    },
    async getShopOrder() {
        let Order = new Parse.Query('Order')
        Order.equalTo('company', company)
        Order.equalTo('store', this.data.store)
        Order.include('store')
        Order.include('user')
        Order.greaterThan('status', '100')
        Order.descending('createdAt')
        let order = await Order.find()
        console.log(order);
        let listJSON = []
        if (order && order.length > 0) {
            order.forEach(c => {
                let orders = c.toJSON()
                orders.time = dateF.formatTime("YYYY-mm-dd HH:MM:SS", orders.createdAt)
                listJSON.push(orders)
            })
        }
        this.setData({
            list: listJSON
        })
        console.log(this.data.list, 111);
    },
    orderdeils(e) {
        let id = e.currentTarget.dataset.item.objectId
        console.log(id);
        wx.navigateTo({
            url: '/nova-tourism/pages/my/merchant/merchant-home/order3-list/order-deils/index?id=' + id,
        });
    },
    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
        let store = options.storeId; //用户
        console.log(store);
        this.setData({ store: store })
        this.getShopOrder()
        console.log(Parse.User.current().id);
    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {
        this.getShopOrder()
    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {

    }
})