feat: complete server-backed six-lesson app and trial tooling
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -9,6 +9,7 @@ import { useUserStore } from '@/stores/user'
|
||||
import { useWalletStore } from '@/stores/wallet'
|
||||
import { useMarketStore, type TimeRange } from '@/stores/market'
|
||||
import { formatNumber, formatDecimal, formatCurrency, formatPercent } from '@/utils/storage'
|
||||
import { tomansForGoldPurchase, tomansForGoldSale } from '@/utils/goldTrade'
|
||||
import { useToast } from '@/composables/useToast'
|
||||
import { illustrations } from '@/assets/illustrations'
|
||||
|
||||
@@ -29,7 +30,16 @@ const timeRanges: { key: TimeRange; label: string }[] = [
|
||||
const showBuyModal = ref(false)
|
||||
const showSellModal = ref(false)
|
||||
const tradeGrams = ref(1)
|
||||
const tradeCost = computed(() => tradeGrams.value * marketStore.currentPrice)
|
||||
const tradeBuyEstimate = computed(() => {
|
||||
const g = Number(tradeGrams.value)
|
||||
if (!Number.isFinite(g) || g <= 0) return null
|
||||
return tomansForGoldPurchase(g)
|
||||
})
|
||||
const tradeSellEstimate = computed(() => {
|
||||
const g = Number(tradeGrams.value)
|
||||
if (!Number.isFinite(g) || g <= 0) return null
|
||||
return tomansForGoldSale(g)
|
||||
})
|
||||
const assetValue = computed(() => walletStore.goldGrams * marketStore.currentPrice)
|
||||
|
||||
function openBuy() { tradeGrams.value = 1; showBuyModal.value = true }
|
||||
@@ -122,8 +132,21 @@ async function confirmSell() {
|
||||
<AppModal :open="showBuyModal" title="خرید طلا" @close="showBuyModal = false">
|
||||
<div class="trade-form">
|
||||
<label class="trade-form__label">مقدار (گرم)</label>
|
||||
<input v-model.number="tradeGrams" type="number" min="0.1" step="0.1" class="trade-form__input" />
|
||||
<p class="trade-form__cost">هزینه: {{ formatCurrency(tradeCost) }}</p>
|
||||
<input
|
||||
v-model.number="tradeGrams"
|
||||
type="number"
|
||||
min="0.000001"
|
||||
step="0.000001"
|
||||
class="trade-form__input"
|
||||
dir="ltr"
|
||||
/>
|
||||
<p class="trade-form__cost">
|
||||
<template v-if="tradeBuyEstimate != null">
|
||||
برآورد هزینه (خرید به بالا): {{ formatCurrency(tradeBuyEstimate) }}
|
||||
</template>
|
||||
<template v-else>مقدار نامعتبر</template>
|
||||
</p>
|
||||
<p class="trade-form__hint">مبلغ نهایی پس از تأیید از سرور ثبت میشود.</p>
|
||||
<p class="trade-form__balance">موجودی: {{ formatCurrency(walletStore.cash) }}</p>
|
||||
</div>
|
||||
<template #footer>
|
||||
@@ -136,8 +159,21 @@ async function confirmSell() {
|
||||
<AppModal :open="showSellModal" title="فروش طلا" @close="showSellModal = false">
|
||||
<div class="trade-form">
|
||||
<label class="trade-form__label">مقدار (گرم)</label>
|
||||
<input v-model.number="tradeGrams" type="number" min="0.1" step="0.1" class="trade-form__input" />
|
||||
<p class="trade-form__cost">دریافتی: {{ formatCurrency(tradeCost) }}</p>
|
||||
<input
|
||||
v-model.number="tradeGrams"
|
||||
type="number"
|
||||
min="0.000001"
|
||||
step="0.000001"
|
||||
class="trade-form__input"
|
||||
dir="ltr"
|
||||
/>
|
||||
<p class="trade-form__cost">
|
||||
<template v-if="tradeSellEstimate != null">
|
||||
برآورد دریافتی (فروش به پایین): {{ formatCurrency(tradeSellEstimate) }}
|
||||
</template>
|
||||
<template v-else>مقدار نامعتبر</template>
|
||||
</p>
|
||||
<p class="trade-form__hint">مبلغ نهایی پس از تأیید از سرور ثبت میشود.</p>
|
||||
<p class="trade-form__balance">طلای موجود: {{ formatDecimal(walletStore.goldGrams) }} گرم</p>
|
||||
</div>
|
||||
<template #footer>
|
||||
@@ -479,6 +515,13 @@ async function confirmSell() {
|
||||
color: var(--gold-light);
|
||||
}
|
||||
|
||||
.trade-form__hint {
|
||||
font-size: 0.75rem;
|
||||
color: var(--text-muted);
|
||||
line-height: 1.5;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.trade-form__balance {
|
||||
font-size: 0.8125rem;
|
||||
color: var(--text-muted);
|
||||
|
||||
Reference in New Issue
Block a user