Explorar o código

修改计算方式错误

xiaohaizhao hai 10 meses
pai
achega
f61b99abe9
Modificáronse 3 ficheiros con 36 adicións e 49 borrados
  1. 2 2
      packageA/salesHourglass/index.js
  2. 0 9
      utils/language.js
  3. 34 38
      utils/matchingFeilType.js

+ 2 - 2
packageA/salesHourglass/index.js

@@ -303,13 +303,13 @@ Page({
             const comingYear = res.data.array.map(v => {
                 return {
                     name: getApp().globalData.Language.getMapText('预计签约金额'),
-                    value: (v.signamount_due / (wx.getStorageSync('languagecode') == 'ZH' ? 10000 : 1000)).toFixed(2) - 0,
+                    value: (v.signamount_due / (wx.getStorageSync('languagecode') == 'ZH' ? 10000 : 1000)).toFixed(0) - 0,
                     date: v.signdate_due
                 }
             }).concat(res.data.array.map(v => {
                 return {
                     name: getApp().globalData.Language.getMapText('预计成交金额'),
-                    value: (v.dealamount_due / (wx.getStorageSync('languagecode') == 'ZH' ? 10000 : 1000)).toFixed(2) - 0,
+                    value: (v.dealamount_due / (wx.getStorageSync('languagecode') == 'ZH' ? 10000 : 1000)).toFixed(0) - 0,
                     date: v.signdate_due
                 }
 

+ 0 - 9
utils/language.js

@@ -48,15 +48,6 @@ class Language {
 			title: this.getMapText(title)
 		})
 	}
-
-	modeBoxPrompts(list, title = '提示', confirmText = '确定') {
-		wx.showModal({
-			title: this.getMapText(title),
-			content: this.joint(list),
-			showCancel: false,
-			confirmText: this.getMapText(confirmText),
-		})
-	}
 	showToast(list) {
 		if (list.length) wx.showToast({
 			title: this.joint(list),

+ 34 - 38
utils/matchingFeilType.js

@@ -1,48 +1,44 @@
 function fileList(list) {
-    if (list.length == 0) return [];
-    let suffixList = {
-            image: ['png', 'jpg', 'jpeg', 'bmp', 'gif', 'webp', 'svg', 'tiff'],
-            video: ['mp4', 'ogg', 'webm'],
-            word: ['doc', 'docx'],
-            excel: ['xls', 'xlsx'],
-            ppt: ['ppt', 'pptx'],
-            txt: ['txt', 'md', 'js', 'json'],
-            pdf: ['pdf'],
-            rar: ['7z', 'zip', 'rar', 'kz', 'ace', 'arj', 'bz2', 'cab', 'gz', 'iso', 'jar', 'lzh', 'tar', 'z'],
-            folder: ['"folder"']
-        },
-        typeList = [];
-    for (let key in suffixList) typeList.push(key);
-    for (let i = 0; i < list.length; i++) {
-        list[i].fileType = 'unknown';
-        list[i].cover = `/static/image/file/unknown.png`
-        const suffix = list[i].postfix.toLowerCase();
-        if (suffix != "folder") {
-            for (let key in suffixList) {
-                if (suffixList[key].some(value => value == suffix)) {
-                    list[i].fileType = key;
-                    if (key == 'image') {
-                        list[i].cover = list[i].url;
-                    } else if (typeList.includes(key)) {
-                        list[i].cover = `/static/image/file/${key}.png`;
-                    }
-                }
-            }
-        } else {
-            list[i].fileType = "folder";
-            list[i].cover = `/static/image/file/folder.png`
-        }
-    }
-    return list;
-};
+    if (!Array.isArray(list) || list.length === 0) return [];
+
+    const suffixList = {
+        image: ['png', 'jpg', 'jpeg', 'bmp', 'gif', 'webp', 'svg', 'tiff'],
+        video: ['mp4', 'ogg', 'webm'],
+        word: ['doc', 'docx'],
+        excel: ['xls', 'xlsx'],
+        ppt: ['ppt', 'pptx'],
+        txt: ['txt', 'md', 'js', 'json'],
+        pdf: ['pdf'],
+        rar: ['7z', 'zip', 'rar', 'kz', 'ace', 'arj', 'bz2', 'cab', 'gz', 'iso', 'jar', 'lzh', 'tar', 'z'],
+        folder: ['folder']
+    };
+
+    return list.map(file => {
+        const suffix = file.postfix ? file.postfix.toLowerCase() : '';
+        const fileType = suffixList.folder.includes(suffix) ? 'folder' : 
+                         Object.keys(suffixList).find(key => suffixList[key].includes(suffix)) || 'unknown';
+
+        return {
+            ...file,
+            fileType,
+            cover: fileType === 'image' ? file.url : 
+                   fileType !== 'unknown' ? `/static/image/file/${fileType}.png` : 
+                   `/static/image/file/unknown.png`
+        };
+    });
+}
+
 
 //得到缩略图或者压缩图  getType默认得到缩略图传true得到压缩图
 function getSpecifiedImage(obj, getType = false) {
-    let type = getType ? 'compressed' : 'thumbnail';
-    let imgObj = obj.subfiles.find(v => v.type == type);
+    if (!obj || !Array.isArray(obj.subfiles)) return "";
+
+    const type = getType ? 'compressed' : 'thumbnail';
+    const imgObj = obj.subfiles.find(v => v.type === type);
     return imgObj ? imgObj.url : "";
 }
 
+
 module.exports = {
     fileList,
     getSpecifiedImage