<template>
	<view class="mainview">
		<view class="topnames" >
					我的
				</view>
		<view class="topimg">
			<view class="touxiang">
				<image :src="src" mode="widthFix" shape="circle"
				style="width: 150rpx;height: 150rpx;"></image>
				
				<!-- <u-upload :fileList="fileList" @afterRead="afterRead" name="6" :multiple='false' :maxCount="1"
					imageMode="true" width="150" height="150">
					<image :src="src" mode="widthFix" shape="circle"
					style="width: 150rpx;height: 150rpx;"></image>
				</u-upload> -->
			</view>
			<view class="Username">
				<view class="Username1">{{getuserInfo.realName}} <span>您好</span>   </view>
				<view class="Username2">
					<view class="">
						您上次更新个人信息时间：
					</view>
					<view class="">
						{{getuserInfo.updateDate}}
					</view>
				</view>
			</view>

			<!-- <view class="changemm">
				<view class="message">
					<view class="wdmessage">已读信息:</view>
					<view class="messagenumber">
						<u-badge type="success" max="99" :value="information1"></u-badge>
					</view>
				</view>
				<view class="message">
					<view class="wdmessage">未读信息:</view>
					<view class="messagenumber">
						<u-badge type="warning" max="99" :value="information2"></u-badge>
					</view>
				</view>
				
			</view> -->
		</view>
		<!-- 头部结束 -->
		<view class="minndle" v-if="$has('app:PersonalInformation')||$has('app:MyOrder')
		||$has('app:MyTask')||$has('app:CommentsSuggestions')">
			<!-- <u-grid :border="false" col="4" @click="navigations">
				<u-grid-item v-for="(listItem,listIndex) in list" :key="listIndex">
					<u-icon :customStyle="{paddingTop:20+'rpx'}" :name="listItem.name" :color="listItem.color"
						:size="55"></u-icon>
					<text class="grid-text" style="padding-top: 8px;">{{listItem.title}}</text>
				</u-grid-item>
			</u-grid> -->
			<view class="information" @click="navigations1" v-if="$has('app:PersonalInformation')">
				<view class="icon1">
					<u-icon name="account" size="55" color="#30D3A2" class=""></u-icon>
				</view>
				<view  style="padding-top: 8px;">
					个人信息
				</view>
			</view>
			<view class="distribute"  @click="navigations2" v-if="$has('app:MyOrder')">
				<view class="icon2">
					<u-icon name="list" size="55" color="#09C700"></u-icon>
				</view>
				<view  style="padding-top: 8px;">
					我的订单
				</view>
			</view>
			<view class="task"  @click="navigations3" v-if="$has('app:MyTask')">
				<view class="icon3">
					<u-icon name="order" size="55" color="#FF9C27"></u-icon>
				</view>
				<view  style="padding-top: 8px;">我的任务</view>
			</view>
			<view class="opinions"  @click="navigations4" v-if="$has('app:CommentsSuggestions')">
				<view class="icon4">
					<u-icon name="more-circle" size="55" color="#F7B717"></u-icon>
				</view>
				<view  style="padding-top: 8px;">意见建议</view>
			</view>
		</view>
		<!-- 导航栏结束 -->
		<view class="middleimgs">
			<!-- <img src="@/static/my/xinxi.png" alt=""> -->
			<u--image  mode="widthFix"  :src="srcxinxi" width="750rpx" height="300rpx"></u--image>
		</view>
		<!-- 中间图片结束 -->
		<view class="appcell">
			<u-cell-group>
				<u-cell title="修改密码" :isLink="true"  @click="changepass">
					<u-icon slot="icon" size="35" name="setting"></u-icon>
				</u-cell>
				<u-cell title="一键退出" :isLink="true" @click="tuichu">
					<u-icon slot="icon" size="35" name="close-circle"></u-icon>
				</u-cell>

			</u-cell-group>
		</view>



		<u-modal :show="showtc" content='请问您是否确定一键退出？' :showConfirmButton='true' :showCancelButton='true'
			@confirm="confirmtc" @cancel='canceltc'></u-modal>

		<!-- <u-tabbar
				:value="value1"
				:fixed="true"
				:placeholder="true"
				@change="name => value1 = name"
				activeColor="#2E69EB"
				:safeAreaInsetBottom="true"
		>
			<u-tabbar-item text="首页" icon="home" @click="click1" ></u-tabbar-item>
			<u-tabbar-item  v-if="$has('app:worktable')"  text="工作台" icon="list" @click="click2" ></u-tabbar-item>
			<u-tabbar-item text="我的" icon="account" @click="click3" ></u-tabbar-item>
		</u-tabbar> -->
		
		
		<u-tabbar class="tabberall" :value="value1" :fixed="true" :placeholder="true" @change="name => value1 = name"
			:safeAreaInsetBottom="true">
			<u-tabbar-item text="首页" @click="click1">
				<image class="u-page__item__slot-icon" slot="active-icon" :src="tabimg1"></image>
				<image class="u-page__item__slot-icon" slot="inactive-icon" :src="tabimg2"></image>
			</u-tabbar-item>
		
			<u-tabbar-item v-if="$has('app:worktable')" text="工作台"  @click="click2">
				<image class="u-page__item__slot-icon" slot="active-icon" :src="tabimg3"></image>
				<image class="u-page__item__slot-icon" slot="inactive-icon" :src="tabimg4"></image>
		
			</u-tabbar-item>
			<u-tabbar-item text="我的" @click="click3">
				<image class="u-page__item__slot-icon" slot="active-icon" :src="tabimg5"></image>
				<image class="u-page__item__slot-icon" slot="inactive-icon" :src="tabimg6"></image>
		
			</u-tabbar-item>
		</u-tabbar>
	</view>
