<template>
	<view class="">
	<view class="information">
		<view class="list">
			<view class="lable">企业单位：</view>
			<view class="input">
				<input type="text" v-model="list.unit" placeholder="请输入企业单位"/>
			</view>
		</view>
		<view class="list">
			<view class="lable">企业统一代码：</view>
			<view class="input">
				<input type="text" v-model="list.id" placeholder="请输入身份证号"/>
			</view>
		</view>
		<view class="list">
			<view class="lable">联系方式：</view>
			<view class="input">
				<input type="text" v-model="list.phone" placeholder="请输入联系方式"/>
			</view>
		</view>
		<view class="list">
			<view class="lable">所在地区：</view>
			<view class="input">
				<pickerAddress class="pickerAddress" :class="{pickerColor: !location}" 
				@change="onCityClick">{{location||'请选择地址'}}</pickerAddress>
			</view>
			<view><img src="@/static/img/jt.png" v-show="!location"></view>
		</view>
		<view class="list">
			<view class="lable">详细地址：</view>
			<view class="input">
				<input type="text" v-model="list.address" placeholder="请输入详细地址" />
			</view>
		</view>
		<view class="list">
			<view class="lable">主营领域：</view>
			<view class="input">
				<input type="text" v-model="list.occupation" placeholder="请输入职业"/>
			</view>
		</view>
		<view class="list">
			<view class="lable">公司年限：</view>
			<view class="input">
				<input type="text" v-model="list.careerYears" placeholder="请输入职业年限"/>
			</view>
		</view>
		<view class="list">
			<view class="lable">保荐人：</view>
			<view class="input">
				<input type="text" v-model="list.sponsor" placeholder="请输入保荐人"/>
			</view>
		</view>
	</view>
	<view class="img">
		<p>品牌logo</p>
		<view class="photo" @click='pic'>
			<img :src="list.img" v-if="list.img"/>
			<img src="@/static/img/k.png" v-else>
		</view>
		
	</view>
	<view class="button" @click="submit">
		提交申请
	</view>
</view>
</template>

<script>
import { apply,getPrice } from '../../api/apply.js'
import  pickerAddress from '@/components/wangding-pickerAddress/wangding-pickerAddress.vue';
	export default {
		components: {
			pickerAddress
		},
		data() {
			return {
				list: {
					unit: '', //企业单位
					id: '', //企业统一代码
					phone: '', //联系方式
					Location: '', //所在地区
					address: '', //详细地址
					occupation: '', //主营领域
					careerYears: '', //公司年限
					sponsor: '', //保荐人
					img: '', //品牌logo
					pay_type: 'weixin', //weixin：微信支付,yue：余额支付
					grade: '' //等级
				},
				province: '', //省
				city: '', //市
				district: '', //区
				TYPE: 2//2代表企业会员
			}
		},
		computed: {
			location() {
				return  this.province + this.city + this.district
			}
		},
		methods: {
			//会员价格
			price() {
				const type = this.TYPE
				getPrice({},type).then(res => {
					console.log(res)
				})
			},
			//提交
			submit() {
				this.price()
				this.list.location = this.location
				const data = this.list
				console.log(data)
				const type = this.TYPE
				apply({ data },type).then(res => {
					console.log(res)
				}).catch(res => {
					console.log(res)
				})
			},
			//图片预览
			pic() {
				const that = this
				uni.chooseImage({
					success: function(res) {
						console.log(res.tempFilePaths[0])
						that.list.img = res.tempFilePaths[0]
					}
				})
			},
			// 选中城市切换
			onCityClick({data}) {
				this.province = data[0];
				this.city = data[1];
				this.district = data[2];
			}
		}
	}
</script>

<style lang="scss">
	page {
		height: 100%;
	}
	body {
		background-color: #f3f3f3;
	}
	.information {
		background-color: #fff;
		margin: 0 10rpx;
		padding: 0 40rpx;
		border-radius: 20rpx;
		font-size: 30rpx;
		margin-top: 30rpx;
	}
	.list {
		display: flex;
		border-bottom: solid 1rpx  #f3f3f3;
		.lable {
			padding: 20rpx;
			width: 270rpx;
		}
		img {
			padding-top: 26rpx;
			width: 0rpx;
			float: right;
		}
		.input {
			input {
				border: 0;
				width: calc(100% - 20rpx);
				font-size: 30rpx;
				padding: 20rpx;
			}
		}
	}
	.img {
		margin: 0 10rpx;
		font-size: 30rpx;
		background-color: #fff;
		padding: 0 24rpx;
		border-radius: 20rpx;
		height: 400rpx;
		margin: 0 10rpx;
		position: relative;
		p {
			padding: 20rpx;
		}
		img {
			width: 160rpx;
		}
	}
	.photo {
		width: 160rpx;
		height: 160rpx;
		margin: auto auto;
		position: absolute;
		left: calc(50% - 80rpx);
	}
	.button {
		position: fixed;
		bottom: 0;
		left: 0;
		width: 100%;
		text-align: center;
		color: #fff;
		background-color: #3b66f5;
		font-size: 30rpx;
		height: 100rpx;
		line-height: 100rpx;
	}
	.pickerAddress {
		margin-top: 20rpx;
		padding-left: 5rpx;
	}
	.pickerColor {
		color: #808080;
	}
</style>
