import order from '@/utils/controls/order';
export default {

    methods:{

        fetch:function (obj) {

            return this.$request({
                url:'order/getOrderList',
                data: {
                    status: this.status
                },
                page: obj,
                token:true
            }).then((data)=>{
                return obj.success((data.data || []).map((item)=>{

                    item.productList = item.productList || [];

                    item.statusOrder = order.getOrderStatus(order.createdOrderStatus(item));


                    return item;

                }));
            }).catch(obj.fail);

        },

        /* 跳转到订单详情 */
        goOrderDetail:function (item) {

            if (item.id) {
                return this.$router.navigateTo({
                    name: 'order-detail',
                    params:{
                        id: item.id
                    },
                    memoryParams:{
                        item:item
                    }
                });
            }

        },

        /* 修改状态 */
        changeStatus:function (e) {

            // 触发更新规则
            return this.$emit('changeStatus',e);
        },

        openPayModal(e){
            // 触发更新规则
            return this.$emit('openPayModal',e);
        },

    },

    mounted(){

        this.$emit('use-target',{
            target: this,
            index: this.index,
            type: this.type
        });
    }

}