</template>

<script>
	import {
		Static
	} from "vue"
	export default {
		data() {
			return {
				tabimg1: require('@/static/tab/h2.png'),
				tabimg2: require('@/static/tab/h1.png'),
				tabimg3: require('@/static/tab/w2.png'),
				tabimg4: require('@/static/tab/w1.png'),
				tabimg5: require('@/static/tab/y2.png'),
				tabimg6: require('@/static/tab/y1.png'),
				
				value1: 2,
				fileList: [],
				showtc: false,
				src: require('@/static/my/tx.png'),
				srcxinxi: 'http://106.54.209.120:8666/image/my/xinxi.png',

				information1: 34,
				information2: 100,
				getuserInfo:{},


			}
		},
		//监听页面加载，其参数为上个页面传递的数据，参数类型为 Object（用于页面传参
		onLoad() {
			this.getuserInfo = uni.getStorageSync('getuserInfo');
			//console.log('111111111111111111', this.getuserInfo)
		},
		//监听页面初次渲染完成。注意如果渲染速度快，会在页面进入动画完成前触发
		onReady() {},

		//监听页面隐藏
		onHide() {},
		//监听窗口尺寸变化
		onResize() {},
		//监听页面卸载
		onUnload() {},
		//监听用户下拉动作，一般用于下拉刷新
		onPullDownRefresh() {},


		methods: {
			click1(){
				uni.navigateTo({
					url: '/pages/index/index'
				})
			},
			click2(){
				uni.navigateTo({
					url: '/pages/Workorder/Workorder'
				})
			},
			click3(){
				uni.navigateTo({
					url: '/pages/my/my'
				})
			},
			// 新增图片
			async afterRead(event) {
				// 当设置 multiple 为 true 时, file 为数组格式，否则为对象格式
				let lists = [].concat(event.file)
				console.log('111111111111111111', lists)
				let fileListLen = this.fileList.length
				lists.map((item) => {
					this.fileList.push({
						...item,
						status: 'uploading',
						message: '上传中'
					})
				})
				for (let i = 0; i < lists.length; i++) {
					const result = await this.uploadFilePromise(lists[i].url)
					let item = this.fileList[fileListLen]
					this.fileList.splice(fileListLen, 1, Object.assign(item, {
						status: 'success',
						message: '',
						url: result
					}))
					fileListLen++
				}
			},
			uploadFilePromise(url) {
				return new Promise((resolve, reject) => {
					let a = uni.uploadFile({
						url: 'http://192.168.2.21:7001/upload', // 仅为示例，非真实的接口地址
						filePath: url,
						name: 'file',
						formData: {
							user: 'test'
						},
						success: (res) => {
							setTimeout(() => {
								resolve(res.data.data)
							}, 1000)
						}
					});
				})
			},
			navigations1(){
				uni.navigateTo({
					url: '/pages/my/Personalinformation/Personalinformation'
				})
			},
			navigations2(){
				// uni.navigateTo({
				// 	url: '/pages/my/Mydistribution/Mydistribution'
				// })
				uni.navigateTo({
					url: '/pages/my/Myorder/Myorder'
				})
			},
			navigations3(){
				uni.navigateTo({
					url: '/pages/my/Mytask/Mytask'
				})
			},
			navigations4(){
				uni.navigateTo({
					url: '/pages/my/Commentssuggestions/Commentssuggestions'
				})
			},
			changepass(){
				uni.navigateTo({
					url: '/pages/my/Changepassword/Changepassword'
				})
			},

			tuichu() {
				this.showtc = true;
			},
			confirmtc() {
				this.showtc = false;
				switch (uni.getSystemInfoSync().platform) {
					case 'android':
						plus.runtime.quit();

						break;
					case 'ios':
						plus.ios.import('UIApplication').sharedApplication().performSelector('exit');

						break;
				}
				//清除缓存
				uni.clearStorageSync();
			},
			canceltc() {
				this.showtc = false;
			},


		}
	}
