<template>
	<view class="cmain">
		<view class="form_group">
			<view class="lable re">企业名称</view>
			<input type="text" placeholder="请输入" v-model="item.name" />
		</view>
		<view class="form_group">
			<view class="lable re">税号</view>
			<input type="text" placeholder="请输入" v-model="item.dutyParagraph" />
		</view>
		<view class="form_group">
			<view class="lable re">法人姓名</view>
			<input type="text" placeholder="请输入" v-model="item.legalPerson" />
		</view>
		<view class="form_group">
			<view class="lable re">法人身份证</view>
			<input type="text" placeholder="请输入" v-model="item.idCard" />
		</view>
		<view class="form_group">
			<view class="lable re">联系号码</view>
			<input type="text" placeholder="请输入" v-model="item.contact" />
		</view>
		<view class="form_group">
			<view class="lable re">开户行</view>
			<input type="text" placeholder="请输入" v-model="item.bankName" />
		</view>
		<view class="form_group">
			<view class="lable re">银行账号</view>
			<input type="text" placeholder="请输入" v-model="item.bankAccount" />
		</view>
		<view class="form_group">
			<view class="lable re">营业执照</view>
			<card v-model="item.pic" pic="../../static/images/yyzz.png"></card>
		</view>
		<button class="btn" @click="save()" v-if="item.judgeStatus != 1">提交审核</button>
	</view>
</template>

<script>
export default {
	data() {
		return {
			item: {}
		};
	},
	onLoad(e) {
		this.http.request({
			url: '/level-one-server/app/TbEnterprise/getInfo',
			success: res => {
				if (res.data.data) {
					this.item = res.data.data;
					uni.setNavigationBarTitle({ title: '我的认证资料' });
				} else {
					uni.setNavigationBarTitle({ title: '填写认证资料' });
				}
			}
		});
	},
	methods: {
		save() {
			let rule = [
				{ name: 'name', checkType: 'notnull', errorMsg: '请输入企业名称' },
				{ name: 'dutyParagraph', checkType: 'notnull', errorMsg: '请输入税号' },
				{ name: 'legalPerson', checkType: 'notnull', errorMsg: '请法人姓名' }
			];
			if (!this.verify.check(this.item, rule)) {
				uni.showModal({ content: this.verify.error, showCancel: false });
				return false;
			}
			this.http.request({
				url: '/level-one-server/app/TbEnterprise/identification',
				method: 'POST',
				data: this.item,
				success: res => {
					uni.showToast({ title: '提交成功' });
					setTimeout(() => {
						uni.$emit('authentication');
						uni.navigateBack();
					}, 1000);
				}
			});
		}
	}
};
</script>

<style lang="scss">
.btn {
	margin-top: 25px;
}
</style>
