shawenguan hai 1 ano
pai
achega
040674b299
Modificáronse 2 ficheiros con 83 adicións e 3 borrados
  1. 21 0
      BoxJsSub/wubian.json
  2. 62 3
      Scripts/wubian/wubianHelper.js

+ 21 - 0
BoxJsSub/wubian.json

@@ -52,6 +52,27 @@
                     "val": true,
                     "type": "boolean",
                     "desc": "默认开启"
+                },
+                {
+                    "id": "WubianMyArtCountCaptureEnabled",
+                    "name": "开启/关闭我拥有的产品数量采集",
+                    "val": true,
+                    "type": "boolean",
+                    "desc": "默认开启"
+                },
+                {
+                    "id": "WubianMyArtCountModifyMode",
+                    "name": "开启/关闭我拥有的产品数量修改模式",
+                    "val": false,
+                    "type": "boolean",
+                    "desc": "默认关闭"
+                },
+                {
+                    "id": "WubianMyAllArtModifyCountData",
+                    "name": "我拥有的产品数量自定义",
+                    "val": "",
+                    "type": "text",
+                    "desc": "我拥有的产品数量自定义"
                 }
             ]
         },

+ 62 - 3
Scripts/wubian/wubianHelper.js

@@ -22,6 +22,9 @@ const WuBianConstKey = {
     TenantId: 'WubianTenantId',
     MarketAlbumListData: 'WubianMarketAlbumListData',
     AllMarketGroupListData: 'WubianAllMarketGroupListData',
+    MyAllArtModifyCountData: 'WubianMyAllArtModifyCountData',
+    MyArtCountCaptureEnabled: 'WubianMyArtCountCaptureEnabled',
+    MyArtCountModifyMode: 'WubianMyArtCountModifyMode',
 
     AllUserSimpleInfo: 'WubianAllUserSimpleInfo',
     ScoreRankDaily: 'WubianScoreRankDaily',
@@ -384,9 +387,56 @@ function handleUserCollectList() {
         return;
     }
     handleHeaders();
-    // rspData.data.list = [];
-    // rspData.data.next = 0;
-    // gRetBody = rspData;
+    let cntDict = getAllArtModifyCountDict();
+    let list = rspData.data.list;
+    if (isMyArtCountCaptureEnabled()) {
+        for (let i = list.length - 1; i >= 0; i--) {
+            const artInfo = list[i];
+            cntDict[artInfo.title] = artInfo.total;
+        }
+        setAllArtModifyCountDict(cntDict);
+    } else {
+        if (isMyArtCountModifyMode()) {
+            for (let i = list.length - 1; i >= 0; i--) {
+                const artInfo = list[i];
+                checkArticleModify(artInfo, cntDict);
+                if (artInfo.total == 0) {
+                    list.splice(i, 1);
+                    cntDict[artInfo.title] = 0;
+                }
+            }
+            gRetBody = rspData;
+            setAllArtModifyCountDict(cntDict);
+        }
+    }
+}
+
+function getAllArtModifyCountDict() {
+    let dict = {};
+    let str = magicJS.data.read(WuBianConstKey.MyAllArtModifyCountData, '');
+    let lineArr = str.split('\n');
+    for (let i = 0; i < lineArr.length; i++) {
+        let kvArr = lineArr[i].trim().split('=');
+        let name = kvArr[0].trim();
+        let count = parseInt(kvArr[1].trim());
+        dict[name] = count;
+    }
+    return dict;
+}
+
+function setAllArtModifyCountDict(dict) {
+    let str = '';
+    for (let name in dict) {
+        str += `${name}=${dict[name]}\n`;
+    }
+    magicJS.data.write(WuBianConstKey.MyAllArtModifyCountData, str);
+}
+
+function checkArticleModify(artInfo, modifyCntDict) {
+    let title = artInfo.title;
+    if (modifyCntDict[title] != void 0) {
+        artInfo.total = modifyCntDict[title];
+    }
 }
 
 function handleInitData() {
@@ -657,6 +707,15 @@ function setActivityDisabled(activityId, bDisabled = true) {
     magicJS.data.write(key, bDisabled);
 }
 
+function isMyArtCountCaptureEnabled() {
+    let isEnabled = magicJS.data.read(WuBianConstKey.MyArtCountCaptureEnabled, true);
+    return isEnabled;
+}
+function isMyArtCountModifyMode() {
+    let isEnabled = magicJS.data.read(WuBianConstKey.MyArtCountModifyMode, false);
+    return isEnabled;
+}
+
 function handleCvtGoodsList() {
     let rspData = getResponsePlainData();
     if (!rspData) {