|
@@ -1,17 +1,26 @@
|
|
|
-import { Component } from '@angular/core';
|
|
|
-import { ModalController, IonModal, IonHeader, IonToolbar, IonTitle, IonContent, IonList, IonItem, IonLabel, IonAvatar, IonButton, IonSegment, IonSegmentButton, IonSegmentContent, IonSegmentView, IonCardContent, IonCardTitle, IonCardHeader, IonCard, IonIcon, IonButtons, IonGrid, IonRow, IonThumbnail, IonSearchbar, IonCol, IonBackButton } from '@ionic/angular/standalone';
|
|
|
-import { addIcons } from 'ionicons';
|
|
|
-import { airplane, bluetooth, call, wifi, close } from 'ionicons/icons';
|
|
|
-import { SaleCardComponent } from '../component/sale-card/sale-card.component';
|
|
|
-import { CommonModule } from '@angular/common';
|
|
|
-import { CloudObject, CloudQuery } from 'src/lib/ncloud';
|
|
|
+import { Component, OnInit } from '@angular/core';
|
|
|
+import { ModalController } from '@ionic/angular';
|
|
|
import { Router } from '@angular/router';
|
|
|
-import { FmChatModalInput } from 'fmode-ng';
|
|
|
+import { CloudObject, CloudQuery } from 'src/lib/ncloud';
|
|
|
+
|
|
|
+// 正确导入所有组件
|
|
|
import { AllProductsModalComponent } from '../all-products-modal/all-products-modal.component';
|
|
|
-import { DetailModalComponent } from '../detail-modal/detail-modal.component'; // 确保此组件已创建
|
|
|
-import { IonicModule } from '@ionic/angular';
|
|
|
+import { DetailModalComponent } from '../detail-modal/detail-modal.component';
|
|
|
+import { SaleCardComponent } from '../component/sale-card/sale-card.component';
|
|
|
+
|
|
|
+// 移除或正确导入 FmChatModalInput
|
|
|
+// 如果 FmChatModalInput 是一个模块,请使用下面的导入方式(假设它是一个模块)
|
|
|
+// import { FmChatModalInputModule } from 'fmode-ng';
|
|
|
+
|
|
|
+// 如果 FmChatModalInput 是一个组件,请使用下面的导入方式(假设它是一个组件)
|
|
|
+// import { FmChatModalInputComponent } from 'fmode-ng';
|
|
|
|
|
|
-addIcons({ airplane, bluetooth, call, wifi });
|
|
|
+// 如果 FmChatModalInput 不是必需的,建议先移除以确保编译通过
|
|
|
+// 这里假设我们移除了它
|
|
|
+
|
|
|
+// 导入必要的模块
|
|
|
+import { IonicModule } from '@ionic/angular';
|
|
|
+import { CommonModule } from '@angular/common';
|
|
|
|
|
|
@Component({
|
|
|
selector: 'app-tab3',
|
|
@@ -23,11 +32,12 @@ addIcons({ airplane, bluetooth, call, wifi });
|
|
|
CommonModule,
|
|
|
AllProductsModalComponent,
|
|
|
DetailModalComponent,
|
|
|
- SaleCardComponent,
|
|
|
- FmChatModalInput,IonBackButton
|
|
|
+ SaleCardComponent
|
|
|
+ // 如果 FmChatModalInput 是模块或组件,根据实际情况添加
|
|
|
+ // FmChatModalInputModule 或 FmChatModalInputComponent
|
|
|
]
|
|
|
})
|
|
|
-export class Tab3Page {
|
|
|
+export class Tab3Page implements OnInit {
|
|
|
showDetailModal = false; // 控制详情模态显示与否
|
|
|
currentProduct: any; // 当前选择的药品信息
|
|
|
|
|
@@ -53,10 +63,16 @@ export class Tab3Page {
|
|
|
private router: Router,
|
|
|
) {}
|
|
|
|
|
|
+ /**
|
|
|
+ * 初始化生命周期钩子,加载药品数据
|
|
|
+ */
|
|
|
async ngOnInit() {
|
|
|
await this.loadProducts();
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 加载药品数据并进行分类
|
|
|
+ */
|
|
|
async loadProducts() {
|
|
|
try {
|
|
|
const query = new CloudQuery('Drug');
|
|
@@ -71,43 +87,38 @@ export class Tab3Page {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- // 打开详情模态窗口
|
|
|
+ /**
|
|
|
+ * 打开详情模态窗口
|
|
|
+ * @param product 当前选择的药品
|
|
|
+ */
|
|
|
openDetailModal(product: any) {
|
|
|
this.currentProduct = product;
|
|
|
this.showDetailModal = true;
|
|
|
}
|
|
|
|
|
|
- // 关闭详情模态窗口
|
|
|
+ /**
|
|
|
+ * 关闭详情模态窗口
|
|
|
+ */
|
|
|
closeDetailModal() {
|
|
|
this.showDetailModal = false;
|
|
|
this.currentProduct = null;
|
|
|
}
|
|
|
|
|
|
- // 根据分类导航到 drug-category 页面
|
|
|
+ /**
|
|
|
+ * 根据分类导航到 drug-category 页面
|
|
|
+ * @param category 选择的分类
|
|
|
+ */
|
|
|
onCategoryClick(category: any) {
|
|
|
this.router.navigate(['/drug-category', category.name]);
|
|
|
}
|
|
|
|
|
|
- // 分享链接功能(可选)
|
|
|
- shareDetailModal() {
|
|
|
- // 实现分享功能
|
|
|
- console.log('分享功能待实现');
|
|
|
- }
|
|
|
-
|
|
|
- // 复制链接功能
|
|
|
- copyLink() {
|
|
|
- const link = window.location.href;
|
|
|
- navigator.clipboard.writeText(link).then(() => {
|
|
|
- console.log('链接已复制');
|
|
|
- // 可添加用户提示
|
|
|
- }).catch(err => {
|
|
|
- console.error('复制失败', err);
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- // 搜索功能
|
|
|
+ // 搜索功能相关属性
|
|
|
searchTerm: string = '';
|
|
|
|
|
|
+ /**
|
|
|
+ * 搜索功能,根据输入关键字过滤药品
|
|
|
+ * @param event 输入事件
|
|
|
+ */
|
|
|
async searchProducts(event: any) {
|
|
|
this.searchTerm = event.detail.value.toLowerCase();
|
|
|
if (this.searchTerm) {
|
|
@@ -121,7 +132,10 @@ export class Tab3Page {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- // 查看更多功能,打开 AllProductsModalComponent 模态窗口
|
|
|
+ /**
|
|
|
+ * 查看更多功能,打开 AllProductsModalComponent 模态窗口
|
|
|
+ * @param type 类型(热销或特价)
|
|
|
+ */
|
|
|
async viewMore(type: string) {
|
|
|
let filteredProducts: Array<CloudObject> = [];
|
|
|
let title: string = '';
|