<template>
	<view class="top-cont">
		<view class="content">
			<view class="user-info">
				<view class="left">
					<view class="name-phone">
						<view class="name">{{user.nickName}}</view>
						<view class="phone" v-if="user!=null">{{utils.parsePhone(user.phonenumber)}}</view>
					</view>
				</view>
				<view class="msg-box"  >
					 {{user.deptName}}
				</view>
			</view>
			<!-- 常用工具 -->
			<view class="used-tools">
				<view class="title">常用工具</view>
				<view class="tools-list">
					<view class="item" @click="toCreateOrder()">
						<image src="https://beiliyo-2025.obs.cn-north-4.myhuaweicloud.com/fs/20250115/1736947748277.png" mode=""></image>
						<text class="text">商品制单</text>
					</view>
					<view class="item" @click="toCreateCoupon()">
						<image src="https://beiliyo-2025.obs.cn-north-4.myhuaweicloud.com/fs/20250115/1736947748287.png" mode=""></image>
						<text class="text">制单优惠券</text>
					</view>
					<!-- <view class="item" @click="toPay()">
						<image src="../static/images/money.png" mode=""></image>
						<text class="text">微信收款</text>
					</view>
					<view class="item" @click="alipay()">
						<image src="../static/images/money.png" mode=""></image>
						<text class="text">支付宝收款</text>
					</view> -->
					<view class="item" @click="toOrder()">
						<image src="https://beiliyo-2025.obs.cn-north-4.myhuaweicloud.com/fs/20250115/1736947748289.png" mode=""></image>
						<text class="text">我的订单</text>
					</view>
					<view class="item" @click="toPackage()">
						<image src="https://beiliyo-2025.obs.cn-north-4.myhuaweicloud.com/fs/20250115/1736947748277.png" mode=""></image>
						<text class="text">商品套餐</text>
					</view>
					<view class="item" @click="toCoupon()">
						<image src="https://beiliyo-2025.obs.cn-north-4.myhuaweicloud.com/fs/20250115/1736947748288.png" mode=""></image>
						<text class="text">套餐优惠券</text>
					</view>
					<!-- <view class="item" @click="tomanage()">
					 	<image src="https://beiliyo-2025.obs.cn-north-4.myhuaweicloud.com/fs/20250115/1736947748289.png" mode=""></image>
					 	<text class="text">客户管理</text>
					 </view> -->
				</view>
			</view>
			<!-- 退出登录按钮 -->
			<view class="log-out" @click="logout">退出登录</view>
		</view>
		
	</view>
</template>

<script>
	import {getUserInfo,getQrImg} from '@/api/companyUser'
	export default {
		data() {
			return {
				 user:null,
			};
		},
		onLoad() {
			console.log("onload")
		},
		onShow() {
			console.log("onshow")
			this.getUserInfo()
		},
		methods: {
			
			alipay(){
				// var url="http://alipay.yjf.runtzh.com/#/?companyId="+this.user.companyId+"&companyUserId="+this.user.userId
				// uni.setClipboardData({
				// 	data:url,
				// 	success:()=>{
				// 		uni.showToast({
				// 			title:'收款地址已复制到剪切板',
				// 			icon:'none'
				// 		})
						
				// 	}
				// });
				
				uni.navigateTo({
					url:'/pages_company/alipayImg'
				})
			},
			tomanage(){
				uni.navigateTo({
					url:"/pages/user/test/manageUser"
				})
			},
			toCard(){
				uni.navigateTo({
					url:'/pages_company/card?cardId='+this.user.cardId
				})
			},
			toCreateOrder(){
				uni.navigateTo({
					url:'/pages_company/order/productList'
				})
			},
			toPay(){
				uni.navigateTo({
					url:'/pages_user/user/pay?companyId='+this.user.companyId+"&companyUserId="+this.user.userId
				})
			},
			toOrder(){
				uni.navigateTo({
					url:'/pages_company/storeOrder?companyId='+this.user.companyId+"&companyUserId="+this.user.userId
				})
			},
			toPackage(){
				uni.navigateTo({
					url:'/pages_company/storeProductPackage?companyId='+this.user.companyId+"&companyUserId="+this.user.userId
				})
			},
			toCoupon(){
				uni.navigateTo({
					url:'/pages_company/coupon'
				})
			},
			toCreateCoupon(){
				uni.navigateTo({
					url:'/pages_company/order/coupon'
				})
			},
			toCreateOrderCoupon(){
				uni.navigateTo({
					url:'/pages_company/order/coupon'
				})
			},
			getUserInfo(){
				var data={token:uni.getStorageSync('CompanyUserToken')}
				getUserInfo(data).then(
					res => {
						if(res.code==200){
							  this.user=res.data;
						}
						else if(res.code==403){
							uni.setStorageSync('CompanyUserToken',null);
							uni.navigateBack({
								delta:-1
							})			
						}else{
							uni.showToast({
								icon:'none',
								title: res.msg,
							});
						}
					},
					rej => {}
				);
			},
			logout(){
			 	uni.showModal({
			 		title:"提示",
			 		content:"确认退出登录吗?",
			 		showCancel:true,
			 		cancelText:'取消',
			 		confirmText:'确定',
			 		success:res=>{
			 			if(res.confirm){
			 				uni.setStorageSync('CompanyUserToken',null);
			 				uni.navigateBack({
			 					delta:-1
			 				})							
			 			}else{
			 			}
			 		}
			 	})
			 },
			 
			// 跳转页面
			navgetTo(url) {
				this.utils.isLogin().then(res => {
					if(res){
						uni.navigateTo({
							url: url
						})
					}
				})
			},
		}
	}
