<template>
	<view class="content">
      <view>
		  <view class="zdyNav">
		  	<view class="status_bar" :style="{height: iStatusBarHeight + 'px'}"></view>
		  	<view class="nav">
		  		<view>欧洲维修</view>
		  	</view>
		  </view>
		  <view class="status_bar" :style="{height: iStatusBarHeight + 'px'}"></view>
		  <view style="height: 44px;"></view>
		  
		  
		  <view class="homePg">
		  	<view class="bg">
		  		<view class="logIn" @click="logIn">立即登录</view>
				<view class="logOutBtn" @click="goIndex">取消登录</view>
		  	</view>
			
		  </view>
	  </view>
		

	</view>
</template>

<script>
	export default {
		data() {
			return {
				iStatusBarHeight: '',
				wxdata:"",
				wxCode:'',
			}
		},
		onLoad() {
			this.iStatusBarHeight = uni.getSystemInfoSync().statusBarHeight;
			var userId = uni.getStorageSync("logInData").uid;
			if (userId) {
				var type = uni.getStorageSync("logInData").type;
				if(type==1){
					uni.navigateTo({
						url:'../index/index'
					})
				}else if(type==2){
					uni.navigateTo({
						url:'../shop/shopIndex/index'
					})
				}
			}
		},
		methods: {
            goIndex() {
            	uni.navigateTo({
            		url: '../index/index'
            	})
            },
			logIn() {
				/* uni.navigateTo({
					url: '../logIn/logIn'
				})
				return false; */
				//提交正式测试
				
                var that=this;
                uni.getUserProfile({
                	lang:'zh_CN',
                	desc:'登录',
                	success:(res)=>{
                		console.log(res);
                		 that.wxdata=res;
                		 /* uni.setStorage({
                			key: 'wxdata',
                			data: res,
                			success: function () {
                			    
                			 
                			}
                		}); */
						that.ipLogin()
                	},
                	fail:(res)=>{
                		console.log(res)
                	}
                });
				//#ifdef H5
				
				uni.navigateTo({
					url: '../logIn/logIn'
				})
				 // #endif
				
			},
			ipLogin(){
			 var that=this;
			 uni.showLoading({ });
			 uni.login({
			   provider: 'weixin',
			   success: function (loginRes) {
			     console.log(loginRes)
				that.wxCode=loginRes.code
				that.getWxOpenID()
					//that.gologin()
				 /* uni.navigateTo({
				  	url: '../logIn/logIn?code='+loginRes.code
				  }) */
			   
			   }
			 });
			
		},
		getWxOpenID(){
			var that=this;
			uni.showLoading({
				title: '请稍等'
			})
			 this.$http('accompany/superusers/getWxOpenID', {
			   code:this.wxCode,
			 },'GET').then(res => {
				//console.log(res)
				//this.openID=res.data.openid;
				//this.session_key=res.data.session_key;
				console.log(this.openID)
				uni.setStorage({
					key: 'wxOpendata',
					data: res.data,
					success: function () {
					   // that.ipLogin()
					  uni.navigateTo({
					   	url: '../logIn/logIn'
					   })
					 
					}
				}); 
				//this.Login()
			})
		},

		}
	}
</script>

<style>
	.content {
		background-color: #EB5808;
		width: 100%;
		height: 100%;
	}

	/* #ifdef H5 */
	.content {
		background-color: #EB5808;
		width: 100%;
		height: 100%;
	}

	/* #endif */

	.zdyNav {
		position: fixed;
		left: 0;
		top: 0;
		background: #FFFFFF;
		z-index: 11;
	}

	.status_bar {
		background: #FFFFFF;
	}

	.nav {
		width: 100vw;
		height: 44px;
		background: #FFFFFF;
		text-align: center;
		font-size: 34rpx;
		line-height: 44px;
		font-weight: bold;
	}

	.homePg {
		position: fixed;
		width: 100vw;
		height: calc(100vh - 44px);
		background-color:#060606;
	}

	.bg {
		width: 100vw;
		height: calc(100vh - 44px);
		background: url(data:image/png;base64,[encoded data, 549544 characters]) no-repeat;
		background-size: 100%;
		position: relative;
		
	}
	.logIn{
		width: 442rpx;
		height: 88rpx;
		background-color: #FF4F00;
		border-radius: 44rpx;
		color: #FFFFFF;
		font-size: 30rpx;
		text-align: center;
		line-height: 88rpx;
		position: absolute;
		left: 154rpx;
		top: 804rpx;
		
	}
	.logOutBtn {
		
		width:750rpx;
		height: 40rpx;
		text-align: center;
		line-height: 40rpx;
		font-size: 28rpx;
		color: #2C2C2C;
		position: absolute;
		left: 0rpx;
		top: 904rpx;
	}
</style>