</script>

<style lang="scss">
	.u-page__item__slot-icon {
		width: 40rpx;
		height: 40rpx;
	}
	.minndle {
		width: 750rpx;
		height: 150rpx;
		margin: 25rpx 0;
		display: flex;
		align-items: center;
		justify-content: space-around;
		text-align: center;
	}
	.icon1{
		display: flex;
		align-items: center;
		justify-content: center;
	}
	.icon2{
		display: flex;
		align-items: center;
		justify-content: center;
	}
	.icon3{
		display: flex;
		align-items: center;
		justify-content: center;
	}
	.icon4{
		display: flex;
		align-items: center;
		justify-content: center;
	}
	.middleimgs {
		width: 750rpx;
		height: 300rpx;
	}

	.mainview {
		width: 750rpx;
		display: flex;
		flex-direction: column;
	}

	.topimg {
		width: 750rpx;
		height: 350rpx;
		display: flex;
		align-items: center;
		// background: linear-gradient(to right, #96C2FF, #5C8FFF);
		  background: url("http://106.54.209.120:8666/image/my/my.png");
		        background-size: 100% 100%;
	}

	.touxiang {
		width: 180rpx;
		height: 180rpx;
		display: flex;
		align-items: center;
		justify-content: center;

		img {
			width: 120rpx;
			height: 120rpx;
			cursor: pointer;
		}
	}

	.Username {
		flex-grow: 1;
		height:350rpx;
		// line-height: 150rpx;
		// font-size: 40rpx;
		// color: #fff;
		// font-weight: bold;
		display: flex;
	justify-content:center;
		flex-direction: column;

	}
.Username1{
	line-height: 100rpx;
	height: 100rpx;
	font-size: 40rpx;
	color: #fff;
	font-weight: bold;
	span{
		padding-left: 15rpx;
		font-size: 30rpx;
		color: #fff;
	}
}

.Username2{
	font-size: 20rpx;
	color: #333333;
}

	.changemm {
		height: 250rpx;
		width: 250rpx;
		display: flex;
		justify-content: center;
		flex-direction: column;
		align-items: flex-end;
	}

	.message {
		display: flex;
		justify-content: flex-end;
		padding-right: 30rpx;
	}

	.wdmessage {
		font-size: 30rpx;
		color: #fff;
		padding-right: 10rpx;
	}

	.messagenumber {
		padding-top: 6rpx;
		width: 70rpx;
	}

	.setdata {
		padding-top: 15rpx;

		img {
			width: 50rpx;
			height: 50rpx;
		}
	}
</style>
