<template>
	<view :style="{'height':contentHeight}" class="levelStyle">
		<image src="https://viitto-1301420277.cos.ap-chengdu.myqcloud.com/Static/no-level-bg.png" v-if="level.Status==2 " style="width: 100%;height: 100%;"></image>
		
		<view  class="imgbg" v-if="level.Status== 1">
			<view class="leve_box">
				<view style="display: flex;flex-direction: row;align-items: center">
					<text style="font-size: 18px;">{{level.GradeInfo.GradeName}}</text>
					<view style="padding: 0 10px;background: rgba(55, 55, 55, 0.1);margin-left: 15px;height: 20px;border-radius: 10px;font-size: 11px;line-height: 20px;">
						<text>下个等级</text>
					</view>
				</view>
				<text style="margin-top: 5px;font-size: 13px;">自购返利:{{level.GradeInfo.CommissionRatio}}%</text>
				<view style="width: 100%;height: 1px;background: #F8F6F5;margin: 5px 0;"></view>
				<text style="font-size: 14px;" v-if="level.GradeInfo.UpgradeNum-level.GradeInfo.MeetNum!=0">还需要：{{level.GradeInfo.UpgradeNum-level.GradeInfo.MeetNum}}个{{level.GradeInfo.UpgradeIdName}}</text>
				<text style="font-size: 14px;" v-if="level.GradeInfo.UpgradeNum-level.GradeInfo.MeetNum==0">已满足升级条件</text>
				<u-line-progress active-color="#2979ff" :striped-active="true" :percent="(level.GradeInfo.MeetNum/level.GradeInfo.UpgradeNum)*100"></u-line-progress>
				<text style="margin-top: 5px;font-size: 13px;">{{level.GradeInfo.MeetNum}}/{{level.GradeInfo.UpgradeNum}}</text>
			</view>
		</view>
	
	</view>
</template>

<script>
	export default {
		data() {
			return {
				pageTitle: "升级规则",
				contentHeight:0,
				show:false,
				mainColor:'',
				secondary:'',
				level:'',
				level_bg2:'',
			}
		},
		created(){
			 this.contentHeight = this.$utils.calcContentHeight(-40)+'px';
			 this.mainColor = this.$uiConfig.mainColor;
			 this.secondary = this.$uiConfig.secondary;
			 this.init()
		},
		mounted() {
			let currentPages = getCurrentPages();
			 let u = "/" + currentPages[currentPages.length-1].route;
			 let pages = wx.getStorageSync("basedata")
			   ? wx.getStorageSync("basedata").bar_title
			   : [];
			  
			 uni.setNavigationBarTitle({
			   title: this.pageTitle,
			 });
		},
		methods: {
			init(){
				uni.showNavigationBarLoading();
				
				this.request2(
				  {
				  	url: '/api/AppletUser/GetUserDistrbutorUpgradeConditionsForFX',
				  	data: {}
				  },	
							
				  (res) => {
					uni.hideNavigationBarLoading()
						this.level = res.data
				  }
				);
			},
			Upgrade(){
				uni.showNavigationBarLoading();
				
				this.request2(
				  {
				  	url: '/api/AppletUser/SetUserDistrbutorUpgrade',
				  	data: {
						Id:this.level.GradeInfo.Id
					}
				  },	
							
				  (res) => {
					uni.hideNavigationBarLoading()
						uni.showToast({
							title:res.message,
							icon:'none'
							
						})
				  }
				);
			}
		}
	}
</script>

<style>
	.levelStyle .imgbg{
		width: 100%;
		height: 100%;
		display: flex;
		flex-direction: column;
		align-items: center;
	}
	.levelStyle .popup{
		width: 100%;
		height: 285px;
		background: #fff;
		display: flex;
		flex-direction: column;
		align-items: center;
		border-radius: 8px;
		overflow: hidden;
		justify-content: space-between;
	}
	.levelStyle .popup_c{
		width: 94%;
		height: 160px;
		padding: 10px;
		border-radius: 5px;
		border: 1px solid #f5f5f5;
	}
	.levelStyle .popup_t{
		width: 100%;
		height:50px ;
		display: flex;
		align-items: center;
		justify-content: center;
	}
	.levelStyle .leve_box{
		width: 94%;
		height: 130px;
		border-radius: 6px;
		background-image: url(../../../static/images/shareTop.png);
		background-repeat: no-repeat;
		background-size: 100% 100%;
		display: flex;
		flex-direction: column;
		padding: 10px;
		color: #FFFFFF
	}
</style>
