add point

This commit is contained in:
Timi
2026-08-11 22:25:30 +08:00
parent e612cfd382
commit 9f60a36c6c
21 changed files with 2928 additions and 36 deletions
+31
View File
@@ -30,6 +30,9 @@
</template>
</t-cell>
</t-cell-group>
<t-cell-group v-if="customer && canReadPointAccount" title="积分" class="point-account" theme="card">
<t-cell title="当前积分余额" :note="pointBalanceText" arrow hover @click="toPointAccount" />
</t-cell-group>
<t-cell-group theme="card">
<div class="conditioning-part bg-white">
<span class="gray">调理部位</span>
@@ -147,12 +150,14 @@
import { DialogPlugin, Toast } from "tdesign-mobile-vue";
import { Time, useUserStore } from "timi-web";
import CustomerAPI from "@/api/CustomerAPI";
import PointAPI from "@/api/PointAPI";
import BodyAreaSelector from "@/components/BodyAreaSelector.vue";
import CodeScanner from "@/components/CodeScanner.vue";
import CustomerProfileCard from "@/components/CustomerProfileCard.vue";
import CustomerSelector from "@/components/CustomerSelector.vue";
import { useSettingStore } from "@/store/settingStore";
import type { BodyAreaValue, Customer } from "@/types/Customer";
import type { PointAccount } from "@/types/Point";
import { getCustomerPhotoURL, normalizeBodyAreaValue } from "@/utils/customer";
import { permissionCodes } from "@/utils/permission";
import { LunarCalendar } from "@/utils/LunarCalendar";
@@ -167,6 +172,7 @@ const settingStore = useSettingStore();
const userStore = useUserStore();
const customer = ref<Customer>();
const pointAccount = ref<PointAccount>();
const invitees = ref<Customer[]>([]);
const selectedInviteeId = ref("");
const selectorVisible = ref(false);
@@ -179,6 +185,8 @@ let latestDecodedText = "";
const inviter = computed(() => customer.value?.introducerCustomer);
const canReadStat = computed(() => userStore.hasPermissions(permissionCodes.stat.read));
const canReadPointAccount = computed(() => userStore.hasPermissions(permissionCodes.point.accountRead));
const pointBalanceText = computed(() => pointAccount.value ? `${(pointAccount.value.balance ?? 0).toLocaleString("zh-CN")} 分` : "尚未产生积分流水");
const creatorName = computed(() => {
const creatorUser = customer.value?.creatorUser;
return creatorUser?.nick || creatorUser?.name || customer.value?.creatorUserId || "无";
@@ -209,6 +217,7 @@ async function loadCustomer(): Promise<void> {
try {
showSolarBirthdate.value = false;
customer.value = await CustomerAPI.detail(id);
await loadPointAccount();
await loadInvitees();
} catch (err) {
customer.value = undefined;
@@ -218,6 +227,18 @@ async function loadCustomer(): Promise<void> {
}
}
async function loadPointAccount(): Promise<void> {
pointAccount.value = undefined;
if (!customer.value?.id || !canReadPointAccount.value) {
return;
}
try {
pointAccount.value = await PointAPI.accountDetail(customer.value.id, customer.value.storeId);
} catch {
pointAccount.value = undefined;
}
}
async function loadInvitees(): Promise<void> {
const customerId = customer.value?.id;
if (!customerId) {
@@ -279,6 +300,16 @@ async function toEdit(): Promise<void> {
await router.push(`/management/customers/${customer.value.id}/edit`);
}
async function toPointAccount(): Promise<void> {
if (!customer.value?.id) {
return;
}
await router.push({
name: "PointAccount",
query: { customerId: customer.value.id, storeId: customer.value.storeId || "" }
});
}
function formatBirthdate(value?: Customer): string {
if (!value?.birthdate) {
return "无";