37 lines
1.4 KiB
JavaScript
37 lines
1.4 KiB
JavaScript
/**
|
||
* 从服务端刷新打手会员/押金/积分等到 globalData(抢单、考试等页共用)
|
||
*/
|
||
import request from './request.js';
|
||
|
||
export async function refreshDashouMembership(app) {
|
||
app = app || getApp();
|
||
try {
|
||
const res = await request({ url: '/yonghu/dashouxinxi', method: 'POST' });
|
||
if (res && res.data && res.data.code == 200) {
|
||
const data = res.data.data || {};
|
||
const clumber = Array.isArray(data.clumber) ? data.clumber : [];
|
||
app.globalData.clumber = clumber;
|
||
if (data.yajin !== undefined) app.globalData.yajin = data.yajin;
|
||
if (data.jifen !== undefined) app.globalData.jinfen = data.jifen;
|
||
if (data.zhanghaostatus !== undefined) app.globalData.zhanghaoStatus = data.zhanghaostatus;
|
||
if (data.dashouzhuangtai !== undefined) app.globalData.dashouzhuangtai = data.dashouzhuangtai;
|
||
return clumber;
|
||
}
|
||
} catch (e) {
|
||
console.error('refreshDashouMembership failed', e);
|
||
}
|
||
return app.globalData.clumber || [];
|
||
}
|
||
|
||
/** 用户是否持有某会员类型(与抢单卡片判断一致;支持总会员 covers) */
|
||
export function userHasHuiyuan(huiyuanList, huiyuanId) {
|
||
if (!huiyuanId) return true;
|
||
const list = huiyuanList || [];
|
||
const req = String(huiyuanId);
|
||
return list.some((h) => {
|
||
if (String(h.huiyuanid) === req) return true;
|
||
const covers = h.included_huiyuan_ids || h.covers || [];
|
||
return Array.isArray(covers) && covers.some((id) => String(id) === req);
|
||
});
|
||
}
|