Forráskód Böngészése

商城订单统计

xhj 2 éve
szülő
commit
1e41bc202c
2 módosított fájl, 75 hozzáadás és 33 törlés
  1. 73 31
      pages/index/index.vue
  2. 2 2
      pages/user/user.vue

+ 73 - 31
pages/index/index.vue

@@ -143,24 +143,24 @@
 		</view>
 		
 		<!-- 图表统计 -->
-		<view class="echart-box">
+		<view class="echart-box" v-if="!userInfo.storeId&&!userInfo.merchantId">
 			<view class="echart-box-header ddflex">
 				<view class="echart-box-title">商城交易趋势</view>
 				<view class="echart-box-moneyType ddflex">
-					<view class="echart-box-moneyType-active">销售金额</view>
-					<view style="border-left: none;">退款金额</view>
+					<view :class="mallType==1?'echart-box-moneyType-active':''" :style="mallType==2?'border-right: none;':''" @click="mallTypeChange(1)">销售金额</view>
+					<view :class="mallType==2?'echart-box-moneyType-active':''" :style="mallType==1?'border-left: none;':''" @click="mallTypeChange(2)">退款金额</view>
 				</view>
 			</view>
 			<view class="ddflex" style="justify-content: center;margin-top: 30rpx;">
 				<view class="echart-box-timeType ddflex">
-					<view :class="'echart-box-timeType-item '+(timeType==1?'echart-box-timeType-item-acitve':'')"
-						@click="timeTypeChange(1)">今日</view>
-					<view :class="'echart-box-timeType-item '+(timeType==2?'echart-box-timeType-item-acitve':'')"
-						@click="timeTypeChange(2)">近7日</view>
-					<view :class="'echart-box-timeType-item '+(timeType==3?'echart-box-timeType-item-acitve':'')"
-						@click="timeTypeChange(3)">近30日</view>
-					<view :class="'echart-box-timeType-item '+(timeType==4?'echart-box-timeType-item-acitve':'')"
-						@click="timeTypeChange(4)">近一年</view>
+					<view :class="'echart-box-timeType-item '+(mallTimeType==1?'echart-box-timeType-item-acitve':'')"
+						@click="mallTimeTypeChange(1)">今日</view>
+					<view :class="'echart-box-timeType-item '+(mallTimeType==2?'echart-box-timeType-item-acitve':'')"
+						@click="mallTimeTypeChange(2)">近7日</view>
+					<view :class="'echart-box-timeType-item '+(mallTimeType==3?'echart-box-timeType-item-acitve':'')"
+						@click="mallTimeTypeChange(3)">近30日</view>
+					<view :class="'echart-box-timeType-item '+(mallTimeType==4?'echart-box-timeType-item-acitve':'')"
+						@click="mallTimeTypeChange(4)">近一年</view>
 				</view>
 			</view>
 			<view style="height:500rpx">
@@ -234,9 +234,13 @@
 				timeType: 1, //统计时间 1.按日 2.按月 3.按季度
 				storeType:1,//营业额查询1.商家 2.门店
 				
+				mallType:1,//1-销售额 2-退款金额 商城数据
+				mallTimeType:1, //1-今日 2-前7天 3-前30天 4-近1年
+				
 				statisticData:{},//统计数据
 				echartData:{},//曲线图
 				storeRanking:{},//营业额排行
+				mallStatisticData:{},//商城营业额
 				
 				userInfo:{},
 
