<template>
	<view class="companyMsg">
		<view class="companyInfoBox">
			<u-form :model="form" :rules="rules" ref="form" label-position='top' label-width='150'
				border-bottom='false'>
				<u-form-item label="公司简介：" prop="companyDesc" border>
					<u-input type="textarea" height="500" border style="width:100%;" :disabled='istest'
						v-model="form.companyDesc" placeholder='输入公司简介' />
				</u-form-item>
			</u-form>

			<view class="descBtn" @click="saveCompanyDesc">
				保存
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				form: {},
				rules: {
					companyDesc: [{
						required: true,
						message: '请输入公司简介',
						trigger: ['blur'],
					}]
				}
			}
		},
		onLoad() {
			this.getApplyDetail()
		},
		onReady() {
			this.$refs.form.setRules(this.rules)
		},
		methods: {
			// 保存
			saveCompanyDesc() {
				this.$refs.form.validate().then(res => {
					const data = {
						applyId: this.form.companyApplyId,
						companyDesc: this.form.companyDesc,
						userId: this.form.userId
					}
					this.http.quickPost('/companyInfo/update', data, true).then(re => {
						uni.showToast({
							icon: 'none',
							title: '修改成功',
							duration: 2000,
						})
						setTimeout(() => {
							uni.switchTab({
								url: '/pages/personal/personal'
							})
						}, 2000)
					})
				}).catch(errors => {

				})
			},
			getApplyDetail() {
				const phoneuserinfo = uni.getStorageSync('wxUserInfo');
				this.http.quickGet(`/tester/cert/apply/${phoneuserinfo.userId}`, true).then(res => {
					if (res.data.code == 200) {
						this.form = res.data.data
						// this.form.companyDesc = res.data.data.companyDesc
					}
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.companyMsg {
		height: 100%;
		padding: 25rpx;
		box-sizing: border-box;

		.companyInfoBox {
			height: 100%;
			padding: 30rpx 20rpx;
			background: #FFFFFF;
		}
	}

	.descBtn {
		width: 100%;
		height: 70rpx;
		background: linear-gradient(90deg, #5EA6FD, #1A81F9);
		border-radius: 35rpx;
		font-weight: 500;
		font-size: 28rpx;
		color: #FFFFFF;
		line-height: 70rpx;
		text-align: center;
		margin-top: 50rpx;
	}
</style>