</script>

<style lang="scss">
	.content{
		margin: 20upx 0upx;
		padding: 0 20upx;
		.user-info{
			padding: 30upx;
			display: flex;
			align-items: center;
			justify-content: space-between;
			.left{
				position: relative;
				display: flex;
				.head-img{
					width: 120upx;
					height: 120upx;
					border-radius: 50%;
					overflow: hidden;
					margin-right: 30upx;
					border: 4upx solid #FFFFFF;
					box-shadow: 0px 5px 15px 2px rgba(0,0,0,0.1);
					image{
						width: 100%;
						height: 100%;
					}
				}
				.name-phone{
					padding-top: 15upx;
					.name{
						font-size: 36upx;
						font-family: PingFang SC;
						font-weight: bold;
						color: #111111;
						line-height: 1;
					}
					.phone{
						font-size: 28upx;
						font-family: PingFang SC;
						font-weight: 500;
						color: #666666;
						line-height: 1;
						margin-top: 30upx;
					}
				}
			}
			.msg-box{
				padding: 5rpx 15upx;
				height: 30upx;
				line-height: 30upx;
				font-size: 22upx;
				font-family: PingFang SC;
				font-weight: 500;
				color: #FFFFFF;
				border-radius: 8rpx;
				background-color: #018C39;
			}
		}
		.used-tools{
			box-sizing: border-box;
			background: #FFFFFF;
			border-radius: 16upx;
			padding: 40upx 30upx;
			
			.title{
				font-size: 32upx;
				font-family: PingFang SC;
				font-weight: bold;
				color: #222222;
				line-height: 1;
			}
			.tools-list{
				margin-top: 50upx;
				display: flex;
				flex-wrap: wrap;
				width: 100%;
				.item{
					box-sizing: border-box;
					width: 25%;
					display: flex;
					flex-direction: column;
					align-items: center;
					justify-content: center;
					margin-bottom: 50upx;
					position: relative;
					image{
						width: 44upx;
						height: 44upx;
					}
					.text{
						font-size: 24upx;
						font-family: PingFang SC;
						font-weight: 500;
						color: #111111;
						line-height: 1;
						margin-top: 20upx;
					}
					.contact-btn{
						display: inline-block;
						position: absolute;
						top: 0;
						left: 0;
						width: 100%;
						height: 100%;
						opacity: 0;
					}
				}
			}
		}
		.log-out{
			height: 80upx;
			line-height: 80upx;
			text-align: center;
			font-size: 26upx;
			font-family: PingFang SC;
			font-weight: 500;
			color: #666666;
			background: #FFFFFF;
			border-radius: 16upx;
			margin-top: 20upx;
		}
	}
</style>
