user-collection.vue 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <template>
  2. <ui-page-layout class="bg-white" title="我的收藏">
  3. <div class="p-24rem">
  4. <ui-main-article v-for="article in articles" :item="article" class="mb-24rem">
  5. <img @click.stop="handleCancel(article)" v-if="article.collect" src="/imgs/star.png" slot="right" class="w-40rem right-0 bottom-17rem absolute"/>
  6. </ui-main-article>
  7. </div>
  8. </ui-page-layout>
  9. </template>
  10. <script>
  11. export default {
  12. components: {},
  13. data(){
  14. return {
  15. articles:[]
  16. }
  17. },
  18. methods:{
  19. async handleLoad(){
  20. let resp = await this.$http.post(this.$api.cms.myCollectArticles,this.$qs.stringify({onPage:false}));
  21. this.articles = resp.data.data.cmsArticles;
  22. },
  23. async handleCancel(item){
  24. await this.$dialog.confirm( {
  25. message:this.$t('您现在正在进行取消收藏操作, 是否继续?'),
  26. title:this.$t('提示'),
  27. confirmButtonText: this.$t('确认'),
  28. cancelButtonText: this.$t('取消'),
  29. });
  30. let resp = await this.$http.post(this.$api.cms.collect,this.$qs.stringify({refArticle:item.code}));
  31. if(resp.data.status === 200){
  32. this.handleLoad();
  33. }
  34. }
  35. },
  36. async created() {
  37. this.handleLoad();
  38. }
  39. };
  40. </script>
  41. <style lang="scss" scoped>
  42. </style>