fix(core): comprehensive fix for state loss across activity, ticket, workspace, favorites and community
这个提交包含在:
@@ -137,12 +137,12 @@
|
||||
<text class="sec-sub">满员即成局</text>
|
||||
</view>
|
||||
<view class="member-list" v-if="activity.participants && activity.participants.length > 0">
|
||||
<view v-for="(p, index) in activity.participants" :key="p.id" class="member-item" :class="{ 'my-member-item': Number(p.userId) === CURRENT_USER_ID }">
|
||||
<view v-for="(p, index) in activity.participants" :key="p.id" class="member-item" :class="{ 'my-member-item': Number(p.userId) === currentUserId }">
|
||||
<image class="member-avatar" :src="p.avatar" mode="aspectFill" />
|
||||
<view class="member-info">
|
||||
<view class="member-top-line">
|
||||
<text class="member-name">{{ p.nickname }}</text>
|
||||
<text class="my-badge" v-if="Number(p.userId) === CURRENT_USER_ID">我的席位</text>
|
||||
<text class="my-badge" v-if="Number(p.userId) === currentUserId">我的席位</text>
|
||||
<text class="member-price-tag" v-if="p.priceAtJoin">
|
||||
出价: ¥{{ p.priceAtJoin }}
|
||||
</text>
|
||||
@@ -158,7 +158,7 @@
|
||||
<view class="checkin-badge" :class="{ checked: p.checkedIn }">
|
||||
{{ p.checkedIn ? '已核销到场' : '待现场核销' }}
|
||||
</view>
|
||||
<text class="btn-micro-leave btn-active" v-if="Number(p.userId) === CURRENT_USER_ID && !p.checkedIn" @click.stop="handleLeave">
|
||||
<text class="btn-micro-leave btn-active" v-if="Number(p.userId) === currentUserId && !p.checkedIn" @click.stop="handleLeave">
|
||||
退席
|
||||
</text>
|
||||
</view>
|
||||
@@ -384,18 +384,26 @@ import {
|
||||
import { ICONS } from '@/common/icons.js';
|
||||
import { getCurrentThemeKey, applyThemeToNativeUI } from '@/common/theme.js';
|
||||
|
||||
const CURRENT_USER_ID = 1001;
|
||||
const currentUserId = computed(() => {
|
||||
try {
|
||||
return Number(uni.getStorageSync('userId')) || 1001;
|
||||
} catch (_) {
|
||||
return 1001;
|
||||
}
|
||||
});
|
||||
const currentActId = ref('1');
|
||||
const verifyCodeInput = ref('');
|
||||
const currentThemeKey = ref(getCurrentThemeKey());
|
||||
|
||||
const isHost = computed(() => {
|
||||
if (!activity.value) return false;
|
||||
return Number(activity.value.creatorId) === CURRENT_USER_ID;
|
||||
return Number(activity.value.creatorId) === currentUserId.value;
|
||||
});
|
||||
|
||||
const myParticipantInfo = computed(() => {
|
||||
if (!activity.value || !activity.value.participants) return null;
|
||||
return activity.value.participants.find(p => Number(p.userId) === CURRENT_USER_ID || Number(p.id) === CURRENT_USER_ID);
|
||||
const uid = currentUserId.value;
|
||||
return activity.value.participants.find(p => Number(p.userId) === uid || Number(p.id) === uid);
|
||||
});
|
||||
|
||||
const isJoined = computed(() => !!myParticipantInfo.value);
|
||||
@@ -421,6 +429,9 @@ onMounted(() => {
|
||||
onShow(() => {
|
||||
currentThemeKey.value = getCurrentThemeKey();
|
||||
applyThemeToNativeUI(currentThemeKey.value);
|
||||
if (currentActId.value) {
|
||||
loadLiveDetail(currentActId.value);
|
||||
}
|
||||
});
|
||||
|
||||
onUnmounted(() => {
|
||||
@@ -458,6 +469,7 @@ const loadLiveDetail = async (id) => {
|
||||
|
||||
onLoad((query) => {
|
||||
const targetId = (query && query.id) ? query.id : '1';
|
||||
currentActId.value = targetId;
|
||||
loadLiveDetail(targetId);
|
||||
});
|
||||
|
||||
@@ -639,7 +651,7 @@ const handleHostVerify = async () => {
|
||||
}
|
||||
try {
|
||||
uni.showLoading({ title: '正在核销签到...' });
|
||||
await verifyActivityCheckin(activity.value.id, code, CURRENT_USER_ID);
|
||||
await verifyActivityCheckin(activity.value.id, code, currentUserId.value);
|
||||
uni.hideLoading();
|
||||
verifyCodeInput.value = '';
|
||||
uni.showToast({ title: '核销成功!搭子已签到', icon: 'success' });
|
||||
@@ -675,7 +687,7 @@ const handleHostCancel = () => {
|
||||
if (res.confirm) {
|
||||
try {
|
||||
uni.showLoading({ title: '正在解散并全额退款...' });
|
||||
await cancelActivity(activity.value.id, CURRENT_USER_ID, '局长主动解散组局');
|
||||
await cancelActivity(activity.value.id, currentUserId.value, '局长主动解散组局');
|
||||
uni.hideLoading();
|
||||
uni.showToast({ title: '组局已成功解散', icon: 'success' });
|
||||
activity.value.status = 'CANCELLED';
|
||||
@@ -703,7 +715,7 @@ const handleLeave = () => {
|
||||
if (res.confirm) {
|
||||
try {
|
||||
uni.showLoading({ title: '正在办理退席...' });
|
||||
await leaveActivity(activity.value.id, CURRENT_USER_ID);
|
||||
await leaveActivity(activity.value.id, currentUserId.value);
|
||||
uni.hideLoading();
|
||||
uni.showToast({ title: '已退席,款项已退回钱包', icon: 'success' });
|
||||
loadLiveDetail(activity.value.id);
|
||||
|
||||
@@ -121,7 +121,7 @@
|
||||
|
||||
<script setup>
|
||||
import { ref, computed, onMounted, onUnmounted } from 'vue';
|
||||
import { onLoad } from '@dcloudio/uni-app';
|
||||
import { onLoad, onShow } from '@dcloudio/uni-app';
|
||||
import { getActivityDetail, verifyActivityCheckin, getMyActivities, leaveActivity } from '@/common/api.js';
|
||||
import { encodeCode128B } from '@/common/barcode.js';
|
||||
import { generateQRCodeMatrix } from '@/common/qrcode.js';
|
||||
@@ -140,6 +140,14 @@ const isCheckedIn = ref(false);
|
||||
const currentTime = ref('');
|
||||
const hasTicket = ref(true);
|
||||
|
||||
const currentUserId = computed(() => {
|
||||
try {
|
||||
return Number(uni.getStorageSync('userId')) || 1001;
|
||||
} catch (_) {
|
||||
return 1001;
|
||||
}
|
||||
});
|
||||
|
||||
const ticketSn = computed(() => {
|
||||
const actId = ticketData.value && ticketData.value.id ? ticketData.value.id : '101';
|
||||
return `TICKET-${actId}-${verifyCode.value}`;
|
||||
@@ -170,7 +178,9 @@ const updateTime = () => {
|
||||
currentTime.value = `${y}-${m}-${d} ${hh}:${mm}:${ss}`;
|
||||
};
|
||||
|
||||
onLoad(async (query) => {
|
||||
let savedQuery = null;
|
||||
|
||||
const loadTicketData = async (query = savedQuery) => {
|
||||
if (query && query.code) {
|
||||
verifyCode.value = String(query.code);
|
||||
}
|
||||
@@ -199,17 +209,18 @@ onLoad(async (query) => {
|
||||
|
||||
// 2. 若无传参,真实拉取当前用户的已报名组局列表
|
||||
try {
|
||||
const myActs = await getMyActivities(1001);
|
||||
const uid = currentUserId.value;
|
||||
const myActs = await getMyActivities(uid);
|
||||
const joinedList = myActs.joined || [];
|
||||
if (joinedList.length > 0) {
|
||||
let targetAct = joinedList.find(act => {
|
||||
const myP = (act.participants || []).find(p => p.userId === 1001 || p.nickname === '同城局长' || p.verifyCode);
|
||||
const myP = (act.participants || []).find(p => Number(p.userId) === uid || p.nickname === '同城局长' || p.verifyCode);
|
||||
return myP && !myP.checkedIn;
|
||||
}) || joinedList[0];
|
||||
|
||||
ticketData.value = targetAct;
|
||||
if (targetAct.participants && targetAct.participants.length > 0) {
|
||||
const myP = targetAct.participants.find(p => p.userId === 1001 || p.verifyCode);
|
||||
const myP = targetAct.participants.find(p => Number(p.userId) === uid || p.verifyCode);
|
||||
if (myP && myP.verifyCode) {
|
||||
verifyCode.value = String(myP.verifyCode);
|
||||
isCheckedIn.value = Boolean(myP.checkedIn);
|
||||
@@ -235,8 +246,16 @@ onLoad(async (query) => {
|
||||
}
|
||||
}
|
||||
} catch (_) {}
|
||||
};
|
||||
|
||||
onLoad(async (query) => {
|
||||
savedQuery = query;
|
||||
await loadTicketData(query);
|
||||
});
|
||||
|
||||
onShow(async () => {
|
||||
await loadTicketData();
|
||||
});
|
||||
|
||||
onMounted(() => {
|
||||
updateTime();
|
||||
@@ -251,7 +270,7 @@ const toggleCheckIn = async () => {
|
||||
if (!isCheckedIn.value) {
|
||||
try {
|
||||
uni.showLoading({ title: '正在核销签到...' });
|
||||
await verifyActivityCheckin(ticketData.value.id, verifyCode.value, 1001);
|
||||
await verifyActivityCheckin(ticketData.value.id, verifyCode.value, currentUserId.value);
|
||||
uni.hideLoading();
|
||||
isCheckedIn.value = true;
|
||||
uni.showToast({
|
||||
@@ -291,7 +310,7 @@ const handleCancelTicket = () => {
|
||||
try {
|
||||
uni.showLoading({ title: '正在办理退票...' });
|
||||
const actId = ticketData.value && ticketData.value.id ? ticketData.value.id : 'act_101';
|
||||
await leaveActivity(actId, 1001);
|
||||
await leaveActivity(actId, currentUserId.value);
|
||||
uni.hideLoading();
|
||||
uni.showToast({ title: '退票成功,款项已退回钱包', icon: 'success' });
|
||||
setTimeout(() => {
|
||||
|
||||
在新工单中引用
屏蔽一个用户