eco-knowledge.ts 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. import { Component } from '@angular/core';
  2. import { CommonModule } from '@angular/common';
  3. import { Router, RouterModule } from '@angular/router';
  4. import { FormsModule } from '@angular/forms';
  5. import { BottomNavComponent } from '../../shared/bottom-nav/bottom-nav.component';
  6. @Component({
  7. selector: 'app-eco-knowledge',
  8. standalone: true,
  9. imports: [CommonModule, RouterModule, FormsModule, BottomNavComponent],
  10. templateUrl: './eco-knowledge.html',
  11. styleUrl: './eco-knowledge.scss'
  12. })
  13. export class EcoKnowledge {
  14. // 顶部导航返回
  15. constructor(private router: Router) {}
  16. goBack(): void {
  17. this.router.navigate(['/consumer/points-mall']);
  18. }
  19. // 搜索与分类
  20. searchText = '';
  21. categories = [
  22. { id: 'all', name: '全部', icon: 'fas fa-th-large', active: true },
  23. { id: 'ar', name: 'AR分类教程', icon: 'fas fa-cube', active: false },
  24. { id: 'policy', name: '政策解读', icon: 'fas fa-file-alt', active: false },
  25. { id: 'share', name: '达人分享', icon: 'fas fa-users', active: false },
  26. { id: 'ranking', name: '环保榜单', icon: 'fas fa-trophy', active: false }
  27. ];
  28. selectCategory(catId: string): void {
  29. this.categories.forEach(c => (c.active = c.id === catId));
  30. this.selectedCategory = catId;
  31. }
  32. selectedCategory = 'all';
  33. // 内容列表(示例数据)
  34. contents = [
  35. {
  36. id: 1,
  37. title: 'AR智能分类教程:如何正确区分可回收物与干垃圾',
  38. desc: '使用AR功能快速识别各类可回收物品,提高分类准确率,避免错误投放...',
  39. tag: 'AR教程',
  40. time: '15分钟前',
  41. icon: 'fas fa-play-circle',
  42. imageClass: 'image-1 video',
  43. liked: false,
  44. likes: 86,
  45. favorited: false
  46. },
  47. {
  48. id: 2,
  49. title: '最新环保政策解读:以旧换新补贴标准与申请流程',
  50. desc: '了解国家最新出台的以旧换新政策,掌握补贴申请流程,享受政策红利...',
  51. tag: '政策解读',
  52. time: '1天前',
  53. icon: 'fas fa-newspaper',
  54. imageClass: 'image-2',
  55. liked: false,
  56. likes: 142,
  57. favorited: false
  58. },
  59. {
  60. id: 3,
  61. title: '环保达人分享:我是如何月赚500元回收金的经验技巧',
  62. desc: '听听环保达人的经验分享,学习高效回收的小技巧,让废品变废为宝...',
  63. tag: '达人分享',
  64. time: '3天前',
  65. icon: 'fas fa-user',
  66. imageClass: 'image-3',
  67. liked: false,
  68. likes: 328,
  69. favorited: false,
  70. progress: 75
  71. },
  72. {
  73. id: 4,
  74. title: '2023年度环保达人榜单发布,看看谁是最强回收王',
  75. desc: '年度环保达人榜单新鲜出炉,学习榜样的回收经验,提升自己的环保贡献...',
  76. tag: '环保榜单',
  77. time: '1周前',
  78. icon: 'fas fa-trophy',
  79. imageClass: 'image-4',
  80. liked: false,
  81. likes: 528,
  82. favorited: false
  83. }
  84. ];
  85. // 交互方法
  86. toggleFavorite(item: any): void {
  87. item.favorited = !item.favorited;
  88. }
  89. toggleLike(item: any): void {
  90. item.liked = !item.liked;
  91. item.likes += item.liked ? 1 : -1;
  92. }
  93. // 模态框
  94. showModal = false;
  95. modalTitle = '';
  96. modalTag = '';
  97. modalIcon = '';
  98. openContent(item: any): void {
  99. this.modalTitle = item.title;
  100. this.modalTag = item.tag;
  101. this.modalIcon = item.icon;
  102. this.showModal = true;
  103. }
  104. closeModal(): void {
  105. this.showModal = false;
  106. }
  107. }