<template>
	<view class="page1">
		<view class="title">
			<view class="title-sreach">
				<view class="back-btn" @tap="back" :style="{'top': menuButtonInfo.top +'px'}">
					<uni-icons type="left" size="28"></uni-icons>
				</view>
				<view class="title-name" :style="{'padding-top': menuButtonInfo.top +'px'}">
					商家中心
				</view>
			</view>
		</view>
		<view class="shop-title">
			<view class="title1">
				<img :src="shop.shopIcon" alt="" />
			</view>
			<view class="title2">
				<view class="title22">
					{{shop.shopName}}
				</view>
				<view class="title33" @tap="updateStatus">
					{{businessStatus == '1'?'暂停营业':'正常营业'}}
					<uni-icons type="right" size="12"></uni-icons>
				</view>
			</view>
		</view>
		<view class="shop-order">
			<view class="order1">
				待办事项
			</view>
			<view class="order2">
				<view class="order22">
					<view class="order33" @tap="goDetail('db',3)">
						<view class="order44">
							0
						</view>
						<view class="order55">
							待接单
						</view>
					</view>
					<view class="order33" @tap="goDetail('db',4)">
						<view class="order44">
							0
						</view>
						<view class="order55">
							待取货
						</view>
					</view>
					<view class="order33" @tap="goDetail('db',5)">
						<view class="order44">
							0
						</view>
						<view class="order55">
							待送达
						</view>
					</view>
				</view>
				<view class="order22">
					<view class="order33" @tap="goDetail('db',2)">
						<view class="order44">
							0
						</view>
						<view class="order55">
							待消费
						</view>
					</view>
					<view class="order33" @tap="goDetail('db',11)">
						<view class="order44">
							0
						</view>
						<view class="order55">
							待退款/售后
						</view>
					</view>
					<view class="order33" @tap="goDetail('db',5)">
						<view class="order44">
							0
						</view>
						<view class="order55">
							待回复差评
						</view>
					</view>
				</view>
			</view>
		</view>
		<view class="shop-order">
			<view class="order1" style="display: flex;">
				<view style="flex: 1;">
					今日实时数据
				</view>
				<view @tap="goDetail('tj')">
					更多
					<uni-icons type="right" size="12"></uni-icons>
				</view>
			</view>
			<view class="data2">
				<view class="data22">
					<view class="data222">
						0
					</view>
					<view class="data333">
						今日订单
					</view>
				</view>
				<view class="data22">
					<view class="data222">
						0
					</view>
					<view class="data333">
						营业额
					</view>
				</view>
			</view>
		</view>
		<view class="shop-order">
			<view class="order1">
				必备工具
			</view>
			<view class="menu2">
				<view class="menu22" @tap="goDetail('sp')">
					<view class="menu33">
						<img src="/static/images/dingdan/dd0.png" alt="" />
					</view>
					<view class="menu44">
						商品管理
					</view>
				</view>
				<view class="menu22" @tap="goDetail('dp')">
					<view class="menu33">
						<img src="/static/images/dingdan/dd1.png" alt="" />
					</view>
					<view class="menu44">
						店铺管理
					</view>
				</view>
				<view class="menu22" @tap="goDetail('dd')">
					<view class="menu33">
						<img src="/static/images/dingdan/dd2.png" alt="" />
					</view>
					<view class="menu44">
						订单管理
					</view>
				</view>
				<view class="menu22" @tap="goDetail('zd')">
					<view class="menu33">
						<img src="/static/images/dingdan/dd3.png" alt="" />
					</view>
					<view class="menu44">
						账单结算
					</view>
				</view>
				<view class="menu22" @tap="goDetail('pj')">
					<view class="menu33">
						<img src="/static/images/dingdan/dd4.png" alt="" />
					</view>
					<view class="menu44">
						顾客评价
					</view>
				</view>
				<view class="menu22" @tap="goDetail('hx')">
					<view class="menu33" style="width: 100%;height: 56rpx;">
						<uni-icons type="scan" size="25"></uni-icons>
					</view>
					<view class="menu44">
						扫码核销
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				menuButtonInfo: {},
				businessStatus:1,
				shop:{}
			}
		},
		onShow() {
			this.menuButtonInfo = uni.getMenuButtonBoundingClientRect()
		},
		onLoad(option) {
			this.getBusinessStatus()
		},
		methods: {
			//获取营业状态
			getBusinessStatus(){
				this.tui.request("/app/shoptakeaway/getByShopId", "GET", {
					shopId: uni.getStorageSync('shopId')
				}, false, true).then((res) => {
					if (res.code == 200) {
						this.shop = res.result
						this.shop.shopIcon = uni.getStorageSync('shopIcon')
						this.businessStatus = res.result.status
					} else {
						this.tui.toast(res.message)
					}
					uni.hideLoading()
				}).catch((res) => {})
			},
			//更改营业状态
			updateStatus(){
				let that = this;
				uni.showModal({
					title: '提示',
					content: '要更改营业状态吗？',
					success: function (res1) {
						if (res1.confirm) {
							that.tui.request("/app/shoptakeaway/update", "post", {
								shopId: uni.getStorageSync('shopId'),
								status:that.businessStatus == "1"?'0':that.businessStatus == "0"?'1':'2'
							}, false, true).then((res) => {
								if (res.code == 200) {
									uni.showToast("更改成功")
									that.businessStatus = that.businessStatus == "1"?'0':that.businessStatus == "0"?'1':'2'
								} else {
									that.tui.toast(res.message)
								}
								uni.hideLoading()
							}).catch((res) => {})
						}
					}
				});
				
			},
			goDetail(type,index) {
				let url = ''
				switch (type) {
					case 'tj':
						url = '/package1/myCenter/dataStatistics'
						break;
					case 'db':
						url = '/package1/myCenter/shopOrderList?index=' + index
						break;
					case 'sp':
						url = '/package1/myCenter/goodsList'
						break;
					case 'dp':
						url = ''
						break;
					case 'dd':
						url = '/package1/myCenter/shopOrderList'
						break;
					case 'zd':
						url = '/package1/myCenter/shopBill'
						break;
					case 'pj':
						url = '/package1/group/shopEvaluate?item=' + JSON.stringify(uni.getStorageSync('schoolShop'))
						break;
					default:
				}
				uni.navigateTo({
					url: url
				})
			},
			back() {
				uni.navigateBack()
			},
		}
	}
