fix: 总会员/体验会员抢单池前端校验与会员状态同步
- dashou-profile 增强 userHasHuiyuan,支持总会员子类型与 ID 等价比较 - 会员支付成功后从 dashouxinxi 刷新完整 clumber,不再只写总会员 ID - order-pool 对齐 accept-order:服务端 clumber、hasRequiredMember、抢单校验 - fighter 我的页下拉刷新正确同步管事/组长角色状态
This commit is contained in:
@@ -23,14 +23,30 @@ export async function refreshDashouMembership(app) {
|
||||
return app.globalData.clumber || [];
|
||||
}
|
||||
|
||||
/** 用户是否持有某会员类型(与抢单卡片判断一致;支持总会员 covers) */
|
||||
/** 会员 ID 等价比较(001 与 1 视为相同,与后端 huiyuan_ids_match 一致) */
|
||||
export function huiyuanIdMatch(a, b) {
|
||||
const left = String(a ?? '').trim();
|
||||
const right = String(b ?? '').trim();
|
||||
if (!left || !right) return false;
|
||||
if (left === right) return true;
|
||||
const leftCore = left.replace(/^0+/, '') || '0';
|
||||
const rightCore = right.replace(/^0+/, '') || '0';
|
||||
return leftCore === rightCore;
|
||||
}
|
||||
|
||||
/** 用户是否持有某会员类型(与抢单卡片判断一致;支持总会员 included_huiyuan_ids / from_bundle) */
|
||||
export function userHasHuiyuan(huiyuanList, huiyuanId) {
|
||||
if (!huiyuanId) return true;
|
||||
if (!huiyuanId && huiyuanId !== 0) return true;
|
||||
const list = huiyuanList || [];
|
||||
const req = String(huiyuanId);
|
||||
return list.some((h) => {
|
||||
if (String(h.huiyuanid) === req || String(h.huiyuan_id) === req) return true;
|
||||
if (huiyuanIdMatch(h.huiyuanid, req) || huiyuanIdMatch(h.huiyuan_id, req)) {
|
||||
return true;
|
||||
}
|
||||
const covers = h.included_huiyuan_ids || h.covers || [];
|
||||
return Array.isArray(covers) && covers.some((id) => String(id) === req);
|
||||
if (Array.isArray(covers) && covers.some((id) => huiyuanIdMatch(id, req))) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user