<template>
	<view class="u-page">
		<view class="se-pt-50 se-pb-40 se-px-40 se-bgc-green se-c-white se-pos">
			<view class="se-flex">
				<image :src="user.headImage" class="se-br-p-50 se-w-100 se-h-100 se-bgc-f5" mode=""></image>
				<view class="se-ml-20 se-flex se-flex-v-sa se-flex-ai-fs">
					<view class="se-flex">
						<text class="se-fw-6 se-fs-30">{{user.nickName}}</text>
						<view class="se-flex se-flex-ai-c se-ml-20" @click="toNav()">
							<image class="se-a-25 se-mr-10" src="@/static/image/pencil.png" mode=""></image>
							<text class="se-fs-22">修改资料</text>
						</view>
					</view>
					<view class="se-fs-24 se-display-ib">
						<text>手机号:</text>
						<text class="se-ml-20">{{user.phone}}</text>
					</view>
					<view class="se-fs-24 se-display-ib">
						<text class="se-tag se-bgc-gray" v-if="companyAuthenticationStatus==2">企业认证-未通过</text>
						<text class="se-tag se-bgc-blue" v-if="companyAuthenticationStatus==1">企业认证-已通过</text>
						<text class="se-tag se-bgc-red" v-if="companyAuthenticationStatus==0">企业认证-审核中</text>
						<text class="se-tag se-bgc-gray" v-if="personAuthenticationStatus==2">个人认证-未通过</text>
						<text class="se-tag se-bgc-blue" v-if="personAuthenticationStatus==1">个人认证-已通过</text>
						<text class="se-tag se-bgc-red" v-if="personAuthenticationStatus==0">个人认证-审核中</text>
					</view>
				</view>
			</view>
		</view>
		<view class="se-m-30 se-mt-30 se-pl-30 se-pr-20 se-br-20 se-bgc-white">
			<view class="se-py-30 se-px-20 se-flex se-flex-h-sb se-b-b"  @click="onIdentity()">
				<view class="se-flex se-flex-ai-c">
					<image class="se-a-30" src="@/static/image/482012.png" mode=""></image>
					<text class="se-ml-20 se-fs-24 se-fw-5">实名认证</text>
				</view>
				<view class="se-flex se-flex-ai-c">
					<u-icon name="arrow-right"></u-icon>
				</view>
			</view>
			<view class="se-py-30 se-px-20 se-flex se-flex-h-sb se-b-b" @click="onReservation()">
				<view class="se-flex se-flex-ai-c">
					<image class="se-a-30" src="@/static/image/482011.png" mode=""></image>
					<text class="se-ml-20 se-fs-24 se-fw-5">预约信息</text>
				</view>
				<view class="se-flex se-flex-ai-c">
					<u-icon name="arrow-right"></u-icon>
				</view>
			</view>
			<view class="se-py-30 se-px-20 se-flex se-flex-h-sb se-b-b" @click="onRelease()">
				<view class="se-flex se-flex-ai-c">
					<image class="se-a-30" src="@/static/image/482014.png" mode=""></image>
					<text class="se-ml-20 se-fs-24 se-fw-5">我的发布</text>
				</view>
				<view class="se-flex se-flex-ai-c">
					<u-icon name="arrow-right"></u-icon>
				</view>
			</view>
			<view class="se-py-30 se-px-20 se-flex se-flex-h-sb se-b-b" @click="onApply()">
				<view class="se-flex se-flex-ai-c">
					<image class="se-a-30" src="@/static/image/482013.png" mode=""></image>
					<text class="se-ml-20 se-fs-24 se-fw-5">我的寻车申请</text>
				</view>
				<view class="se-flex se-flex-ai-c">
					<u-icon name="arrow-right"></u-icon>
				</view>
			</view>
			<view class="se-py-30 se-px-20 se-flex se-flex-h-sb se-b-b" @click="onInvite()">
				<view class="se-flex se-flex-ai-c">
					<image class="se-a-30" src="@/static/image/482012.png" mode=""></image>
					<text class="se-ml-20 se-fs-24 se-fw-5">我的邀请</text>
				</view>
				<view class="se-flex se-flex-ai-c">
					<u-icon name="arrow-right"></u-icon>
				</view>
			</view>
			<view class="se-py-30 se-px-20 se-flex se-flex-h-sb se-b-b" @click="onRecommend()">
				<view class="se-flex se-flex-ai-c">
					<image class="se-a-30" src="@/static/image/482012.png" mode=""></image>
					<text class="se-ml-20 se-fs-24 se-fw-5">我的推荐</text>
				</view>
				<view class="se-flex se-flex-ai-c">
					<u-icon name="arrow-right"></u-icon>
				</view>
			</view>
			<view class="se-py-30 se-px-20 se-flex se-flex-h-sb se-b-b" @click="onCustomerService()">
				<view class="se-flex se-flex-ai-c">
					<image class="se-a-30" src="@/static/image/470868.png" mode=""></image>
					<text class="se-ml-20 se-fs-24 se-fw-5">在线客服</text>
				</view>
				<view class="se-flex se-flex-ai-c">
					<u-icon name="arrow-right"></u-icon>
				</view>
			</view>
			<view class="se-py-30 se-px-20 se-flex se-flex-h-sb se-b-b" @click="onVersion()">
				<view class="se-flex se-flex-ai-c">
					<image class="se-a-30" src="@/static/image/470868.png" mode=""></image>
					<text class="se-ml-20 se-fs-24 se-fw-5">关于我们</text>
				</view>
				<view class="se-flex se-flex-ai-c">
					<u-icon name="arrow-right"></u-icon>
				</view>
			</view>
			<view class="se-py-30 se-px-20 se-flex se-flex-h-sb" @click="onLogOut()">
				<view class="se-flex se-flex-ai-c">
					<text class="se-fs-24 se-fw-5">退出登录</text>
				</view>
				<view class="se-flex se-flex-ai-c">
					<u-icon name="arrow-right"></u-icon>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import { getInfo,queryPhone } from "@/common/api.js"
	export default {
		data() {
			return {
				user:{},
				phone:"",
				companyAuthenticationStatus:null,
				personAuthenticationStatus:null,
			}
		},
		onLoad() {
			
		},
		onShow() {
			this.onUserInfo()
			this.onQueryPhone()
		},
		methods: {
			onUserInfo(){
				let that = this
				getInfo({id:uni.getStorageSync('userInfo').id}).then(response=>{
					console.info('resultresult',response)
					that.user = response.result.memberInfo
					that.companyAuthenticationStatus = response.result.companyAuthenticationStatus
					that.personAuthenticationStatus = response.result.personAuthenticationStatus
					uni.setStorageSync('userInfo', response.result.memberInfo)
					uni.setStorageSync("companyAuthenticationStatus",response.result.companyAuthenticationStatus)
					uni.setStorageSync("personAuthenticationStatus",response.result.personAuthenticationStatus)
				}).catch(err=>{})
			},
			onQueryPhone(){
				queryPhone({}).then(response=>{
					this.phone = response.result.paramValue
				}).catch(error=>{
					
				})
			},
			// 实名认证
			onIdentity(){
				uni.navigateTo({
					url:"/pages/identity/index?userStatus=1"
				})
			},
			onInvite(){
				uni.navigateTo({
					url:"/pages_subpack/invite/index"
				})
			},
			onRecommend(){
				uni.navigateTo({
					url:"/pages_subpack/recommend/index"
				})
			},
			onRelease(){
				let that = this
				if (that.companyAuthenticationStatus == 1){
					uni.navigateTo({
						url:"/pages_subpack/release/list"
					})
				}else{
					uni.showModal({
						title:"未企业认证",
						showCancel:false,
						content:"立即前往认证",
						success() {
							that.onIdentity()
						}
					})
				}
			},
			onApply(){
				let that = this
				if (that.companyAuthenticationStatus == 1 || that.personAuthenticationStatus == 1){
					uni.navigateTo({
						url:"/pages_subpack/apply/list"
					})
				}else{
					uni.showModal({
						title:"未实名认证",
						showCancel:false,
						content:"立即前往实名认证",
						success() {
							that.onIdentity()
						}
					})
				}
			},
			onSystem(){
				uni.navigateTo({
					url:"/pages_subpack/system/index"
				})
			},
			onReservation(){
				let that = this
				if (that.companyAuthenticationStatus == 1 || that.personAuthenticationStatus == 1){
					uni.navigateTo({
						url:"/pages/reservation/index"
					})
				}else{
					uni.showModal({
						title:"未实名认证",
						showCancel:false,
						content:"立即前往实名认证",
						success() {
							that.onIdentity()
						}
					})
				}
			},
			onVersion(){
				uni.navigateTo({
					url:"/pages_subpack/version/index"
				})
			},
			onLogOut(){
				uni.showModal({
					title:"温馨提示",
					content:"确定退出当前登录",
					cancelText:"取消",
					confirmText:"确定",
					success:(res)=> {
						console.info(res)
						if(res.confirm==true){
							uni.removeStorageSync("userId")
							uni.removeStorageSync("shareId")
							uni.removeStorageSync("userInfo")
							uni.removeStorageSync("token")
							uni.removeStorageSync("sessionKey")
							uni.removeStorageSync("companyAuthenticationStatus")
							uni.removeStorageSync("personAuthenticationStatus")
							uni.navigateTo({
								url:"/pages/auth/index"
							})
						}
					}
				})
				
			},
			toNav(){
				uni.navigateTo({
					url:"/pages/login/index"
				})
			},
			onCustomerService(){
				let that = this
				// let obj = that.$utils.getkeyContent('phone')
				if (uni.canIUse('makePhoneCall')) {
					uni.makePhoneCall({
					  phoneNumber: String(that.phone),
					  success: function () {
						console.log('拨打电话成功');
					  },
					  fail: function () {
						console.log('拨打电话失败');
					  }
					});
				} else {
					console.log('你的设备不支持拨打电话功能');
				}
				
			}
		}
	}
</script>

<style>
	page {
		background-color: #f5f5f5 !important;
	}

	.se-grid {
		display: grid;
		grid-template-columns: 1fr 1fr 1fr 1fr;
		gap: 10rpx;
		padding-bottom: 4rpx;
	}
	.se-tag{
		margin-right: 10rpx;
		margin-top: 5px;
		padding: 5rpx 10rpx;
		border-radius: 4rpx;
		border: 2rpx solid rgba(0,0,0,0.00);
		font-size: 16rpx;
		font-family: PingFang SC, PingFang SC-Bold;
		font-weight: 700;
		text-align: center;
	}
</style>