<template>
	<view class="content">
		<view class="row1">
			<text class="tit">企业头像</text>
			<view class="background-img" @click.stop="imgsub">
				<image class="background-img" v-model="qyList.headimg" :src="qyList.headimg" mode="aspectFill">
				</image>
			</view>
		</view>
		<view class="row">
			<text class="tit">企业名称</text>
			<input class="input" type="text" v-model="qyList.name" placeholder-class="placeholder" />
		</view>
		<view class="row">
			<text class="tit">企业简介</text>
			<input class="input" type="text" placeholder-class="placeholder" disabled value="修改" style="color: #3075ff;"
				@click="navto('/pages/set/bjq')" />
		</view>
		<view class="" v-html="content" style="padding: 20rpx;background-color: #fff;text-align: justify;">
			
		</view>
		<view class="add-btn" @click="confirm">提交</view>
	</view>
</template>

<script>
	import {
		changeInformation,
		enterprise
	} from '@/api/user.js'
	import {
		mapState,
		mapMutations
	} from 'vuex';
	import {
		upload
	} from '@/api/order.js';
	import {
		userEdit,
		logout
	} from '@/api/set.js';
	export default {
		data() {
			return {
				userInfo1: '',
				show: false,
				password: '',
				qyList: {},
				maxText: 225, //最大字数
				currentWordNumber: 0, //当前字数
				content: '', //企业简介
			}
		},
		computed: {
			...mapState('user', ['userInfo'])
		},
		onLoad() {
			enterprise().then(res => {
				console.log(res, '信息');

				this.qyList = res.data
				// res.data.introduce = JSON.parse(JSON.stringify(res.data.introduce))
				this.content = res.data.introduce.replace(/<img/g,"<img style='max-width:100%;height:auto;'");
			})
		},

		methods: {
			...mapMutations('user', ['logout']),
			navto(url) {
				uni.navigateTo({
					url
				})
			},
			imgsub() {
				console.log('上传头像')
				upload({
					filename: ''
				}).then(data => {
					console.log("data", data);
					this.qyList.headimg = data[0].url;
					console.log(this.qyList.headimg, '22312');
				})
			},

			confirm() {
				let obj = this
				changeInformation({
						headimg: obj.qyList.headimg,
						name: obj.qyList.name,
						introduce: obj.content,
					})
					.then(e => {
						// console.log(e, '返回');
						obj.$api.msg('修改成功');
						setTimeout(() => {
							uni.switchTab({
								url: '/pages/user/user'
							});
						}, 1000);
						console.log(e, '1');
					})
					.catch(e => {
						console.log(e, '2');
					});
			},
		}
	}
</script>

<style lang="scss">
	.row1 {
		display: flex;
		align-items: center;
		justify-content: space-between;
		position: relative;
		padding: 0 30upx;
		height: 110upx;
		background: #fff;
		margin-bottom: 20upx;

		.tit {
			flex-shrink: 0;
			width: 200rpx;
			font-size: $font-lg;
			color: $font-color-dark;
		}

		.background-img {
			width: 80rpx;
			height: 80rpx;
			border-radius: 50%;
			background: #f2f2f2;
		}
	}

	.row {
		position: relative;
		display: flex;
		align-items: center;
		padding: 0 30upx;
		min-height: 110upx;
		background: #fff;
		align-items: flex-start;
		line-height: 110rpx;

		.tit {
			flex-shrink: 0;
			width: 200upx;
			font-size: $font-lg;
			color: $font-color-dark;
		}

		.input {
			flex: 1;
			text-align: right;
			font-size: $font-base;
			color: $color-gray;
			height: 110rpx;
		}

		.currentWordNumber {
			color: #999999;
			font-size: 24rpx;
			position: absolute;
			right: 0;
			bottom: 0;
			margin: -100rpx 30rpx;
		}
	}

	.add-btn {
		display: flex;
		align-items: center;
		justify-content: center;
		margin: 158rpx auto 30rpx;
		width: 560rpx;
		height: 80rpx;
		background: linear-gradient(0deg, #2E58FF, #32C6FF);
		border-radius: 40px;
		color: #FFFFFF;
	}

	.out {
		display: flex;
		align-items: center;
		justify-content: center;
		margin: 0 auto 30rpx;
		width: 560rpx;
		height: 80rpx;
		border: 1px solid #32C6FF;
		background: #FFFFFF;
		border-radius: 40px;
		color: #32C6FF;
	}

	.psw-wrapper {
		width: 548rpx;
		height: 344rpx;
		background-color: #ffffff;

		.psw-title {
			width: 100%;
			font-size: 35rpx;
			padding: 43rpx 0 49rpx;
			text-align: center;
			font-weight: 800;
		}

		.psw-ipt {
			display: block;
			background-color: #dce3ed;
			height: 90rpx;
			width: 464rpx;
			padding-left: 30rpx;
			margin: 0 auto;
			font-size: 80rpx;
		}

		.psw-btn text {
			display: inline-block;
			text-align: center;
			width: 50%;
			padding-top: 29rpx;
			font-size: 35rpx;
		}

		.psw-qd {
			color: #32C6FF;
		}
	}
</style>
