<style>
	.compInformation {
		background-color: #fff;
		margin-bottom:140px;
	}

	.compInfoList {
		width: 100%;
		display: flex;
		height: 60px;
		align-items: center;
		padding: 0 20px;
		border-bottom: 1px solid #F2F3F6;
	}

	.comInforName {
		width: 25%;
		color: #000;
	}

	.comInforName text {
		color: red;
		margin-left:3px;
	}

	.comInfoInput {
		width: 75%;
		margin-top: 2px;
		font-size: 13px;
		color:#808080;
		text-align: right;
	}
	.comInBtn{
		position: fixed;
		bottom:0;
		width:100%;
		height:50px;
		color:#fff;
		z-index:99;
		font-size: 16px;
		text-align: center;
		line-height: 50px;
		background-color: #0b0052;
	}
</style>
<template>
	<view class="compInformation">
		<view class="compInfoList">
			<view class="comInforName">
				中文名称<text>*</text>
			</view>
			<input class="uni-input comInfoInput" v-model="msg.CompanyName" placeholder="请输入公司中文名称" />
		</view>
		<view class="compInfoList">
			<view class="comInforName">
				英文名称
			</view>
			<input class="uni-input comInfoInput" v-model="msg.CompanyEnName" placeholder="请输入公司英文名称" />
		</view>
		<view class="compInfoList">
			<view class="comInforName">
				联系人<text>*</text>
			</view>
			<input class="uni-input comInfoInput" v-model="msg.Principal" placeholder="请输入公司联系人" />
		</view>
		<view class="compInfoList">
			<view class="comInforName">
				联系电话<text>*</text>
			</view>
			<input class="uni-input comInfoInput" v-model="msg.Mobile" type="number" placeholder="请输入公司联系电话" />
		</view>
		<view class="compInfoList">
			<view class="comInforName">
				公司邮箱<text>*</text>
			</view>
			<input class="uni-input comInfoInput" v-model="msg.EMail" placeholder="请输入公司邮箱" />
		</view>
		<view class="compInfoList">
			<view class="comInforName">
				法人
			</view>
			<input class="uni-input comInfoInput" v-model="msg.LegalPerson" placeholder="请输入法人" />
		</view>
		<view class="compInfoList">
			<view class="comInforName">
				公司微信
			</view>
			<input class="uni-input comInfoInput" v-model="msg.WechatNo" placeholder="请输入公司微信" />
		</view>
		<view class="compInfoList">
			<view class="comInforName">
				公司介绍
			</view>
			<input class="uni-input comInfoInput" v-model="msg.CompanyIntro" placeholder="公司介绍" />
		</view>
		<view class="compInfoList">
			<view class="comInforName">
				公司官网
			</view>
			<input class="uni-input comInfoInput" v-model="msg.DomainUrl" placeholder="请输入公司官网" />
		</view>
		<view class="compInfoList">
			<view class="comInforName">
				成立时间
			</view>
			<view @click="showStart=true" style="width:75%;color:#808080;text-align: right;height:30px;">{{msg.FoundingTime}}</view>
		</view>
		<view class="compInfoList">
			<view class="comInforName">
				员工数量
			</view>
			<input class="uni-input comInfoInput" v-model="msg.EmployeeNum" placeholder="请输入员工数量" />
		</view>
		<view class="compInfoList">
			<view class="comInforName">
				<view>年销售额</view>
				<view>（万元）</view>
			</view>
			<input class="uni-input comInfoInput" v-model="msg.AnnualSales" placeholder="请输入年销售额" />
		</view>
		<view class="compInfoList">
			<view class="comInforName">
				<view>年进口额</view>
				<view>（万元）</view>
			</view>
			<input class="uni-input comInfoInput" v-model="msg.AnnualImport" placeholder="请输入年进口额" />
		</view>
		<view class="compInfoList">
			<view class="comInforName">
				中文地址
			</view>
			<input class="uni-input comInfoInput" v-model="msg.Address" placeholder="请输入公司中文地址" />
		</view>
		<view class="compInfoList">
			<view class="comInforName">
				英文地址
			</view>
			<input class="uni-input comInfoInput" v-model="msg.EnAddress" placeholder="请输入公司英文地址" />
		</view>
		<view class="compInfoList">
			<view class="comInforName">
				行业
			</view>
			<input class="uni-input comInfoInput" v-model="msg.Industry" placeholder="请输入行业" />
		</view>
		<view class="compInfoList">
			<view class="comInforName">
				出口国
			</view>
			<input class="uni-input comInfoInput" v-model="msg.ExportCountry" placeholder="请输入主要出口国" />
		</view>
		<view class="compInfoList">
			<view class="comInforName">
				进口国
			</view>
			<input class="uni-input comInfoInput" v-model="msg.ImportCountry" placeholder="请输入主要进口国" />
		</view>
		<view class="compInfoList">
			<view class="comInforName">
				进口品目
			</view>
			<input class="uni-input comInfoInput" v-model="msg.ImportCategory" placeholder="请输入主要进口品目" />
		</view>
		<view class="compInfoList">
			<view class="comInforName">
				其他
			</view>
			<input class="uni-input comInfoInput" v-model="msg.OtherInfo" placeholder="请输入其他" />
		</view>
		<view class="comInBtn" @click="saveInfo()">提交</view>
		<u-picker v-model="showStart" mode="time" :params="params" @confirm='btnStart' :default-time='defaultTime'></u-picker>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				pageTitle: "公司资料",
				dataList: [],
				showStart: false,
				defaultTime: '',
				params: {
					year: true,
					month: true,
					day: true,
					hour: false,
					minute: false,
					second: false
				},
				msg: {
					CompanyId: 0, //编号
					CompanyName: "", //公司名称
					CompanyEnName: "", //公司英文名称
					Principal: "", //联系人
					Mobile: "", //联系电话
					EMail: "", //邮箱
					LegalPerson: "", //法人
					WechatNo: "", //公司微信
					CompanyIntro: "", //公司介绍
					DomainUrl: "", //官网
					FoundingTime: "", //成立时间
					EmployeeNum: "", //员工人数
					AnnualSales: "", //年销售(万元)
					AnnualImport: "", //年进口额
					Address: "", //详细地址
					EnAddress: "", //详细地址(英文)
					Industry: "", //行业
					ExportCountry: "", //主要出口国
					ImportCountry: "", //主要进口国家
					ImportCategory: "", //主要进口类目
					OtherInfo: "" //其他内容
				}
			};
		},
		mounted() {
			uni.setNavigationBarTitle({
				title: this.pageTitle,
			});
			var currTime = new Date();             
			var year = currTime.getFullYear();
			var month = currTime.getMonth() + 1;
			var day = currTime.getDate();
			if(month<10){
				month='0'+month;
			}
			if(day<10){
				day='0'+day;
			}
			this.msg.FoundingTime =year+'-'+ month+'-'+day;
		},
		onLoad(options) {
			
		},
		created() {
			this.getList();
		},
		onShow() {

		},
		methods: {
			//获取数据
			getList() {
				uni.showLoading({
					title: '加载中'
				});
				this.request2({
						url: "/api/AppletTrade/GetUserCompany",
						data: {},
					},
					(res) => {
						uni.hideLoading();
						if (res.resultCode == 1) {
							if(res.data){
								if(res.data.CompanyName){
									this.msg.CompanyName=res.data.CompanyName;
								}
								if(res.data.CompanyEnName){
									this.msg.CompanyEnName=res.data.CompanyEnName;
								}
								if(res.data.Principal){
									this.msg.Principal=res.data.Principal;
								}
								if(res.data.Mobile){
									this.msg.Mobile=res.data.Mobile;
								}
								if(res.data.EMail){
									this.msg.EMail=res.data.EMail;
								}
								if(res.data.LegalPerson){
									this.msg.LegalPerson=res.data.LegalPerson;
								}
								if(res.data.WechatNo){
									this.msg.WechatNo=res.data.WechatNo;
								}
								if(res.data.CompanyIntro){
									this.msg.CompanyIntro=res.data.CompanyIntro;
								}
								if(res.data.DomainUrl){
									this.msg.DomainUrl=res.data.DomainUrl;
								}
								// if(res.data.FoundingTime){
								// 	this.msg.FoundingTime=res.data.FoundingTime;
								// }
								if(res.data.EmployeeNum){
									this.msg.EmployeeNum=res.data.EmployeeNum;
								}
								if(res.data.AnnualSales){
									this.msg.AnnualSales=res.data.AnnualSales;
								}
								if(res.data.AnnualImport){
									this.msg.AnnualImport=res.data.AnnualImport;
								}
								if(res.data.Address){
									this.msg.Address=res.data.Address;
								}
								if(res.data.EnAddress){
									this.msg.EnAddress=res.data.EnAddress;
								}
								if(res.data.Industry){
									this.msg.Industry=res.data.Industry;
								}
								if(res.data.ExportCountry){
									this.msg.ExportCountry=res.data.ExportCountry;
								}
								if(res.data.ImportCountry){
									this.msg.ImportCountry=res.data.ImportCountry;
								}
								if(res.data.ImportCategory){
									this.msg.ImportCategory=res.data.ImportCategory;
								}
								if(res.data.OtherInfo){
									this.msg.OtherInfo=res.data.OtherInfo;
								}
								if(res.data.FoundingTimeStr){
									this.msg.FoundingTime = res.data.FoundingTimeStr;
								}
							}
						}
					}
				);
			},
			//保存数据
			saveInfo(){
				if(this.msg.CompanyName==''){
					uni.showToast({
					  title: "请输入公司中文名称",
					  icon:'none'
					});
					return;
				}
				if(this.msg.Principal==''){
					uni.showToast({
					  title: "请输入联系人",
					  icon:'none'
					});
					return;
				}
				if(this.msg.Mobile==''){
					uni.showToast({
					  title: "请输入联系电话",
					  icon:'none'
					});
					return;
				}
				if(this.msg.EMail==''){
					uni.showToast({
					  title: "请输入公司邮箱",
					  icon:'none'
					});
					return;
				}
				this.request2({
						url: "/api/AppletTrade/SetCompany",
						data: this.msg,
					},
					(res) => {
						if (res.resultCode == 1) {
							uni.showToast({
							  title: "保存成功",
							});
							this.getList();
							uni.navigateTo({
								url: '/pages/index/index'
							});
						}
					}
				);
			},
			btnStart(val) {
				uni.hideLoading();
				this.msg.FoundingTime = val.year+'-'+val.month+'-'+val.day;
			},
		},
	}
</script>

<style>
</style>
