<template>
	<view class="page-card" v-if="!isLoading">
    <!-- 日期筛选 -->
    <div class="uni-flex ai-center screen-box">
      <picker mode="date" @change="bindDateChange($event,0)" :value="pageData.searchTime[0]" :end="pageData.endDate" start="2018-12-01" class="screen-unit">
        <text>{{pageData.searchTime[0]}}</text>
        <text class="uni-icon uni-icon-arrowdown"></text>
      </picker>
      <text class="mr20">至</text>
      <picker mode="date" @change="bindDateChange($event,1)" :value="pageData.searchTime[1]" :end="pageData.endDate" start="2018-12-01" class="screen-unit">
        <text>{{pageData.searchTime[1]}}</text>
        <text class="uni-icon uni-icon-arrowdown"></text>
      </picker>
    </div>

<!--    @tap="toTrend"-->
		<view class="head-card" v-show="pageMsg.Serverpart_Name">
			<view class="uni-flex jc-between ai-center text-strong">
				<view class=""> {{pageMsg.Serverpart_Name}} </view>
				<view class=""> ¥{{$util.fmoney(pageMsg.Serverpart_Revenue,2)}} </view>
			</view>
			<view class="uni-flex jc-between ai-center">
				<text class="" v-if="pageMsg.Serverpart_S"> {{pageMsg.Serverpart_S}} &nbsp; &nbsp;¥{{$util.fmoney(pageMsg.Serverpart_RevenueS,2)}}</text>
				<text class="" v-if="pageMsg.Serverpart_N"> {{pageMsg.Serverpart_N}} &nbsp; &nbsp;¥{{$util.fmoney(pageMsg.Serverpart_RevenueN,2)}}</text>
			</view>
		</view>
		<view class="page-list" v-if="pageMsg.ShopList && pageMsg.ShopList.length>0">
