tab2.page.html 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. <ion-header [translucent]="true">
  2. <ion-toolbar class="custom-toolbar">
  3. <div class="search-bar">
  4. <ion-searchbar
  5. placeholder="搜索"
  6. class="custom-searchbar"
  7. (ionInput)="searchProducts($event)">
  8. </ion-searchbar>
  9. </div>
  10. <ng-container *ngIf="!searchTerm">
  11. <div class="header">
  12. <ion-card-header>
  13. <ion-card-title>
  14. <ion-segment
  15. [(ngModel)]="selectedSegment"
  16. (ionChange)="segmentChanged($event)"
  17. scrollable>
  18. <ion-segment-button
  19. *ngFor="let segment of segments"
  20. [value]="segment">
  21. {{ segment }}
  22. </ion-segment-button>
  23. </ion-segment>
  24. </ion-card-title>
  25. </ion-card-header>
  26. </div>
  27. </ng-container>
  28. </ion-toolbar>
  29. </ion-header>
  30. <ion-content class="knowledge" [fullscreen]="true">
  31. <ion-loading
  32. *ngIf="isLoading"
  33. message="加载中...">
  34. </ion-loading>
  35. <ion-content class="knowledge" [fullscreen]="true">
  36. <ng-container *ngIf="!searchTerm; else searchResults">
  37. <div class="content">
  38. <ion-card>
  39. <ion-card-content>
  40. <!-- 轮播图区域 -->
  41. <div class="carousel-container">
  42. <div class="carousel" [style.transform]="'translateX(-' + currentSlide * 100 + '%)'">
  43. <div class="slide" *ngFor="let image of images; trackBy: trackByIndex">
  44. <img [src]="image" alt="轮播图" />
  45. </div>
  46. </div>
  47. <button class="prev" (click)="prevSlide()">&#10094;</button>
  48. <button class="next" (click)="nextSlide()">&#10095;</button>
  49. <div class="dots">
  50. <span
  51. class="dot"
  52. *ngFor="let image of images; let i = index"
  53. [class.active]="i === currentSlide"
  54. (click)="goToSlide(i)">
  55. </span>
  56. </div>
  57. </div>
  58. <!-- 文章卡片区域 -->
  59. <app-article-card
  60. *ngFor="let card of cards; trackBy: trackById"
  61. [card]="card"
  62. (click)="openDetailModal(card)">
  63. </app-article-card>
  64. </ion-card-content>
  65. </ion-card>
  66. </div>
  67. </ng-container>
  68. <!-- 搜索结果 -->
  69. <ng-template #searchResults>
  70. <div>
  71. <app-article-card
  72. *ngFor="let product of products; trackBy: trackById"
  73. [card]="product"
  74. (click)="openDetailModal(product)">
  75. </app-article-card>
  76. <div *ngIf="products.length === 0" class="no-results">
  77. <h2>寻找中··· 请耐性等待 ····</h2>
  78. </div>
  79. </div>
  80. </ng-template>
  81. <!-- 详细信息模态 -->
  82. <ion-modal [isOpen]="isModalOpen" cssClass="bottom-modal">
  83. <ng-template>
  84. <ion-header>
  85. <ion-toolbar>
  86. <ion-buttons slot="start">
  87. <ion-button (click)="closeDetailModal()">关闭</ion-button>
  88. </ion-buttons>
  89. <ion-title>{{ currentProduct?.get('category') }}</ion-title>
  90. <ion-buttons slot="end">
  91. <ion-button (click)="shareDetailModal()">分享</ion-button>
  92. </ion-buttons>
  93. </ion-toolbar>
  94. </ion-header>
  95. <ion-content class="ion-padding">
  96. <div class="modal-content" *ngIf="currentProduct">
  97. <h1 class="product-name">{{ currentProduct.get('title') }}</h1>
  98. <p><strong>作者:</strong>{{ currentProduct.get('author') }}</p>
  99. <p>{{ currentProduct.get('content')[0] }}</p>
  100. <div class="image-container">
  101. <img [src]="currentProduct.get('image')[0]" alt="图片" class="medicine-image" />
  102. </div>
  103. <p>{{ currentProduct.get('content')[1] }}</p>
  104. <div class="image-container">
  105. <img [src]="currentProduct.get('image')[1]" alt="图片" class="medicine-image" />
  106. </div>
  107. <div class="stats">
  108. <p><strong>阅读量:</strong>{{ currentProduct.get('views') }}</p>
  109. <p><strong>点赞量:</strong>{{ currentProduct.get('likes') }}</p>
  110. </div>
  111. </div>
  112. </ion-content>
  113. <ion-footer>
  114. <ion-item>
  115. <ion-input
  116. [(ngModel)]="comment"
  117. (ionInput)="onCommentInput($event)"
  118. placeholder="请输入评论">
  119. </ion-input>
  120. <ion-button (click)="postComment()">发布</ion-button>
  121. </ion-item>
  122. </ion-footer>
  123. </ng-template>
  124. </ion-modal>
  125. <!-- 分享模态 -->
  126. <ion-modal class="share-modal" [isOpen]="shareDetail">
  127. <ng-template>
  128. <ion-header>
  129. <ion-toolbar>
  130. <ion-buttons slot="end">
  131. <ion-button (click)="closeShareModal()">X</ion-button>
  132. </ion-buttons>
  133. <ion-title>分享</ion-title>
  134. </ion-toolbar>
  135. </ion-header>
  136. <ion-content>
  137. <ion-item>
  138. <ion-label position="stacked">分享链接</ion-label>
  139. <ion-input [value]="shareLink" readonly></ion-input>
  140. </ion-item>
  141. <ion-button expand="block" (click)="copyLink()">复制链接</ion-button>
  142. </ion-content>
  143. <ion-footer>
  144. <ion-item>
  145. <ion-input
  146. [(ngModel)]="comment"
  147. (ionInput)="onCommentInput($event)"
  148. placeholder="请输入评论">
  149. </ion-input>
  150. <ion-button (click)="postComment()">发布</ion-button>
  151. </ion-item>
  152. </ion-footer>
  153. </ng-template>
  154. </ion-modal>
  155. </ion-content>