MCPcopy Create free account
hub / github.com/chavyleung/scripts / checkIsVip

Function checkIsVip

zsfc/zsfc.js:617–644  ·  view source on GitHub ↗

* @description 掌飞购物相关函数,判断用户是否为会员用户。 * @returns {Promise } 包含会员状态的 Promise 对象。

()

Source from the content-addressed store, hash-verified

615 * @returns {Promise<object>} 包含会员状态的 Promise 对象。
616 */
617async function checkIsVip() {
618 // 初始化会员情况默认为非会员
619 let result = false;
620
621 // 构建所请求的 URL 地址
622 const url = `https://bang.qq.com/app/speed/treasure/index?${$.queryStr({
623 'roleId': $.read(`zsfc_roleId`),
624 'uin': $.read(`zsfc_uin`),
625 'areaId': $.read(`zsfc_areaId`),
626 })}`;
627
628 // 返回一个 Promise 对象,用于异步操作
629 return new Promise(resolve => {
630 // 发送 GET 请求,获取寻宝页面数据
631 $.get(url, (error, response, data) => {
632 try {
633 if (data) {
634 // 提取userInfo和mapInfo的数据
635 const userInfoData = eval(data.match(/window\.userInfo\s*=\s*eval\('([^']+)'\);/)?.[1]);
636 result = userInfoData.vip_flag !== 0;
637 }
638 } finally {
639 // 解析 Promise,将结果对象传递给 resolve 函数
640 resolve(result);
641 }
642 });
643 });
644}
645
646/**
647 * @description 掌飞购物相关函数,根据商品名称搜索商品信息

Callers 1

zsfc.jsFile · 0.85

Calls 2

queryStrMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected