Explorar o código

优化渲染机制

xiaohaizhao hai 1 ano
pai
achega
c83c69ad88
Modificáronse 1 ficheiros con 25 adicións e 27 borrados
  1. 25 27
      packageA/achievement/index.js

+ 25 - 27
packageA/achievement/index.js

@@ -215,41 +215,39 @@ Page({
         return dataType == 3 ? data : sortOut(data, res.data, dataType == 2)
       })
     };
-    getData(1).then(res => {
-      this.setData({
-        zysj: res
-      })
-    });
-    getData(2).then(res => {
-      this.setData({
-        xssj: res
-      })
-    });
-    getData(3).then(res => {
-      for (const key in res) {
+    wx.showLoading({
+      title: '加载中...',
+      mask: true
+    })
+    Promise.all([getData(1), getData(2), getData(3)]).then(res => {
+      wx.hideLoading()
+      for (const key in res[2]) {
         if (key == 'tab') continue;
-        res[key].target_l = conversion(res[key].target_l);
+        res[2][key].target_l = conversion(res[2][key].target_l);
         //实际
-        res[key].amount = conversion(res[key].amount);
-        res[key].outamount = conversion(res[key].outamount);
-        res[key].invoiceamount = conversion(res[key].invoiceamount);
+        res[2][key].amount = conversion(res[2][key].amount);
+        res[2][key].outamount = conversion(res[2][key].outamount);
+        res[2][key].invoiceamount = conversion(res[2][key].invoiceamount);
         //差额
-        res[key].unamount = CNY(res[key].unamount / 10000, '');
-        res[key].unamountcolor = res[key].unamount >= 0 ? '#5AB73F' : '#EB4B5C';
+        res[2][key].unamount = CNY(res[2][key].unamount / 10000, '');
+        res[2][key].unamountcolor = res[2][key].unamount >= 0 ? '#5AB73F' : '#EB4B5C';
 
-        res[key].unoutamount = CNY(res[key].unoutamount / 10000, '');
-        res[key].unoutamountcolor = res[key].unoutamount >= 0 ? '#5AB73F' : '#EB4B5C';
-        res[key].uninvoiceamount = CNY(res[key].uninvoiceamount / 10000, '');
-        res[key].uninvoiceamountcolor = res[key].uninvoiceamount >= 0 ? '#5AB73F' : '#EB4B5C';
+        res[2][key].unoutamount = CNY(res[2][key].unoutamount / 10000, '');
+        res[2][key].unoutamountcolor = res[2][key].unoutamount >= 0 ? '#5AB73F' : '#EB4B5C';
+        res[2][key].uninvoiceamount = CNY(res[2][key].uninvoiceamount / 10000, '');
+        res[2][key].uninvoiceamountcolor = res[2][key].uninvoiceamount >= 0 ? '#5AB73F' : '#EB4B5C';
         //达成率
-        res[key].wcamount = currency(res[key].wcamount).multiply(100) + '%';
-        res[key].wcoutamount = currency(res[key].wcoutamount).multiply(100) + '%';
-        res[key].wcinvoiceamount = currency(res[key].wcinvoiceamount).multiply(100) + '%';
+        res[2][key].wcamount = currency(res[2][key].wcamount).multiply(100) + '%';
+        res[2][key].wcoutamount = currency(res[2][key].wcoutamount).multiply(100) + '%';
+        res[2][key].wcinvoiceamount = currency(res[2][key].wcinvoiceamount).multiply(100) + '%';
       }
+
       this.setData({
-        yjsj: res
+        zysj: res[0],
+        xssj: res[1],
+        yjsj: res[2],
       })
-    });
+    })
   },
   dropdownItemChange({
     detail