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

Function searchShop

zsfc/zsfc.js:651–681  ·  view source on GitHub ↗

* @description 掌飞购物相关函数,根据商品名称搜索商品信息 * @param {string} shopName - 要搜索的商品名称 * @returns {Promise } 包含商品信息的 Promise 对象

(shopName)

Source from the content-addressed store, hash-verified

649 * @returns {Promise<Object>} 包含商品信息的 Promise 对象
650 */
651async function searchShop(shopName) {
652 // 初始化目标商品对象
653 let targetShopObject = {};
654
655 // 构建请求体
656 const options = {
657 url: `https://bang.qq.com/app/speed/mall/search?${$.queryStr({
658 'uin': $.read(`zsfc_uin`),
659 'userId': $.read(`zsfc_userId`),
660 'token': $.read(`zsfc_token`),
661 'start': '0',
662 'paytype': '1', // 按点券筛选
663 'order': '2', // 按点券筛选
664 'text': encodeURIComponent(shopName)
665 })}`,
666 headers: { Referer: `https://bang.qq.com/app/speed/mall/main2` },
667 };
668
669 // 返回一个 Promise 对象,用于异步操作
670 return new Promise(resolve => {
671 // 发送 POST 请求,获取商品信息
672 $.post(options, (err, resp, data) => {
673 if (data) {
674 const body = $.toObj(data);
675 targetShopObject = body.data.find(item => item.szName === shopName);
676 }
677 // 解析 Promise,将结果对象传递给 resolve 函数
678 resolve(targetShopObject);
679 });
680 });
681}
682
683/**
684 * @description 掌飞购物相关函数,获取点券和消费券信息

Callers 1

zsfc.jsFile · 0.85

Calls 3

queryStrMethod · 0.45
postMethod · 0.45
toObjMethod · 0.45

Tested by

no test coverage detected