<template>
	<view :style="{'height':contentHeight}" class="levelStyle">
		<image src="../../../static/images/icon/no-level-bg.png" v-if="level=='' " style="width: 100%;height: 100%;"></image>
		
		<view  class="imgbg">
			<text style="display: inline-block;width: 94%;margin: 15px 0;" >升级状态:{{level.Status==1?'正常':(level.Status==2?'暂无升级':'')}}</text>
			<view class="leve_box">
				<text style="font-size: 18px;">等级名称：{{level.GradeInfo.GradeName}}</text>
				<view style="display: flex;flex-direction: row;align-items: center;justify-content: space-between;margin-top: 15px;">
					<text>升级所需数量:{{level.GradeInfo.UpgradeNum}}</text>
					<text>已达成数量:{{level.GradeInfo.MeetNum}}</text>
				</view>
				<text style="font-size: 16px;margin-top: 15px;">升级所需下级等级：{{level.GradeInfo.UpgradeIdName}}</text>
			</view>
		</view>
		<u-popup v-model="show"
				mode="center"
				length="80%"
				
		>
				<view class="popup">
					<view class="popup_t">
						<Text>等级说明</Text>
					</view>
					<view class="popup_c">
						<Text>{{level.UpgradeIdName}}</Text>
					</view>
					<view class="popup_t" style="border-top: 1px solid #f5f5f5;" @click="show=false">
						<Text>我知道了</Text>
					</view>
				</view>
		</u-popup>
	</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>
