Browse Source

水电月消费记录去重

soft5566 3 years ago
parent
commit
566ee50fa3
3 changed files with 52 additions and 41 deletions
  1. 2 2
      pages/index/index.vue
  2. 24 18
      pagesElectric/dfxq/dfxq.vue
  3. 26 21
      pagesElectric/sfxq/sfxq.vue

+ 2 - 2
pages/index/index.vue

@@ -17,10 +17,10 @@
 					<image src="../../static/images/air.png" mode=""></image>
 					<image src="../../static/images/air.png" mode=""></image>
 					<text>共享空调</text>
 					<text>共享空调</text>
 				</navigator>
 				</navigator>
-				<navigator :url="'/pagesClockIn/index/index'" open-type="navigate" class="menu_item">
+				<!-- <navigator :url="'/pagesClockIn/index/index'" open-type="navigate" class="menu_item">
 					<image src="../../static/images/clockIn.png" mode=""></image>
 					<image src="../../static/images/clockIn.png" mode=""></image>
 					<text>校园打卡</text>
 					<text>校园打卡</text>
-				</navigator>
+				</navigator> -->
 			</view>
 			</view>
 		</view>
 		</view>
 		<view class="qr_code" v-if="showQR_code">
 		<view class="qr_code" v-if="showQR_code">

+ 24 - 18
pagesElectric/dfxq/dfxq.vue

@@ -222,49 +222,55 @@
 
 
 				// console.log(res.data)
 				// console.log(res.data)
 				if (res.data.rows.length == 0) {
 				if (res.data.rows.length == 0) {
-					return
+					return;
 				}
 				}
 
 
 				if (typeof res.data.rows === 'undefined') {
 				if (typeof res.data.rows === 'undefined') {
 					uni.showToast({
 					uni.showToast({
 						title: '加载数据异常',
 						title: '加载数据异常',
 						duration: 1500
 						duration: 1500
-					})
+					});
 
 
-					return
+					return;
 				} else {
 				} else {
+					var tableData = []
 					for (let i = 0; i < res.data.rows.length; i++) {
 					for (let i = 0; i < res.data.rows.length; i++) {
-						let dataTime = res.data.rows[i].dataTime
-						let zongStart = res.data.rows[i].zongStart
-						let zongEnd = res.data.rows[i].zongEnd
-						let totalPower = res.data.rows[i].totalPower
-						let totalMoney = res.data.rows[i].totalMoney
+						let dataTime = res.data.rows[i].dataTime;
+						let zongStart = res.data.rows[i].zongStart;
+						let zongEnd = res.data.rows[i].zongEnd;
+						let totalPower = res.data.rows[i].totalPower;
+						let totalMoney = res.data.rows[i].totalMoney;
 
 
-						zongStart = zongStart.toFixed(2)
-						zongEnd = zongEnd.toFixed(2)
-						totalPower = totalPower.toFixed(2)
-						totalMoney = totalMoney.toFixed(2)
+						zongStart = zongStart.toFixed(2);
+						zongEnd = zongEnd.toFixed(2);
+						totalPower = totalPower.toFixed(2);
+						totalMoney = totalMoney.toFixed(2);
 
 
 						if (this.moneyPer <= 0.00) {
 						if (this.moneyPer <= 0.00) {
 							if (totalPower > 0.00 && totalMoney > 0.00) {
 							if (totalPower > 0.00 && totalMoney > 0.00) {
-								let moneyPer = totalMoney / totalPower
-								this.moneyPer = moneyPer.toFixed(2)
+								let moneyPer = totalMoney / totalPower;
+								this.moneyPer = moneyPer.toFixed(2);
 
 
 								if (this.moneyPer <= 0.00) {
 								if (this.moneyPer <= 0.00) {
-									this.moneyPer = 0.61
+									this.moneyPer = 0.61;
 								}
 								}
 							}
 							}
 						}
 						}
 
 
-						totalMoney = '¥' + totalMoney
-						this.tableData.push({
+						totalMoney = '¥' + totalMoney;
+						tableData.push({
 							dataTime,
 							dataTime,
 							zongStart,
 							zongStart,
 							zongEnd,
 							zongEnd,
 							totalPower,
 							totalPower,
 							totalMoney
 							totalMoney
-						})
+						});
 					}
 					}
+					this.tableData = tableData.filter(function(item, index, self) {
+						return index === self.findIndex(function(t) {
+							return t.dataTime === item.dataTime && t.totalPower === item.totalPower && t.totalMoney === item.totalMoney;
+						});
+					});
 				}
 				}
 			}
 			}
 		}
 		}

