let Parse = getApp().Parse;
const company = getApp().globalData.company
const dateF = require('../../../../../../utils/date')
Page({
    /**
     * 页面的初始数据
     */
    data: {
        store: null,
        list: null,
    },
    async getShopOrder() {
        let ShopOrder = new Parse.Query('ShopOrder')
        ShopOrder.equalTo('company', company)
        ShopOrder.equalTo('shopStore', this.data.store)
        ShopOrder.include('shopStore')
        ShopOrder.include('user')
        ShopOrder.greaterThan('status', 100)
        ShopOrder.descending('createdAt')
        let shopOrder = await ShopOrder.find()
        let listJSON = []
        if (shopOrder && shopOrder.length > 0) {
            shopOrder.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);
    },
    orderdeils(e) {
        let id = e.currentTarget.dataset.item.objectId
        console.log(id);
        wx.navigateTo({
            url: '/nova-tourism/pages/my/merchant/merchant-home/order-list/order-deils/index?id=' + id,
        });
    },
    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function(options) {
        let store = options.storeId; //用户
        console.log(store);
        this.setData({ store: store })
        this.getShopOrder()
    },

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

    },

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

    },

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

    },

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

    },

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

    },

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

    },

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

    }
})