<template>
	<view class="user" :class="$store.state.AppStyle" style="background-color: #f6f6f6;">
		<view class="header" :style="[{height:CustomBar + 'px'}]">
			<view class="cu-bar bg-white" :style="{'height': CustomBar + 'px','padding-top':StatusBar + 'px'}">
				<view class="action" @tap="back">
					<text class="cuIcon-back"></text>
				</view>
				<view class="content text-bold" :style="[{top:StatusBar + 'px'}]">
					蓝V申请
				</view>
			</view>
		</view>
		<view :style="[{padding:NavBar+5 + 'px 10px 0px 10px'}]"></view>
		<form>
			<!-- <view class="cu-form-group">
				<view class="title">法人姓名</view>
				<input placeholder="请输入企业法人姓名" v-model="name" name="input"></input>
			</view>
			<view class="cu-form-group">
				<view class="title">工商号</view>
				<input placeholder="企业工商注册号/统一信用代码" v-model="regno" name="input"></input>
			</view> -->
			<view class="cu-form-group">
				<view class="title">申请理由</view>
				<input placeholder="请输入申请理由" v-model="entname" name="input"></input>
			</view>
			<!-- <view class="cu-form-group">
				<view class="title">法人身份证</view>
				<input placeholder="请输入法人身份证号码" v-model="idcard" name="input"></input>
			</view> -->
			<view class="all-btn margin-top">
				<view class="user-btn flex flex-direction">
					<button class="cu-btn bg-blue margin-tb-sm lg" @tap="company">提交申请</button>
				</view>
			</view>
		</form>

	</view>
</template>

<script>
	import { localStorage } from '../../js_sdk/mp-storage/mp-storage/index.js'
	export default {
		data() {
			return {
				StatusBar: this.StatusBar,
				CustomBar: this.CustomBar,
				NavBar:this.StatusBar +  this.CustomBar,
				AppStyle:this.$store.state.AppStyle,
				
				uid:0,
				idcard:"",
				name:"",
				regno:"",
				entname:"",
				
				userInfo:"",
				token:'',
				
				
			}
		},
		onPullDownRefresh(){
			var that = this;
			
		},
		onShow(){
			var that = this;
			// #ifdef APP-PLUS
			
			//plus.navigator.setStatusBarStyle("dark")
			// #endif
			if(localStorage.getItem('token')){
				
				that.token = localStorage.getItem('token');
			}
			that.getCacheInfo();
		},
		onLoad() {
			var that = this;
			// #ifdef APP-PLUS || MP
			that.NavBar = this.CustomBar;
			// #endif
		},
		methods: {
			back(){
				uni.navigateBack({
					delta: 1
				});
			},
			getCacheInfo(){
				var that = this;
				if(localStorage.getItem('userinfo')){
					var userInfo = JSON.parse(localStorage.getItem('userinfo'));
					that.uid=userInfo.uid;
					that.userInfo = userInfo;
				}
			},
			company() {
				var that = this;
				if(that.entname==""){
					uni.showToast({
						title: "请输入申请理由",
						icon: 'none'
					})
					return false;
				}
				var data = {
					name:"蓝v申请",
					idcard:"1",
					regno:"1",
					entname:that.entname,
				}
				uni.showLoading({
					title: "加载中"
				});
				that.$Net.request({
					
					url: that.$API.addCompany(),
					data:{
						"params":JSON.stringify(that.$API.removeObjectEmptyKey(data)),
						"token":that.token
					},
					header:{
						'Content-Type':'application/x-www-form-urlencoded'
					},
					method: "get",
					dataType: 'json',
					success: function(res) {
						setTimeout(function () {
							uni.hideLoading();
						}, 1000);
						uni.showToast({
							title: res.data.msg,
							icon: 'none'
						})
						if(res.data.code==1){
							uni.showToast({
								title: "提交成功！",
								icon: 'none'
							})
							setTimeout(function () {
								that.back();
							}, 1000);
							
							
						}
						
					},
					fail: function(res) {
						setTimeout(function () {
							uni.hideLoading();
						}, 1000);
						uni.showToast({
							title: "网络开小差了哦",
							icon: 'none'
						})
						uni.stopPullDownRefresh()
					}
				})
			},
		}
	}
</script>

<style>
</style>
