<template>
	<view class="content">
		<view class="top">
			<view class="avater">
				<image :src="userInfo.avatar" class="avater-img" mode=""></image>
			</view>
			<view class="name-box">
				<view class="name-top">
					{{userInfo.nickname}}
				</view>
			<!-- 	<view class="name-footbox">
					<text class="name-foot">
						小天使
					</text>
				</view> -->
			</view>
		</view>
	<!-- 	<view class="center-box">
			<view class="center-top">
				<view class="top-left">
					正在参与
				</view>
				<view class="top-right">
					小天使在行动·关爱自症儿童
				</view>
			</view>
			<view class="center-foot">
				<view class="foot-list">
					<view class="list-top">
						88
					</view>
					<view class="list-foot">
						捐款人数
					</view>
				</view>
				<view class="foot-list">
					<view class="list-top">
						8888.88
					</view>
					<view class="list-foot">
						募集善款
					</view>
				</view>
				<view class="foot-list">
					<view class="list-top">
						88
					</view>
					<view class="list-foot">
						排名
					</view>
				</view>
			</view>
		</view> -->

		<view class="tt">
							<view class="tt-box border-b" @click="tohelp">
							<image src="../../static/icon/icon-04.png" class="tt-icon1" mode=""></image>
								<view class="tt-txt">
								求救记录
								</view>
								<image src="../../static/icon/next.png" class="next-icon" mode=""></image>
							</view>
							<view class="tt-box" @click="torreco">
						<image src="../../static/icon/icon-05.png" class="tt-icon1" mode=""></image>
										<view class="tt-txt">
											救援记录
										</view>
								<image src="../../static/icon/next.png" class="next-icon" mode=""></image>
									</view>
	   </view>
	</view>
</template>

<script>
	import { mapState, mapMutations } from 'vuex';
	import {
		saveUrl,
		interceptor
	} from '@/utils/loginUtils.js';
	import {
		userinfo
	} from '@/api/user.js';
	// #ifdef H5
	import { weixindata } from '@/utils/wxAuthorized';
	// #endif
	export default{
		data(){
			return{
				
			}
		},
		onShow() {
			console.log(this);
			//	判断是否已经登录
			if (this.hasLogin) {
				this.loadBaseData();
			} else {
				saveUrl();
				uni.showModal({
					title: '登录',
					content: '您未登录，是否马上登陆?',
					success: e => {
						if (e.confirm) {
							interceptor();
						}
					},
					fail: e => {
						console.log(e);
					}
				});
			}
			this.type = this.userInfo.type;
			// 保存当前页面
		},
		computed: {
			...mapState('user',['hasLogin', 'userInfo'])
		},
		methods:{
			...mapMutations('user', ['setUserInfo']),
			loadBaseData() {
				userinfo({}).then(({ data }) => {
					this.setUserInfo(data);
				});
				// #ifdef H5
				weixindata();
				// #endif
			},
			torreco(){
				uni.navigateTo({
					url:'/pages/applic/rescuerecords'
				})
			},
			tohelp(){
				uni.navigateTo({
					url:'/pages/applic/helprecords'
				})
			}
		}
	}
</script>

<style lang="scss">
	.content{
		line-height: 1;
		.top{
			width: 750rpx;
			height: 370rpx;
			// background-color: #CB131B;
			background: url(../../static/images/bgi2.png)no-repeat top left;
			background-size:750rpx 370rpx;
			display: flex;
			align-items: center;
			padding-left: 55rpx;
			
			.avater{
				width: 150rpx;
				height: 150rpx;
				margin-right: 28rpx;
				.avater-img{
					width: 100%;
					height: 100%;
					border-radius: 50%;
				}
			}
			.name-box{
				// flex: 1;
				.name-top{
					font-size: 42rpx;
					font-weight: 400;
					color: #FFFFFF;
					margin-bottom: 15rpx;
				}
				.name-footbox{
					.name-foot{
						text-align: center;
						font-size: 22rpx;
						font-weight: 400;
						color: #FFFFFF;
						background: rgba(255, 255, 255, 0.2);
						border: 1px solid #FFFFFF;
						border-radius: 20rpx;
						padding: 3rpx 13rpx;
					}
				}
				
			}
		}
		.center-box{
			width: 687rpx;
			// height: 235px;
			background: #FFE8E8;
			border-radius: 16rpx;
			margin: -90rpx auto 0;
			.center-top{
				width: 687rpx;
				height: 80rpx;
				background: #FFFFFF;
				border-radius: 16rpx 16rpx 0 0;
				display: flex;
				align-items: center;
				padding-left: 30rpx;
				.top-left{
					width: 126rpx;
					line-height: 32rpx;
					text-align: center;
					background: linear-gradient(0deg, #C90F1B, #F14D33);
					font-size: 22rpx;
					font-weight: 400;
					color: #FFFFFF;
					border-radius: 20rpx;
					margin-right: 10rpx;
				}
				.top-right{
					font-size: 22rpx;
					font-weight: 400;
					color: #CB151D;
				}
			}
			.center-foot{
				height: 155rpx;
				display: flex;
				.foot-list{
					flex: 1;
					text-align: center;
					padding-top: 20rpx;
					.list-top{
						font-size: 39rpx;
						font-weight: 400;
						color: #CB141D;
						line-height: 58rpx;
					}
					.list-foot{
						font-size: 39rpx;
						font-weight: 400;
						color: #666666;
						line-height: 58rpx;
					}
				}
			}
		}
		.tt{
			margin:  20rpx auto 0;
			width: 700rpx;
			box-shadow: 0px 0px 20rpx 0px rgba(49, 49, 52, 0.06);
			border-radius: 10rpx;
			background-color: #ffffff;
	    .tt-box{
			width: 700rpx;
			height: 100rpx;
			padding:0 30rpx;
			// margin-top: 37rpx;
			display: flex;
			align-items: center;
			
			.tt-icon{
				width: 40rpx;
				height: 40rpx;
			}
			.tt-icon1{
				width: 40rpx;
				height: 36rpx;
			}
			.tt-txt{
				margin-left: 20rpx;
				font-size: 28rpx;
				font-weight: 300;
				color: #000000;
				flex: 1;
			}
			.next-icon{
				width: 30rpx;
				height: 38rpx;
			}
		}
		.border-b{
			border-bottom: 1px solid #F1F1F1;
		}
		}
	}
</style>
