<template>
	<view>
		<public-module></public-module>
		<view class="headers " :style="headerStyle">
			<view class="dis a-c j-c">
				<text>首页</text>
			</view>
		</view>
		<!-- <image style="position: relative;height:230px" src="../../static/beijing.png"></image> -->
		<!-- <image v-if="type == 1" style="position: relative;height:230px" src="../../static/shouye1.png"></image> -->
		<view class="Personnel">
			<view class="avatar">
				<image src="/static/img/Frame (8).png"  mode=""></image>
				<text>团队新人员加入信息/新出单信息</text>
			</view>
			<uni-notice-bar show-icon scrollable text="uni-app 版正式发布，开发一次，同时发布iOS、Android、H5、微信小程序、支付宝小程序、百度小程序、头条小程序等7大平台。" />
		</view>
		<view class="insurance dis j-s" >
			<view style="text-align: center;">
				<view class="insurance-cash" >{{totalList.sumPremium || 0}}</view>
				<text class="insurance-text">总保费	</text>
			</view>
			<view style="text-align: center;">
				<view class="insurance-cash">{{totalList.teamManNum || 0}}</view>
				<text class="insurance-text">总人数	</text>
			</view>
			<view style="text-align: center;">
				<view class="insurance-cash">{{totalList.extractFee || 0}}</view>
				<text class="insurance-text">总佣金</text>
			</view>
		</view>
		<view >
			<view class="institutional-data  dis j-s" v-if="type == 2 ||userInfo.sysUser.level==5">
				<view class="inst-con" @click="userInfo.sysUser.level==5 ?closeInstitution():closeStudion()">
					<view>工作室</view>
					<text >{{userInfo.sysUser.level==5 ?totalList.workroomNum :totalList.workroomTeamNum}}</text>
				</view>
				<view class="inst-con"  @click="userInfo.sysUser.level==5 ?recruitmentWorkCode() :recruitmentCode()">
					<view>招募码</view>
					<text >扫码加入</text>
				</view>
			</view>
			<view class="inst-data dis j-s" v-if="type == 1 && userInfo.sysUser.level!==5" >
				<view class="inst-con" @click="closePartner()">
					<view >合伙人</view>
					<text >{{totalList.partnerNum}}</text>
				</view>
				<view class="inst-con" @click="closeInstitution()">
					<view>工作室</view>
					<text >{{totalList.workroomNum}}</text>
				</view>
			</view>
		</view>
		<u-popup v-model="ShowModalCode" mode="bottom"  border-radius="15" >
				<view class="ShowModalCode-style ">
					<text>团队招募码</text>
					<view class=" ShowModalCode-con">
						<view>扫码加入</view>
						<image :src="teamImg" mode="widthFix" lazy-load style="width: 150px;"></image>
					</view>
				</view>
		</u-popup>
		<u-popup v-model="ShowModalCodebusiness" mode="bottom" border-radius="15">
			<view>
				<text class=" ShowModalCode-business">工作室业务</text>
				<view>
					<radio-group class="uni-list" @change="styleChange">
						<view v-for="(item, index) in styles" :key="index" class="uni-list-item">
							<view class="uni-list-item__container">
								<view class="uni-list-item__content">
									<text class="uni-list-item__content-title">{{ item.text }}</text>
								</view>
								<view class="uni-list-item__extra">
									<radio :value="item.value" :checked="item.checked" />
								</view>
							</view>
							<view class="uni-list-item__notestext">{{ item.notestext }}</view>
						</view>
					</radio-group>
				</view>
				<view class="ShowModalCode-sumbit" @click="ShowModalCodeSumbit()">确定</view>
			</view>
		</u-popup>
		<u-popup v-model="ShowModalCode1" mode="bottom" border-radius="15">
			<view class="ShowModalCode-style ">
				<text>工作室招募码</text>
				<view class=" ShowModalCode-con">
					<view>扫码加入</view>
					<image :src="workImg" mode="widthFix" lazy-load style="width: 150px;"></image>
				</view>
			</view>
		</u-popup>
	</view>
</template>
<script>
	import QR from "@/common/wxqrcode.js"
	import {
		mapState,
		mapMutations
	} from "vuex"
