let Parse = getApp().Parse;
const dateF = require('../../../../../utils/date')
const company = getApp().globalData.company

let navigationBarHeight = getApp().globalData.statusBarHeight + 44;
Page({

    /**
     * 页面的初始数据
     */
    data: {
        roomId: null,
        comments: []
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function(options) {
        console.log(options)
        let roomId = options.id
        if (!roomId) {
            wx.navigateTo({
                url: `/nova-tourism/pages/index/index`
            })
        }
        this.setData({ roomId })
        this.getComments()
    },

    async getComments() {
        let Order = new Parse.Query('ShopOrder')
        Order.equalTo("shopStore", this.data.roomId);
        Order.include("user");
        Order.include("goods");
        Order.greaterThanOrEqualTo("status", 800);
        Order.skip((this.data.loadIndex - 1) * 10)
        Order.ascending('updatedAt')
        Order.limit(10)
        Order.find().then(res => {
            let comments = []
            res.forEach(item => {
                let activitys = item.toJSON()
                activitys.orderTime = dateF.formatTime("YYYY-mm-dd HH:MM:SS", activitys.goods.updatedAt)

                comments.push(activitys)
            })


            this.setData({
                    comments
                }),
                console.log(this.data.comments)
        })
    },

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

    },

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

    },

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

    },

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

    },

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

    },

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

    },

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

    }
})