<template>
	<!-- 商家助手首页 -->
	<view class="index">
		<view class="head">
			<!-- @tap="demoaudio" -->
			<view class="tit">店铺名称:{{storeinfo.shop_name}} </view>
			<!-- {{shop.shop_name}} -->
			<view class="jiu">

				<view class="jiu_01">
					<navigator url="/pages/notice/notice">
						<view>
							<image class="img" src="/static/icon/newsicon.png" mode=""></image>
						</view>
						<view>消息通知</view>
					</navigator>
				</view>
				<view class="jiu_01">
					<navigator url="/pages/user/tongji/tongji">
						<view>
							<image class="img" src="/static/icon/zijinicons.png" mode=""></image>
						</view>
						<view>商户资金管理</view>
					</navigator>
				</view>
				<view class="jiu_01 ">
					<navigator url="/pages/user/mingxi/mingxi">
						<view>
							<image class="img" src="/static/icon/3.png" mode=""></image>
						</view>
						<view>佣金明细</view>
					</navigator>
				</view>
			</view>
		</view>
		<view class="more">
			<view class='mo'>
				<view class='mo_01'>数据交易</view>
				<navigator url="/pages/user/tongji/tongji">
					<view class='mo_02'>更多 <uni-icon type="arrowright" size="15" color="#D6D6D6"></uni-icon>
					</view>
				</navigator>
			</view>
		</view>
		<navigator url="/pages/user/tongji/tongji" class="shuju">
			<view class="shuju_01">
				<view>今日订单/今日收益</view>
				<view class="shuju_01_s" v-if="countdata.order_day">{{countdata.order_day}}/￥{{countdata.money_day}}</view>
				<view class="shuju_01_s" v-else>0 / ¥0</view>
			</view>
			<view class="shuju_01 no">
				<view>昨日订单/金额</view>
				<view class="shuju_01_s" v-if="countdata.order_yesterday">{{countdata.order_yesterday}} /¥{{countdata.money_yesterday}}</view>
				<view class="shuju_01_s" v-else>0 / ¥0</view>
			</view>

			<view class="shuju_01">
				<view>总订单数</view>
				<view class="shuju_01_s" v-if="countdata.total_order">{{countdata.total_order}}</view>
				<view class="shuju_01_s" v-else>0</view>
			</view>
			<view class="shuju_01 no">
				<view>总收入</view>
				<view class="shuju_01_s" v-if="countdata.money">¥ {{countdata.money}}</view>
				<view class="shuju_01_s" v-else>￥0 </view>
			</view>
		</navigator>
		<view class="BH"></view>
		<view class="six">
			<view class="jiu_max" v-if="shop_type=='goods'">
				<navigator url="/pages/edit/pro_manage/pro_manage">
					<view class="jiu_min">
						<view>
							<image class="img" src="/static/icon/20.png" mode=""></image>
						</view>
						<view>商品管理</view>
					</view>
				</navigator>
			</view>

			<view class="jiu_max " v-if="shop_type=='ele'">
				<navigator url="/pages/eleProduct/eleProduct">
					<view class="jiu_min">
						<view>
							<image class="img" src="/static/icon/20.png" mode=""></image>
						</view>
						<view>外卖产品</view>
					</view>
				</navigator>
			</view>

			<!-- 酒店管理 -->
			<view class="jiu_max " v-if="shop_type=='hotel'">
				<navigator url="/pages/HotelManage/HotelManage">
					<view class="jiu_min">
						<view>
							<image class="img" src="/static/icon/20.png" mode=""></image>
						</view>
						<view>酒店管理</view>
					</view>
				</navigator>
			</view>




			<!-- 商城不要分类  这个是外卖的-->
			<view class="jiu_max" v-if="shop_type=='ele'">
				<navigator url="/pages/shopCategory/shopCategory?type=1">
					<view class="jiu_min">
						<view>
							<image class="img" src="/static/icon/6.png" mode=""></image>
						</view>
						<view>商品分类</view>
					</view>
				</navigator>
			</view>

			<!-- 这个是商城的 -->
			<view class="jiu_max" v-if="shop_type=='goods'">
				<navigator url="/pages/storeCategory/storeCategory?type=1">
					<view class="jiu_min">
						<view>
							<image class="img" src="/static/icon/6.png" mode=""></image>
						</view>
						<view>商品分类</view>
					</view>
				</navigator>
			</view>



			<!-- <view class="jiu_01">
				<navigator url="/pages/shopCategory/shopCategory?type=2">
					<view>
						<image class="img" src="/static/icon/21.png" mode=""></image>
					</view>
					<view>商品属性</view>
				</navigator>
			</view> -->


			<!-- 只有商城才有规格 外卖没有规格 -->
			<!-- v-if="shop_type=='goods'" -->
			<!-- 商城和外卖都有规格 -->
			<view class="jiu_max">
				<navigator url="/pages/specs/specs?type=2">
					<view class="jiu_min">
						<view>
							<image class="img" src="/static/icon/22.png" mode=""></image>
						</view>
						<view>商品规格</view>
					</view>
				</navigator>
			</view>


			<view class="jiu_max" v-if="shop_type=='ele'">
				<!-- 外卖订单 -->
				<navigator url="/pages/order/order">
					<view class="jiu_min">
						<view>
							<image class="img" src="/static/icon/8.png" mode=""></image>
						</view>
						<view>订单管理</view>
					</view>

				</navigator>
			</view>

			<view class="jiu_max" v-if="shop_type=='goods'">
				<!-- 商城订单 -->
				<navigator url="/pages/order/shopOrder">
					<view class="jiu_min">
						<view>
							<image class="img" src="/static/icon/8.png" mode=""></image>
						</view>
						<view>订单管理</view>
					</view>
				</navigator>
			</view>

			<!-- 酒店的订单  酒店订单管理-->
			<view class="jiu_max" v-if="shop_type=='hotel'">
				<!-- 酒店的订单 -->
				<navigator url="/pages/hotelOrder/hotelOrder">
					<view class="jiu_min">
						<view>
							<image class="img" src="/static/icon/8.png" mode=""></image>
						</view>
						<view>订单管理</view>
					</view>
				</navigator>
			</view>


			<view class="jiu_max ">
				<navigator url="/pages/kehu/kehu">
					<view class="jiu_min">
						<view>
							<image class="img" src="/static/icon/people.png" mode=""></image>
						</view>
						<view>锁客列表</view>
					</view>
				</navigator>
			</view>

			<!-- 活动管理  只有商城才有抽奖活动-->
			<view class="jiu_max " v-if="shop_type=='goods'">
				<navigator url="/pages/LuckDraw/homenav/homenav">
					<view class="jiu_min">
						<view>
							<image class="img" src="/static/news/liwuiocn.png" mode=""></image>
						</view>
						<view>抽奖活动</view>
					</view>
				</navigator>
			</view>


			<view class="jiu_max ">
				<navigator url="/pages/CardSend/CardSend">
					<view class="jiu_min">
						<view>
							<image class="img" src="/static/news/coupon.png" mode=""></image>
						</view>
						<view>优惠券管理</view>
					</view>
				</navigator>
			</view>

			<view class="jiu_max ">
				<navigator url="/pages/Printer/AddPrinter">
					<view class="jiu_min">
						<view>
							<image class="img" src="/static/news/printer.png" mode=""></image>
						</view>
						<view>添加打印机</view>
					</view>
				</navigator>
			</view>

		</view>
		<view class="BH"></view>



		<yomol-upgrade ref="yomolUpgrade"></yomol-upgrade>
		<!-- 升级组件 -->

		<Welcome ref="Welcome"></Welcome>
		<!-- 欢迎回来 -->

	</view>
