XWookey vor 1 Jahr
Ursprung
Commit
4fe11d44c5
3 geänderte Dateien mit 97 neuen und 43 gelöschten Zeilen
  1. 0 38
      pages/charginfo/charginfo.js
  2. 48 0
      pages/index/index.js
  3. 49 5
      pages/search_result/search_result.js

+ 0 - 38
pages/charginfo/charginfo.js

@@ -34,43 +34,7 @@ Page({
     isLogin: false,
     resultTable: []
   },
-  resetResultData(resultList,data){
-    if(!resultList){
-      return;
-    }
-    for(let i=0;i<resultList.length;i++){
-      if(resultList[i].currentTime){
-        data.chargprice = resultList[i].elecPrice
-        data.serviceprice = resultList[i].serviceprice
-      }
-    }
-  },
 
-  resetResultList(resultList){
-    let that = this
-    if(!resultList){
-      return;
-    }
-    resultList.forEach(item=>{
-      item["sumPrice"] = that.resetResultListSumPrice(item);
-      if(!item.elecPrice){
-        item["elecPrice"] = '暂无费用'
-      }
-      if(!item.servicePrice){
-        item["servicePrice"] = '暂无费用'
-      }
-    })
-  },
-  resetResultListSumPrice(item){
- 
-    if(!item.elecPrice){
-      return '暂无费用'
-    }
-    if(!item.servicePrice){
-      return '暂无费用'
-    }
-    return parseFloat((item.elecPrice + item.servicePrice).toFixed(6))
-  },
   /**
    * 生命周期函数--监听页面加载
    */
@@ -83,8 +47,6 @@ Page({
         console.info(res)
         var seeInfoChargPile = res.data;
         let resultTable = seeInfoChargPile.resultList
-        that.resetResultList(resultTable);
-        that.resetResultData(resultTable,seeInfoChargPile)
         that.setData({
           resultTable
         })

+ 48 - 0
pages/index/index.js

@@ -187,7 +187,52 @@ Page({
       }
     }
   },
+  resetchargStations(data){
+    let that = this
+    for(let i=0;i<data.length;i++){
+      let seeInfoChargPile = data[i];
+      let resultTable = seeInfoChargPile.resultList
+      that.resetResultList(resultTable);
+      that.resetResultData(resultTable,seeInfoChargPile)
+    }
+  },
+  resetResultData(resultList,data){
+    if(!resultList){
+      return;
+    }
+    for(let i=0;i<resultList.length;i++){
+      if(resultList[i].currentTime){
+        data.chargprice = resultList[i].elecPrice
+        data.serviceprice = resultList[i].serviceprice
+      }
+    }
+  },
+
+  resetResultList(resultList){
+    let that = this
+    if(!resultList){
+      return;
+    }
+    resultList.forEach(item=>{
+      item["sumPrice"] = that.resetResultListSumPrice(item);
+      if(!item.elecPrice){
+        item["elecPrice"] = '暂无费用'
+      }
+      if(!item.servicePrice){
+        item["servicePrice"] = '暂无费用'
+      }
+    })
+  },
+  resetResultListSumPrice(item){
  
+    if(!item.elecPrice){
+      return '暂无费用'
+    }
+    if(!item.servicePrice){
+      return '暂无费用'
+    }
+    return parseFloat((item.elecPrice + item.servicePrice).toFixed(6))
+  },
 
   onLoad(e) {
 
@@ -273,6 +318,8 @@ Page({
           method: 'POST',
           success(res) {
             //userInfo.flag = true;
+            that.resetchargStations(res.data)
+
             if (isLogin && userInfo.flag) {
               wx.request({
                 url: getApp().globalData.postHeadAgreement + '/restapi/wechat/userChargStations',
@@ -867,6 +914,7 @@ Page({
               },
               method: 'POST',
               success(res) {
+                that.resetchargStations(res.data)
                 let {
                   data
                 } = res;

+ 49 - 5
pages/search_result/search_result.js

@@ -20,6 +20,53 @@ Page({
     keywords: null,
     moneyPng: ''
   },
+  resetchargStations(data){
+    let that = this
+    for(let i=0;i<data.length;i++){
+      let seeInfoChargPile = data[i];
+      let resultTable = seeInfoChargPile.resultList
+      that.resetResultList(resultTable);
+      that.resetResultData(resultTable,seeInfoChargPile)
+    }
+  },
+  resetResultData(resultList,data){
+    if(!resultList){
+      return;
+    }
+    for(let i=0;i<resultList.length;i++){
+      if(resultList[i].currentTime){
+        data.chargprice = resultList[i].elecPrice
+        data.serviceprice = resultList[i].serviceprice
+      }
+    }
+  },
+
+  resetResultList(resultList){
+    let that = this
+    if(!resultList){
+      return;
+    }
+    resultList.forEach(item=>{
+      item["sumPrice"] = that.resetResultListSumPrice(item);
+      if(!item.elecPrice){
+        item["elecPrice"] = '暂无费用'
+      }
+      if(!item.servicePrice){
+        item["servicePrice"] = '暂无费用'
+      }
+    })
+  },
+  resetResultListSumPrice(item){
+ 
+    if(!item.elecPrice){
+      return '暂无费用'
+    }
+    if(!item.servicePrice){
+      return '暂无费用'
+    }
+    return parseFloat((item.elecPrice + item.servicePrice).toFixed(6))
+  },
+
   onLoad(e) {
     let {
       city,
@@ -67,7 +114,7 @@ Page({
       },
       method: 'POST',
       success(res) {
-
+        that.resetchargStations(res.data)
         //userInfo.flag = true;
         if (isLogin && userInfo.flag) {
           wx.request({
@@ -254,10 +301,7 @@ Page({
       },
       method: 'POST',
       success(res) {
-        var chargPile = res.data;
-        let resultTable = chargPile.resultList
-        that.resetResultList(resultTable);
-        that.resetResultData(resultTable,chargPile)
+        that.resetchargStations(res.data)
         //userInfo.flag = true;
         if (isLogin && userInfo.flag) {
           wx.request({