<template>
	<view>
		<u-navbar :border-bottom="false" back-icon-size="35" title="关于我们" title-size="32" :background="background"
			:back-text-style="hhyanm" title-color="#000000" back-icon-color="#000000"></u-navbar>

		<view class="box" v-if="state == 0 || state == 3">
			<view class="item-submit" v-if="state == 3">
				<view>审核未通过, 请重新提交审核</view>
			</view>
			<view class="item">
				<view class="item-text">联系我们</view>
			</view>
			<view class="item">
				<view class="item-text">反馈意见</view>
			</view>
			<view class="item">
				<view class="item-text">检查更新</view>
				</view>
			</view>
			<view class="item">
				<view class="item-text">清除缓存</view>
			</view>
			<view class="item">
				<view class="item-text">性别</view>
			</view>


		</view>
		<view v-if="state == 1">
			<view class="item-submit">
				目前正在审核请耐心等待
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				title: '',
				phone: '',
				username: '',
				password: '',
				img: '',
				content: '',
				array: [{
					name: '男'
				}, {
					name: '女'
				}],
				action: 'https://xlzx.vvv5g.com/app/index.php?i=2&c=entry&a=wxapp&m=yzd_edu&do=UploadImg', // 图片上传地址
				index: 0,
				state: 0,
			}
		},
		onLoad() {
			this.getMyIdentity();
		},
		methods: {
			getMyIdentity: function(e) {
				this.$post({
					data: {
				 	do: 'GetMyIdentity',
						data: {
							user_id: uni.getStorageSync('id'),
						}
					}
				}).then(res => {
					this.state = res.data.state;
				})
			},
			// 选择图片上传
			choodeImage() {
				uni.chooseImage({
					count: 1,
					sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图，默认二者都有
					sourceType: ['album'], //从相册选择
					success: (res) => {
						// this.img = res.tempFilePaths[0]
						uni.showLoading({
							title: '上传中...'
						})
						uni.uploadFile({
							url: 'https://xlzx.vvv5g.com/app/index.php?i=2&c=entry&a=wxapp&m=yzd_edu&do=UploadImg', //仅为示例，非真实的接口地址
							filePath: res.tempFilePaths[0],
							name: 'upfile',
							success: (uploadFileRes) => {
								uni.hideLoading()
								console.log(uploadFileRes, '111111111111111')
								console.log(uploadFileRes);
								this.img = uploadFileRes.data
							}
						});
					}
				})
			},
			bindPickerChange: function(e) {
				console.log('picker发送选择改变，携带值为：' + e.detail.value)
				this.index = e.detail.value
			},
			submit: function(e) {

				if (!this.title) {
					uni.showToast({
				 	title: '请输入姓名',
						icon: 'none'
					})
					return
				}

				if (!this.phone) {
					uni.showToast({
						title: '请输入手机号码',
						icon: 'none'
					})
					return
				}

				if (!this.username) {
					uni.showToast({
						title: '请输入账号',
						icon: 'none'
					})
					return
				}

				var pwdRegex = new RegExp('(?=.*[0-9])(?=.*[a-zA-Z]).{6,30}');
				if (!pwdRegex.test(this.password)) {
					uni.showToast({
						title: "您的密码复杂度太低（密码中必须包含字母、数字），请及时修改密码！",
						icon: 'none'
					})
					return
				}

				if (!this.img) {
					uni.showToast({
						title: '请上传您的资质',
						icon: 'none'
					})
					return
				}

				this.$post({
					data: {
						do: 'LecturerSettled',
						data: {
							"title": this.title,
							"phone": this.phone,
							"username": this.username,
							"password": this.password,
							"img": this.img,
							"content": '',
							"sex": this.index + 1,
							"user_id": uni.getStorageSync('id'),
						}
					}
				}).then(res => {
				 console.log(res, 'ssssssssssssssssssssss')
					uni.showToast({
						title: '添加成功',
						mask: true
					})
					setTimeout(() => {
						uni.navigateBack()
					}, 1500)
				})
			}
		}
	}
</script>

<style>
	.item {
		display: flex;
		padding: 27rpx 0;
		border-bottom: 1px solid #f3f3f3;
		align-items: center;
	}

	.box {
		padding: 10rpx 30rpx;
	}

	.item-input {
		padding-left: 10rpx;
		width: 70%;
	}

	.item-text {
		min-width: 115rpx;
	}

	.img {
		width: 100%;
		height: 320rpx;
	}

	.item-button {
		width: 247rpx;
		max-content: 80rpx;
		text-align: center;
		line-height: 80rpx;
		background-color: #04ba8f;
		color: #fff;
		border-radius: 94rpx;
		box-shadow: 0 6rpx 6rpx rgba(0, 0, 0, .05);
		margin: 20rpx 0;
	}

	.item-submit {
		display: flex;
		justify-content: center;
		align-items: center;
	}

	.item-u {
		display: flex;
		padding: 10rpx 0;
		align-items: center;
	}
	
	.choose-outer{
	    width: 290rpx; 
	    height: 198rpx; 
	    border: 2px dotted #CCCCCC; 
	    border-radius: 15rpx;
	    display: flex;
	    flex-direction: column;
	    justify-content: center;
	    align-items: center;
	}
</style>
