Skip to content

Commit ac8f802

Browse files
committed
fix
1 parent 9d1c86f commit ac8f802

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

Scripts/wsgw.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ class Widget extends DmYY {
104104
);
105105
console.log(response);
106106
this.settings.data = [];
107-
response.forEach((dataInfo) => {
107+
response?.forEach((dataInfo) => {
108108
const dataSource = {
109109
user: '**',
110110
left: {
@@ -133,13 +133,13 @@ class Widget extends DmYY {
133133
dataSource.left.arrearsOfFees = dataInfo.arrearsOfFees;
134134

135135
dataSource.right.previousBill = parseFloat(
136-
this.last(dataInfo.monthElecQuantity.mothEleList).monthEleCost
136+
this.last(dataInfo.monthElecQuantity?.mothEleList || [])
137+
?.monthEleCost || 0
137138
);
138139

139-
const oldVal = this.last(
140-
dataInfo.monthElecQuantity.mothEleList,
141-
2
142-
).monthEleCost;
140+
const oldVal =
141+
this.last(dataInfo.monthElecQuantity?.mothEleList || [], 2)
142+
?.monthEleCost || 1;
143143

144144
dataSource.right.previousBillRate =
145145
((dataSource.right.previousBill - oldVal) / oldVal) * 100;
@@ -149,7 +149,7 @@ class Widget extends DmYY {
149149
);
150150

151151
dataSource.right.thisYear = parseFloat(
152-
dataInfo.monthElecQuantity.dataInfo.totalEleCost
152+
dataInfo.monthElecQuantity?.dataInfo?.totalEleCost || 0
153153
);
154154

155155
const lastYearVal = dataInfo.lastYearElecQuantity.dataInfo.totalEleCost;

0 commit comments

Comments
 (0)