<template>
	<div class="page-body" v-if="showPage">
	
		<div class="service-brand-box" >
			<div class="uni-flex align-center">
				
				<image v-if="pageMsg.Brand_ICO" :src="pageMsg.Brand_ICO" mode="aspectFit"></image>
				<image v-else src="/static/images/revenue/home.png" mode="aspectFit"></image>
				
				
				<div class="band-name">{{pageMsg.Brand_Name}}</div>
			</div>
			<div class="price-num">{{pageMsg.Revenue_Amount ? $util.fmoney(pageMsg.Revenue_Amount,2) :'0.00'}}</div>
		</div>
		<!--服务区门店分析-->
		
		<div style="margin-top: 0 20rpx;" >
			<shopCell v-for="(item,i) in pageMsg.listBrandShopModel" :key="i" :item='item' @toggleShow="toggleShow" :i='i'></shopCell>
			
		</div>
	</div>
</template>

<script>
	import shopCell from './components/listUnit.vue'
	export default {
		data() {
			return {
				showPage:false,
				
				pageMsg: {},
				keyJson : {
						SHOWMORE_SIGN: { 1: '【长款】',2:'【异常长款】' }, // 长款
						SHOWLESS_SIGN:{ 1: '【短款】',2:'【异常短款】' }, // 短款
						SHOWABNORMAL_SIGN: { 1: '【异常校验】'},  // 异常日结
						SHOWSCAN_SIGN : { 1: '【扫】'},  // 扫码上传
						SHOWSSUPPLY_SIGN : { 1: '【补】' }, // 账期补录
						SHOWCHECK_SIGN : { 1: '【稽核检查】' }, // 稽核检查
						INTERFACE_SIGN : { 1: '【接口传输】' }, // 接口传输
					}
			}
		},
		components:{
			shopCell
		},
		methods: {
			toggleShow(i){
				
				let item = this.pageMsg.listBrandShopModel[i]
				item.show = !item.show 
				this.$forceUpdate()
			},
			
			
			getDetail(data){
				let arr =[]
				let keyJson = this.keyJson
				var keyCode =  ['SHOWABNORMAL_SIGN','SHOWCHECK_SIGN','SHOWMORE_SIGN','SHOWLESS_SIGN','SHOWSCAN_SIGN','SHOWSSUPPLY_SIGN','INTERFACE_SIGN']
					 keyCode.map(n=>{
						
						if( keyJson[n][data[n]] ) arr.push( keyJson[n][data[n]])
						
					})
					return arr
			},
			getBrandRevenue(obj) {
				let _this = this
				this.$request.$webGet('/WeChat/GetServerpartBrandShop', {
					Serverpart_Id: obj.id,
					business_Brand: obj.bid,
					pushProvinceCode: obj.provinceId,
					statictics_Time: obj.time,
					bussiness_Trade: obj.btid,
				}).then(res => {
					uni.hideLoading()
					if (res.Result_Code != 100) return
					res.Result_Data.listBrandShopModel.map(n=>{
						n.show = true
						n.detail =  this.getDetail(n)
					})
					_this.pageMsg = res.Result_Data
					_this.showPage =true
				})
			},
		},
		onUnload() {
			this.$util.addUserBehavior()
		},
		onLoad(option) {
			uni.showLoading({
				title:'正在加载...'
			})
			this.getBrandRevenue(option)
		}
	}
</script>

<style scoped>
	.page-body {
		background-color: #fff;
		padding-top: 40rpx;
		height: 100%;
	}
	/*服务区分析*/
	
	/* 服务区品牌详情 */
	.service-brand-box {
		
		width: 693rpx;
		height: 103rpx;
		color: #fff;
		border-radius: 10rpx;
		background: url(/static/images/revenue/brand-card.png) no-repeat 60rpx center,linear-gradient(#98a1c2 0%, #aab3d0 100%);
		background-size: contain;
		display: flex;
		align-items: center;
		margin: 0 auto;
		
		padding: 0 25rpx;
		justify-content: space-between;
		box-sizing: border-box;
	}
	.service-brand-box image {
		height: 60rpx;
		width: 60rpx;
		border: 2rpx solid #fff;
		border-radius: 50%;
		margin-right: 24rpx;
	}
	.service-brand-box .price-num {
		font-size: 40rpx;
		font-family: Bahnschrift Regular;
	}
</style>