<!--			<view v-for="(dateItem,i) in pageMsg.revenueReportDetilsDates" :key="i">-->
<!--				<text class="list-date"> {{// $util.cutDate(dateItem.Statistics_Date,'MM.DD')}}</text>-->
				<view class="cell-body uni-flex ai-center" v-for="(item,i) in pageMsg.ShopList" :key="i">
					<image :src="item.BusinessType_Logo || '/static/images/revenue/operating-shop.png'" mode="aspectFit"></image>
					<view class="">
						<view class="uni-flex ai-center jc-between">
							<text>{{item.BusinessType_Name}}</text>
							<text class="shop-total">＋ ¥{{$util.fmoney(item.BusinessType_Revenue,2)}}</text>
						</view>
						<view class="uni-flex ai-center jc-between">
							<text style="display: inline-block;width: 20%" class="type-text" :class="{'scan':item.Upload_Type==1,'port':item.Upload_Type==2}">
								<template v-if="item.Upload_Type==1">
									扫码上传
								</template>
								<template v-else-if="item.Upload_Type==2" >
									接口传输
								</template>
								<template v-else>
									自动上传
								</template>
								<!-- <text class="type-text scan" v-if="item.Upload_Type==1" >扫码上传</text>
								<text class="type-text port" >接口传输</text>
								<text v-else>自动上传</text> -->
							</text>
							<view class="uni-flex ai-center" style="display: inline-block;width: 80%">
                <div style="display: inline-block;width: 48%;text-align: left;margin-right: 4%" class="text-coast">
                  <text style="display: inline-block;width: 40px;text-align: left">
                    {{item.Serverpart_RevenueS===0 || item.Serverpart_RevenueS? `${item.Serverpart_S}： `:''}}
                  </text>
                  <text  style="display: inline-block;width: calc(100% - 50px);margin-left: 10px">
                    {{item.Serverpart_RevenueS===0 || item.Serverpart_RevenueS? `¥${$util.fmoney(item.Serverpart_RevenueS,2)}`:''}}
                  </text>
                </div>
								<div style="display: inline-block;width: 48%;text-align: right" class="text-coast">
                  <text style="display: inline-block;width: 40px;text-align: left">
                    {{item.Serverpart_RevenueN===0 || item.Serverpart_RevenueN? `${item.Serverpart_N}： `:''}}
                  </text>
                  <text  style="display: inline-block;width: calc(100% - 50px);margin-left: 10px">
                    {{item.Serverpart_RevenueN===0 || item.Serverpart_RevenueN? `¥${$util.fmoney(item.Serverpart_RevenueN,2)}`:''}}
                  </text>
                </div>
              </view>
						</view>

					</view>
				</view>
<!--			</view>-->
		</view>
		<view class="" v-if="isLoading && !pageOption.Serverpart_Name">
			<noFound nodata="true" :text="noDataText"/>
		</view>
	</view>
</template>

<script>
import request from '@/util/index.js'
	export default {
		data() {
      let now = new Date()
      let nowTime = this.$util.cutDate(now, 'YYYY-MM-DD',-1)
      let sTime = this.$util.cutDate(now, 'YYYY-MM-DD', -1)
			return {
				isLoading: true,
        pageData: {
          endDate: nowTime,
          searchTime: [sTime,nowTime],
          msg: {},
          isLoading: true,
          exsideShow: true,
          insideShow: true,
        },
        pageMsg:{},
				pageOption: {},
				noDataText: '抱歉，没有数据，请稍后重试'
			}
		},
		methods: {
      bindDateChange(e,index){
        let nowDate = this.pageData.searchTime[index]
        if(e.detail.value != nowDate){
          this.pageData.searchTime[index] = e.detail.value
          this.$forceUpdate()
          this.getDetail({st:this.pageData.searchTime[0],et:this.pageData.searchTime[1],id:this.pageOption.id,pcode:this.pageOption.pcode})
        }
      },
      toTrend(){
				this.$util.toNextRoute('navigateTo','/pages/operatingStatements/operatingTrend?name='+this.pageMsg.Serverpart_Name+'&time='+this.pageOption.et+'&id='+this.pageOption.id+'&ProvinceCode='+this.pageOption.pcode)
			},
			getDetail(obj){
				let _this = this
				uni.showLoading({
					title:'正在加载...',
					mask:true
				})
				// _this.$request.$webGet('WeChat/GetRevenueReportDetils',{
        request.$webGet('CommercialApi/Revenue/GetRevenueReportDetil',{
          startTime: obj.st,
          endTime: obj.et,
          serverpartId: obj.id,
          provinceCode: obj.pcode,
          SearchKeyName:_this.pageOption.searchKey,
          SearchKeyValue:_this.pageOption.searchValue,
          BusinessType:_this.pageOption.BusinessTypeValue>0?_this.pageOption.BusinessTypeValue:'',
          SettlementMode:_this.pageOption.SettlementModeValue>0?_this.pageOption.SettlementModeValue:'',
				}).then(res=>{
					if(res.Result_Code==100) {
						_this.pageMsg = res.Result_Data

					}else if(res.Result_Code==200 || res.Result_Code==999){
            _this.noDataText = '暂无数据'
          } else{
						_this.noDataText = res.Result_Desc
					}
					uni.hideLoading()
					_this.isLoading = false
				})
			},
		},
    // 拿到传入的数据
		onLoad(op) {
      console.log('op',op)
			this.pageOption = op
      if (this.pageOption.st){
        this.pageData.searchTime[0] = this.pageOption.st
      }
      if (this.pageOption.et){
        this.pageData.searchTime[1] = this.pageOption.et
      }
			this.getDetail(op)
		}
	}
</script>

<style>
	page {
		background-color: #fff;
	}
	.page-card {
		margin: 0 20rpx 30rpx;

	}
  .screen-box {
    background-color: #fff;
    padding: 0 20rpx;
    position: sticky;
    top: 0;
    left: 0;
    z-index: 9;
  }
  .screen-box .screen-unit {
    display: flex;
    align-items: center;
    width: 200rpx;
    padding: 0 14rpx;
    line-height: 3;
  }
  .screen-box .mr20 {
    margin-right: 20rpx;
    color: #95999C;
  }
  .uni-icon-arrowdown {
    font-size: 22rpx;
    color: #C7C7C7;
    margin-left: 8rpx;
  }
  .screen-box text {
    line-height: 3;
  }
  .screen-box image{
    width: 12rpx;
    height: 8rpx;
    margin: 0 16rpx;
    vertical-align: middle;
  }
	.head-card {
		padding: 30rpx 35rpx;
		background: linear-gradient(to left, #f7f6f8 0%, #eceaeb 100%);
		border-radius: 12rpx 12rpx 0 0 ;
	}
	.head-card > view+view {
		margin-top: 16rpx;
	}
	.text-strong {
		font-weight: bolder;
	}
	.head-card > view>text {
		font-size: 24rpx;
		color: #333;
	}
	.list-date {
		font-size: 22rpx;
		background-color: #f8f8f8;
		border-radius: 4rpx;
		padding: 4rpx 12rpx;
		margin-top: 20rpx;
	}
	.page-list {
		border: 1rpx solid #F0F0F0;
		border-radius: 0 0 12rpx 12rpx;
		overflow: hidden;

		padding: 30rpx 16rpx 30rpx 16rpx;
	}
	.cell-body {
		position: relative;
		padding: 20rpx 20rpx 20rpx 0;
	}
	.cell-body image {
		width: 60rpx;
		height: 60rpx;
		border-radius: 50%;
		margin-right: 16rpx;
	}
	.cell-body>view {
		flex: 1;
	}
	.page-list text {
		font-size: 22rpx;
		color: #2E2E2E;
	}
	text.shop-total {
		font-size: 24rpx;
	}
	text.type-text {
		color: #DFBE9F;
		display: flex;
		align-items: center;
	}
	text.type-text.scan::before,text.type-text.port::before {
		content: '';
		width: 21rpx;
		height: 23rpx;
		margin-right: 8rpx;
	}
	text.type-text.scan::before {
		background: url(/static/images/revenue/scan-up.png) no-repeat center;
		background-size: contain;
	}
	text.type-text.port::before {
		background: url(/static/images/revenue/port.png) no-repeat center;
		background-size: contain;
	}
	text.type-text.port {
		color: #95BAF2;
	}
	text.text-coast {
		color: #848484;
		width: 184rpx;
    text-align: right;
	}
	/*text.text-coast + text.text-coast {*/
	/*	text-align: right;*/
	//}
</style>
