feat: 添加交易类型枚举,更新交易页面以支持买入和卖出功能
This commit is contained in:
@@ -30,3 +30,8 @@ export enum GenderEnum {
|
||||
FEMALE = "female",
|
||||
OTHER = "other",
|
||||
}
|
||||
|
||||
export enum TradeTypeEnum {
|
||||
BUY = "buy",
|
||||
SELL = "sell",
|
||||
}
|
||||
|
||||
@@ -50,34 +50,6 @@ const { t } = useI18n();
|
||||
<div>{{ Number(data?.totalSupply) }}{{ t('market.tradeRwa.units.shares') }}</div>
|
||||
</ion-col>
|
||||
</ion-row>
|
||||
<ion-row>
|
||||
<ion-col>
|
||||
<div class="label">
|
||||
{{ t('market.tradeRwa.fields.perUserLimit') }}
|
||||
</div>
|
||||
<div>{{ Number(data?.perUserLimit) }}{{ t('market.tradeRwa.units.shares') }}</div>
|
||||
</ion-col>
|
||||
<ion-col>
|
||||
<div class="label">
|
||||
{{ t('market.tradeRwa.fields.launchDate') }}
|
||||
</div>
|
||||
<div>{{ useDateFormat(data?.launchDate || '', 'YYYY/MM/DD HH:mm') }}</div>
|
||||
</ion-col>
|
||||
</ion-row>
|
||||
<ion-row>
|
||||
<ion-col>
|
||||
<div class="label">
|
||||
{{ t('market.tradeRwa.fields.subscriptionStartDate') }}
|
||||
</div>
|
||||
<div>{{ useDateFormat(data?.subscriptionStartDate || '', 'YYYY/MM/DD HH:mm') }}</div>
|
||||
</ion-col>
|
||||
<ion-col>
|
||||
<div class="label">
|
||||
{{ t('market.tradeRwa.fields.subscriptionEndDate') }}
|
||||
</div>
|
||||
<div>{{ useDateFormat(data?.subscriptionEndDate || '', 'YYYY/MM/DD HH:mm') }}</div>
|
||||
</ion-col>
|
||||
</ion-row>
|
||||
</ion-grid>
|
||||
|
||||
<!-- Rwa status -->
|
||||
|
||||
@@ -4,8 +4,9 @@ import { toastController } from "@ionic/vue";
|
||||
import CryptocurrencyColorNuls from "~icons/cryptocurrency-color/nuls";
|
||||
import IcSharpEditNote from "~icons/ic/sharp-edit-note";
|
||||
import { client, safeClient } from "@/api";
|
||||
import RwaAbout from "./components/about.vue";
|
||||
import RwaBase from "./components/base.vue";
|
||||
import { TradeTypeEnum } from "@/api/enum";
|
||||
import About from "./components/about.vue";
|
||||
import Base from "./components/base.vue";
|
||||
|
||||
const props = defineProps<{
|
||||
data: RwaData;
|
||||
@@ -14,25 +15,8 @@ const props = defineProps<{
|
||||
const { t } = useI18n();
|
||||
const router = useRouter();
|
||||
|
||||
const model = useTemplateRef<ModalInstance>("model");
|
||||
|
||||
async function handleSubscribe(val: number) {
|
||||
await safeClient(client.api.rwa.subscription.apply.post({
|
||||
editionId: props.data.id,
|
||||
quantity: String(val),
|
||||
}));
|
||||
const toast = await toastController.create({
|
||||
message: t("market.tradeRwa.subscribeSuccess"),
|
||||
duration: 2000,
|
||||
position: "bottom",
|
||||
color: "success",
|
||||
});
|
||||
|
||||
await toast.present();
|
||||
model.value?.$el.dismiss();
|
||||
}
|
||||
function gotoEdit() {
|
||||
router.push({ name: "trade-rwa-edit" });
|
||||
function gotoTrade(mode: TradeTypeEnum) {
|
||||
router.push(`/layout/trade?mode=${mode}&type=RWA&symbol=${props.data.product.code}`);
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -70,10 +54,10 @@ function gotoEdit() {
|
||||
|
||||
<ui-tabs size="small" class="my-3">
|
||||
<ui-tab-pane name="overview" :title="t('market.tradeRwa.tabs.overview')">
|
||||
<RwaBase :data="data" />
|
||||
<Base :data="data" />
|
||||
</ui-tab-pane>
|
||||
<ui-tab-pane name="about" title="相关文档">
|
||||
<RwaAbout :data="data" />
|
||||
<About :data="data" />
|
||||
</ui-tab-pane>
|
||||
</ui-tabs>
|
||||
</ion-content>
|
||||
@@ -81,13 +65,12 @@ function gotoEdit() {
|
||||
<ion-footer>
|
||||
<ion-toolbar class="ion-padding-horizontal ion-toolbar">
|
||||
<div class="flex justify-center my-2 gap-5">
|
||||
<ion-button id="open-modal" shape="round" expand="block" color="success">
|
||||
{{ t('market.tradeRwa.subscribe') }}
|
||||
<ion-button shape="round" expand="block" color="success" @click="gotoTrade(TradeTypeEnum.BUY)">
|
||||
买入
|
||||
</ion-button>
|
||||
<ion-button shape="round" expand="block" color="danger" @click="gotoTrade(TradeTypeEnum.SELL)">
|
||||
卖出
|
||||
</ion-button>
|
||||
|
||||
<ion-modal ref="model" trigger="open-modal" :initial-breakpoint="0.4" :breakpoints="[0, 0.4]">
|
||||
<subscribe-rwa :unit-price="Number(data?.unitPrice || 0)" :max="Number(data?.perUserLimit || 0)" @subscribed="handleSubscribe" />
|
||||
</ion-modal>
|
||||
</div>
|
||||
</ion-toolbar>
|
||||
</ion-footer>
|
||||
|
||||
@@ -5,7 +5,7 @@ const props = defineProps<{
|
||||
id: string;
|
||||
}>();
|
||||
|
||||
const { data } = safeClient(client.api.rwa.subscription.available_editions({ editionId: props.id }).get());
|
||||
const { data } = safeClient(client.api.rwa.tokenization.tradable_products({ id: props.id }).get());
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -14,7 +14,7 @@ const { data } = safeClient(client.api.rwa.subscription.available_editions({ edi
|
||||
<ion-toolbar class="ion-toolbar">
|
||||
<ui-back-button slot="start" />
|
||||
<ion-title>
|
||||
{{ data?.product.code }}
|
||||
{{ data?.product?.code }}
|
||||
</ion-title>
|
||||
</ion-toolbar>
|
||||
</ion-header>
|
||||
|
||||
@@ -1,13 +1,17 @@
|
||||
<script setup lang="ts">
|
||||
import type { ChartingLibraryWidgetOptions } from "#/charting_library";
|
||||
import { useRouteQuery } from "@vueuse/router";
|
||||
import { caretDownOutline, ellipsisHorizontal } from "ionicons/icons";
|
||||
import MaterialSymbolsCandlestickChartOutline from "~icons/material-symbols/candlestick-chart-outline";
|
||||
import { TradeTypeEnum } from "@/api/enum";
|
||||
import { TradingViewChart } from "@/tradingview/index";
|
||||
import OrdersPanel from "./components/orders-panel.vue";
|
||||
import TradeSwitch from "./components/trade-switch.vue";
|
||||
import TradeWay from "./components/trade-way.vue";
|
||||
|
||||
const mode = ref<"buy" | "sell">("buy");
|
||||
const mode = useRouteQuery<TradeTypeEnum>("mode", TradeTypeEnum.BUY);
|
||||
const symbol = useRouteQuery<string>("symbol", "BTCUSD");
|
||||
|
||||
const tradingviewOptions: Partial<ChartingLibraryWidgetOptions> = {
|
||||
disabled_features: [
|
||||
"create_volume_indicator_by_default",
|
||||
@@ -21,7 +25,7 @@ const tradingviewOptions: Partial<ChartingLibraryWidgetOptions> = {
|
||||
<ion-toolbar class="ion-toolbar">
|
||||
<div slot="start" class="flex items-center gap-1 px-4">
|
||||
<div class="text-md font-bold">
|
||||
BTC/USDT
|
||||
{{ symbol }}
|
||||
</div>
|
||||
<ui-tag size="mini" type="tertiary">
|
||||
现货
|
||||
@@ -39,7 +43,7 @@ const tradingviewOptions: Partial<ChartingLibraryWidgetOptions> = {
|
||||
</ion-toolbar>
|
||||
</ion-header>
|
||||
<ion-content :fullscreen="true">
|
||||
<TradingViewChart class="mb-5" height="300px" symbol="BTCUSD" :options="tradingviewOptions" />
|
||||
<TradingViewChart class="mb-5" height="300px" :symbol="symbol" :options="tradingviewOptions" />
|
||||
|
||||
<div class="grid grid-cols-5 px-4">
|
||||
<div class="col-span-3 space-y-2">
|
||||
|
||||
Reference in New Issue
Block a user