<template>
	<view class="pages">
		<view class="myinfo-wrap">
			<view class="myinfo">
				<view class="myinfo-photo">
					<image class="myinfo-photo-img" :src="user.icon" mode=""></image>
				</view>
				<view class="myinfo-text">
					<view class="myinfo-text-name">{{user.nickname || '登录/注册'}}</view>
					<view class="myinfo-text-identity">{{usertype}} | {{usercompany}}</view>
				</view>
			</view>		
			<view class="myinfo-focus">
				<view class="myinfo-focus-item myinfo-focus-myfocus">
					<navigator url="/pages/usercenter/myfocus/myfocus">
						<view class="number">{{pre.want||0}}</view>
					</navigator>
					<view class="text">我有意向的</view>
				</view>
				<view class="myinfo-focus-item myinfo-focus-focusme">
					<navigator url="/pages/usercenter/focusme/focusme">
						<view class="number">{{pre.own}}</view>
					</navigator>
					<view class="text">有意向我的</view>
				</view>
			</view>
		</view>		
		<!-- myinfo-wrap end -->
		<view class="wrap">
			<navigator url="/pages/usercenter/mypublish/mypublish">
				<view class="select-bar">
					<svg class="icon select-bar-icon" aria-hidden="true">
						<use xlink:href="#iconwodedingdan"></use>
					</svg>
					<view class="select-bar-text">我的信息发布</view>
					<view class="select-bar-arrow"></view>
				</view>
			</navigator>
			<navigator url="/pages/usercenter/authentication/authentication">
				<view class="select-bar">
					<svg class="icon select-bar-icon" aria-hidden="true">
						<use xlink:href="#iconwodetuandui"></use>
					</svg>
					<view class="select-bar-text">企业认证</view>
					<view class="select-bar-arrow"></view>
				</view>
			</navigator>
			<navigator url="/pages/usercenter/feedback/feedback">
				<view class="select-bar">
					<svg class="icon select-bar-icon" aria-hidden="true">
						<use xlink:href="#iconbangzhu"></use>
					</svg>
					<view class="select-bar-text">帮助反馈</view>
					<view class="select-bar-arrow"></view>
				</view>
			</navigator>
		</view>
	</view>
</template>

<script>
	import { mapState, mapMutations } from 'vuex';
	export default {
		data() {
			return {
				params:{
					token:'',
					tokenhead:'',
				},
				name:'',
				usertype:'',
				usercompany:'',
				myfocus:0,
				focusme:1,
				pre:[],
				user:[],
				wxuser:[],
				
			}
		},
		onShow() {
			let serf = this;
			//检查登录,获取token
			let loginRes = this.checkLogin('/pages/index/index', '2');
			// console.log(loginRes);
			if(!loginRes){return false;}
			serf.params.token=loginRes[0];			
		},
		onLoad() {
			// let type=localStorage.getItem("type");
			// if(type){
			// 	this.change(type)
			// }
			// else{
			// 	localStorage.setItem("type",this.type);
			// };
			console.log('userInfo',this.userInfo,'hasLogin',this.hasLogin);
			let self = this;
			uni.getStorage({
				key:'token',
				success: function (res) {
					self.params.token = res.data;
				   // console.log(res.data);
				}
			});
			uni.getStorage({
				key:'tokenhead',
				success: function (res) {
					self.params.tokenhead = res.data;
				   // console.log(res.data);
				}
			});
			try {
			    const value = uni.getStorageSync('userInfo');
			    if (value) {
					console.log('this.userinfo',JSON.parse(JSON.stringify(value)));
					this.pre = value.pre;
					this.user = value.user;
					this.wxuser = value.wxUsers;
			    }
			} catch (e) {
				window.location.replace(this.config.loginUrl);
			};
			uni.getStorage({
				key:'userInfo',
				success: function (res) {
					// this.pre = res.data.pre;
					// this.user = res.data.user;
					// this.wxuser = res.data.wxUsers;
					// console.log('res.data',res.data);
					// console.log('this.pre',this.pre);
					// console.log('this.user',this.user);
					// console.log('this.wxuser',this.wxuser);
				}
			});
			//获取会员信息
			let thetoken = this.params.tokenhead + this.params.token;
			// this.$api.http.get(this.config.apiBaseurl+'/sso/info',{header: {Authorization:thetoken}}).then(res => {				
			// 	this.userinfo = res.data.data;
			// 	console.log('this.userinfo',JSON.parse(JSON.stringify(this.userinfo)));
			// }).catch(err => {			
			// });
		},
		methods: {

		},
		// computed:{
		// 	...mapState(['hasLogin','userInfo'])
		// }
	}
</script>

<style scoped>
	@import url("./usercenter.css");
</style>