+ 26 - 21
pagesElectric/sfxq/sfxq.vue

@@ -4,8 +4,7 @@
 		<view class="same-month">
 		<view class="same-month">
 			<view class="title">
 			<view class="title">
 				<view class="vertical-line"></view>
 				<view class="vertical-line"></view>
-				<view class="title-txt"><text class="caption">当月详情</text><text
-						class="hah">/</text>时间更新到{{sameMonthData.dataTime}}</view>
+				<view class="title-txt"><text class="caption">当月详情</text><text class="hah">/</text>时间更新到{{sameMonthData.dataTime}}</view>
 			</view>
 			</view>
 			<view class="content-details">
 			<view class="content-details">
 				<view class="item">
 				<view class="item">
@@ -177,7 +176,7 @@
 					if (res.data.data.length == 0) {
 					if (res.data.data.length == 0) {
 						return
 						return
 					}
 					}
-					
+
 					let zongEnd = res.data.data[0].zongEnd
 					let zongEnd = res.data.data[0].zongEnd
 					let totalMoney = res.data.data[0].totalMoney
 					let totalMoney = res.data.data[0].totalMoney
 					let totalPower = res.data.data[0].totalPower
 					let totalPower = res.data.data[0].totalPower
@@ -230,42 +229,48 @@
 					uni.showToast({
 					uni.showToast({
 						title: '加载数据异常',
 						title: '加载数据异常',
 						duration: 1500
 						duration: 1500
-					})
+					});
 
 
-					return
+					return;
 				} else {
 				} else {
+					var tableData = []
 					for (let i = 0; i < res.data.rows.length; i++) {
 					for (let i = 0; i < res.data.rows.length; i++) {
-						let dataTime = res.data.rows[i].dataTime
-						let zongStart = res.data.rows[i].zongStart
-						let zongEnd = res.data.rows[i].zongEnd
-						let totalPower = res.data.rows[i].totalPower
-						let totalMoney = res.data.rows[i].totalMoney
+						let dataTime = res.data.rows[i].dataTime;
+						let zongStart = res.data.rows[i].zongStart;
+						let zongEnd = res.data.rows[i].zongEnd;
+						let totalPower = res.data.rows[i].totalPower;
+						let totalMoney = res.data.rows[i].totalMoney;
 
 
-						zongStart = zongStart.toFixed(2)
-						zongEnd = zongEnd.toFixed(2)
-						totalPower = totalPower.toFixed(2)
-						totalMoney = totalMoney.toFixed(2)
+						zongStart = zongStart.toFixed(2);
+						zongEnd = zongEnd.toFixed(2);
+						totalPower = totalPower.toFixed(2);
+						totalMoney = totalMoney.toFixed(2);
 
 
 						if (this.moneyPer <= 0.00) {
 						if (this.moneyPer <= 0.00) {
 							if (totalPower > 0.00 && totalMoney > 0.00) {
 							if (totalPower > 0.00 && totalMoney > 0.00) {
-								let moneyPer = totalMoney / totalPower
-								this.moneyPer = moneyPer.toFixed(2)
+								let moneyPer = totalMoney / totalPower;
+								this.moneyPer = moneyPer.toFixed(2);
 
 
 								if (this.moneyPer <= 0.00) {
 								if (this.moneyPer <= 0.00) {
-									this.moneyPer = 0.61
+									this.moneyPer = 0.61;
 								}
 								}
 							}
 							}
 						}
 						}
 
 
-						totalMoney = '¥' + totalMoney
-						this.tableData.push({
+						totalMoney = '¥' + totalMoney;
+						tableData.push({
 							dataTime,
 							dataTime,
 							zongStart,
 							zongStart,
 							zongEnd,
 							zongEnd,
 							totalPower,
 							totalPower,
 							totalMoney
 							totalMoney
-						})
+						});
 					}
 					}
+					this.tableData = tableData.filter(function(item, index, self) {
+						return index === self.findIndex(function(t) {
+							return t.dataTime === item.dataTime && t.totalPower === item.totalPower && t.totalMoney === item.totalMoney;
+						});
+					});
 				}
 				}
 			}
 			}
 		}
 		}
@@ -364,4 +369,4 @@
 			}
 			}
 		}
 		}
 	}
 	}
-</style>
+</style>