<template>
	<view class="content">
		<view class="content_box">
			<view class="row b-b">
				<text class="tit">机构名称</text>
				<input class="input" type="text" disabled="true" v-model="name" placeholder="请输入机构名称" placeholder-class="placeholder" />
			</view>
			<view class="row b-b">
				<text class="tit">联系电话</text>
				<input class="input" type="text" disabled="true"  v-model="phone" placeholder="请输入联系电话" placeholder-class="placeholder" />
			</view>
			<view class="row b-b">
				<text class="tit">负责人</text>
				<input class="input" type="text" disabled="true"  v-model="leader" placeholder="请输入负责人姓名" placeholder-class="placeholder" />
			</view>
		</view>
		<view class="content_box">
			<view class="row b-b"><!-- @tap="showPicker('region')" -->
				<text class="tit">省市区</text>
				<input class="input" disabled="disabled" v-model="addr" placeholder="请选择省市区"></input>
			</view>
			<w-picker mode="region"  :value="defaultRegion" default-type="value"  @confirm="onConfirm($event,'region')" @cancel="handleCancel" ref="region" ></w-picker>
			<view class="row b-b">
				<text class="tit">详细地址</text>
				<input class="input" type="text"  v-model="address" disabled="true" placeholder="请输入商家地址" placeholder-class="placeholder" />
			</view>
		</view>
		<!-- <view class="content_box">
			<view class="examine_list">
				<view class="examine_name">营业执照</view>
				<view class="examine_img"><image :src="img" @click="scImg('img')"></image></view>
			</view>
		</view> -->
		<!-- <view class="add-btn" @click="confirm">提交申请</view> -->
	</view>
</template>

<script>
import { mapState, mapMutations } from 'vuex';
import uniList from '@/components/uni-list/uni-list.vue';
import uniListItem from '@/components/uni-list-item/uni-list-item.vue';
import wPicker from "@/components/w-picker/w-picker.vue"
import { setOrgan } from "@/api/index.js"
import { getUserInfo } from '@/api/login.js';
// import { upload } from '@/api/index.js';
export default {
	components: {
		uniList,
		uniListItem,
		wPicker
	},
	data() {
		return {
			checked:false,
			name:'',//机构名称
			phone:"",
			region:'',
			defaultRegion:[],
			defaultRegion1:[],
			options:[],
			ext_info:'',
			leader :'',//负责人
			addr:'',//省市区
			address:'',//详细地址
			// img:'/static/img/add.png',
		};
	},
	onShow() {
		let obj = this;
		obj.ext_info = obj.userInfo.ext_info;
		console.log(obj.ext_info,88)
		obj.addr = obj.ext_info.province+ obj.ext_info.city + obj.ext_info.district;
		obj.address = obj.ext_info.detail_address;
		obj.name = obj.ext_info.name;
		obj.phone = obj.ext_info.mobile;
		obj.leader = obj.ext_info.leader
		obj.province = obj.ext_info.province;
		obj.city = obj.ext_info.city;
		obj.district = obj.ext_info.district;
		obj.province_id = obj.ext_info.province_id;
		obj.city_id = obj.ext_info.city_id;
		obj.district_id = obj.ext_info.district_id;
	},
	computed: {
		...mapState(['userInfo'])
	},
	methods: {
		...mapMutations(['setUserInfo']),
		//省市区弹窗
		showPicker(type){
			this.$refs[type].show();
		},
		// scImg(item) {
		// 	upload({
		// 		file: ''
		// 	}).then(e => {
				
		// 	}).catch((e) => {
				
		// 	});
		// },
		//阅读并同意
		//取消弹窗
		handleCancel(){
			
		},
		//省市区选择确定
		onConfirm(res,type){
			let obj = this;
			obj.result=res;
			obj.addr = res.result;
			if(res.name){
				obj.province = res.name[0];
				obj.city = res.name[1];
				obj.district = res.name[2];
			}
			obj.province_id = res.value[0];
			obj.city_id = res.value[1];
			obj.district_id = res.value[2];
			obj.hospital = '';//重置医院
			console.log(obj.addr)
			console.log(obj.province,obj.city,obj.district)
			console.log(obj.province_id,obj.city_id,obj.district_id)
			// obj.ListDate();
		},
		//提交
		confirm() {
			let obj = this;
			setOrgan({
				name: obj.name,
				mobile: obj.phone,
				province: obj.province,
				province_id: obj.province_id,
				city: obj.city,
				city_id: obj.city_id,
				district: obj.district,
				district_id: obj.district_id,
				leader:obj.leader,
				detail_address:obj.address,
				latitude:1,
				longitude:1
			})
				.then(function(e) {
					obj.$api.msg(e.msg);
					obj.GetUser();
					setTimeout(function() {
						uni.switchTab({
							url:'/pages/user/user'
						})
					  }, 500);
				})
				.catch(e => {
					console.log(e)
				});
		},
		GetUser() {
			let obj = this;
			getUserInfo({})
				.then(function(e) {
					obj.setUserInfo(e.data);
				})
				.catch(function(e) {
					console.log(e);
				});
		},
	}
};
</script>

<style lang="scss">
page {
	background: $page-color-base;
	padding-top: 25rpx;
}
.content_box {
	background-color: #ffffff;
	width: 92%;
	margin: 0rpx auto;
	border-radius: 15rpx;
	margin-bottom: 25rpx;
}
.row {
	display: flex;
	align-items: center;
	// position: relative;
	padding: 0 30rpx;
	height: 110rpx;
	background: #fff;
	border-bottom: 1rpx solid #f8f6f6;

	.tit {
		flex-shrink: 0;
		width: 180rpx;
		font-size: 30rpx;
		color: $font-color-dark;
	}
	.input {
		flex: 1;
		font-size: 30rpx;
		color: $font-color-dark;
	}
	.iconlocation {
		font-size: 36rpx;
		color: $font-color-light;
	}
}
.examine_name {
	color: #171717;
	font-size: 28rpx;
	padding: 25rpx 25rpx;
}
.examine_img {
	width: 100%;
	text-align: center;
	padding-bottom: 25rpx;
}
.examine_img image {
	width: 200rpx;
	height: 200rpx;
}
.default-row {
	margin-top: 16rpx;
	.tit {
		flex: 1;
	}
	switch {
		transform: translateX(16rpx) scale(0.9);
	}
}
.add-btn {
	position: fixed;
	bottom: 0rpx;
	width: 100%;
	height: 100rpx;
	font-size: $font-lg;
	color: #fff;
	background-color: #6786FB;
	line-height: 100rpx;
	text-align: center;
}
.img_box {
	padding: 35rpx 35rpx;
	width: 250rpx;
	height: 250rpx;
}
.img_box image {
	width: 100%;
	height: 100%;
}
.alert-box {
	background-color: #ffffff;
}
.b-b:after {
	position: relative !important;
}
.check_box {
	padding: 25rpx 25rpx;
	font-size: 28rpx;
	text{
		color: #6786FB;
	}
}

</style>
