<template>
	<view class="page1">
		<view class="list-box">
			<view class="list-1">
				<view class="list-name">
					营业开始时间
				</view>
				<view class="list-right">
					<picker mode="time" :value="shop.businessHourBegin" start="00:00" end="23:59" @change="bindTimeChange($event,'start')">
						<view class="uni-input">{{shop.businessHourBegin}}</view>
					</picker>
				</view>
			</view>
			<view class="list-1">
				<view class="list-name">
					营业结束时间
				</view>
				<view class="list-right">
					<picker mode="time" :value="shop.businessHourEnd" start="00:00" end="23:59" @change="bindTimeChange($event,'end')">
						<view class="uni-input">{{shop.businessHourEnd}}</view>
					</picker>
				</view>
			</view>
			
			<view class="list-1">
				<view class="list-name">
					营业状态
				</view>
				<view class="list-right">
					{{shop.status == 0?'正常营业':shop.status == 1?'暂停营业':'冻结'}}
				</view>
			</view>
			<view class="list-1">
				<view class="list-name">
					拼团佣金
				</view>
				<view class="list-right">
					{{shop.commissionRateMore}}元
				</view>
			</view>
			<view class="list-1">
				<view class="list-name">
					单独购买佣金
				</view>
				<view class="list-right">
					{{shop.commissionRateOne}}元
				</view>
			</view>
			<view class="list-1">
				<view class="list-name">
					经营品类
				</view>
				<view class="list-right">
					{{shop.type}}
				</view>
			</view>
			<view class="list-1">
				<view class="list-name">
					是否支持配送
				</view>
				<view class="list-right">
					{{shop.isDelivery == 0?'是':'否'}}
				</view>
			</view>
			<view class="list-1">
				<view class="list-name">
					出餐时间
				</view>
				<view class="list-right">
					{{shop.cookingTime}}分钟
				</view>
			</view>
			<view class="list-1">
				<view class="list-name">
					排名
				</view>
				<view class="list-right">
					{{shop.shoprank}}名
				</view>
			</view>
			<view class="list-1">
				<view class="list-name">
					是否价格锁定
				</view>
				<view class="list-right">
					{{shop.isPriceLock== 0?'是':'否'}}
				</view>
			</view>
		</view>
		<view class="list-box">
			<view class="list-2" @click="submit">
				保存
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				shop:{}
			}
		},
		onLoad() {
			this.getShopMsg()
			
		},
		methods: {
			getShopMsg(){
				this.NB.sendRequest('/app/shoptakeaway/getByShopId', {
					shopId: uni.getStorageSync('shopId')
				}, false, 'get', 'application/x-www-form-urlencoded').then(res => {
					if (res.code == 200) {
						this.shop = res.result
						for (let key in this.shop) {
						  if (this.shop[key] === null) {
						    delete this.shop[key];
						  }
						}
					} else {
						uni.showToast(res.message)
					}
				})
				
			},
			bindTimeChange(e,type){
				if(type == 'start'){
					this.shop.businessHourBegin = e.detail.value
				}else{
					this.shop.businessHourEnd = e.detail.value
				}
				
			},
			submit(){
				this.NB.sendRequest('/app/shoptakeaway/update', this.shop, false, 'POST', 'application/x-www-form-urlencoded').then(res => {
					if (res.code == 200) {
						uni.showModal({
							title: '提示',
							content: '更新信息成功',
							showCancel:false,
							success: function (res) {
								if (res.confirm) {
									uni.navigateBack()
								}
							}
						});
					} else {
						uni.showToast(res.message)
					}
				})
			}
		}
	}
</script>

<style>
	page,.page1{
		width: 100%;
		height: 100%;
		font-size: 28rpx;
		background: #eee;
	}
	.list-box{
		width: 100%;
		height: auto;
		background: #fff;
		margin-top: 20rpx;
		
	}
	.list-1{
		display: flex;
		width: 100%;
		height: 100rpx;
		line-height: 100rpx;
		border-bottom: 1px solid #eee;
		
	}
	.list-2{
		width: 100%;
		height: 100rpx;
		line-height: 100rpx;
		text-align: center;
		border-bottom: 1px solid #eee;
	}
	.list-icon{
		width: 100rpx;
		height: 100rpx;
		text-align: center;
	}
	.list-name{
		flex: 1;
		padding-left: 20rpx;
	}
	.list-right{
		flex: 1;
		height: 100rpx;
		text-align: right;
		padding-right: 20rpx;
		overflow: hidden;
	}
	.upload-img{
		width:60rpx;
		height: 60rpx;
		background-size: 100%;
		margin-top: 20rpx;
	}
	.list-2{
		width: 100%;
		height: 100rpx;
		line-height: 100rpx;
		text-align: center;
		border-bottom: 1px solid #eee;
	}
</style>