Browse Source

feat: 统计

2912631854@qq.com 1 year ago
parent
commit
dda148728b
1 changed files with 76 additions and 30 deletions
  1. 76 30
      pages/statistics/index.vue

+ 76 - 30
pages/statistics/index.vue

@@ -23,12 +23,12 @@
 					总营业额
 				</view>
 				<view class="right">
-					共{{list.totalNums}}笔
+					共{{list.totalNums==null?'0':list.totalNums}}笔
 				</view>
 			</view>
 			<view class="two">
 				<text>¥</text>
-				<text>{{list.totalAmount}}</text>
+				<text>{{list.totalAmount==null?'0':list.totalAmount}}</text>
 			</view>
 		</view>
 		<view class="echarts-one">
@@ -41,7 +41,7 @@
 						房费
 					</view>
 					<view class="price">
-						{{list.roomAmount}}
+						{{list.roomAmount==null?'0':list.roomAmount}}
 					</view>
 				</view>
 				<view class="list">
@@ -49,7 +49,7 @@
 						商品
 					</view>
 					<view class="price">
-						{{list.breakfastAmount}}
+						{{list.breakfastAmount==null?'0':list.breakfastAmount}}
 					</view>
 				</view>
 				<view class="list">
@@ -57,7 +57,7 @@
 						其他
 					</view>
 					<view class="price">
-						{{list.othersAmount}}
+						{{list.othersAmount==null?'0':list.othersAmount}}
 					</view>
 				</view>
 
@@ -99,25 +99,25 @@
 
 <script>
 	// import uCharts from '@/utils/u-charts.js';
-	import PieCharts from "@/components/Charts/PieCharts.vue"
-	import LineOne from "@/components/Charts/LineOne.vue"
-	import LineTwo from "@/components/Charts/LineTwo.vue"
+	// import PieCharts from "@/components/Charts/PieCharts.vue"
+	// import LineOne from "@/components/Charts/LineOne.vue"
+	// import LineTwo from "@/components/Charts/LineTwo.vue"
 	export default {
 		components: {
-			PieCharts,
-			LineOne,
-			LineTwo
+			// PieCharts,
+			// LineOne,
+			// LineTwo
 		},
 		data() {
 			return {
 				h: uni.getSystemInfoSync().windowHeight,
 				mt: uni.getSystemInfoSync().statusBarHeight + 54,
-				date: '2024-01',
+				date: '',
 				fromData: {
-					dateDay: '2024-01',
+					dateDay: '',
 					homestayId: ''
 				},
-
+				// 营业概况
 				chartDataPied: {},
 				optsPied: {
 					rotate: false,
@@ -156,7 +156,7 @@
 				},
 				PieChartsList: {},
 
-				// 公司营收
+				// 交易趋势
 				revenueChartDataOne: {},
 				revenueOptsone: {
 					color: ["#4B98FE"],
@@ -175,6 +175,7 @@
 						data: [{
 							axisLineColor: "#FFFFFF",
 							min: 0,
+							// max: 20000
 						}],
 					},
 					legend: {
@@ -195,7 +196,7 @@
 				dataListOne: [],
 
 
-				// 公司营收
+				// 入住率
 				revenueChartDataTwo: {},
 				revenueOptstwo: {
 					color: ["#4B98FE"],
@@ -245,10 +246,44 @@
 				this.getList()
 			}
 
+
+		},
+		onLoad() {
+			this.getDays(0)
 		},
 		methods: {
+
+
+			getDays(day) {
+				var today = new Date();
+
+				var targetday_milliseconds = today.getTime() + 1000 * 60 * 60 * 24 * day;
+
+				today.setTime(targetday_milliseconds); //注意,这行是关键代码
+
+				var tYear = today.getFullYear();
+				var tMonth = today.getMonth();
+				var tDate = today.getDate();
+				var week = today.getDay();
+				tMonth = this.doHandleMonth(tMonth + 1);
+				tDate = this.doHandleMonth(tDate);
+				console.log('------', tYear + '-' + tMonth);
+				this.date = tYear + '年' + tMonth + '月'
+				this.fromData.dateDay = tYear + '-' + tMonth
+				return tYear + '-' + tMonth
+			},
+
+			doHandleMonth(month) {
+				var m = month;
+				if (month.toString().length == 1) {
+					m = "0" + month;
+				}
+				return m;
+			},
+
+			// 重选时间
 			bindDateChange(e) {
-				this.date = e.detail.value
+				this.date = e.detail.value.slice(0, 4) + "年" + e.detail.value.slice(5, 7) + "月"
 				this.fromData.dateDay = e.detail.value
 				this.getList()
 			},
@@ -262,13 +297,14 @@
 
 			getList() {
 				this.$api.get('/merchant/hotel/mine/getHotelCountInfo', this.fromData).then(res => {
-					console.log(res);
 					this.list = res.data.data
-					// 环图 营业概况
+					this.dataListOne = []
+					this.dataListTwo = []
+					//  营业概况
 					this.getServerData();
-					// 交易趋势
+					//  交易趋势
 					this.drawRevenueChartsOne()
-					// 入住率
+					//  入住率
 					this.drawRevenueChartstwo()
 				})
 			},
@@ -277,23 +313,25 @@
 			// 环图 营业概况
 			getServerData() {
 				this.PieChartsList = this.list
-				console.log('环图2222', this.PieChartsList);
 				this.PieChartsList = {
 					series: [{
 						data: [{
 								"name": "房费",
-								"value": this.PieChartsList.roomAmount,
+								"value": this.PieChartsList.roomAmount == null ? '0' : this.PieChartsList
+									.roomAmount,
 								"labelText": "房费" + this.PieChartsList.roomRatio + '%'
 							},
 							{
 								"name": "商品",
-								"value": this.PieChartsList.othersAmount,
-								"labelText": "商品" + this.PieChartsList.othersRatio + '%'
+								"value": this.PieChartsList.othersAmount == null ? '0' : this.PieChartsList
+									.othersAmount,
+								"labelText": "商品" + this.PieChartsList.breakfastRatio + '%'
 							},
 							{
 								"name": "其他",
-								"value": this.PieChartsList.breakfastAmount,
-								"labelText": "其他" + this.PieChartsList.breakfastRatio + '%',
+								"value": this.PieChartsList.breakfastAmount == null ? '0' : this
+									.PieChartsList.breakfastAmount,
+								"labelText": "其他" + this.PieChartsList.othersRatio + '%',
 							},
 
 						],
@@ -306,9 +344,12 @@
 			// 交易趋势
 			drawRevenueChartsOne() {
 				// this.list = this.objList
-				// console.log('交易趋势33333333', this.list);
-				this.list.checkedInChant.forEach(item => {
-					this.dataListOne.push(item.checkedInRatio)
+				// if (this.list.dealLineChant == null) {
+				// 	this.dataListOne.push('0')
+				// } else {
+				// }
+				this.list.dealLineChant.forEach(item => {
+					this.dataListOne.push(item.orderAmount)
 				})
 				let list1 = {
 					categories: [
@@ -331,6 +372,11 @@
 
 			// 入住率
 			drawRevenueChartstwo() {
+				// this.list = this.objList
+				// if (this.list.checkedInChant == null) {
+				// 	this.dataListOne.push('0')
+				// } else {
+				// }
 				this.list.checkedInChant.forEach(item => {
 					this.dataListTwo.push(item.checkedInRatio)
 				})