|
@@ -1,26 +1,18 @@
|
|
|
-import { Component, OnInit } from '@angular/core';
|
|
|
-import { ModalController } from '@ionic/angular';
|
|
|
-import { Router } from '@angular/router';
|
|
|
+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 } from '@ionic/angular/standalone';
|
|
|
+import { ExploreContainerComponent } from '../explore-container/explore-container.component';
|
|
|
+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 { Router } from '@angular/router';
|
|
|
+import { FmChatModalInput } from 'fmode-ng';
|
|
|
import { AllProductsModalComponent } from '../all-products-modal/all-products-modal.component';
|
|
|
-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';
|
|
|
-
|
|
|
-// 如果 FmChatModalInput 不是必需的,建议先移除以确保编译通过
|
|
|
-// 这里假设我们移除了它
|
|
|
-
|
|
|
-// 导入必要的模块
|
|
|
+import { DetailModalComponent } from '../detail-modal/detail-modal.component'; // 确保此组件已创建
|
|
|
import { IonicModule } from '@ionic/angular';
|
|
|
-import { CommonModule } from '@angular/common';
|
|
|
+
|
|
|
+addIcons({ airplane, bluetooth, call, wifi });
|
|
|
|
|
|
@Component({
|
|
|
selector: 'app-tab3',
|
|
@@ -32,12 +24,12 @@ import { CommonModule } from '@angular/common';
|
|
|
CommonModule,
|
|
|
AllProductsModalComponent,
|
|
|
DetailModalComponent,
|
|
|
- SaleCardComponent
|
|
|
- // 如果 FmChatModalInput 是模块或组件,根据实际情况添加
|
|
|
- // FmChatModalInputModule 或 FmChatModalInputComponent
|
|
|
+ ExploreContainerComponent,
|
|
|
+ SaleCardComponent,
|
|
|
+ FmChatModalInput
|
|
|
]
|
|
|
})
|
|
|
-export class Tab3Page implements OnInit {
|
|
|
+export class Tab3Page {
|
|
|
showDetailModal = false; // 控制详情模态显示与否
|
|
|
currentProduct: any; // 当前选择的药品信息
|
|
|
|
|
@@ -63,16 +55,10 @@ export class Tab3Page implements OnInit {
|
|
|
private router: Router,
|
|
|
) {}
|
|
|
|
|
|
- /**
|
|
|
- * 初始化生命周期钩子,加载药品数据
|
|
|
- */
|
|
|
async ngOnInit() {
|
|
|
await this.loadProducts();
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 加载药品数据并进行分类
|
|
|
- */
|
|
|
async loadProducts() {
|
|
|
try {
|
|
|
const query = new CloudQuery('Drug');
|
|
@@ -87,38 +73,43 @@ export class Tab3Page implements OnInit {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 打开详情模态窗口
|
|
|
- * @param product 当前选择的药品
|
|
|
- */
|
|
|
+ // 打开详情模态窗口
|
|
|
openDetailModal(product: any) {
|
|
|
this.currentProduct = product;
|
|
|
this.showDetailModal = true;
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 关闭详情模态窗口
|
|
|
- */
|
|
|
+ // 关闭详情模态窗口
|
|
|
closeDetailModal() {
|
|
|
this.showDetailModal = false;
|
|
|
this.currentProduct = null;
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 根据分类导航到 drug-category 页面
|
|
|
- * @param category 选择的分类
|
|
|
- */
|
|
|
+ // 根据分类导航到 drug-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) {
|
|
@@ -132,10 +123,7 @@ export class Tab3Page implements OnInit {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 查看更多功能,打开 AllProductsModalComponent 模态窗口
|
|
|
- * @param type 类型(热销或特价)
|
|
|
- */
|
|
|
+ // 查看更多功能,打开 AllProductsModalComponent 模态窗口
|
|
|
async viewMore(type: string) {
|
|
|
let filteredProducts: Array<CloudObject> = [];
|
|
|
let title: string = '';
|