<template>
	<base-page>
		<view class="common-wrap common-form">
			<view class="store-information">
				<view class="store-status">门店信息</view>
				<view class="store-types">
					<view class="info-left">
						<view class="type type1">
							<view>门店名称：</view>
							<view>{{storeData.store_name}}</view>
						</view>
						<view class="type type1">
							<view>门店电话：</view>
							<view class="message">{{storeData.telphone}}</view>
						</view>
						<view class="type type1">
							<view>门店类型：</view>
							<view class="message">{{storeData.store_type == 'directsale' ? '直营店' : '加盟店'}}</view>
						</view>
						<view class="type type1">
							<view>门店地址：</view>
							<view class="message">{{storeData.full_address}}{{storeData.address}}</view>
						</view>
						
					</view>
					<view class="info-img">
						<image :src="$util.img(storeData.store_image)" @error="$util.img(defaultImg.store)" mode="aspectFit"></image>
					</view>
					<view type="" class="btn" @click="$util.redirectTo('/pages/store/config')">设置</view>
				</view>
			</view>
			
			<view class="store-information">
				<view class="store-status">运营信息</view>
				<view class="store-types">
					<view class="info-left">
						<view class="type type1">
							<view>营业状态：</view>
							<view class="message">{{storeData.status == 1 ? '营业中' : '已停业'}}</view>
						</view>
						<view class="type type1">
							<view>营业时间：</view>
							<view class="message">{{storeData.open_date}}</view>
						</view>
						<view class="type type1">
							<view>同城配送：</view>
							<view>{{storeData.is_o2o ? '开启' : '关闭'}}</view>
						</view>
						<view class="type type1">
							<view>门店自提：</view>
							<view class="message">{{storeData.is_pickup ? '开启' : '关闭'}}</view>
						</view>
						<view class="type type1">
							<view>自提日期：</view>
							<view class="message" v-if="storeData.time_type == 1">
								<text class="week" v-if="storeData.time_week.includes('1') || storeData.time_week.includes(1)">周一</text>
								<text class="week" v-if="storeData.time_week.includes('2') || storeData.time_week.includes(2)">周二</text>
								<text class="week" v-if="storeData.time_week.includes('3') || storeData.time_week.includes(3)">周三</text>
								<text class="week" v-if="storeData.time_week.includes('4') || storeData.time_week.includes(4)">周四</text>
								<text class="week" v-if="storeData.time_week.includes('5') || storeData.time_week.includes(5)">周五</text>
								<text class="week" v-if="storeData.time_week.includes('6') || storeData.time_week.includes(6)">周六</text>
								<text class="week" v-if="storeData.time_week.includes('0') || storeData.time_week.includes(0)">周日</text>
							</view>
							<view class="message" v-if="storeData.time_type == 0">每天</view>
						</view>
						<view class="type type1">
							<view>自提时间：</view>
							<view class="message">{{storeData.start_time}}-{{storeData.end_time}}</view>
						</view>
						
						<view class="type type1">
							<view>库存设置：</view>
							<view class="message">{{storeData.stock_type == 'all' ? '总部统一库存' : '门店独立库存'}}</view>
						</view>
						
					</view>
					<view type="" class="btn" @click="$util.redirectTo('/pages/store/operate')">设置</view>
				</view>
			</view>
			 
			<nc-loading :layer-background="{ background: 'rgba(255,255,255,.8)' }" ref="loading"></nc-loading>
		</view>
	</base-page>
</template>

