add animated amount

This commit is contained in:
Timi
2026-10-16 18:34:01 +08:00
parent b60fc6bd80
commit fe467e8781
12 changed files with 150 additions and 96 deletions
+19 -21
View File
@@ -54,7 +54,7 @@
<strong v-text="getItemTitle(item)" />
<t-button theme="danger" variant="text" size="extra-small" @click="removeItem(index)">删除</t-button>
</div>
<product-selector
<product-select-form-item
:model-value="item.skuId ? { skuId: item.skuId, skuUnitId: item.skuUnitId || '' } : undefined"
:selected-product="getProduct(item)"
label="产品"
@@ -93,8 +93,12 @@
<t-input v-model="item.remark" borderless placeholder="选填" />
</t-form-item>
<div class="price">
<strong class="coin red">¥</strong>
<strong class="value red" v-text="getItemSubtotalText(item)" />
<animated-amount
class="red text-bold"
prefix="¥"
empty-text="0.00"
:value="calculateItemAmount(item)"
/>
</div>
</div>
</div>
@@ -197,10 +201,14 @@
</t-form>
<div class="submit-wrap glass-white bg-white">
<div class="total">
<span>订单总价</span>
<span class="label">订单总价</span>
<div class="price">
<strong class="red coin">¥</strong>
<strong class="red value" v-text="totalAmountText" />
<animated-amount
class="red text-bold"
prefix="¥"
empty-text="0.00"
:value="totalAmount"
/>
</div>
</div>
<t-button
@@ -220,7 +228,7 @@
<script setup lang="ts">
import { type Attachment, useUserStore } from "timi-web-api";
import { Time } from "timi-web";
import { AnimatedAmount, Time } from "timi-web";
import { DialogPlugin } from "tdesign-mobile-vue";
import CustomerAPI from "@/api/CustomerAPI";
import ProductAPI from "@/api/ProductAPI";
@@ -229,6 +237,7 @@ import CodeScanner from "@/components/CodeScanner.vue";
import CustomerProfileCard from "@/components/CustomerProfileCard.vue";
import CustomerSelector from "@/components/CustomerSelector.vue";
import MediaSelector from "@/components/mediaSelector/MediaSelector.vue";
import ProductSelectFormItem from "@/components/productSelector/ProductSelectFormItem.vue";
import ProductStockPreview from "@/components/ProductStockPreview.vue";
import type { Customer } from "@/types/Customer";
import type { Product, ProductSku, ProductSkuUnit } from "@/types/Product";
@@ -361,7 +370,6 @@ const totalAmount = computed(() => {
}
return amount;
});
const totalAmountText = computed(() => totalAmount.value === undefined ? "0.00" : formatProductAmount(totalAmount.value));
const paymentAmountPlaceholder = computed(() => `订单总金额:${formatProductAmount(totalAmount.value || 0)}`);
function createItem(): FormItem {
@@ -428,10 +436,6 @@ function calculateItemAmount(item: FormItem): number | undefined {
const result = Number(amount / quantityScale);
return Number.isSafeInteger(result) ? result : undefined;
}
function getItemSubtotalText(item: FormItem): string {
const amount = calculateItemAmount(item);
return amount === undefined ? "0.00" : formatProductAmount(amount);
}
async function loadCustomer(value: string | string[]): Promise<void> {
const id = Array.isArray(value) ? value[0] : value;
customer.value = id ? await CustomerAPI.detail(id) : undefined;
@@ -754,12 +758,9 @@ onUnmounted(() => navBarStore.clearRight());
.price {
display: flex;
font-size: 1.5rem;
align-items: baseline;
justify-content: end;
.value {
font-size: 1.5rem;
}
}
.add {
@@ -796,18 +797,15 @@ onUnmounted(() => navBarStore.clearRight());
display: flex;
flex-direction: column;
span {
.label {
color: var(--td-text-color-secondary);
font-size: .6875rem;
}
.price {
display: flex;
font-size: 1.5rem;
align-items: baseline;
.value {
font-size: 1.5rem;
}
}
}