<template>
	<view>
		<view class="title">
			<view class="title-sreach">
				<view class="back-btn" @tap="back" :style="{'top': menuButtonInfo.top +'px'}">
					<uni-icons type="left" size="28"></uni-icons>
				</view>
				<view class="title-name" :style="{'padding-top': menuButtonInfo.top +'px'}">
					配送排位赛
				</view>
			</view>
		</view>
		<uni-notice-bar v-if="reward != ''" show-icon scrollable :text="reward" />
		
		<view class="paiming">
			<view style="width: 200rpx;height: 100rpx;position: absolute;bottom: 30%;left: 6%;text-align: center;color: #fff;font-size: 34rpx;font-weight: bold;">
				<view>
					{{fireList[1].workerName == undefined?'':fireList[1].workerName}}
				</view>
				<view style="line-height: 60rpx;">
					{{fireList[1].orderCount == undefined?'':fireList[1].orderCount}}
				</view>
			</view>
			<view style="width: 200rpx;height: 100rpx;position: absolute;top: 50%;left: 37%;text-align: center;color: #fff;font-size: 34rpx;font-weight: bold;">
				<view>
					{{fireList[0].workerName == undefined?'':fireList[0].workerName}}
				</view>
				<view style="line-height: 60rpx;">
					{{fireList[0].orderCount == undefined?'':fireList[0].orderCount}}
				</view>
			</view>
			<view style="width: 200rpx;height: 100rpx;position: absolute;bottom: 27%;right: 6%;text-align: center;color: #fff;font-size: 34rpx;font-weight: bold;">
				<view>
					{{fireList[2].workerName == undefined?'':fireList[2].workerName}}
				</view>
				<view style="line-height: 60rpx;">
					{{fireList[2].orderCount == undefined?'':fireList[2].orderCount}}
				</view>
			</view>
		</view>
		<view class="content-list">
			<view v-for="(item,index) in fireList" :key="index" class="content-item">
				<view v-if="index == 0" style="justify-content: center;align-items: center;display: flex;">
					<uni-icons type="medal-filled" size='22' color="#fcdb56"></uni-icons>
				</view>
				<view v-if="index == 1" style="justify-content: center;align-items: center;display: flex;">
					<uni-icons type="medal-filled" size='22' color="#dedee0"></uni-icons>
				</view>
				<view v-if="index == 2" style="justify-content: center;align-items: center;display: flex;">
					<uni-icons type="medal-filled" size='22' color="#f6bf6f"></uni-icons>
				</view>
				<view v-if="index != 0 && index != 1 && index != 2" style="width: 44rpx;justify-content: center;align-items: center;display: flex;">{{index + 1}}</view>
				<view class="box-left">
					<img :src="item.icon || '/static/images/img/songshu.png'"/>
				</view>
				<view class="box-right">
					<view class="box-right-num">{{item.workerName == null?'暂无':item.workerName}}</view>
					<view class="box-right-name">{{item.orderCount}}单</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				menuButtonInfo: {},
				range:[],
				fireList:[],
				indexList: [],
				reward:'',
				bigImg:[],
				swiperDotIndex:0,
				
			};
		},
		onShow(){
			this.getMonth()
			this.getFireList()
			this.menuButtonInfo = uni.getMenuButtonBoundingClientRect()
		},
		onReachBottom() {
			this.getFireList();
			
		},
		methods: {
			lunbochange(e) {
				this.current = e.detail.current
			},
			getFireList(){ 
				this.tui.request("/mall/delivery/countOrdersLimit", "GET", {regionId: JSON.parse(uni.getStorageSync('area')).id}, false, true).then((res) => {
					if (res.code == 200) {
						if(res.result.data != null){
							this.fireList = res.result.data
						}
						
						if(res.result.reward != undefined && res.result.reward != null){
							this.reward = '排位规则：'
							for(let i = 0; i < res.result.reward.length; i++){
								this.reward += '第' + res.result.reward[i].orderNum + '名 - 奖励' + res.result.reward[i].reward + '元；'
							}
							this.reward += '晚上10点截止'
						}	
					} else {
						this.tui.toast(res.message)
					}
				}).catch((res) => {})
			},
			searchList(res) {
				this.pageNum = 1;
				this.fireList = [];
				this.getFireList()
			},
			//获取当月1日到当前时间
			getMonth() {
				let date = new Date()
				let year = date.getFullYear().toString()   //'年'
				let month = date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1).toString():(date.getMonth()+1).toString()  //'月'
				let da = date.getDate() < 10 ? '0'+date.getDate().toString():date.getDate().toString()  //'日'
				let end = year + '-' + month + '-' + da  //当天
				let beg = year + '-' + month + '-01'    //当月第一天
				this.range = [beg,end]
			},
			largeImg(img) {
				if((img.productPicture == null &&img.productPictures == null) || (img.productPicture == '' &&img.productPictures == '') || (img.productPicture == null &&img.productPictures == '') || (img.productPicture == '' &&img.productPictures == null)){
					this.tui.toast("暂无可展示的图片",300)
					return
				}
				this.bigImg = []
				if(img.productPicture != null){
					let data = {
						productPicture:img.productPicture
					}
					this.bigImg.push(data)
				}
				if(img.productPictures != null){
					for(let i=0;i<img.productPictures.length;i++){
						this.bigImg.push(img.productPictures[i])
					}
				}
				this.$refs.imgPopup.open()
			},
			back() {
				uni.navigateBack()
			},
		}
	}
