bug修复
This commit is contained in:
parent
a368474ffb
commit
78858de9c4
@ -1,29 +1,28 @@
|
||||
<template>
|
||||
<full-page pageClass="coupons-page" :customScroll="true">
|
||||
<scroll-view
|
||||
class="coupon-scroll"
|
||||
scroll-y="true"
|
||||
refresher-enabled="true"
|
||||
:refresher-triggered="refreshing"
|
||||
@refresherrefresh="refreshCoupons"
|
||||
>
|
||||
<scroll-view class="coupon-scroll" scroll-y="true" refresher-enabled="true" :refresher-triggered="refreshing"
|
||||
@refresherrefresh="refreshCoupons">
|
||||
<view class="page-body">
|
||||
<view class="user-card" @click="toSelectPage">
|
||||
<view class="avatar">
|
||||
<uni-icons type="person-filled" size="36" color="#c0c4cc" />
|
||||
</view>
|
||||
<view class="user-main">
|
||||
<view class="user-name">{{ customerName || "未选择档案" }}</view>
|
||||
<view class="user-corp">所属机构:{{ corpName || "-" }}</view>
|
||||
</view>
|
||||
<uni-icons type="right" size="16" color="#c0c4cc" />
|
||||
</view>
|
||||
|
||||
<view class="summary">
|
||||
以下为“<text class="summary-name">{{ customerName || "-" }}</text>”的所有剩余权益
|
||||
</view>
|
||||
<view v-if="loading" class="empty">加载中...</view>
|
||||
<view v-else-if="!list.length" class="empty">暂无体验券</view>
|
||||
<view v-else class="coupon-list">
|
||||
<view
|
||||
v-for="item in list"
|
||||
:key="item._id"
|
||||
class="coupon-card"
|
||||
:class="item.cardClass"
|
||||
@click="openPoster(item)"
|
||||
>
|
||||
<image
|
||||
v-if="item.posterUrl"
|
||||
class="coupon-poster"
|
||||
:src="item.posterUrl"
|
||||
mode="aspectFill"
|
||||
/>
|
||||
<view v-for="item in list" :key="item._id" class="coupon-card" :class="item.cardClass"
|
||||
@click="openPoster(item)">
|
||||
<image v-if="item.posterUrl" class="coupon-poster" :src="item.posterUrl" mode="aspectFill" />
|
||||
<view v-else class="coupon-poster coupon-poster--empty">体验券</view>
|
||||
<view class="coupon-body">
|
||||
<view class="coupon-title-row">
|
||||
@ -38,11 +37,8 @@
|
||||
<view class="coupon-info-row coupon-info-row--projects">
|
||||
<text class="coupon-info-label">项目</text>
|
||||
<view class="coupon-project-list">
|
||||
<view
|
||||
v-for="project in item.projectSnapshot || []"
|
||||
:key="project.projectId"
|
||||
class="coupon-project-item"
|
||||
>
|
||||
<view v-for="project in item.projectSnapshot || []" :key="project.projectId"
|
||||
class="coupon-project-item">
|
||||
<text>{{ project.projectName || "未命名项目" }}</text>
|
||||
<text>×{{ project.usageCount || 1 }}</text>
|
||||
</view>
|
||||
@ -74,11 +70,7 @@
|
||||
<!-- 海报领取弹窗 -->
|
||||
<view v-if="posterVisible" class="poster-mask" @click="closePoster">
|
||||
<view class="poster-dialog" @click.stop>
|
||||
<image
|
||||
class="poster-image"
|
||||
:src="current?.posterUrl || ''"
|
||||
mode="widthFix"
|
||||
/>
|
||||
<image class="poster-image" :src="current?.posterUrl || ''" mode="widthFix" />
|
||||
<view class="poster-info">
|
||||
<view class="poster-title">{{ current?.activityName || "体验券" }}</view>
|
||||
<view class="poster-desc">{{ current?.projectText }}</view>
|
||||
@ -97,18 +89,21 @@ import { onLoad, onShow } from "@dcloudio/uni-app";
|
||||
import { storeToRefs } from "pinia";
|
||||
import useAccount from "@/store/account";
|
||||
import api from "@/utils/api";
|
||||
import { get } from "@/utils/cache";
|
||||
import { get, remove } from "@/utils/cache";
|
||||
import { toast } from "@/utils/widget";
|
||||
import { normalizeCorpId } from "@/utils/api-base-config";
|
||||
import FullPage from "@/components/full-page.vue";
|
||||
|
||||
const HOME_CURRENT_TEAM_CACHE_KEY = "home-current-team-info";
|
||||
const RIGHTS_SELECTION_CACHE_KEY = "experience-coupon-rights-selection";
|
||||
const { account } = storeToRefs(useAccount());
|
||||
const { getTeams } = useAccount();
|
||||
|
||||
const corpId = ref("");
|
||||
const teamId = ref("");
|
||||
const customerId = ref("");
|
||||
const customerName = ref("");
|
||||
const corpName = ref("");
|
||||
const list = ref([]);
|
||||
const loading = ref(false);
|
||||
const refreshing = ref(false);
|
||||
@ -116,6 +111,16 @@ const posterVisible = ref(false);
|
||||
const current = ref(null);
|
||||
const claiming = ref(false);
|
||||
|
||||
async function loadCorpName() {
|
||||
if (!corpId.value) {
|
||||
corpName.value = "";
|
||||
return;
|
||||
}
|
||||
const res = await api("getCorpInfo", { corpId: corpId.value }, false);
|
||||
const corp = Array.isArray(res?.data) ? res.data[0] : null;
|
||||
corpName.value = corp?.corp_name || corp?.corpName || "";
|
||||
}
|
||||
|
||||
function toTimestamp(value) {
|
||||
if (!value) return 0;
|
||||
const numeric = Number(value);
|
||||
@ -186,6 +191,7 @@ async function resolveContext(options = {}) {
|
||||
corpId.value = normalizeCorpId(options.corpId || corpId.value || "");
|
||||
teamId.value = options.teamId || teamId.value || "";
|
||||
customerId.value = options.customerId || options.memberId || customerId.value || "";
|
||||
customerName.value = options.name ? decodeURIComponent(options.name) : customerName.value;
|
||||
|
||||
const cached = get(HOME_CURRENT_TEAM_CACHE_KEY) || {};
|
||||
let teams = [];
|
||||
@ -203,6 +209,7 @@ async function resolveContext(options = {}) {
|
||||
if (!corpId.value) corpId.value = normalizeCorpId(matched?.corpId || cached.corpId || "");
|
||||
if (!teamId.value) teamId.value = matched?.teamId || cached.teamId || "";
|
||||
if (!corpId.value) return false;
|
||||
await loadCorpName();
|
||||
|
||||
if (customerId.value) return true;
|
||||
|
||||
@ -212,6 +219,7 @@ async function resolveContext(options = {}) {
|
||||
const customers = res?.success && Array.isArray(res.data) ? res.data : [];
|
||||
const preferred = customers.find((c) => c.relationship === "本人") || customers[0];
|
||||
customerId.value = preferred?._id || "";
|
||||
customerName.value = preferred?.name || customerName.value || "";
|
||||
return !!customerId.value;
|
||||
}
|
||||
|
||||
@ -296,6 +304,32 @@ async function refreshCoupons() {
|
||||
}
|
||||
}
|
||||
|
||||
async function syncSelectedProfile() {
|
||||
const selected = get(RIGHTS_SELECTION_CACHE_KEY);
|
||||
if (!selected) return false;
|
||||
remove(RIGHTS_SELECTION_CACHE_KEY);
|
||||
corpId.value = normalizeCorpId(selected.corpId || corpId.value || "");
|
||||
teamId.value = selected.teamId || teamId.value || "";
|
||||
customerId.value = selected.customerId || selected.memberId || customerId.value || "";
|
||||
customerName.value = selected.name || customerName.value || "";
|
||||
await loadCorpName();
|
||||
await loadCoupons();
|
||||
return true;
|
||||
}
|
||||
|
||||
function toSelectPage() {
|
||||
const params = [
|
||||
`corpId=${encodeURIComponent(corpId.value || "")}`,
|
||||
`teamId=${encodeURIComponent(teamId.value || "")}`,
|
||||
`customerId=${encodeURIComponent(customerId.value || "")}`,
|
||||
`mode=back`,
|
||||
`target=coupons`,
|
||||
].join("&");
|
||||
uni.navigateTo({
|
||||
url: `/pages/experience-coupon/select-rights-archive?${params}`,
|
||||
});
|
||||
}
|
||||
|
||||
function openPoster(item) {
|
||||
if (item?.displayStatus !== "issued") {
|
||||
toast(item?.displayStatusText || "当前体验券不可领取");
|
||||
@ -351,6 +385,8 @@ onLoad(async (options = {}) => {
|
||||
});
|
||||
|
||||
onShow(async () => {
|
||||
const changed = await syncSelectedProfile();
|
||||
if (changed) return;
|
||||
if (corpId.value && customerId.value) {
|
||||
await loadCoupons();
|
||||
}
|
||||
@ -374,6 +410,58 @@ onShow(async () => {
|
||||
background: #f5f5f5;
|
||||
}
|
||||
|
||||
.user-card {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
background: #fff;
|
||||
border-radius: 0;
|
||||
padding: 24rpx 30rpx;
|
||||
border-bottom: 1px solid #eceff4;
|
||||
}
|
||||
|
||||
.avatar {
|
||||
width: 88rpx;
|
||||
height: 88rpx;
|
||||
border-radius: 50%;
|
||||
background: #f0f2f5;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
margin-right: 20rpx;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.user-main {
|
||||
min-width: 0;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.user-name {
|
||||
font-size: 32rpx;
|
||||
font-weight: 600;
|
||||
color: #222;
|
||||
margin-bottom: 8rpx;
|
||||
}
|
||||
|
||||
.user-corp {
|
||||
font-size: 24rpx;
|
||||
color: #888;
|
||||
}
|
||||
|
||||
.summary {
|
||||
padding: 18rpx 30rpx;
|
||||
font-size: 26rpx;
|
||||
color: #666;
|
||||
background: #f0f2f5;
|
||||
border-top: 1px solid #eceff4;
|
||||
border-bottom: 1px solid #eceff4;
|
||||
}
|
||||
|
||||
.summary-name {
|
||||
color: #065bd6;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.coupon-card {
|
||||
display: flex;
|
||||
gap: 20rpx;
|
||||
@ -475,7 +563,7 @@ onShow(async () => {
|
||||
color: #909399;
|
||||
}
|
||||
|
||||
.coupon-info-row > text:last-child,
|
||||
.coupon-info-row>text:last-child,
|
||||
.coupon-project-list {
|
||||
min-width: 0;
|
||||
overflow-wrap: anywhere;
|
||||
|
||||
@ -80,7 +80,8 @@ function buildTargetUrl(item) {
|
||||
const name = encodeURIComponent(item.name || "");
|
||||
|
||||
if (target.value === "coupons") {
|
||||
return `/pages/experience-coupon/my-coupons?corpId=${corp}&teamId=${team}&customerId=${customer}`;
|
||||
const corpName = encodeURIComponent(item.corpName || "");
|
||||
return `/pages/experience-coupon/my-coupons?corpId=${corp}&teamId=${team}&customerId=${customer}&name=${name}&corpName=${corpName}`;
|
||||
}
|
||||
if (target.value === "health") {
|
||||
return `/pages/health/list?teamId=${team}&corpId=${corp}&id=${customer}&name=${name}`;
|
||||
|
||||
@ -16,7 +16,7 @@
|
||||
<view class="profile-title">{{ customerName || "请选择档案" }}</view>
|
||||
<view class="profile-sub">所属机构:{{ corpName || "-" }}</view>
|
||||
</view>
|
||||
<view class="profile-arrow">></view>
|
||||
<uni-icons type="right" size="16" color="#c0c4cc" />
|
||||
</view>
|
||||
|
||||
<picker mode="date" fields="month" :value="selectedMonth" @change="handleMonthChange">
|
||||
|
||||
@ -11,7 +11,7 @@
|
||||
<view class="profile-title">{{ customerName || "请选择档案" }}</view>
|
||||
<view class="profile-sub">所属机构:{{ corpName || "-" }}</view>
|
||||
</view>
|
||||
<view class="profile-arrow">></view>
|
||||
<uni-icons type="right" size="16" color="#c0c4cc" />
|
||||
</view>
|
||||
|
||||
<picker mode="date" fields="month" :value="selectedMonth" @change="handleMonthChange">
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user