<template>
	<view :style="'background-color: '+theme.bg+';color: '+theme.text" style="height: 100vh;">
		<myNav :title="i18n.TranRecord.title2"></myNav>
		<!-- 身体 -->
		<view class="width-750 padding-w-30 padding-t-16">
			<view class="height-76 flex align-center">
				<text class="font-28">{{i18n.TranRecord.text19}}：</text>
			</view>
			<view class="height-96 flex align-center">
				<input class="flex-1 font-28 color-C3C3C3" type="number" v-model="BCnum" :placeholder="i18n.TranRecord.tos1" placeholder-class="color-C3C3C3" >
			</view>
			<view @click="sureBC" class="btn">{{i18n.TranRecord.text20}}</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				statusBar: uni.getSystemInfoSync().statusBarHeight,
				BCnum: '0',
				flag: true,
				
				theme: '',
			}
		},
		computed: {
			i18n() {
				return this.$t('message');
			}
		},
		onShow() {
			if (uni.getStorageSync("theme") == "dark") {
				this.theme = this.$store.state.darkTheme
			} else {
				this.theme = this.$store.state.lightTheme
			}
			this.get_strategy()
		},
		methods: {
			// 获取补仓限制
			get_strategy() {
				this.post('/strategy/get_strategy_setting', {
					exchange_id: uni.getStorageSync('exchange_id')
				}).then(res => {
					console.log(res)
					if (res.code == 1) {
						this.BCnum = res.data.bc_min_limit
					}
				})
			},
			sureBC() {
				if (!this.flag) return
				if (this.BCnum == '') {
					this.tos(this.i18n.TranRecord.tos1);
					return
				}
				this.flag = false
				uni.showLoading({
					title: ''
				})
				this.post('/strategy/setbc_limit', {
					bc_min_limit: this.BCnum,
					exchange_id: uni.getStorageSync('exchange_id')
				}).then(res => {
					console.log(res)
					this.flag = true
					uni.hideLoading()
					if (res.code == 1) {
						this.tos(res.msg)
						setTimeout(() => {
							uni.navigateBack()
						}, 500)
					}
				})
			},
		}
	}
</script>

<style lang="scss">
	.fixed1 {
		position: fixed;
		top: 0;
		z-index: 1000;
	}
	.btn{
		width: 690rpx;
		height: 96rpx;
		border-radius: 20rpx;
		background-color: #0165EE;
		line-height: 96rpx;
		text-align: center;
		font-size: 32rpx;
		color: #FFFFFF;
		position: fixed;
		bottom: 200rpx;
	}
</style>
