import notice from '@/utils/notice/index';
export default {

    data(){
        return {
            address:{}
        }
    },

    methods:{

        setAddress(address){
            this.address = address;
        },

        triggerAddress(){
            if (this.loadingStatus) return;

            return this.$router.navigateTo({
                name:'address',
                params:{
                    type:'select',
                    id: this.address && this.address.id || ''
                }
            });
        }

    },

    onShow(){
        if (this.uploadOrder) {
            this.$refs.header.reload(2);
            this.uploadOrder = false;
        }
    },

    created(){
        notice.on('order',(data)=>{
            if (data.item && data.item.id !== this.address.id) {
                this.setAddress(data.item);
                this.uploadOrder = true;
            }
        },'select-address');
    },

    beforeDestroy(){
        notice.off('order','select-address');
    }

}