<template>
	<view class="container">
		<view class="page-block">
			<view class="page-title-block">
				<view class="title">员工信息</view>
			</view>
			<view class="content">
				
				<view class="cell flex flex-y-center">
					<view class="title-block">
						<text>门店</text>
					</view>
					<view class="desc">
						<view class="input-box">{{shop_title}}</view>
					</view>
				</view>
				
				<view class="cell flex flex-y-center">
					<view class="title-block">
						<text>员工名称</text>
					</view>
					<view class="desc">
						<view class="input-box">{{info.nickname}}</view>
					</view>
				</view>
				
				<view class="cell flex flex-y-center">
					<view class="title-block">
						<text>员工编号</text>
					</view>
					<view class="desc">
						<view class="input-box">{{info.number}}</view>
					</view>
				</view>
				
				<view class="cell flex flex-y-center">
					<view class="title-block">
						<text>手机号码</text>
					</view>
					<view class="desc">
						<view class="input-box">{{info.phone}}</view>
					</view>
				</view>
				<view class="cell flex flex-y-center">
					<view class="title-block">
						<text>密码</text>
					</view>
					<view class="desc">
						<view class="input-box">{{info.pass}}</view>
					</view>
				</view>
				<view class="cell flex flex-y-center">
					<view class="title-block">
						<text>性别</text>
					</view>
					<view class="desc">
						<view class="input-box">{{info.sex==1?'男':'女'}}</view>
					</view>
				</view>
				<view class="cell flex flex-y-center">
					<view class="title-block">
						<text>真实姓名</text>
					</view>
					<view class="desc">
						<view class="input-box">{{info.name}}</view>
					</view>
				</view>
				<view class="cell flex flex-y-center">
					<view class="title-block">
						<text>创建时间</text>
					</view>
					<view class="desc">
						<view class="input-box">{{info.addtime}}</view>
					</view>
				</view>
			</view>
		</view>
		
		<view style="height:30rpx;"></view>
		<view class="footer-bar" style="height: 100rpx;">
			<view class="content flex flex-center" style="height: 100rpx;">
				<view class="detail-btn flex flex-center" @click="del" style="border-right: 2rpx solid #F4F5F7;">
					<image src="./static/images/icon_16.png" mode="aspectFit" class="btn-icon"></image>
					<view style="color:#999999">删除员工</view>
				</view>
				<view class="detail-btn flex flex-center" @click="enit">
					<image src="./static/images/icon_17.png" mode="aspectFit" class="btn-icon"></image>
					<view style="color:#3387FF">重新编辑</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				info: {},
				type:2,
				store_id:'',
				id:'',
				admin_id:'',tableTypeList:[],shop_title:''
			}
		},
		
		onLoad(e) {
			this.store_id = uni.getStorageSync("store_id");
			this.admin_id = uni.getStorageSync("admin_id");
			this.id = e.id;
			this.type=e.type || 2;
			this.shop_store_index();
		},

		methods: {
			shop_store_index() {
				this.request({
					url: 'Smdcshop/shop_store_index',
					data: {
						admin_id:this.admin_id,
					}
				}).then(res => {
					if (res.code == 200) {
						this.tableTypeList = res.data;
						this.getData(this.id)
					}
				})
			},
			
			enit() {
				let info = this.info;
				uni.redirectTo({
					url: `./staffAdd?id=${info.id}&type=${this.type}`
				})
			},
			del() {
				uni.showModal({
					title: '提示',
					content: '是否要删除？',
					showCancel: true,
					cancelText: '取消',
					confirmText: '确定',
					success: res => {
						if (res.confirm) {
							this.request({
								url: 'Smdcshop/staff_delect',
								data: {
									id: this.id,
								},
							}).then(res => {
								console.log(res, "res")
								if (res.code === 200 || res.code === "200") {
									uni.showToast({
										title:res.message,
										icon: "none",
									})
									setTimeout(() => {
										uni.navigateBack()
									}, 2000)
								}
							}).catch((res) => {
								uni.showToast({
									title: res.message,
									icon: "none",
								})
							});
						}
					},
					fail: () => {},
					complete: () => {}
				});
			},
			getData(id) {
				this.request({
					url: 'Smdcshop/staff_info',
					data: {
						id: id
					}
				}).then(res => {
					if (res.code == "200") {
						this.info = res.data;
						if(this.tableTypeList.length>0){
							for (let i of this.tableTypeList) {
								if (i.id == Number(res.data.storeid)) {
									this.shop_title = i.title;
								}
							}
						}
						
						
					}
				})
			}
		}
	}
</script>
<style>
	@import url("./static/css/common.css");
	page {
		background-color: #F4F5F7;
	}
</style>
