<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" v-if="user.deptName">
					{{user.deptName}}
				</view>
			</view>
			<!-- 常用工具 -->
			<view class="used-tools">
				<view class="title">常用工具</view>
				<view class="tools-list">
					<view class="item" @click="toCreateOrder()">
						<image src="https://jnlzjk-1323137866.cos.ap-chongqing.myqcloud.com/shop/images/order.png"
							mode=""></image>
						<text class="text">商品制单</text>
					</view>
					<view class="item" @click="toCreateCoupon()">
						<image src="https://jnlzjk-1323137866.cos.ap-chongqing.myqcloud.com/shop/images/icon_coupon.png"
							mode=""></image>
						<text class="text">制单优惠券</text>
					</view>
					<view class="item" @click="toPay()">
						<image src="https://jnlzjk-1323137866.cos.ap-chongqing.myqcloud.com/shop/images/money.png"
							mode=""></image>
						<text class="text">微信收款</text>
					</view>
					<!-- <view class="item" @click="alipay()">
						<image src="https://jnlzjk-1323137866.cos.ap-chongqing.myqcloud.com/shop/images/money.png" mode=""></image>
						<text class="text">支付宝收款</text>
					</view> -->
					<view class="item" @click="toOrder()">
						<image src="https://jnlzjk-1323137866.cos.ap-chongqing.myqcloud.com/shop/images/order.png"
							mode=""></image>
						<text class="text">我的订单</text>
					</view>
					<view class="item" @click="toPackage()">
						<image src="https://jnlzjk-1323137866.cos.ap-chongqing.myqcloud.com/shop/images/package.png"
							mode=""></image>
						<text class="text">商品套餐</text>
					</view>
					<view class="item" @click="toCoupon()">
						<image src="https://jnlzjk-1323137866.cos.ap-chongqing.myqcloud.com/shop/images/icon_coupon.png"
							mode=""></image>
						<text class="text">套餐优惠券</text>
					</view>
					<view class="item" @click="toPaywechat()">
						<image src="https://kuanyitang-1317640934.cos.ap-shanghai.myqcloud.com/app/image/wechat.png"
							mode=""></image>
						<text class="text">微信收款码</text>
					</view>
					<!-- <view class="item" @click="navTo('/pages_company/voice')">
						<u-icon name="mic" size="28"></u-icon>
						<view class="text">声音录制</view>
					</view>
					<view class="item" @click="navTo('/pages_company/voiceList')">
						<u-icon name="mic" size="28"></u-icon>
						<view class="text">声音采集</view>
					</view> -->
					<view class="item" @click="toShareLive()">
						<image :src="imgPath+ '/userapp/images/live_icon.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 {
				imgPath: this.$store.state.imgpath,
				user: null,
			};
		},
		onLoad() {
			console.log("onload")
		},
		onShow() {
			console.log("onshow")
			this.getUserInfo()
		},
		methods: {
			toShareLive() {
				uni.navigateTo({
					url: '/pages_company/shareLive?companyId=' + this.user.companyId + "&companyUserId=" + this
						.user.userId
				})
			},
			toPaywechat() {
				uni.navigateTo({
					url: '/pages_company/wechatcode?companyId=' + this.user.companyId
				})
			},
			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'
				})
			},
			navTo(url) {
				uni.navigateTo({
					url: url
				})
			},
			toCard() {
				uni.navigateTo({
					url: '/pages_company/card?cardId=' + this.user.cardId
				})
			},
			toCreateOrder() {
				uni.navigateTo({
					url: '/pages_company/order/productList?companyId=' + this.user.companyId + "&companyUserId=" + this.user.userId
				})
			},
			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;
				font-size: 22upx;
				font-family: PingFang SC;
				font-weight: 500;
				color: #FFFFFF;
				border-radius: 8rpx;
				background-color: #2BC7B9;
			}
		}

		.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>