fix(core): comprehensive fix for state loss across activity, ticket, workspace, favorites and community
这个提交包含在:
@@ -169,9 +169,10 @@ export async function leaveActivity(activityId, userId = 2001) {
|
||||
/**
|
||||
* 获取“我的组局”(发起的 + 报名的)
|
||||
*/
|
||||
export async function getMyActivities(userId = 1001) {
|
||||
export async function getMyActivities(userId) {
|
||||
const uid = normalizeUserId(userId);
|
||||
try {
|
||||
const res = await http.get(`/users/${userId}/my-activities`);
|
||||
const res = await http.get(`/users/${uid}/my-activities`);
|
||||
if (res) {
|
||||
return {
|
||||
created: (res.created || []).map(formatActivityData),
|
||||
@@ -477,7 +478,13 @@ export async function likePost(id, action, userId) {
|
||||
* 规范化用户ID,自动兼容历史测试账号映射 (将虚拟陪伴师 101 映射至真实用户 2006)
|
||||
*/
|
||||
function normalizeUserId(uid) {
|
||||
const n = Number(uid);
|
||||
let target = uid;
|
||||
if (!target && target !== 0) {
|
||||
try {
|
||||
target = uni.getStorageSync('userId');
|
||||
} catch (_) {}
|
||||
}
|
||||
const n = Number(target);
|
||||
if (n === 101) return 2006;
|
||||
return (!isNaN(n) && n > 0) ? n : 1001;
|
||||
}
|
||||
@@ -952,9 +959,10 @@ export async function updateExpertServiceStatus(expertId = 101, serviceId, statu
|
||||
/**
|
||||
* 获取用户收藏的陪玩列表
|
||||
*/
|
||||
export async function getFavorites(userId = 1001) {
|
||||
export async function getFavorites(userId) {
|
||||
const uid = normalizeUserId(userId);
|
||||
try {
|
||||
const res = await http.get(`/favorites?userId=${userId}`);
|
||||
const res = await http.get(`/favorites?userId=${uid}`);
|
||||
return res || [];
|
||||
} catch (err) {
|
||||
console.warn('[API] 获取收藏列表异常:', err.message);
|
||||
@@ -965,9 +973,10 @@ export async function getFavorites(userId = 1001) {
|
||||
/**
|
||||
* 探测是否已收藏特定陪玩
|
||||
*/
|
||||
export async function checkFavorite(expertId, userId = 1001) {
|
||||
export async function checkFavorite(expertId, userId) {
|
||||
const uid = normalizeUserId(userId);
|
||||
try {
|
||||
const res = await http.get(`/favorites/check?userId=${userId}&expertId=${expertId}`);
|
||||
const res = await http.get(`/favorites/check?userId=${uid}&expertId=${expertId}`);
|
||||
return res && res.isFavorite;
|
||||
} catch (err) {
|
||||
console.warn('[API] 探测收藏状态异常:', err.message);
|
||||
@@ -978,9 +987,10 @@ export async function checkFavorite(expertId, userId = 1001) {
|
||||
/**
|
||||
* 添加收藏
|
||||
*/
|
||||
export async function addFavorite(expertId, userId = 1001) {
|
||||
export async function addFavorite(expertId, userId) {
|
||||
const uid = normalizeUserId(userId);
|
||||
try {
|
||||
const res = await http.post('/favorites', { userId, expertId });
|
||||
const res = await http.post('/favorites', { userId: uid, expertId });
|
||||
return res;
|
||||
} catch (err) {
|
||||
console.warn('[API] 添加收藏异常:', err.message);
|
||||
@@ -991,9 +1001,10 @@ export async function addFavorite(expertId, userId = 1001) {
|
||||
/**
|
||||
* 取消收藏
|
||||
*/
|
||||
export async function removeFavorite(expertId, userId = 1001) {
|
||||
export async function removeFavorite(expertId, userId) {
|
||||
const uid = normalizeUserId(userId);
|
||||
try {
|
||||
const res = await http.delete(`/favorites/${expertId}?userId=${userId}`);
|
||||
const res = await http.delete(`/favorites/${expertId}?userId=${uid}`);
|
||||
return res;
|
||||
} catch (err) {
|
||||
console.warn('[API] 取消收藏异常:', err.message);
|
||||
@@ -1004,9 +1015,10 @@ export async function removeFavorite(expertId, userId = 1001) {
|
||||
/**
|
||||
* 获取分销团队列表 (一级与二级成员)
|
||||
*/
|
||||
export async function getDistributionTeam(userId = 1001) {
|
||||
export async function getDistributionTeam(userId) {
|
||||
const uid = normalizeUserId(userId);
|
||||
try {
|
||||
const res = await http.get(`/distribution/team?userId=${userId}`);
|
||||
const res = await http.get(`/distribution/team?userId=${uid}`);
|
||||
return res || { directCount: 0, indirectCount: 0, totalTeamCount: 0, directList: [], indirectList: [] };
|
||||
} catch (err) {
|
||||
console.warn('[API] 获取分销团队异常:', err.message);
|
||||
@@ -1017,9 +1029,10 @@ export async function getDistributionTeam(userId = 1001) {
|
||||
/**
|
||||
* 获取分销返佣订单记录
|
||||
*/
|
||||
export async function getDistributionRecords(userId = 1001) {
|
||||
export async function getDistributionRecords(userId) {
|
||||
const uid = normalizeUserId(userId);
|
||||
try {
|
||||
const res = await http.get(`/distribution/records?userId=${userId}`);
|
||||
const res = await http.get(`/distribution/records?userId=${uid}`);
|
||||
return res || [];
|
||||
} catch (err) {
|
||||
console.warn('[API] 获取分销返佣记录异常:', err.message);
|
||||
|
||||
在新工单中引用
屏蔽一个用户