diff --git a/auto-imports.d.ts b/auto-imports.d.ts index 07d3e21..f5718a5 100644 --- a/auto-imports.d.ts +++ b/auto-imports.d.ts @@ -334,6 +334,9 @@ declare global { export type { UploadFetchOptions } from './src/utils/aws/s3' import('./src/utils/aws/s3') // @ts-ignore + export type { PageInstance, InputInstance, ModalInstance, ContentInstance } from './src/utils/ionic-helper' + import('./src/utils/ionic-helper') + // @ts-ignore export type { Wallet } from './src/store/wallet' import('./src/store/wallet') } diff --git a/components.d.ts b/components.d.ts index 22b8917..1720e9c 100644 --- a/components.d.ts +++ b/components.d.ts @@ -30,7 +30,10 @@ declare module 'vue' { IonItem: typeof import('@ionic/vue')['IonItem'] IonLabel: typeof import('@ionic/vue')['IonLabel'] IonList: typeof import('@ionic/vue')['IonList'] + IonModal: typeof import('@ionic/vue')['IonModal'] IonPage: typeof import('@ionic/vue')['IonPage'] + IonRadio: typeof import('@ionic/vue')['IonRadio'] + IonRadioGroup: typeof import('@ionic/vue')['IonRadioGroup'] IonRefresher: typeof import('@ionic/vue')['IonRefresher'] IonRefresherContent: typeof import('@ionic/vue')['IonRefresherContent'] IonRouterOutlet: typeof import('@ionic/vue')['IonRouterOutlet'] @@ -72,7 +75,10 @@ declare global { const IonItem: typeof import('@ionic/vue')['IonItem'] const IonLabel: typeof import('@ionic/vue')['IonLabel'] const IonList: typeof import('@ionic/vue')['IonList'] + const IonModal: typeof import('@ionic/vue')['IonModal'] const IonPage: typeof import('@ionic/vue')['IonPage'] + const IonRadio: typeof import('@ionic/vue')['IonRadio'] + const IonRadioGroup: typeof import('@ionic/vue')['IonRadioGroup'] const IonRefresher: typeof import('@ionic/vue')['IonRefresher'] const IonRefresherContent: typeof import('@ionic/vue')['IonRefresherContent'] const IonRouterOutlet: typeof import('@ionic/vue')['IonRouterOutlet'] diff --git a/src/utils/ionic-helper.ts b/src/utils/ionic-helper.ts new file mode 100644 index 0000000..dd103d6 --- /dev/null +++ b/src/utils/ionic-helper.ts @@ -0,0 +1,4 @@ +export type PageInstance = InstanceType; +export type InputInstance = InstanceType; +export type ModalInstance = InstanceType; +export type ContentInstance = InstanceType; diff --git a/src/views/product/components/subscribe.vue b/src/views/product/components/subscribe.vue new file mode 100644 index 0000000..2e1309f --- /dev/null +++ b/src/views/product/components/subscribe.vue @@ -0,0 +1,322 @@ + + + + + diff --git a/src/views/product/index.vue b/src/views/product/index.vue index a0f4145..a59d1e2 100644 --- a/src/views/product/index.vue +++ b/src/views/product/index.vue @@ -2,18 +2,22 @@ import type { Treaty } from "@elysiajs/eden"; import type { InfiniteScrollCustomEvent } from "@ionic/vue"; import type { TreatyQuery } from "@/api/types"; +import { modalController } from "@ionic/vue"; import { calendarOutline, cardOutline, timeOutline, trendingUpOutline } from "ionicons/icons"; import { client, safeClient } from "@/api"; +import Subscribe from "./components/subscribe.vue"; type Product = Treaty.Data["data"][number]; type ProductQuery = TreatyQuery; +const modalInst = useTemplateRef("modalInst"); const [query] = useResetRef({ offset: 0, limit: 10, }); const data = ref([]); const isFinished = ref(false); +const walletStore = useWalletStore(); async function fetchData() { const { data: responseData } = await safeClient(client.api.subscription.products.get({ query: { ...query.value } })); @@ -38,9 +42,25 @@ function handleProductClick(product: Product) { // TODO: 跳转到产品详情 } -function handleSubscribe(product: Product) { +async function handleSubscribe(product: Product) { console.log("申购产品:", product.name); - // TODO: 实现申购功能 + await walletStore.syncWallets(); + const wallets = walletStore.wallets.filter(w => w.walletType.allowTransaction === true); + const modal = await modalController.create({ + component: Subscribe, + componentProps: { + productId: product.id, + wallets, + onClose: () => { + modal.dismiss(); + }, + onSuccess: () => { + modal.dismiss(); + console.log("申购成功"); + }, + }, + }); + await modal.present(); } onMounted(() => { @@ -128,6 +148,8 @@ onMounted(() => { 我要申购 + +