<template>
	<view class="tn-safe-area-inset-bottom">
		<!-- 顶部自定义导航 -->
		<tn-nav-bar :isBack="false" backTitle="" :bottomShadow="true" backgroundColor="#FFFFFF">
			<view class="custom-nav tn-flex tn-flex-col-center tn-flex-row-left">
				<view style="padding-left: 15rpx;" @click="goBack()">
					<text class="tn-icon-left" style="font-size: 40rpx;"></text>
				</view>
				<view class="tn-margin-top"
					style=";text-shadow:  1rpx 0 0 #FFF, 0 1rpx 0 #FFF, -1rpx 0 0 #FFF , 0 -1rpx 0 #FFF;">
					<tn-tabs :list="[{name:'我的信息'}]" :current="topCurrent" activeColor="#000" :bold="false"
						:fontSize="36"></tn-tabs>
				</view>
			</view>
		</tn-nav-bar>

		<view class="tn-margin-top" :style="{paddingTop: vuex_custom_bar_height + 'px'}"
			style="padding-bottom: 160rpx;">
			<view class="tn-flex tn-flex-row-between tn-strip-bottom-min tn-padding tn-flex-col-center">
				<view class="justify-content-item">
					<view class="tn-text-bold tn-text-lg">
						证件照
					</view>
				</view>
				<view class="justify-content-item tn-text-lg tn-color-grey">
					<view @click="d_img">
						<image :src="apiImgUrl+addMod.photo_image" mode="aspectFill"
							style="width: 150rpx;height: 150rpx;border-radius: 50%;"></image>
					</view>
				</view>
			</view>
			<view class="tn-flex tn-flex-row-between tn-strip-bottom-min tn-padding">
				<view class="justify-content-item" style="width: 100%;">
					<view class="tn-text-bold tn-text-lg">
						姓名
					</view>
					<view class="tn-color-gray tn-padding-top-xs">
						<tn-input v-model="addMod.nikename" placeholder="请填写姓名" />
					</view>
				</view>
			</view>
			<view class="tn-flex tn-flex-row-between tn-strip-bottom-min tn-padding">
				<view class="justify-content-item" style="width: 100%;">
					<view class="tn-text-bold tn-text-lg">
						手机号
					</view>
					<view class="tn-color-gray tn-padding-top-xs">
						<tn-input v-model="addMod.phone" placeholder="请填写手机号" />
					</view>
				</view>
			</view>
			<view class="tn-flex tn-flex-row-between tn-strip-bottom-min tn-padding">
				<view class="justify-content-item" style="width: 100%;">
					<view class="tn-text-bold tn-text-lg">
						微信号
					</view>
					<view class="tn-color-gray tn-padding-top-xs">
						<tn-input v-model="addMod.wx_number" placeholder="请填写微信号" />
					</view>
				</view>
			</view>
			<view class="tn-flex tn-flex-row-between tn-strip-bottom-min tn-padding">
				<view class="justify-content-item" style="width: 100%;">
					<view class="tn-text-bold tn-text-lg">
						公司名称
					</view>
					<view class="tn-color-gray tn-padding-top-xs">
						<tn-input v-model="addMod.enterprise_name" placeholder="请填写公司名称" />
					</view>
				</view>
			</view>
			<view class="tn-flex tn-flex-row-between tn-strip-bottom-min tn-padding">
				<view class="justify-content-item" style="width: 100%;">
					<view class="tn-text-bold tn-text-lg">
						自我介绍
					</view>
					<view class="tn-color-gray tn-padding-top-xs">
						<tn-input v-model="addMod.introduction" :height="150" type="textarea" placeholder="请填写自我介绍" />
					</view>
				</view>
			</view>
			<view class="tn-flex tn-flex-row-between tn-strip-bottom-min tn-padding">
				<view class="justify-content-item" style="width: 100%;">
					<view class="tn-text-bold tn-text-lg">
						公司介绍
					</view>
					<view class="tn-color-gray tn-padding-top-xs">
						<tn-input v-model="addMod.enterprise_Introduction" :height="150" type="textarea"
							placeholder="请填写公司介绍" />
					</view>
				</view>
			</view>
		</view>
		<view class="tn-flex tn-footerfixed">
			<view class="tn-flex-1 justify-content-item tn-margin-sm tn-text-center">
				<tn-button backgroundColor="#82B2FF" fontColor="#ffffff" padding="40rpx 0" width="60%" shadow fontBold
					@click="setUserEditDo">
					<!-- <text class="tn-icon-light tn-padding-right-xs tn-color-black"></text> -->
					<text>提交审核</text>
				</tn-button>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		getUserIndex,
		setUserEdit
	} from "@/util/api";
	import store from "@/store";

	export default {
		data() {
			return {
				topCurrent: 0,
				showAuthorizationModal: false,
				index: 0,
				date: '2000-01-29',
				userInfo: {},
				addMod: {
					photo_image: '',
					member_id: '',
					nikename: '',
					phone: '',
					wx_number: '',
					introduction: '',
					enterprise_name: '',
					enterprise_Introduction: '',
					association_id: '',
				},
				apiImgUrl: this.$store.state.imgUrl,
				apiUpUrl: this.$store.state.apiUrl
			}
		},
		onLoad() {
			var uid = uni.getStorageSync('uid');
			this.uid = uid;
			this.getUserInfo();
		},
		methods: {
			d_img() {
				var that = this;
				uni.chooseImage({
					count: 1, //默认9
					sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图，默认二者都有
					sourceType: ['album'], //从相册选择
					success: function(res) {
						uni.uploadFile({
							url: that.apiUpUrl + '/common/upload', //仅为示例，非真实的接口地址
							filePath: res.tempFilePaths[0],
							name: 'file',
							success: (uploadFileRes) => {
								var data = JSON.parse(uploadFileRes.data);
								console.log(data);
								that.addMod.photo_image = data.data.url;
							}
						});
					}
				});
			},
			setUserEditDo() {
				setUserEdit(this.addMod)
					.then(res => {
						console.log(res);
						if (res.code == 1) {
							uni.showToast({
								title: '信息已提交审核',
								icon: 'none',
								duration: 2000
							});
						} else {
							uni.showModal({
								title: '提示',
								content: res.msg,
							});
						}
					})
					.catch(error => {
						uni.showToast({
							title: error,
							icon: 'none',
							duration: 2000
						});
					})
			},
			getUserInfo() {
				getUserIndex({
						member_b_id: this.uid,
						member_id: this.uid
					})
					.then(res => {
						console.log(res);
						this.addMod = {
							photo_image: res.data.photo_image,
							member_id: res.data.member_id,
							nikename: res.data.nikename,
							phone: res.data.phone,
							wx_number: res.data.wx_number,
							introduction: res.data.introduction,
							enterprise_name: res.data.enterprise_name,
							enterprise_Introduction: res.data.enterprise_Introduction,
							association_id: res.data.association_id
						}
					})
					.catch(error => {
						uni.showToast({
							title: error,
							icon: 'none',
							duration: 2000
						});
					})
			},
			// 跳转
			tn(e) {
				uni.navigateTo({
					url: e,
				});
			},
			goBack() {
				if (getCurrentPages().length > 1) {
					uni.navigateBack()
				} else {
					uni.redirectTo({
						url: '/pages/index/index'
					})

				}
			},

		}
	}
