shawenguan 1 an în urmă
părinte
comite
4a2d7b81dc
1 a modificat fișierele cu 17 adăugiri și 2 ștergeri
  1. 17 2
      Scripts/imoutai/imoutaiHelper.js

+ 17 - 2
Scripts/imoutai/imoutaiHelper.js

@@ -54,6 +54,7 @@ const iMT_Location = {
 
 const iMT_BuyItemCodes = ["10941", "10942"]; // 申购商品ID名单列表
 
+const iMT_DynProducts = {};
 
 let retBody;
 if (!lk.isExecComm) {
@@ -634,6 +635,16 @@ function fliterShopByDistance(itemId, shops, lat, lng){
     return retList;
 }
 
+// 获取产品信息
+function getProductInfo(productId, fieldName) {
+    for (const k in productInfo) {
+        const { picUrl, title, price, count, itemId, inventory, areaLimitTag, areaLimit } = iMT_DynProducts[k];
+        if (productId === itemId) {
+            return productInfo[k][fieldName];
+        }
+    }
+}
+
 async function getShopItem(sessionId, itemId, token, deviceId, province, city, district, zeroTimeStamp) {
     return new Promise((resolve, _reject) => {
         try {
@@ -680,7 +691,8 @@ async function getShopItem(sessionId, itemId, token, deviceId, province, city, d
                             if (jsonRetObj.code == 2000) {
                                 const rspData = jsonRetObj.data || {};
                                 let shops = rspData.shops || [];
-                                // lk.log(`data=${JSON.stringify(shopIds)}`);
+                                iMT_DynProducts = rspData.items;
+                                lk.log(`data=${JSON.stringify(rspData.items)}`);
                                 if(fliterRule == 0){
                                     shops = fliterShopByDistance(itemId, shops, iMT_Location.lat, iMT_Location.lng);
                                 }else if(fliterRule == 1){
@@ -695,9 +707,12 @@ async function getShopItem(sessionId, itemId, token, deviceId, province, city, d
                                         if (district && !new RegExp(district).test(shopInfo.districtName)){
                                             continue;
                                         }
-                                        if (checkShopItemIdIndex(skuData, itemId) > -1) {
+                                        const findIndex = checkShopItemIdIndex(skuData, itemId);
+                                        if (findIndex > -1) {
                                             lk.log(`shopInfo=${JSON.stringify(shopInfo)}`);
                                             lk.log(`skuData=${JSON.stringify(skuData)}`);
+                                            const { count, itemId, inventory, ownerName } = skuData.items[findIndex];
+                                            lk.log(`【${ownerName}】[${shopId}-${itemId}] ${getProductInfo(itemId, 'title')}  价格:${getProductInfo(itemId, 'price')}  库存:${inventory}`);
                                             ret = shopId;
                                             break;
                                         }