</template>

<script>
	import uniBadge from "@/components/uni/uni-badge/uni-badge.vue"
	import uniIcon from "@/components/uni/uni-icon/uni-icon.vue"
	import yomolUpgrade from '@/components/yomol-upgrade/yomol-upgrade.vue'; //升级组件
	import Welcome from "@/components/Welcome/Welcome.vue"; //欢迎回来

	import {
		storeIndex
	} from "@/utils/api/api.js";
	export default {
		data() {
			return {

				tancl: false,
				shop: {},
				countdata: {},
				shop_type: "", //店铺类型 ele goods
			}
		},
		components: {
			uniIcon,
			uniBadge,
			yomolUpgrade, //升级组件
			Welcome,
		},
		computed: {
			storeinfo() {
				return this.$store.state.userInfo;
			}
		},
		onLaunch() {


		},
		onLoad() {
			//显示欢迎回来~
			setTimeout(() => {
				this.$refs.Welcome.show();
			}, 2000)

		},
		//下拉刷新
		onPullDownRefresh() {
			this.storeIndexfun(); //获取信息
			// uni.stopPullDownRefresh();//结束下拉刷新
		},
		onShow() {
			this.storeIndexfun();
			// 判断用户有没有绑定手机号

			//检测更新
			setTimeout(() => {
				// this.$refs.yomolUpgrade.checkVersionClick()
				// this.$refs.yomolUpgrade.checkVersionClick();
				// #ifdef APP-PLUS
				//this.checkVersionClick();//自动检测更新

				this.$refs.yomolUpgrade.checkVersionClick();

				// #endif
			}, 1000)
		},
		methods: {


			demoaudio() {
				//语音提醒
				//AudioVoice   openVoice

				// setInterval(()=>{
				// 	this.$store.dispatch('AudioVoice',"您有新的资金变化,请注意查看").then((e) => {
				// 		console.log(e);
				// 	})
				// },10000);


				this.$store.dispatch('AudioVoice', "您有新的订单,请注意查看").then((e) => {
					console.log(e);
					//震动 调用

					//400ms
					//长震动
					uni.vibrateLong({
						success: (re) => {

						},
						fail: (a) => {

						}
					})

					// 短震动
					//15ms
					// uni.vibrateShort()({
					// 	success:(re)=> {

					// 	},
					// 	fail:(a)=> {

					// 	}
					// })
				})
			},
			//弹窗
			tan() {
				this.tancl = !this.tancl
			},


			//获取首页的数据
			async storeIndexfun() {
				let res = await storeIndex({

				});
				uni.stopPullDownRefresh(); //结束下拉刷新
				if (res.code == 0) {
					this.countdata = res.data.counts; //统计的数据
					this.shop_type = res.data.shop_type; //店铺类型 商城 goods

				} else {
					this.$api.msg(res.msg);
				}
			}

		}
	}
