// packageA/mycomponent/offline_order/offline_order.js
Component({
    properties: {
        order_data: {
            type: Object
        }
    },
    data: {
        language: "",
        showMore: false
    },

    lifetimes: {
        attached () {
            let language = wx.getStorageSync("langIndex");
            this.setData({ language: language.en });
        }
    },
    
    methods: {
        toggle () {
            this.setData({
                showMore: !this.data.showMore
            })
        },
        //跳转商品详情页面
        toGoodsDetail(e) {
            let goods = e.currentTarget.dataset.good;
            if(this.data.order_data.deposit_ladder && this.data.order_data.deposit_ladder.activity_id || this.data.order_data.deposit_ladder_dj && this.data.order_data.deposit_ladder_dj.activity_id){
                let activity_id = this.data.order_data.deposit_ladder && this.data.order_data.deposit_ladder.activity_id ? this.data.order_data.deposit_ladder.activity_id : this.data.order_data.deposit_ladder_dj.activity_id;
                //尾款商品跳转详情
                wx.navigateTo({
                    url: "/packageH/deposit_group/activity_index/activity_index?id=" + activity_id,
                });
                return;
            }
            if (this.data.order_data.plugin_id == 54) {
                let store_id = null;
                if (goods.store_id && goods.store_id != 0 && goods.store_id != "undefined") {
                    store_id = "/" + goods.store_id;
                }

                wx.navigateTo({
                    url: "/packageA/detail_v2/detail_v2?id=0" + store_id + "&name=group&fight_groups=" + goods.goods_id,
                });
            } else {
                wx.navigateTo({
                    url: "/packageA/detail_v2/detail_v2?id=" + goods.goods_id,
                });
            }
        },

        // 评价，追评，查看评价按钮
        evaluateOpration(e) {
            let btn = e.target.dataset.btn;
            let item = e.target.dataset.goods;
            let order_id = e.target.dataset.order.id;
            //value-0评价 value-1追加评价 value-2查看评价详情
            if (btn.value == 0) {
            wx.navigateTo({
                url: '/packageD/member/evaluate/evaluate?order_id=' + order_id + '&id=' + item.id
            });
            } else if (btn.value == 1) {
            wx.navigateTo({
                url: '/packageD/member/addevaluate/addevaluate?order_id=' + order_id + '&item=' + JSON.stringify(item)
            });
            } else if (btn.value == 2) {
            let options = "?order_id=" + order_id;
            options = options + '&goods_id=' + item.has_one_comment.goods_id;
            options = options + '&comment_id=' + item.has_one_comment.id;
            options = options + '&order_goods_id=' + item.id;
            wx.navigateTo({
                url: '/packageD/member/CommentDetails/CommentDetails' + options
            });
            }
        },
    }
})