</script>

<style lang="scss" scoped>
	/* 授权 */
	.login-page {
		width: 100vw;
		height: 100vh;
		display: flex;
		align-items: center;
		justify-content: center;
	}

	/* 授权按钮 */
	.submit-btn {
		width: 100%;
		background-color: #05C160;
		color: #FFFFFF;
		margin-top: 60rpx;
		border-radius: 10rpx;
		padding: 25rpx;
		font-size: 32rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		margin: 30rpx;
	}

	/* 间隔线 start*/
	.tn-strip-bottom-min {
		width: 100%;
		border-bottom: 1rpx solid #F8F9FB;
	}

	.tn-strip-bottom {
		width: 100%;
		border-bottom: 20rpx solid rgba(241, 241, 241, 0.8);
	}

	/* 间隔线 end*/


	/* 用户头像 start */
	.logo-image {
		width: 80rpx;
		height: 80rpx;
		position: relative;
	}

	.logo-pic {
		background-size: cover;
		background-repeat: no-repeat;
		// background-attachment:fixed;
		background-position: top;
		border: 2rpx solid rgba(255, 255, 255, 0.05);
		box-shadow: 0rpx 0rpx 80rpx 0rpx rgba(0, 0, 0, 0.15);
		border-radius: 50%;
		overflow: hidden;
		// background-color: #FFFFFF;
	}


	/* 底部悬浮按钮 start*/
	.tn-tabbar-height {
		min-height: 100rpx;
		height: calc(120rpx + env(safe-area-inset-bottom) / 2);
	}

	.tn-footerfixed {
		position: fixed;
		width: 100%;
		bottom: calc(30rpx + env(safe-area-inset-bottom));
		z-index: 1024;
		box-shadow: 0 1rpx 6rpx rgba(0, 0, 0, 0);

	}

	/* 底部悬浮按钮 end*/
</style>