<template>
	<u-popup :show="show" @close="show=false" mode="left">
		<view class="userPopup">
			<div class="user" @click="itemClick({path:'/page_salesman_index/userCenter/userInfo'})">
				<image style="margin-right: 18rpx;" :src="$util.img(userInfo.headimg)" mode="aspectFill"></image>
				{{userInfo.realname}}
			</div>

			<div class="operation-list">
				<div class="operation-item" v-for="(item,index) in operationList" :key="index" @click="itemClick(item)">
					<image v-if="item.iconURL" :src="item.iconURL"></image>
					<u-icon v-if="item.icon" :name="item.icon"></u-icon>
					<div>{{item.name}}</div>
				</div>
			</div>
		</view>
	</u-popup>

</template>

<script>
	import APPUpdate from '@/config/appUpdate.js';
	export default {
		data() {
			return {
				show: false,
				userInfo: uni.getStorageSync('userInfo'),
				headimg: '',
				nickname: '',
				operationList: [{
						name: '修改密码',
						iconURL: this.$util.img(`/upload/weapp/pageSalesman/index/xg.png`),
						path: '/page_salesman_index/userCenter/changePassword',
						icon:'',
					},
					// {
					// 	name:'支付设置',
					// 	iconURL:this.$util.img(`/upload/weapp/pageSalesman/index/zf.png`),
					// 	path:'/page_salesman_index/userCenter/paySet'
					// },
					{
						name: '意见反馈',
						iconURL: this.$util.img(`/upload/weapp/pageSalesman/index/yj.png`),
						path: '/pages_tool/config/msg_slip',
						icon:'',
					},
					{
						name: '关于我们',
						iconURL: this.$util.img(`/upload/weapp/pageSalesman/index/gy.png`),
						path: '/pages_tool/config/about_us',
						icon:'',
					},
					this.$isIOS ? null : {
						name: '版本检测',
						iconURL: '',
						path: '',
						icon:'question-circle',
					},
					{
						name: '退出登录',
						iconURL: '',
						path: '/pages_tool/login/login',
						icon:'setting',
					},

				].filter(v => v),
			};
		},
		created() {},
		methods: {
			start() {
				this.show = true
			},
			itemClick({ path, name }) {
				if (name == '版本检测') {
					// #ifdef APP-PLUS
					// true 没有新版本的时候有提示，默认：false
					APPUpdate(true);
					// #endif
					return
				}
				if (name == '退出登录') {
					uni.removeStorage({
						key: 'token',
						success: res => {
							uni.setStorageSync('loginLock', 1);
							uni.removeStorageSync('userInfo');
							uni.removeStorageSync('salesmanAuth');
							// uni.removeStorageSync('authtwo')
							// this.$util.redirectTo('/pages_tool/login/login');
							uni.reLaunch({
								url: '/pages_tool/login/login'
							});
						}
					});
					return
				}

				uni.navigateTo({
					url: path
				})
			}
		}
	}
</script>

<style lang="scss">
	.userPopup {

		/* #ifndef H5 */
		padding: 140rpx 90rpx 0 32rpx;
		/* #endif */
		/* #ifdef H5 */
		padding: 80rpx 90rpx 0 32rpx;

		/* #endif */
		.operation-list {
			.operation-item {
				font-size: 28rpx;
				font-family: PingFangSC-Regular, PingFang SC;
				font-weight: 400;
				color: #222222;
				line-height: 40rpx;
				display: flex;
				align-items: center;
				margin-bottom: 46rpx;

				image {
					width: 28rpx;
					height: 28rpx;
					margin-right: 24rpx;
				}
				/deep/ .u-icon{
					margin-right: 22rpx;
				}
			}
		}

		.user {
			display: flex;
			align-items: center;
			font-size: 32rpx;
			font-family: PingFangSC-Medium, PingFang SC;
			font-weight: 500;
			color: #222222;
			margin-bottom: 64rpx;

			image {
				width: 70rpx;
				height: 70rpx;
				border-radius: 50%;
			}
		}
	}
</style>
