<template>
	<view>
		<view class="listBox" v-for="(item,index) in list" :key="index" :style="'background-color: '+background+';color: '+color">
			<view class="width-100b height-100 flex align-center justify-between" style="border-bottom: 1px solid rgba(209,209,209,0.3)">
				<view class="height-90 flex direction-column align-start justify-center">
					<view class="flex align-center ">
						<text v-if="currentIndex==4" class="font-28 bold-font margin-r-10">{{item.coinname}}</text>
						<text class="font-28 bold-font numbold-font">{{item.type=='more'?i18n.cycle.long:i18n.cycle.short}}</text>
						<text class="font-26 numbold-font" :style="'color:'+fu_color">{{item.coinname}}</text>
					</view>
					<text class="font-20 numbold-font" :style="'color:'+fu_color">{{item.createtime}}</text>
				</view>
				<text @click="setCheck(item.id,item.zy_price,item.zs_price)" v-if="currentIndex==1"
				class="font-26 numbold-font weight-bold">{{i18n.cycle.set}}</text>
				<button v-if="currentIndex==0" @click="revocation(item.id)" class="cu-btn loginBtn"
				:style="'border: 1rpx solid '+color+';color: '+color">{{i18n.cycle.revoke}}</button>
				<text v-if="currentIndex==4" class="font-26 color-0165EE">{{statusFilter(item.status)}}</text>
			</view>
			<view class="width-100b margin-t-10 flex flex-wrap">
				<view style="width: 33%;" class="height-70 flex direction-column align-start justify-around">
					<text class="font-26 nummedium-font">{{Number(item.price).toFixed(price_jd)}}</text>
					<text class="font-24 nummedium-font" :style="'color:'+fu_color">{{i18n.cycle.unit}}</text>
				</view>
				<view style="width: 33%;" class="height-70 flex direction-column align-center justify-around">
					<text class="font-26 nummedium-font">{{parseInt(item.num)}}*{{item.multiple}}</text>
					<text class="font-24 nummedium-font" :style="'color:'+fu_color">{{i18n.cycle.beishu}}</text>
				</view>
				<view v-if="item.status==0||item.status==1" style="width: 33%;" class="height-70 flex direction-column align-end justify-around">
					<text class="font-26 nummedium-font">{{nowPrice.toFixed(price_jd)}}</text>
					<text class="font-24 nummedium-font" :style="'color:'+fu_color">{{i18n.cycle.currPrice}}</text>
				</view>
				<view v-if="item.status==2" style="width: 33%;" class="height-70 flex direction-column align-end justify-around">
					<text class="font-26 nummedium-font">{{Number(item.pc_price).toFixed(price_jd)}}</text>
					<text class="font-24 nummedium-font" :style="'color:'+fu_color">{{i18n.cycle.closing}}</text>
				</view>
				<view v-if="item.status==3" style="width: 33%;" class="height-70 flex direction-column align-end justify-around">
					<text class="font-26 nummedium-font">{{item.updatetime}}</text>
					<text class="font-24 nummedium-font" :style="'color:'+fu_color">{{i18n.cycle.revokeTime}}</text>
				</view>
				<view style="width: 33%;" class="margin-t-10 height-70 flex direction-column align-start justify-around">
					<text class="font-26 nummedium-font">{{item.promise_fee}}</text>
					<text class="font-24 nummedium-font" :style="'color:'+fu_color">{{i18n.cycle.margin}}</text>
				</view>
				<view style="width: 33%;" class="margin-t-10 height-70 flex direction-column align-center justify-around">
					<text class="font-26 nummedium-font">{{item.fee}}</text>
					<text class="font-24 nummedium-font" :style="'color:'+fu_color">{{i18n.cycle.service}}</text>
				</view>
				<view v-if="item.status==0||item.status==3" style="width: 33%;" class="margin-t-10 height-70 flex direction-column align-end justify-around">
					<text class="font-26 nummedium-font">{{item.coinname}}</text>
					<text class="font-24 nummedium-font" :style="'color:'+fu_color">{{i18n.cycle.currency}}</text>
				</view>
				<view v-if="item.status==1" style="width: 33%;" class="margin-t-10 height-70 flex direction-column align-end justify-around">
					<text v-if="item.type=='more'" :class="nowPrice>=item.price?'color-00C481':'color-FF4040'" class="font-24 nummedium-font">{{((nowPrice - item.price)*item.num*shizhi).toFixed(6)}}</text>
					<text v-if="item.type=='free'" :class="item.price>nowPrice?'color-00C481':'color-FF4040'" class="font-24 nummedium-font">{{((item.price - nowPrice)*item.num*shizhi).toFixed(6)}}</text>
					<text class="font-24 nummedium-font" :style="'color:'+fu_color">{{i18n.cycle.profit}}</text>
				</view>
				<view v-if="item.status==2" style="width: 33%;" class="margin-t-10 height-70 flex direction-column align-end justify-around">
					<text :class="item.income>=0?'color-00C481':'color-FF4040'" class="font-26 nummedium-font">{{item.income||0}}</text>
					<text class="font-24 nummedium-font" :style="'color:'+fu_color">{{i18n.cycle.profit}}</text>
				</view>
			</view>
			<view v-if="currentIndex==1" class="width-100b height-50 margin-t-10 flex align-center justify-end">
				<button v-if="currentIndex==1" @click="closeOut(item.id)" class="cu-btn loginBtn1">{{i18n.cycle.close}}</button>
			</view>
			<view v-if="currentIndex==4" class="">
				<view v-if="item.status==0" class="width-100b height-50 margin-t-10 flex align-center justify-end">
					<button @click="revocation(item.id)" class="cu-btn loginBtn" :style="'color:'+color+';border: 1rpx solid '+color+';'">{{i18n.cycle.revoke}}</button>
				</view>
				<view v-if="item.status==1" class="width-100b height-50 margin-t-10 flex align-center justify-between">
					<text @click="setCheck(item.id,item.zy_price,item.zs_price)" class="font-26 numbold-font weight-bold">{{i18n.cycle.set}}</text>
					<button @click="closeOut(item.id)" class="cu-btn loginBtn1">{{i18n.cycle.close}}</button>
				</view>
			</view>
		</view>
		
		<view class="">
			<view v-if="loading" class="width-100b padding-c-50 flex align-center justify-center">
				<u-loading show mode="flower" size="40"></u-loading>
			</view>
			<view v-if="!loading&&list.length==0" class="width-100b padding-c-50 flex direction-column align-center justify-center">
				<text class="font-28 nummedium-font" :style="'color:'+fu_color">{{i18n.cycle.nodata}}</text>
			</view>
		</view>
		
	</view>
