import data from '../data/data';
import dateParse from '@/utils/tool/date';
export default {

    data(){
      return {
          data
      }
    },

    computed:{
      info(){
          return data[this.status] || data['1'];
      }
    },

    methods:{

        fetch:function (obj) {

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

                    item.starttime =  dateParse(item.starttime,'YYYY.MM.DD');
                    item.endtime =  dateParse(item.endtime,'YYYY.MM.DD');

                    return item;

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

        }

    },

    mounted(){

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

}