<template>
	<view class="bind-user">
		<view class="bind-user-header">
			<view class="flex mb28">
				<up-image width="139rpx" height="139rpx" :src="userInfo?.userImage" shape="circle"></up-image>
				<view class="header-name">
					<view class="font32 mb20" :style="{color:'#000'}">{{ userInfo?.userName}}</view>
					<!-- <view class="label1" v-if="userInfo.userHhRole == 1">
						初级伴宠师
					</view>
					<view class="label1" v-if="userInfo.userHhRole == 2">
						中级伴宠师
					</view>
					<view class="label1"v-if="userInfo.userHhRole == 3">
						高级伴宠师
					</view> -->
					<view class="label1" v-if="baseInfo.partner_level">
						{{ baseInfo.partner_level }}
					</view>
					<view class="flex font24">
                        <view 
                        style="margin-right: 20rpx;"
                        :style="{color:'#A55822'}" v-if="baseInfo.partner_new_num">
                            当前分成比例<text :style="{color:'#C12525'}">{{baseInfo.partner_new_num}}</text>
						</view>
						<view :style="{color:'#A55822'}" v-if="baseInfo.partner_upgrade_num">
                            晋级后分成比例<text :style="{color:'#C12525'}">{{baseInfo.partner_upgrade_num}}</text>
						</view>
					</view>
				</view>
			</view>
			<view class="flex flex-evenly mt60">
				<view class="header-card card-left box-size"
					@click="configPopupRef.open('icon_popularize_strategy')">
					<view class="flex-between flex">
						<view class="mr20">
							<view class="mb20 ml20" :style="{color:'#A55822',fontWeight:'bold',fontSize:'30rpx'}">
								{{ configList.icon_popularize_strategy.paramValue }}
							</view>
							<view :style="{color:'#A55822',fontSize:'22rpx'}">{{ configList.icon_popularize_strategy.paramValueText }}</view>
						</view>
						<up-image :show-loading="true" src="https://cdn.catmdogd.com/Work/image/work/icon1.png"
							width="71rpx" height="85rpx"></up-image>
					</view>
				</view>
				<view class="header-card card-right box-size"
					@click="configPopupRef.open('icon_popularize_tutorial')">
					<view class="flex flex-between">
						<view class="mr20">
							<view class="mb20 ml20" :style="{color:'#A55822',fontWeight:'bold',fontSize:'30rpx'}">
								{{ configList.icon_popularize_tutorial.paramValue }}
							</view>
							<view :style="{color:'#A55822',fontSize:'22rpx'}">{{ configList.icon_popularize_tutorial.paramValueText }}</view>
						</view>
						<up-image :show-loading="true" src="https://cdn.catmdogd.com/Work/image/work/icon2.png"
							width="71rpx" height="85rpx"></up-image>
					</view>
				</view>
			</view>
		</view>
		
		<!-- 
			:style="{'background-image' : `url(${configList.background_popularize_one.paramValueImage})`}" -->
		
		<view class="bind-main">
			<view class="bind-main-one mb10"
			:style="{'background-image' : `url('${configList.background_popularize_one.paramValueImage}')`}">
				<view class="mb20 font32">邀请码邀请</view>
				<view class="mb20">用户输入邀请码，直接完成绑定</view>
				<up-input disabled v-model="baseInfo.user_code">
					<template #suffix>
						<up-button @click="copyMessage(baseInfo.user_code)" text="复制" type="success" size="small" shape="circle"></up-button>
					</template>
				</up-input>
			</view>
			<view class="bind-main-two mb10"
			:style="{'background-image' : `url('${configList.background_popularize_two.paramValueImage}')`}">
				<view class="mb20 font32">分享海报邀请</view>
				<view class="mb20">扫码进入猫妈狗爸完成绑定</view>
				<up-button @click="toSharing" text="保存海报" type="primary" shape="circle" plain style="background: transparent;"></up-button>
			</view>
			<view class="bind-main-three"
			:style="{'background-image' : `url('${configList.background_popularize_three.paramValueImage}')`}">
				<view class="mb20 font32">分享链接邀请</view>
				<view class="mb20">复制链接给好友，进入直接绑定</view>
				<up-input disabled v-model="dataF.invitation_url">
					<template #suffix>
						<up-button @click="copyMessage(dataF.invitation_url)" text="复制" type="success" size="small" shape="circle"></up-button>
					</template>
				</up-input>
			</view>
		</view>
		
		<configPopup ref="configPopupRef" />
	</view>
</template>

<script setup>
	import {
		computed,
		ref,
		onMounted,
	} from "vue";
	import {
		useStore
	} from "vuex"
	
	import {
		binBaseInfo,
		bindCode,
	} from "@/api/home.js"
	
	import configPopup from '@/components/configPopup.vue'
	
	const store = useStore();
	
	
	const dataF = ref({})
	const baseInfo = ref({})


	const configPopupRef = ref(null)
	
	const configList = computed(() => {
		return store.getters.configList
	})

	const userInfo = computed(() => {
		return store.getters.userInfo
	})
	
	//复制
	const copyMessage = (value) => {
		uni.setClipboardData({
			data: value,
			success: function(res) {
				uni.getClipboardData({
					success: function(res) {
						uni.showToast({
							icon: 'none',
							title: "复制成功",
						});
					},
				});
			},
		});
	}
	
	const getBaseInfo = () => {
		binBaseInfo(baseInfo.value.userId).then(res => {
			baseInfo.value = res.data
		})
		bindCode(baseInfo.value.userId).then(res => {
			dataF.value = res.data
		})
	}
	
	function toSharing(){
		uni.navigateTo({
			url: `/otherPages/workbenchManage/bindUser/sharing`
		})
	}
	
	onMounted(() => {
		baseInfo.value = JSON.parse(uni.getStorageSync("baseInfo"))
		getBaseInfo()
	})
</script>


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