</script>

<style lang="scss">
	.paiming{
		background: url('https://jewel-shop.oss-cn-beijing.aliyuncs.com/a07b86e1b1c74c88ac42dcc8a592980c.jpg') no-repeat;
		width: 100%;
		height: 680rpx;
		background-size: 100%;
		position: relative;
		z-index: 97;
	}
	.content-list{
		width: 90%;
		overflow: scroll;
		border-radius: 20rpx;
		background: #fff;
		margin: -50rpx auto 0;
		position: relative;
		z-index: 98;
	}
	.content-item{
		height: 180rpx;
		width: 100%;
		padding: 0 20rpx;
		font-size: 32rpx;
		border-bottom: 1px solid #eee;
		display: flex;
	}
	.box-left {
		width: 130rpx;
		height: 131rpx;
		background-size: 100%;
		margin: 25rpx 30rpx 25rpx 10rpx;
	}
	
	.box-left img {
		width: 100%;
		height: 100%;
		border-radius: 131rpx;
	}
	
	.box-right {
		margin-top: 17rpx;
		padding-top:30rpx;
	}
	
	.box-right-price {
		display: flex;
		font-size: 25rpx;
	}
	.noPic{
		border-radius: 10px;
		width: 140rpx;
		height: 140rpx;
		// margin: 30rpx 0 0 30rpx;
		text-align: center;
		line-height: 140rpx;
		color: #777;
		background: rgba(247, 248, 248, 0.6);
	}
	.box-right-num {
		padding: 5rpx 0;
		color: #000;
		font-weight: bold;
		font-size: 30rpx;
	}
	.box-right-name {
		font-size: 26rpx;
		height: 50rpx;
		line-height: 50rpx;
	}
	.showImg-box{
		width: 700rpx;
		height: 1000rpx;
		border-radius: 10px;
	}
	.swiper-box {
		height: 1000rpx;
	}
	.swiper-item {
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;
		height: 1000rpx;
		color: #fff;
		background-color: #cee1fd;
		border-radius: 10px;
	}
	.title {
		background: url('https://jewel-shop.oss-cn-beijing.aliyuncs.com/8bc15960c2dc40268e295d6dd23aecce.png') no-repeat;
		width: 100%;
		height: 20%;
	}
	
	.title-sreach {
		width: 100%;
		display: flex;
		height: 200rpx;
		position: relative;
	}
	
	.back-btn {
		position: absolute;
		bottom: 0;
		left: 0;
	}
	
	.title-name {
		padding-top: 110rpx;
		font-size: 36rpx;
		font-weight: 700;
		flex: 1;
		text-align: center;
	}
</style>