</script>

<style lang="scss">
	page {
		width: 100%;
		height: 100%;
		font-size: 24rpx;
		background: #F5F8F5;
		color: #00231C;
	}

	.page1 {
		width: 100%;
		height: 100%;
		font-size: 24rpx;
		position: relative;
	}

	.title {
		background: url('https://jewel-shop.oss-cn-beijing.aliyuncs.com/8bc15960c2dc40268e295d6dd23aecce.png') no-repeat;
		width: 100%;
		height: 20%;
	}

	.title-sreach {
		width: 100%;
		display: flex;
		height: 200rpx;
		position: relative;
	}

	.back-btn {
		position: absolute;
		bottom: 0;
		left: 0;
	}

	.title-name {
		padding-top: 110rpx;
		font-size: 36rpx;
		font-weight: 700;
		flex: 1;
		text-align: center;
	}

	.shop-title {
		width: 95%;
		margin: -130rpx auto 0;
		padding: 20rpx;
		background: #fff;
		border-radius: 20rpx;
		display: flex;
		font-size: 28rpx;
		font-weight: 700;
	}

	.title1 {
		width: 70rpx;
		height: 70rpx;

		img {
			width: 100%;
			height: 100%;
			border-radius: 10rpx;
		}
	}
	.title2{
		    flex: 1;
		    line-height: 70rpx;
		    display: flex;
	}
	.title22{
		    flex: 1;
		    padding-left: 20rpx;
	}
	.shop-order{
		width: 95%;
		margin: 20rpx auto 0;
		background: #fff;
		border-radius: 20rpx;
		padding: 0 20rpx 0;
	}
	.order1{
		height: 70rpx;
		line-height: 70rpx;
		font-size: 28rpx;
		font-weight: 700;
		border-bottom: 1px solid #eee;
	}	
	.order22{
		display: flex;
		height: 100rpx;
		padding-top: 20rpx;
	}
	.order33{
		flex: 1;
		text-align: center;
	}
	.order44{
		font-size: 28rpx;
		font-weight: 700;
	}
	.data2{
		    display: flex;
		    height: 140rpx;
		    text-align: center;
		    padding-top: 20rpx;
	}
	.data22{
		flex: 1;
	}
	.data222{
		    font-size: 36rpx;
		    font-weight: 700;
		    padding-bottom: 20rpx;
	}
	.menu2{
		display: flex;
		flex-wrap: wrap;
		text-align: center;
		padding-top: 20rpx;
	}
	.menu22{
		width: 25%;
		    height: 120rpx;
	}
	.menu33{
		img{
			width: 50rpx;
			    height: 50rpx;
			background-size: 100%;
		}
	}
	.menu44{
		height: 40rpx;
		line-height: 40rpx;
	}
</style>