shawenguan 2 gadi atpakaļ
vecāks
revīzija
14c564f8d3
2 mainītis faili ar 66 papildinājumiem un 7 dzēšanām
  1. 8 2
      BoxJsSub/JoJo_BoxJs.json
  2. 58 5
      Scripts/gandartHelper.js

+ 8 - 2
BoxJsSub/JoJo_BoxJs.json

@@ -35,8 +35,7 @@
                 "lkGandartCastingId",
                 "lkGandartTransactionRecordId",
                 "lkGandartLimitPrice",
-                "lkGandartCollectionName",
-                "lkGandartCollectionCateLst"
+                "lkGandartCollectionName"
             ],
             "settings": [
                 {
@@ -101,6 +100,13 @@
                   "val": "",
                   "type": "text",
                   "desc": "产品名称"
+                },
+                {
+                  "id": "lkGandartCollectionCateLst",
+                  "name": "产品列表",
+                  "val": "[]",
+                  "type": "textarea",
+                  "desc": "产品列表"
                 }
             ]
         }

+ 58 - 5
Scripts/gandartHelper.js

@@ -61,13 +61,59 @@ function getInfo() {
             lk.msg('');
             return;
         }
+        if(url.match(/\/base\/v2\/resaleManage\/resale\/findAllIsOpenResale/)){
+            lk.log(`获取最新产品开放在售列表`);
+            let data = lk.getResponseBody();
+            try {
+                data = JSON.parse(data);
+                if (data["success"]) {
+                    let obj = data["obj"];
+                    let oldItemlst = JSON.parse(lk.getVal(gandartCollectionCateLstKey, '[]'));
+                    let pageItemlst = obj;
+                    let newLst = checkAppendCollectionItemsDiff(oldItemlst, pageItemlst);
+                    let jsonStr = JSON.stringify(newLst);
+                    lk.setVal(gandartCollectionCateLstKey, jsonStr);
+                    lk.log(jsonStr);
+                }
+                // lk.appendNotifyInfo('🎉更新了产品列表');
+            } catch (e) {
+                lk.logErr(e);
+                lk.execFail();
+            }
+            lk.msg('');
+            return;
+        }
+
+        // if(url.match(/\/base\/v2\/favorite\/selectRecord/)){
+        //     lk.log(`获取收藏的产品列表`);
+        //     let data = lk.getResponseBody();
+        //     try {
+        //         data = JSON.parse(data);
+        //         if (data["success"]) {
+        //             let obj = data["obj"];
+        //             let oldItemlst = JSON.parse(lk.getVal(gandartCollectionCateLstKey, '[]'));
+        //             let pageItemlst = obj;
+        //             let newLst = checkAppendCollectionItemsDiff(oldItemlst, pageItemlst);
+        //             let jsonStr = JSON.stringify(newLst);
+        //             lk.setVal(gandartCollectionCateLstKey, jsonStr);
+        //             lk.log(jsonStr);
+        //         }
+        //         // lk.appendNotifyInfo('🎉更新了产品列表');
+        //     } catch (e) {
+        //         lk.logErr(e);
+        //         lk.execFail();
+        //     }
+        //     lk.msg('');
+        //     return;
+        // }
+
         if(url.match(/\/market\/api\/v3\/resaleManage\/resale\/tradingMarket/)){
             lk.log(`获取最新Token并更新产品列表`);
             // lk.log(JSON.stringify($request.headers));
             if ($request.headers['token']) {
                 let jwktoken = $request.headers['token'];
                 lk.setVal(gandartTokenKey, jwktoken);
-                lk.appendNotifyInfo('🎉成功获取最新Token');
+                // lk.appendNotifyInfo('🎉成功获取最新Token');
             }
             let data = lk.getResponseBody();
             try {
@@ -81,7 +127,7 @@ function getInfo() {
                     lk.setVal(gandartCollectionCateLstKey, jsonStr);
                     lk.log(jsonStr);
                 }
-                lk.appendNotifyInfo('🎉更新了产品列表');
+                // lk.appendNotifyInfo('🎉更新了产品列表');
             } catch (e) {
                 lk.logErr(e);
                 lk.execFail();
@@ -125,21 +171,28 @@ function getInfo() {
     }
 }
 
+function copyDictTo(fromDic, toDic) {
+    toDic = toDic || {};
+    for(let k in fromDic){
+        toDic[k] = fromDic[k];
+    }
+    return toDic;
+}
+
 function checkAppendCollectionItemsDiff(cLst, pageLst){
     let dic = {};
     for (const d of cLst) {
         dic[d.castingId] = d;
     }
     for (const d of pageLst) {
-        dic[d.castingId] = d;
+        dic[d.castingId] = copyDictTo(d, dic[d.castingId]);
     }
     let newLst = [];
     for(let k in dic){
         let ele = {
             castingId: dic[k].castingId,
             collectionName: dic[k].collectionName,
-            resalePrice: dic[k].resalePrice,
-            viewSort: dic[k].viewSort || 0,
+            resalePrice: dic[k].resalePrice || 0,
         };
         newLst.push(ele);
     }