<template>
	<view class="">
		<view class="lable-title">
			<view class=""></view>
			<text class="lable-title-icon iconfont">&#xe611;</text>
		</view>
		<u-list class="swiper-list" :style="{'height': scrollHeight ? `${scrollHeight}px` : '' }">

			<template v-for="item in list">
				<view class="content-box" :rise-fall="stocksColor">
					<view class="content-top">
						<view class="top-left">
							<view class="top-left-title">
								<text>{{ item.symbol }}</text>
								<text>{{ item.type_name }}</text>
							</view>
							<view class="top-left-b">
								<text>{{ item.multiple }}倍杠杆</text>
								<text class="top-left-b-tag">逐仓做多</text>
								<text class="top-left-b-tag">逐仓做多</text>
							</view>
						</view>

						<view :class="['top-right' , $setColor(item.profits)]">
							<text class="color">{{ item.profits || '--'}}</text>
							<text class="color top-right-float"><text
									class="bdColor">平仓盈亏</text>{{ item.fact_profits }}%</text>
						</view>
					</view>
					<view class="content-info">
						<view class="info-item">
							<text class="info-item-lable">保证金(USDT)</text>
							<text class="info-item-val">{{ item.caution_money }}</text>
						</view>
						<view class="info-item">
							<text class="info-item-lable">开仓价格(USDT)</text>
							<text class="info-item-val">{{ item.price }}</text>
						</view>
						<view class="info-item">
							<text class="info-item-lable">平仓价格(USDT)</text>
							<text class="info-item-val">{{ item.origin_price }}</text>
						</view>


						<view class="info-item">
							<text class="info-item-lable">平仓数量(张)</text>
							<text class="info-item-val">{{ item.number }}</text>
						</view>
						<view class="info-item">
							<text class="info-item-lable">手续费(USDT)</text>
							<text class="info-item-val">{{ item.trade_fee || '--' }}</text>
						</view>
						<view class="info-item">
							<text class="info-item-lable">平仓类型(USDT)</text>
							<text class="info-item-val">{{ item.type_name }}</text>
						</view>
					</view>
					<view class="record-hint">
						<text class="record-lable">平仓时间 {{ $getData_(item.create_time ) }}</text>
						<view class="record-icon">
							<text class="icon-size iconfont">&#xe8b0;</text>
							<text class="icon-size">分享</text>
						</view>
					</view>
				</view>
				<gap />
			</template>
		</u-list>
	</view>
</template>

<script>
	import {
		mapGetters
	} from 'vuex'
	import {
		Api_getRegister
	} from "@/api/index.js"
	export default {
		name: 'login',
		props: {
			listHeight: {
				type: Number,
				default: 0
			},
			status: {
				type: Number,
				default: ''
			},
		},
		data() {
			return {
				scrollHeight: 0,
				list: [],
				limit: 10,
				page: 1,
			};
		},
		// 80rpx
		watch: {
			listHeight: {
				handler(newH) {
					if (newH) {
						this.scrollHeight = newH - uni.upx2px(80);
					}
				},
				immediate: true
			},
			status: {
				handler(newSatus, oldStatus) {
					if (newSatus === -1 && newSatus !== oldStatus) {
						this.limit = 10;
						this.page = 1;
						this.getRegister()
					}
				},
				immediate: true
			},
		},
		computed: {
			...mapGetters([
				"stocksColor",
			])
		},
		mounted() {
			// this.getRegister()
		},
		methods: {
			getRegister() {
				Api_getRegister({
					status: this.status,
					legal_id: 3,
					currency_id: 1,
					page:this.page,
					limit:this.limit
				}).then(res => {
					console.log('res', res)
					const data = res.message;
					this.list = this.list.concat(data.data)
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	@import "~../sustainability/index.scss";
</style>