<template>
	<!-- <view class="container" :style="{'min-height':`calc(100vh - ${(statusBarHeight+navBareight)+'px'})` }"> -->
	<view class="container">
		<navBar title="推广中心" :back="true" color="#333333" background="#FFFFFF" />
		<view class="outerBox">
			<!-- <view class="navHeight" :style="{height:statusBarHeight+'px'}"></view> -->
			<view class="userBox">
				<image class="avatar" :src="!userInfo.avatar?picBase+'defaultAvatar.png':userInfo.avatar" mode="">
				</image>
				{{userInfo.name?userInfo.name:'默认用户'}}
				<view class="flag" :style="{'background-image':`url(${picBase+'dashi_bg.png'})`}">
					推广大使
					<!-- <image src="../../../static/other/huangguan.png" mode="" class="hg_i"></image> -->
				</view>
			</view>

			<view class="card" :style="{'background-image':`url(${picBase+'center_c_bg.png'})`}">
				<!-- <image src="../../../static/other/liujiaoxing.png" mode="widthFix" class="ljx_i"></image> -->

				<view class="imgPos">

				</view>

				<view class="labelBox">
					推广收入.
					<image :src="state?eyeSrc:eyeSrc2" mode="widthFix" class="eye" @click="handleShow"></image>
				</view>

				<view class="shouRu">
					<view class="left">
						累计收入:{{state?'￥'+info.totalIncome:'******'}}
					</view>
					<view class="right">
						可提现收入: {{state?'￥'+info.withdrawIncome:'******'}}
					</view>
				</view>
			</view>


			<view class="titleM">
				推广大使权益
			</view>
			<view class="list">
				<view class="item" v-for="(item,index) in serList" @click="toPage(index)">
					<!-- <view class="iconBox"> -->
					<image :src="item.icon" mode="widthFix" class="iconBox"></image>
					<!-- </view> -->
					{{item.txt}}
				</view>
			</view>
			<!-- <view class="bLogo"> -->
			<image :src="picBase+'logo_b.png'" mode="" class="bLogo"></image>
			<!-- 短腿鹤伴读
			</view> -->
		</view>
	</view>
</template>

<script>
	// import navBar from '@/components/navBar/index.vue'
	import {
		getUserInfo,
		getYongjinList
	} from '@/api/index/index.js'
	export default {
		// components: {
		// 	navBar
		// },
		data() {
			return {

				statusBarHeight: 20,
				navBareight: 45,
				picBase: this.$picBase2,
				userInfo: null,
				state: true,
				eyeSrc: this.$picBase2 + 'zyan.png',
				eyeSrc2: this.$picBase2 + 'biyan.png',
				serList: [{
						txt: '推广团队',
						icon: this.$picBase2 + 'icon1.png'
					},
					{
						txt: '佣金明细',
						icon: this.$picBase2 + 'icon2.png'
					},
					{
						txt: '佣金提现',
						icon: this.$picBase2 + 'icon3.png'
					},
					{
						txt: '提现明细',
						icon: this.$picBase2 + 'icon2.png'
					},
					{
						txt: '分享海报',
						icon: this.$picBase2 + 'icon5.png'
					},
				],
				info: {
					totalIncome: 0,
					withdrawIncome: 0,
					// data: []
				}
			}
		},
		onLoad() {
			this.getUserInfo()

			//获取手机系统信息 -- 状态栏高度
			let {
				statusBarHeight,
				windowWidth
			} = uni.getSystemInfoSync()
			this.statusBarHeight = statusBarHeight
			this.windowWidth = windowWidth
		},

		onShow() {
			this.getYongjinList()
		},
		methods: {

			async getYongjinList() {
				let res1 = await getYongjinList()
				console.log('佣金明细返回值--------', res1);
				if (res1.code == 0) {
					this.info = res1.data
				} else {
					this.$toast(res1.message)
				}
			},
			async getUserInfo() {
				let res1 = await getUserInfo()
				console.log('用户信息返回值--------', res1);
				if (res1.code == 0) {
					uni.setStorageSync('userInfo', res1.data)
					this.userInfo = res1.data
				} else {
					this.$toast(res1.message)
				}
			},
			handleShow() {
				this.state = !this.state
			},
			toPage(i) {
				if (i == 0) {
					uni.navigateTo({
						url: '/pages/my/team/index'
					})
				} else if (i == 1) {
					uni.navigateTo({
						url: '/pages/my/yongjinDetail/index'
					})
				} else if (i == 2) {
					uni.navigateTo({
						url: '/pages/my/cash/index'
					})
				} else if (i == 3) {
					uni.navigateTo({
						url: '/pages/my/cashRecord/index'
					})
				} else {
					uni.navigateTo({
						url: '/pages/my/tuiguangHaibao/index'
					})
				}
			},
		}
	}
</script>

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