<template>
  <ui-page-layout class="bg-white" title="我的收藏">
    <div class="p-24rem">
      <ui-main-article v-for="article in articles" :item="article" class="mb-24rem">

        <img @click.stop="handleCancel(article)" v-if="article.collect" src="/imgs/star.png" slot="right"  class="w-40rem right-0 bottom-17rem absolute"/>

      </ui-main-article>
    </div>
  </ui-page-layout>
</template>

<script>
  export default {
    components: {},
    data(){
      return {
        articles:[]
      }
    },
    methods:{
      async handleLoad(){
        let resp = await this.$http.post(this.$api.cms.myCollectArticles,this.$qs.stringify({onPage:false}));
        this.articles = resp.data.data.cmsArticles;

      },
      async handleCancel(item){

        await this.$dialog.confirm( {
          message:this.$t('您现在正在进行取消收藏操作, 是否继续?'),
          title:this.$t('提示'),
          confirmButtonText: this.$t('确认'),
          cancelButtonText: this.$t('取消'),
        });

        let resp = await  this.$http.post(this.$api.cms.collect,this.$qs.stringify({refArticle:item.code}));
        if(resp.data.status === 200){
          this.handleLoad();
        }

      }
    },
    async created() {
      this.handleLoad();
    }

  };
</script>

<style lang="scss" scoped>

</style>
