actObjReport.vue 7.49 KB
<template>
	<div>
		<headerComp  :leftImgSrc="leftImg" :title="titleStr" :rightImgSrc="rightImg" @leftClick="backFun" @rightClick="conditionFun"></headerComp>
		<div style="height: 18.11upx;"></div>
		<linechart :chart-data="chartData.HolidayNear" bind-id='HolidayNear'></linechart>
		<circlebar :chart-data="chartData.HolidayEffect" bind-id='HolidayEffect'></circlebar>
		<linechart :chart-data="chartData.HolidayHourDetail" bind-id='HolidayHourDetail'></linechart>
	</div>
</template>

<script>
	import headerComp from '../../../components/header'
	import backArrow from '../../../static/header/backArrow.png'
	import other from '../../../static/header/other.png'
	import circlebar from '../../../components/circleBarChart'
	import linechart from '../../../components/lineChart'

	export default{
		data(){
			return{
				titleStr:'节假日活动对比',
				leftImg:backArrow,
				rightImg:other,
				atoken:'',
				keyArr:[],
				chartIds:'',
				reportType:'mall',
				accountId:[],
				orgIds:'',
				date:'',
				isDay:true,
				isHour:false,
				isMin:false,
				chartData:{},
				gateId:[],
				floorId:[],
				storeId:[]
			}
		},
		onLoad: function (option) {
			if(option.types){
				this.reportType=option.types;
			}
				uni.getStorage({
					key:'atoken',
					success:(res)=>{
						this.atoken=res.data;
					}
				})
				uni.getStorage({
					key:'accountList',
					success:(res)=>{
						if(res.data){
							var list=JSON.parse(res.data);
							list.forEach((item,index)=>{
								if(index==0){
									this.accountId.push(item.id)
								}
							})
						}
					}
				})
				uni.getStorage({
					key:'selectAccountIdArr',
					success:(res)=> {
						this.accountId=JSON.parse(res.data);
					},
					complete: (res) => {
					}
				})
				uni.getStorage({
					key:'selectGateIdArr',
					success:(res)=> {
						this.gateId=JSON.parse(res.data);
					},
					complete: (res) => {
					}
				})
				uni.getStorage({
					key:'selectFloorIdArr',
					success:(res)=> {
						this.floorId=JSON.parse(res.data);
					},
					complete: (res) => {
					}
				})
				uni.getStorage({
					key:'selectStoreIdArr',
					success:(res)=> {
						this.storeId=JSON.parse(res.data);
					},
					complete: (res) => {
					}
				})
				
				var currentYear=[]
				uni.getStorage({
					key:'currentYear',
					success:(res)=> {
						currentYear=JSON.parse(res.data);
					},
					complete: (res) => {
					}
				})
				var a1=0;
				if(currentYear[0].index){
					a1=currentYear[0].index;
				}else{
					a1=currentYear[0];
				}
				var from='',to='';
				var year =1999+a1;
				from=year+'-01-01';
				to=year+'-12-31';
				this.date=from+','+to;
				uni.getStorage({
					key:'selectDate',
					success:(res)=> {
						if(res.data.indexOf(',')!=-1){
							this.date=res.data;
						}else{
							uni.setStorage({
								key:'selectDate',
								data:this.date
							})
						}
					},
					complete: (res) => {
					}
				})
				this.getReportKey();
		},
		computed: {
			i18n() {
				return this.$t("index")
			}
		},
		components:{
			headerComp,circlebar,linechart
		},
		methods: {
			backFun(){
				uni.reLaunch({
					url:"../index",
				})
			},
			conditionFun(){
				uni.setStorage({
					key:'backUrl',
					data:7
				})
				uni.navigateTo({
					url:'../condition'
				})
			},
			getReportKey(){
					var report='holidayObject';
					this.keyArr=['HolidayNear','HolidayEffect','HolidayHourDetail'];
				
				uni.showLoading({
					title: '加载中'
				});
				uni.request({
					url:window.url+'/reportCharts',
					data:{
						report:report,
						_t:Date.parse(new Date())/1000
					},
					header: {
						'Authorization': this.atoken //自定义请求头信息
					},
					method:'GET',
					success:(res) =>{
						this.chartIds='';
						res.data.data.forEach(item=>{
							if(this.keyArr.indexOf(item.key)!='-1'){
								this.chartIds+=item.id+','
							}
						})
						this.chartIds=this.chartIds.substring(0,this.chartIds.length-1);
						this.getChartData();
					}
				})
			},
			getChartData(){
				this.orgIds=''
					var data={}
					var url=''
					var holidayEventId='';
					uni.getStorage({
						key:'eventIdArr',
						success:(res)=> {
							holidayEventId=JSON.parse(res.data)[0];
						},
						complete: (res) => {
						}
					})
					if(this.reportType=='mall'){
						url=window.url+'/report/holidayObject/mall';
						this.accountId.forEach(item=>{
							this.orgIds+=item+','
						})
						this.orgIds=this.orgIds.substring(0,this.orgIds.length-1);
						data={
							orgIds:this.orgIds,
							chartIds:this.chartIds,
							date:this.date.split(',')[0],
							holidayEventId:holidayEventId,
							kpiType:'TRAFFIC',
							_t:Date.parse(new Date())/1000
						}
					}else if(this.reportType=='gate'){
						url=window.url+'/report/holidayObject/gate';
						this.gateId.forEach(item=>{
							this.orgIds+=item+','
						})
						this.orgIds=this.orgIds.substring(0,this.orgIds.length-1);
						data={
							orgIds:this.orgIds,
							chartIds:this.chartIds,
							date:this.date.split(',')[0],
							holidayEventId:holidayEventId,
							kpiType:'TRAFFIC',
							_t:Date.parse(new Date())/1000
						}
					}else if(this.reportType=='floor'){
						url=window.url+'/report/holidayObject/floor';
						this.floorId.forEach(item=>{
							this.orgIds+=item+','
						})
						this.orgIds=this.orgIds.substring(0,this.orgIds.length-1);
						data={
							orgIds:this.orgIds,
							chartIds:this.chartIds,
							date:this.date.split(',')[0],
							holidayEventId:holidayEventId,
							kpiType:'TRAFFIC',
							_t:Date.parse(new Date())/1000
						}
					}else if(this.reportType=='area'){
						url=window.url+'/report/holidayObject/zone';
						this.storeId.forEach(item=>{
							this.orgIds+=item+','
						})
						this.orgIds=this.orgIds.substring(0,this.orgIds.length-1);
						data={
							orgIds:this.orgIds,
							chartIds:this.chartIds,
							date:this.date.split(',')[0],
							holidayEventId:holidayEventId,
							kpiType:'TRAFFIC',
							_t:Date.parse(new Date())/1000
						}
					}
					if(!holidayEventId){
						uni.request({
							url:window.url+'/events/getEvent',
							data:{
								mallId: this.accountId[0],
								year: this.date.split(',')[0],
								_t:Date.parse(new Date())/1000
							},
							header: {
								'Authorization': this.atoken //自定义请求头信息
							},
							method:'GET',
							success:(res) =>{
								data.holidayEventId=res.data.data[0].id;
								uni.request({
									url:url,
									header: {
										'Authorization': this.atoken //自定义请求头信息
									},
									data:data,
									method:'GET',
									success:(res) =>{
										uni.hideLoading()
										var datas=res.data.data;
										this.chartData=datas.body;
									}
								})
								
							}
						})
					}else{
						uni.request({
							url:url,
							header: {
								'Authorization': this.atoken //自定义请求头信息
							},
							data:data,
							method:'GET',
							success:(res) =>{
								uni.hideLoading()
								var datas=res.data.data;
								this.chartData=datas.body;
							}
						})
					}
					
				
			}
		},
	}
</script>

<style>
	.selectBox{
		width: 646.73upx;
		height: 61.59upx;
		font-size:21.74upx;
		line-height: 61.59upx;
		display: flex;
		flex-direction: row;
		margin: 0 auto;
		margin-bottom: 18.11upx;
	}
	.sItem{
		flex: 1;
		background:#FFFFFF;
		text-align: center;
		cursor: pointer;
		border-right:1px solid #DBDBDB ;
	}
	.sItem:last-of-type{
		border-right:none
	}
	.checkedItem{
		background: #0069FF;
		color: #FFFFFF;
		border: #0069FF;
	}
</style>