import { vShow } from "vue"
export default {
	computed: {
		...mapState(['userInfo', "userCheckInfo", ]),
	},
	data() {
		return {
			ShowModalCode:false,
			ShowModalCode1:false,
			ShowModalCodebusiness:false,
			teamImg:'',
			workImg:'',
			totalList:{},
			type: uni.getStorageSync('type'),
			headerStyle: {
				backgroundColor: 'transparent',
				backgroundImage: '',
				backgroundSize: '',
				backgroundPosition: '',
				boxShadow: ''
				// 其他样式属性...
			},
			styles: [{
				value: '1',
				text: '渠道',
				notestext: '团队长加出单员模式，无分销模式，结费都在团队长处。',
				checked: true
			},
			{
				value: '2',
				notestext: '团队长加代理人模式，三级分销模式，结费方式为个人，有佣金。',
				text: '个代'
			}
			],
			deptSource:1
			// type:JSON.parse(localStorage.getItem('type')).data
		}
	},
	async onShow(e) {
		this.type = uni.getStorageSync('type')
		let res = await this.$http.get('/APPPartner/getHomePage', {
			type: uni.getStorageSync('type'),
		});
		if (res.code == '200') {
			this.totalList = res.data
		}
	
	},
	methods: {
		styleChange(e) {
			this.deptSource = e.detail.value
		},
		recruitmentCode(){
			this.ShowModalCode=true
			this.teamImg = QR.createQrCodeImg(this.$base.h5BaseUrl + "/#/pages/index/applyteam?userId="+this.userInfo.sysUser.userId, {
				size: parseInt(200) //二维码大小  
			})
		},
		ShowModalCodeSumbit(){
			console.log(this.deptSource,44444444);
			this.ShowModalCode1=true
			this.workImg = QR.createQrCodeImg(this.$base.h5BaseUrl + "/#/pages/index/applystudio?deptSource=" + this.deptSource + '&userId=' + this.userInfo.sysUser.userId, {
				size: parseInt(200) //二维码大小  
			})
		},
		recruitmentWorkCode(){
			this.ShowModalCodebusiness=true
			this.deptSource = 1

		},
		detail(id){
			uni.navigateTo({
				url: "/pages/institutional/walletDetail?id="+id
			})
		},
		closeDetailPro(val){
				uni.navigateTo({
					url: `/pages/institutional/detail?deptId=${val.deptId}&deptName=${val.deptName}&startTime=${val.startTime}`
				})
			},
		
		closeInstitution() {
			// if(this.totalList.workroomNum>0){
				
			// }
			this.totalList.type=1
			uni.navigateTo({
				url: "/pages/institutional/institutionalTeam?key="+encodeURIComponent(JSON.stringify(this.totalList))
			})
		},
		closeStudion() {
			uni.navigateTo({
				url: "/pages/institutional/institutional?key="+encodeURIComponent(JSON.stringify(this.totalList))
			})
		},
		closePartner() {
			uni.navigateTo({
				url: "/pages/institutional/partner"
			})
		},
		viewTeam() {
			uni.navigateTo({
				url: "/pages/institutional/institutional" 
			})
		},
		bankCard() {
			uni.navigateTo({
				url: "/pages/wallet/bankCard"
			})
		},
		bankwallet() {
			uni.navigateTo({
				url: "/pages/index/applystudio"
			})
		},
	}
}
</script>
<style lang="scss" scoped>


.homepage {
	display: flex;
	width: 100%;
	justify-content: space-between;
}

.homepage>view {
	width: 47%;
	height: 100px;
	// min-height: 18vh;
	// max-height: 22vh;
	background-size: contain;
}

.wallet {
	padding: 15upx 20upx;
}

.wallet>view:nth-child(1) {
	color: #333333;
	font-size: 14px;
	font-weight: bold;
}

.wallet>view:nth-child(2) {
	margin-top: 5upx;
	font-size: 12px;
	color: rgba(51, 51, 51, 0.8);
}

.homepage>view:nth-child(1) {
	background: url(../../static/qianbao.png) no-repeat;
	background-size: 100% 100%;
}

.homepage>view:nth-child(2) {
	background: url(../../static/yinhangka.png) no-repeat;
	background-size: 100% 100%;
}

.institutional-data {
	margin: 16px;
}
.institutional-data>view:nth-child(1) {
	background: url(../../static/work.png) no-repeat;
	background-size: 100% 100%;
	color: #009B9F;
}

.institutional-data>view:nth-child(2) {
	background: url(../../static/zhaomum.png) no-repeat;
	background-size: 100% 100%;
	color: #3168DA;
}
// .institutional-title {
// 	padding: 10upx 10upx 20upx 10upx;
// 	font-weight: bold;

// 	text {
// 		font-size: 14px;
// 	}
// }

// .institutional-list {
// 	background: #FFFFFF;
// 	border-radius: 12px 12px 12px 12px;
// 	padding: 0 20upx;
// 	font-size: 38upx;

// }