@@ -624,7 +628,7 @@
 						confine: true
 					},
 					legend: {
-						data: ['销售金额', '同比','环比'],
+						data: ['金额', '同比','环比'],
 						x: 'center', //可设定图例在左、右、居中
 						y: 'top', //可设定图例在上、下、居中
 						padding: [15, 0, 0, 0]
@@ -638,7 +642,7 @@
 					},
 					xAxis: [{
 						type: 'category',
-						data: ['2023-01=22','2023-02','2023-03','2023-04','2023-05'],
+						data: ['2023-01-22','2023-02','2023-03','2023-04','2023-05'],
 						axisLine: {
 							lineStyle: {
 								color: '#999999'
@@ -688,7 +692,7 @@
 						}
 					}],
 					series: [{
-							name: '销售金额',
+							name: '金额',
 							type: 'bar',
 							data: [5000,6000,7000,8500,5500],
 							showSymbol: false,
@@ -750,6 +754,7 @@
 				await this.getUserInfo()
 				await this.getEchartData()
 				await this.getStatisticData()
+				await this.getMallStatisticData()
 				if(!this.userInfo.storeId)
 					await this.getStoreData()
 				
@@ -793,6 +798,22 @@
 				
 				this.init()
 			},
+			// 商城统计时间切换
+			async mallTimeTypeChange(val) {
+				if (this.mallTimeType == val) return false
+				this.mallTimeType = val
+				await this.getMallStatisticData()
+				
+				this.init()
+			},
+			// 商城统计类型切换
+			async mallTypeChange(val) {
+				if (this.mallType == val) return false
+				this.mallType = val
+				await this.getMallStatisticData()
+				
+				this.init()
+			},
 			init() {
 				this.$refs.chart.init(echarts, async chart => {
 					// let echartData = await this.getEchartData()
@@ -873,28 +894,35 @@
 				if(this.$refs.chart7){
 					this.$refs.chart7.init(echarts, async chart => {
 						// let echartData = await this.getEchartData()
+						if(this.mallType==1){
+							this.option7.legend.data[0] = '销售金额'
+							this.option7.series[0].name = '销售金额'
+						}else{
+							this.option7.legend.data[0] = '退款金额'
+							this.option7.series[0].name = '退款金额'
+						}
 						this.option7.yAxis[0].axisLabel.fontSize = 13 * this.rpxTopxScale
 						this.option7.yAxis[1].axisLabel.fontSize = 13 * this.rpxTopxScale
 						this.option7.xAxis[0].axisLabel.fontSize = 13 * this.rpxTopxScale
 						this.option7.legend.itemHeight = 10 * this.rpxTopxScale
 						this.option7.legend.itemWidth = 40 * this.rpxTopxScale
-						// if(this.echartData.orderList.length>0){
-						// 	this.option7.xAxis[0].data = this.echartData.orderList.map(item=>{return item.showTime})
-						// 	this.option7.series[0].data = this.echartData.orderList.map(item=>{return item.orderCount})
-						// }else{
-						// 	this.option7.xAxis[0].data = []
-						// 	this.option7.series[0].data = []
-						// }
-						// if(this.echartData.profitList.length>0){
-						// 	this.option7.series[1].data = this.echartData.profitList.map(item=>{return item.profit})
-						// }else{
-						// 	this.option7.series[1].data = []
-						// }
-						// if(this.echartData.turnoverList.length>0){
-						// 	this.option7.series[2].data = this.echartData.turnoverList.map(item=>{return item.turnover})
-						// }else{
-						// 	this.option7.series[2].data = []
-						// }
+						if(this.mallStatisticData.totalTurnoverRefundList.length>0){
+							this.option7.xAxis[0].data = this.mallStatisticData.totalTurnoverRefundList.map(item=>{return item.showTime})
+							this.option7.series[0].data = this.mallStatisticData.totalTurnoverRefundList.map(item=>{return item.turnover})
+						}else{
+							this.option7.xAxis[0].data = []
+							this.option7.series[0].data = []
+						}
+						if(this.mallStatisticData.totalTurnoverYoyRefundList.length>0){
+							this.option7.series[1].data = this.mallStatisticData.totalTurnoverYoyRefundList.map(item=>{return item.turnover})
+						}else{
+							this.option7.series[1].data = []
+						}
+						if(this.mallStatisticData.totalTurnoverQoqRefundList.length>0){
+							this.option7.series[2].data = this.mallStatisticData.totalTurnoverQoqRefundList.map(item=>{return item.turnover})
+						}else{
+							this.option7.series[2].data = []
+						}
 						chart.setOption(this.option7);
 					});
 				}
@@ -929,6 +957,20 @@
 					})
 				})
 			},
+			// 获取商城图表数据
+			getMallStatisticData() {
+				return new Promise((r, j) => {
+					let d = {
+						orderState:this.mallType,// 1-销售额 2-退款金额
+						type:this.mallTimeType//1-今日 2-前7天 3-前30天 4-近1年
+					}
+					req.getRequest('/admin/v2/statistic/chartMall', d, res => {
+						console.log('statistic Mall', res)
+						this.mallStatisticData = res
+						r(res)
+					})
+				})
+			},
 			// 获取当前用户
 			getUserInfo(){
 				return new Promise((r, j) => {

+ 2 - 2
pages/user/user.vue

@@ -83,11 +83,11 @@
 					<image src="../../static/pages/images/user_service4.png"></image>
 					<text>运营数据</text>
 				</navigator>
-				<navigator url="" hover-class="none" class="li" @click="jumpUrl('merchant/order')">
+				<navigator v-if="isLogin&&!userInfos.storeId&&!userInfos.merchantId" url="" hover-class="none" class="li" @click="jumpUrl('merchant/order?tabIndex=0')">
 					<image src="../../static/pages/images/user_service9.png"></image>
 					<text>商城订单</text>
 				</navigator>
-				<navigator url="" hover-class="none" class="li" @click="jumpUrl('promote/withdrawal/myCard/myCard')">
+				<navigator v-if="isLogin&&(userInfos.storeId||userInfos.merchantId)" url="" hover-class="none" class="li" @click="jumpUrl('promote/withdrawal/myCard/myCard')">
 					<image src="../../static/pages/images/user_service10.png"></image>
 					<text>我的银行卡</text>
 				</navigator>