</script>


<style lang="scss">
	.index {
		background: #fff;

		.H50 {
			height: 100upx;
		}

		.head {
			//background:  linear-gradient(to bottom, #52c693, #27a26c);
			background: linear-gradient(to bottom, #f37b1d, #ff3600);
			text-align: center;
			padding: 40upx 0 20upx;
			color: #fff;
			font-size: 28upx;
		}

		.jiu {
			padding: 20upx;
			display: flex;
			flex-wrap: wrap;
			color: #fff;
		}

		.jiu_01 {
			width: 33%;
			text-align: center;
			padding: 30upx 20upx 30upx;
			box-sizing: border-box;
			font-size: 24upx;
		}

		.jiu_max {
			width: 33%;
		}

		.jiu_min {
			width: 100%;
			text-align: center;
			padding: 30upx 20upx 30upx;
			box-sizing: border-box;
			font-size: 24upx;
		}

		.jiu_01 .img {
			width: 64upx;
			height: 64upx;
			margin-bottom: 20upx;
		}

		.jiu_min .img {
			width: 64upx;
			height: 64upx;
			margin-bottom: 20upx;
		}

		.mo {
			padding: 20upx;
			display: flex;
			justify-content: space-between;
			border-bottom: 2upx solid #f0f0f0;
			line-height: 40upx;
		}

		.mo_01 {
			padding-left: 20upx;
			box-sizing: border-box;
			width: 80%;
			height: 40upx;
			overflow: hidden;
			border-left: 6upx solid #EC521B;
			font-size: 28upx;
			font-weight: bold;
		}

		.mo_01 span {
			color: #8E8E8E;
			font-weight: 100;
			font-size: 24upx;
			padding-left: 20upx;
		}

		.mo_02 {
			color: #D6D6D6;
		}

		.shuju {
			display: flex;
			flex-wrap: wrap;
		}

		.shuju_01 {
			width: 50%;
			text-align: center;
			padding: 32upx 20upx;
			box-sizing: border-box;
			font-size: 28upx;
			line-height: 50upx;
			font-size: 32upx;
			border-right: 1px solid #f0f0f0;
			border-bottom: 1px solid #f0f0f0;
		}

		.shuju_01_s {
			color: #EB511B;
			font-weight: 800;
			font-size: 32upx;
		}

		.no {
			border-right: none;
		}

		.BH {
			background-color: #F1F1F1;
			height: 10upx;
		}

		.six {
			padding: 20upx;
			display: flex;
			flex-wrap: wrap;
		}

		.list_01 {
			padding: 30upx 20upx 16upx;
			border-bottom: 1px solid #F4F4F4;
			font-size: 24upx;
		}
	}
</style>