.view-now {
	background: linear-gradient(90deg, #7E99D1 0%, #4F78B1 100%);
	border-radius: 20px 20px 20px 20px;
	color: #fff;
	font-size: 11px;
	padding: 2px 10px;
}
.view-now1{
	background-color: rgba(79, 120, 177, 0.1);
	color: #537BB4;
	border-radius: 20px 20px 20px 20px;
	font-size: 11px;
	padding: 2px 10px;
}
.homepage-title {
	margin-top: 5px;

	button {
		background-color: #FEF0E1;
		color: #FE8F1C;
	}
}

.homepage-title>button:last-child {
	background: #E6FAE3;
	color: #3AC716;
	margin-left: 10px;
}

.button1 {
	background-color: #FEF0E1;
	color: #FE8F1C;
	font-size: 11px;
	padding: 5px 10px
}

.button2 {
	background: #E6FAE3;
	color: #3AC716;
	margin-left: 10px;
	font-size: 11px;
	padding: 5px 10px
}

.inst-data {
	margin: 16px;
}

.inst-con {
	width: 47%;
	padding: 13px 18px;
	}	
.inst-con>view:nth-child(1) {
	font-size: 19px;
	font-weight: 700;
}

.inst-con>view:nth-child(2) {
	font-size: 13px;
	font-weight: 400;
}

.inst-data>view:nth-child(1) {
	background: url(../../static/hehuor.png) no-repeat;
	background-size: 100% 100%;
	color: #3168DA;
}

.inst-data>view:nth-child(2) {
	background: url(../../static/work.png) no-repeat;
	background-size: 100% 100%;
	color: #009B9F;
}
.headers {
		position: fixed;
		top: 0;
		left: 0;
		height: auto;
		width: 100%;
		z-index: 999999;
		padding: 16px;
		padding-top: 40px;

		>view {
			width: 100%;
			height: 100%;
			position: relative;
		}
		text {
			font-size: 18px;
			font-weight: 700;
			color: #333333;
		}
	}
	.Personnel {
		height: auto;
		width: 100%;
		background: #F7F7F7;
		background-image: url("/static/beijing.png");
		background-size: 100% 100%;
		padding: 200px 16px 15px 16px;
	
		.avatar {
			background: #FFFFFF;
			box-shadow: 0px 0 8px 0px rgba(0,0,0,0.1);
			border-radius: 5px 5px 5px 5px;
			padding: 0 10px;
			line-height: 35px;
			height: 35px;
			image {
				display: inline-block;
				width: 16px;
				height: 16px;
				vertical-align: middle;
				margin-right: 5px;
			}
			
		}
		
	}
	.insurance{
		margin: 0 16px;
		background: #FFFFFF;
		box-shadow: 0px 0 8px 0px rgba(0,0,0,0.1);
		border-radius: 5px 5px 5px 5px;
		padding: 20px 30px;
		.insurance-cash{
			font-weight: 700;
			font-size: 21px;
			color: #333333;
			line-height: 24px;
			margin-bottom: 5px;
		}
		.insurance-text{
			font-weight: 300;
			font-size: 13px;
			color: #999999;
			line-height: 15px;
		}
	}
	.studio{
		margin:16px;
	}
	.ShowModalCode-style{
		text:first-child{
			display: block;
			font-weight: 600;
			font-size: 16px;
			color: #333333;
			border: 1px solid #EEEEEE;
			padding: 15px;
			text-align: center;
		}
	}
	.ShowModalCode-con{
		padding: 30px;
		text-align: center;
		image{
			margin: 0 auto;
			margin-top: 15px;
		}
	}
	.ShowModalCode-business {
	display: block;
	font-weight: 600;
	font-size: 16px;
	color: #333333;
	// border: 1px solid #EEEEEE;
	padding: 15px;
	text-align: center;
}
.ShowModalCode-sumbit {
	background: linear-gradient(132deg, #2DD9FF 0%, #2D6DFF 100%);
	border-radius: 5px 5px 5px 5px;
	height: 40px;
	line-height: 40px;
	font-size: 16px;
	color: #FFFFFF;
	margin: 15px;
	text-align: center;
}
.uni-list {
	flex: 1;
}

.uni-list-item:first-child {
	/* #ifndef APP-NVUE */
	// display: flex;
	/* #endif */
	flex: 1;
	flex-direction: row;
	background-color: #FFFFFF;
	border-bottom-style: solid;
	border-bottom-width: 1px;
	border-bottom-color: #eee;
}


.uni-list-item__container {
	padding: 12px 15px;
	width: 100%;
	flex: 1;

	position: relative;
	/* #ifndef APP-NVUE */
	display: flex;
	box-sizing: border-box;
	/* #endif */
	flex-direction: row;
	justify-content: space-between;
	align-items: center;

}

.uni-list-item__notestext {
	padding: 0 15px 15px 15px;
	font-size: 15px;
	color: #666666;
}

.uni-list-item__content-title {
	font-size: 17px;
	color: #333333;
}
</style>