<template>
	<view class="container login">
		<view class="login-main">
			<image class="logo" src="https://static.caimei365.com/app/img/icon/login-logo@3x.png" mode=""></image>
			<text class="logo-text">生美/医美采购服务平台</text>
		</view>
		<view class="login-input">
			<input type="number" 
				   v-model="shareCode"  
				   maxlength="6" 
				   class="input" 
				   placeholder="请输入邀请码"
			/>
		</view>
		<view class="login-btn"  @click.stop="goLogin">查看订单</view>
	</view>
</template>
<script>
	import authorize from '@/common/config/authorize.js' 
	export default{
		data() {
			return{
				imagePath:'https://img.caimei365.com/group1/M00/03/83/Cmis214FbbCAQhKoAAKWfqqSIds292.png',
				shareCode:'',  		//获取用户登录的邀请码
				isUserInfo:false,	//控制显示授权弹窗
				nickName:'',		//存储用户名
				userInfo:'',		//存储微信用户授权信息
				shopOrderId:0,			//订单ID
				userID:0			,//分享人的用户ID
				isShareStatus:false,
				serviceProviderId:''
			}
		},
		onLoad(option) {
			this.shopOrderId = option.shopOrderId
			console.log(this.shopOrderId)
		},
		methods:{
			goLogin() {
				if(this.shareCode == ''){
					this.$util.msg('请联系分享人获取分享码',2000);
					return
				}
				if(!this.$api.isNumber(this.shareCode)){
					this.$util.msg('分享码格式不正确',2000);
					return
				}
				authorize.getCode('weixin').then(wechatcode =>{
					authorize.getUserInfo('weixin').then(wxResponse =>{
						let params ={
								code:wechatcode,
								encryptedData:wxResponse.encryptedData,
								iv:wxResponse.iv,
								shopOrderId:this.shopOrderId,
								source:3,
								shareCode:this.shareCode
							}
						this.ShopService.MiniShipments(params).then(res =>{
							if(res.data.resultCode ==3){
								console.log('供应商发货人员');
								this.$api.navigateTo(`/pages/supplier/order/order-details?shopOrderId=${this.shopOrderId}`)
							}
						}).catch(error =>{
							this.$util.msg(error.msg,2000);
						})	
					})	
				})
			},
		},
		onShow() {
			
		}
	}
</script>

<style lang="scss">
	.login{
		width: 100%;
		height:100%;
		background: #FFFFFF;
		.model-warp.none{
			display: none;			
		}
		.model-warp.show{
			display: block;
		}
		.login-main{
			width: 100%;
			display: flex;
			flex-direction: column;
			align-items: center;
			height: 198rpx;
			padding: 170rpx 0 90rpx 0;
			.logo{
				width: 138rpx;
				height: 118rpx;
				display: block;
			}
			.logo-text{
				font-size: 40rpx;
				line-height: 44rpx;
				color: $color-system;
				font-weight: 600;
				margin-top: 20rpx;
			}
		}
		.login-input{
			width: 654rpx;
			height: 40rpx;
			padding: 24rpx;
			margin: 0 auto;
			margin-bottom: 24rpx;
			background: #F7F7F7;
			border-radius: 14rpx;
			.input{
				width: 100%;
				height: 100%;
				background: #F7F7F7;
				font-size: $font-size-28;
				line-height: 40rpx;
				color: #333333;
				border-radius: 14rpx;
			}
		}
		.login-row{
			padding: 0 24rpx;
			font-size: $font-size-28;
			line-height: 40rpx;
			color: #E15616;
			margin-bottom: 48rpx;
		}
		.login-btn{
			width: 702rpx;
			height: 88rpx;
			border-radius: 14rpx;
			font-size: $font-size-28;
			line-height: 88rpx;
			color: #FFFFFF;
			margin: 0 auto;
			text-align: center;
			background: $btn-confirm;
			margin-top: 48rpx;
		}
	}
</style>