shawenguan 1 anno fa
parent
commit
c3be0fd0d3
2 ha cambiato i file con 52 aggiunte e 14 eliminazioni
  1. 8 0
      BoxJsSub/wubian.json
  2. 44 14
      Scripts/wubian/wubianHelper.js

+ 8 - 0
BoxJsSub/wubian.json

@@ -68,6 +68,14 @@
                     "desc": "默认关闭"
                 },
                 {
+                    "id": "WubianMyAllArtRealCountData",
+                    "name": "我拥有的产品实际数量",
+                    "val": "[]",
+                    "type": "textarea",
+                    "autoGrow": true,
+                    "desc": "我拥有的产品实际数量"
+                },
+                {
                     "id": "WubianMyAllArtModifyCountData",
                     "name": "我拥有的产品数量自定义",
                     "val": "[]",

+ 44 - 14
Scripts/wubian/wubianHelper.js

@@ -23,7 +23,7 @@ const WuBianConstKey = {
     MarketAlbumListData: 'WubianMarketAlbumListData',
     AllMarketGroupListData: 'WubianAllMarketGroupListData',
     MyAllArtModifyCountData: 'WubianMyAllArtModifyCountData',
-    MyAllArtModifyCountData2: 'WubianMyAllArtModifyCountData2',
+    MyAllArtRealCountData: 'WubianMyAllArtRealCountData',
     MyArtCountCaptureEnabled: 'WubianMyArtCountCaptureEnabled',
     MyArtCountModifyMode: 'WubianMyArtCountModifyMode',
     ArtIdNameMapData: 'WubianArtIdNameMapData',
@@ -389,31 +389,33 @@ function handleUserCollectList() {
     }
     handleHeaders();
     let artIdNameMapData = magicJS.data.read(WuBianConstKey.ArtIdNameMapData, {});
-    let cntDict = getAllArtModifyCountDict();
+    let realCntDict = getMyAllArtRealCountData();
+    let modCntDict = getAllArtModifyCountDict();
     let list = rspData.data.list;
     for (let i = list.length - 1; i >= 0; i--) {
         const artInfo = list[i];
         artIdNameMapData[artInfo.artId] = artInfo.title;
+        realCntDict[artInfo.title] = artInfo.total;
     }
     magicJS.data.write(WuBianConstKey.ArtIdNameMapData, artIdNameMapData);
     if (isMyArtCountCaptureEnabled()) {
         for (let i = list.length - 1; i >= 0; i--) {
             const artInfo = list[i];
+            realCntDict[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;
-                }
+        setAllArtRealCountDict(realCntDict);
+    }
+    if (isMyArtCountModifyMode()) {
+        for (let i = list.length - 1; i >= 0; i--) {
+            const artInfo = list[i];
+            checkArticleModify(artInfo, modCntDict);
+            if (artInfo.total == 0) {
+                list.splice(i, 1);
+                modCntDict[artInfo.title] = 0;
             }
-            gRetBody = rspData;
-            setAllArtModifyCountDict(cntDict);
         }
+        gRetBody = rspData;
+        setAllArtModifyCountDict(modCntDict);
     }
 }
 
@@ -485,6 +487,30 @@ function checkArticleModify(artInfo, modifyCntDict) {
     }
 }
 
+function getMyAllArtRealCountData() {
+    let str = magicJS.data.read(WuBianConstKey.MyAllArtRealCountData, '');
+    if (str && str.trim().length > 0) {
+        let lineArr = str.split('\n');
+        for (let i = 0; i < lineArr.length; i++) {
+            let kvArr = lineArr[i].trim().split('=');
+            let name = kvArr[0].trim();
+            if (kvArr[1]) {
+                let count = parseInt(kvArr[1].trim());
+                dict[name] = count;
+            }
+        }
+    }
+    return dict;
+}
+
+function setAllArtRealCountDict(dict) {
+    let str = '';
+    for (let name in dict) {
+        str += `${name}=${dict[name]}\n`;
+    }
+    magicJS.data.write(WuBianConstKey.MyAllArtRealCountData, str);
+}
+
 function handleInitData() {
     let rspData = getResponsePlainData();
     if (!rspData) {
@@ -656,6 +682,8 @@ function hadnleMarketGroupList() {
     let list = rspData.data?.list || [];
     let groupName = '';
     let nowTime = Date.now();
+
+    let artIdNameMapData = magicJS.data.read(WuBianConstKey.ArtIdNameMapData, {});
     for (let i = 0; i < list.length; ++i) {
         let item = list[i];
         dataDict[item.artId] = item;
@@ -664,7 +692,9 @@ function hadnleMarketGroupList() {
         item.updateTime = nowTime;
         sortId += 1;
         groupName = item.groupName;
+        artIdNameMapData[item.artId] = item.title;
     }
+    magicJS.data.write(WuBianConstKey.ArtIdNameMapData, artIdNameMapData);
     for (let artId in dataDict) {
         let item = dataDict[artId];
         if (item.updateTime == void 0) {