<template>
	<view class="cmain">
		<view class="form_group">
			<view class="lable re">企业名称</view>
			<input type="text" placeholder="请输入" v-model="item.name" :disabled="item.judgeStatus==1?true:false" />
		</view>
	<!-- 	<view class="form_group">
			<view class="lable re">税号</view>
			<input type="text" placeholder="请输入" v-model="item.dutyParagraph" :disabled="item.judgeStatus==1?true:false"/>
		</view> -->
		<view class="form_group">
			<view class="lable re">姓名</view>
			<input type="text" placeholder="请输入" v-model="item.legalPerson" :disabled="item.judgeStatus==1?true:false" />
		</view>
		<view class="form_group">
			<view class="lable re">身份证号</view>
			<input type="text" maxlength="18" placeholder="请输入" v-model="item.idCard" :disabled="item.judgeStatus==1?true:false" />
		</view>
		<view class="form_group">
			<view class="lable re">联系号码</view>
			<input type="text" maxlength="11" placeholder="请输入" v-model="item.contact" :disabled="item.judgeStatus==1?true:false" />
		</view>
		<view class="form_group">
			<view class="lable re">银行账号</view>
			<input type="text" maxlength="16" placeholder="请输入" v-model="item.bankAccount" :disabled="item.judgeStatus==1?true:false" />
		</view>
	<!-- 	<view class="form_group">
			<view class="lable re">地址</view>
			<input type="text" placeholder="请输入" v-model="item.address" :disabled="item.judgeStatus==1?true:false" />
		</view> -->
		<!-- <view class="form_group">
			<view class="lable re">法人身份证</view>
			<card v-model="item.pic" pic="../../../static/images/yyzz.png"></card>
		</view> -->
		<view class="form_group" v-if="item.type==1">
			<view class="lable re">营业执照</view>
			<card v-model="item.businessLicense" 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: {},
			param: {},
		};
	},
	onLoad(e) {
		this.param.appUserId = this.getUser().id
		this.http.request({
			url: '/level-two-server/app/TbPurchaser/info',
			data: this.param,
			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: 'corporateName', checkType: 'notnull', errorMsg: '请输入法人姓名' },
				{ name: 'businessLicense', checkType: 'notnull', errorMsg: '请上传营业执照' }
			];
			if (!this.verify.check(this.item, rule)) {
				uni.showModal({ content: this.verify.error, showCancel: false });
				return false;
			}
			this.item.loginUserId = this.getUser().id
			this.http.request({
				url: '/level-two-server/app/TbPurchaser/identification',
				method: 'POST',
				data: this.item,
				contentType: 'application/json;charset=UTF-8',
				success: res => {
					uni.showToast({ title: '提交成功' });
					uni.$emit('purchaserAuth');
					uni.navigateBack();
				}
			});
		}
	}
};
</script>

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