<template>
	<view>
		<u-navbar back-text="隐私设置"  back-icon-color="#ffffff"
			:background="{backgroundColor: '#2795FD',}" :back-text-style="{color: '#ffffff'}"></u-navbar>
		<view class="top">
			<view>
				<img src="@/pages/packages/as-components/privacy.png">
			</view>
			<view>
				<view>我们时刻保护</view>
				<view>你的隐私安全</view>
			</view>
		</view>
		<u-select v-model="updateintention" :list="intentionList" @confirm="updateintentionBtn" ></u-select>

		<!-- 其他服务 -->
		<view class="card ">
			<view class="span_view">
				<view>求职状态
					
					
					
				</view>
				<view  class="span_view_select">
					勿扰<u-switch  size="40"  @change="change1" v-model="intention"></u-switch>求职
					
				</view>
			</view>
				<u-line color="#E6E6E6"></u-line>
			<view class="span_view">
				<view>简历状态</view>
				<view  class="span_view_select">
					隐藏<u-switch  size="40" @change="change2" v-model="jobStatus"></u-switch>公开
					
				</view>
			</view>
			<u-line color="#E6E6E6"></u-line>
			<view class="span_view">
				<view>真实姓名保护
					<view class="span_view777">开启后，对外显示名称将展示“X女士/先生”</view>
				</view>
				<view  class="span_view_select">
					关闭<u-switch  size="40"  @change="change3" v-model="isAnonymous"></u-switch>开启
					
				</view>
			</view>
				

			
		</view>
		
	</view>
</template>

<script>
	import * as API from '@/apis/pagejs/packages.js'
	import * as API_weixin from '@/apis/weixin.js'


	export default {
		components: {
		
		},
		data() {
			return {
				src: '',
				show: false,
				value: 'false',
				userInfo: {},
				showPhone: false,
				confirmText: '拨打电话',
				content: "",
				checked:false,
				num1: 0,
				num2: 0,
				num3: 0,//0 未创建 ，1 审批中， 2 成功
				isReady:false,
				updateintention:false,
				intention: '',
				jobStatus:false,
				isAnonymous:false,
				intentionList:[
					{
						value: '1',
						label: '求职中'
					},
					{
						value: '2',
						label: '隐藏简历'
					},
					{
						value: '3',
						label: '已入职/勿扰'
					},
				],
				
			}
		},
		onLoad() {
			
		},
		onShow(){
			this.userInfo = this.carhelp.getPersonInfo()
			this.intention=this.userInfo .intention==1
			this.isAnonymous=this.userInfo.isAnonymous
			this.jobStatus=this.userInfo.jobStatus==null?true:this.userInfo.jobStatus=="1"
		},
		methods: {
			change1(index){
				this.intention=index;
				this.updateApi()
			},
			change2(index){
				this.jobStatus=index;
				this.updateApi()
			},
			change3(index){
				this.isAnonymous=index;
				this.updateApi()
			},
			updateApi(){
				uni.showLoading({
					title: "加载中",
					mask: true,
				})
				API.updatePerson({
					intention: this.intention?"1":"2",
					isAnonymous:this.isAnonymous,
					jobStatus:this.jobStatus?"1":"0"
				}).then((res) => {
					uni.hideLoading();
					this.userInfo.intention=this.intention?"1":"2";
					this.userInfo.isAnonymous=this.isAnonymous;
					this.userInfo.jobStatus=this.jobStatus?"1":"0";
					this.carhelp.setPersonInfo(this.userInfo)
				}).catch(error => {
					this.showPhone = false;
					uni.hideLoading();
				})
			},
			updateintentionBtn(e){
				console.log(e);
				this.intention=e[0].value
				this.updateApi()
			},
			
		}
	}
</script>
<style>
	page {
		background: #F0F0F2;
		padding-bottom: 150px;
	}
</style>
<style lang="scss" scoped>
	.showImg {
		width: 38rpx;
		height: 38rpx;
	}

	.top {
		background-color: #2795FD ;
		display: flex;
		align-items: center;
		padding: 40rpx 32rpx 88rpx;
		font-size: 48rpx;
		justify-content: center;
		color:#fff;
		img{
			width: 168rpx;
			height: 168rpx;
		}
	}


	.card {
		    position: relative;
		    top: -40px;
		background-color: #fff;
		border-radius: 12px;
		margin: 32rpx;
		padding:8rpx 32rpx;

		.title {
			color: rgba(16, 16, 16, 1);
			font-size: 32rpx;
			margin-bottom: 20rpx;
		}
		.span_view{
			display: flex;
			justify-content: space-between;
			padding:32rpx 0;
			font-size: 38rpx;
			color: rgba(51, 51, 51, 1);
			.span_view777{
				color:#777777;
				font-size: 24rpx;
			}
			
			.span_view_select{
				display: flex;
				font-size: 24rpx;
				align-items: center;
				min-width: 220rpx;
				 justify-content: flex-end;
			}
			
		}

	}

	
	
	
	
	.greencircle:after {
	  content: '';
	  margin: 3px;
	  display: table;
	  width: 6px;
	  height: 6px;
	 
	  border-radius: 50%;
	}
	.greencircle2:after {
		 background: #54b86c;
	}
	.greencircle1:after {
		 background:  #dc4441;
	}
</style>