</template>

<script>
	export default {
		name:'contractListItem',
		props: {
			//标题
			list: {
				type: Array,
				default: []
			},
			currentIndex: {
				type: Number,
				default: 0
			},
			loading: {
				type: Boolean,
				default: false
			},
			nowPrice:{//币种当前价格
				type: Number,
				default: 0
			},
			shizhi:{//设备比例
				type: Number,
				default: 0
			},
			price_jd:{
				type: Number,
				default: 4
			},
			background:{
				type: String,
				default: '#ffffff'
			},
			color:{
				type: String,
				default: '#17181A'
			},
			fu_color:{
				type: String,
				default: '#B7B7B7'
			}
		},
		data() {
			return {
			}
		},
		computed: {
			i18n() {
				return this.$t('message');
			}
		},
		methods: {
			statusFilter(index){
				return this.i18n.cycle.tablist1State[index]
			},
			// 撤销
			revocation(id) {
				uni.showLoading({
					mask:true
				})
				setTimeout(()=>{
					uni.hideLoading()
					this.$emit('revocation',id)
				},2500)
			},
			// 平仓
			closeOut(id) {
				uni.showLoading({
					mask:true
				})
				setTimeout(()=>{
					uni.hideLoading()
					this.$emit('closeOut',id)
				},2500)
			},
			// 设置止盈止损
			setCheck(id,zy_price,zs_price) {
				this.$emit('setCheck',id,zy_price,zs_price)
			},
		}
	}
</script>

<style scoped>
	.listBox{
		width: 100%;
		/* height: 186rpx; */
		padding: 20rpx 30rpx;
		margin: 0 auto 20rpx;
		/* background: #FFFFFF; */
	}
	.loginBtn{
		width: 190rpx;
		padding: 0 18rpx;
		height: 48rpx;
		background: rgba(0,0,0,0) !important;
		border-radius: 4rpx;
		font-size: 24rpx;
	}
	.loginBtn1{
		width: 190rpx;
		padding: 0 18rpx;
		height: 48rpx;
		border-radius: 4rpx;
		color: #FFFFFF;
		background: #3ECEB2 !important;
		font-size: 24rpx;
	}
</style>