<script>
	export default {
		data() {
			return {
				storeData:{
					'store_name' : '',
					'store_image' : '',
					'status' : 0,
					'telphone' : '',
					'open_date' : '',
					'is_o2o' : 0,
					'is_pickup' : 0,
					'time_type' : 0,
					'start_time' : '00:00',
					'end_time' : '23:59',
					'stock_type' : 'all',
					'time_week' : '',
					'latitude' : 39.909,
					'longitude' : 116.39742,
					'province_id' : 110000,
					'city_id' : 110100,
					'district_id' : 110101,
					'address' : '西长安街1号',
					'full_address' : '北京市-北京市-东城区',
					'store_type' : 'directsale'
				},
				covers: [{
					latitude: 39.909,
					longitude: 116.39742,
					iconPath: '/static/location.png'
				}],
				defaultRegions:[],
			};
		},
		onLoad() {},
		onShow() {
			this.getData();
		},
		methods: {
			getData() {
				this.$api.sendRequest({
					url: '/store/storeapi/store/info',
					success: res => {
						if (res.code >= 0) {
							this.storeData = res.data;
							this.storeData.start_time = this.timeFormat(this.storeData.start_time);
							this.storeData.end_time = this.timeFormat(this.storeData.end_time);
							
							this.$refs.loading.hide();
						} else {
							this.$util.showToast({
								title: res.message
							});
						}
					}
				});
			},
			timeFormat(time){
				let h = parseInt(time / 3600);
				let i = parseInt(time % 3600 / 60);
				h = h < 10 ? '0'+h : h; 
				i = i < 10 ? '0'+i : i;
				return h+':'+i;
			}
		}
	}
</script>

<style lang="scss">
	.common-form{
		margin: 0.15rem 0.2rem;
	}
	.store-information {
		width: 100%;
		background: #eff0f4;
		box-sizing: border-box;
		padding-bottom: 0.1rem;
		.store-status {
			font-size: 0.24rem;
			font-weight: bold;
			margin-bottom: 0.24rem;
		}
		.store-types {
			width: 100%;
			min-height: 1rem;
			background: #ffffff;
			padding: 0.2rem 0.3rem;
			display: flex;
			flex-direction: row;
			justify-content: space-between;
			margin-bottom: 0.2rem;
			box-sizing: border-box;
			position: relative;
			.info-left{
				display: flex;
				flex-direction: column;
				justify-content: space-between;
				
			}
			.btn{
				position: absolute;
				top: 0.2rem;
				right: 0.2rem;
				color: $uni-color-primary;
				cursor: pointer;
			}
			.info-img{
				margin-top: 0.4rem;
				image{
					max-width: 1.5rem;
					height: 1rem;
				}
			}
			.type {
				padding-left: 0.1rem;
				view {
					font-size: 0.14rem;
					.look {
						color: $uni-color-primary;
						margin-left: 0.24rem;
					}
				}
				view:nth-child(1) {
					width: 0.9rem;
					text-align: right;
					margin-right: 0.1rem;
				}
			}
			.type1 {
				display: flex;
				align-items: center;
				height: .34rem;
			}
		}
		.goods-info {
			min-height: 2.7rem;
			background: #ffffff;
			padding: 0.2rem;
			box-sizing: border-box;
			.title {
				font-size: 0.18rem;
				font-weight: 550;
				margin: 0.2rem 0;
			}
			.table {
				width: 100%;
				box-sizing: border-box;
				margin-bottom: 0.2rem;
				.table-all {
					width: 100%;
					display: flex;
					align-items: center;
					justify-content: space-between;
					padding: 0 0.38rem;
					box-sizing: border-box;
					.table-td {
						font-size: 0.14rem;
						text-align: left;
						display: flex;
						align-items: center;
						justify-content: center;
						image {
							margin-right: 0.1rem;
						}
					}
					.table-goods-name{
						image{
							width: .6rem;
							height: .6rem;
							margin-right: .1rem;
							flex-shrink: 0;
						}
					}
				}
				.table-th {
					height: 0.56rem;
					background: #f7f8fa;
				}
				.table-tr {
					height: 0.7rem;
					border-bottom: 0.01rem solid #e6e6e6;
					.table-td {
						image {
							width: 0.5rem;
							height: 0.5rem;
						}
						.gift-tag {
							font-size: .12rem;
							background: #f00;
							margin-right: .05rem;
							color: #fff;
							line-height: 1;
							padding: .01rem .05rem;
							border-radius: .03rem;
						}
						.content-text {
							width: 80%;
							height: 0.4rem;
							text-overflow: -o-ellipsis-lastline;
							overflow: hidden;
							text-overflow: ellipsis;
							display: -webkit-box;
							-webkit-line-clamp: 2;
							line-clamp: 2;
							-webkit-box-orient: vertical;
						}
					}
				}
				.refund-success {
					color: $primary-color;
					font-size: .12rem;
					margin-top: .05rem;
				}
			}
		}
	}
	.week{
		margin-right: 0.1rem;
	}
</style>
