<!-- 首页 -->
<template>
	<view class="content">

		<!-- 检测进行中 今日成交金额  今日订单数量 底部为总 -->
		<view class="c-top">
			<view style="width: 100%; height: 44px;"></view>
			<view class="top-ail">
				<!-- 新增 -->
				<view class="top-two">
					<view class="" @click="getback()">
						<uni-icons type="left" color="#ffffff" size="22"></uni-icons>
					</view>
					<view class="bai-title">信息管理</view>
					<view style="width: 15px; height: 100%;"></view>
				</view>
				<!-- 	<view class="top-two">
					<view class="dix">
						<view class="touxiang">
							<image :src="baseUrl +user.partnerLogo" mode=""></image>
						</view>
						<view class="t-title">{{user.partnerName}}</view>
					</view>
					<view class="dix">
						<text class="baizi" v-if="user.isWorking == 1">营业中</text>
							<text class="baizi" v-if="user.isWorking == 0">休息中</text>
							<switch :checked="isWorking" @change="getying()" color="#3CBC6F" style="transform:scale(0.7)"/>
					</view>
				</view> -->

<!--				<view class="threebox">-->
<!--					&lt;!&ndash; @click="gostatistics()" &ndash;&gt;-->
<!--					<view class="t-box">-->
<!--						<view class="xbai">合规合格</view>-->
<!--						<view class="dbai">{{threenum.hgNum}}</view>-->

<!--					</view>-->
<!--					<view class="t-box">-->
<!--						<view class="xbai">当日订单</view>-->
<!--						<view class="dbai">{{threenum.todayOrderNum}}</view>-->

<!--					</view>-->
<!--					<view class="t-box">-->
<!--						<view class="xbai">双燃料合格</view>-->
<!--						<view class="dbai">{{threenum.srlNum}}</view>-->

<!--					</view>-->
<!--				</view>-->
				<!-- 	<view class="threebox" @click="gocode">
					扫一扫
				</view> -->

				<!-- 订单 -->
				<view class="t-bottom">
					<view class="x-title">信息上传</view>
					<view class="fourbox">
						<view class="f-box" @click="gorelease()">
							<view class="jgbox">
								<image src="../../static/detection/fbsp.png" mode=""></image>
							</view>
							<text class="h-text">发布商品</text>
						</view>
						<view class="f-box" @click="goorder()">
							<view class="jgbox">
								<image src="../../static/detection/spgl.png" mode=""></image>
							</view>
							<text class="h-text">商品管理</text>
						</view>
						<view class="f-box" @click="goordermanage()">
							<view class="jgbox">
								<image src="../../static/detection/ddgl.png" mode=""></image>
							</view>
							<text class="h-text">订单管理</text>
						</view>
						<view class="f-box" @click="goyggl()">
							<view class="jgbox">
								<image src="../../static/detection/shgl.png" mode=""></image>
							</view>
							<text class="h-text">员工管理</text>
						</view>
						<view class="f-box" @click="gocode">
							<view class="jgbox">
								<image src="../../static/detection/ddhx.png" mode=""></image>
							</view>
							<text class="h-text">订单核销</text>
						</view>

						<view class="f-box" @click="reservations()">
							<view class="j-icon" v-if="appAndPick.appointNum != 0">
								<text>{{appAndPick.appointNum }}</text>
							</view>
							<view class="jgbox">
								<image src="../../static/detection/hxjl.png" mode=""></image>
							</view>
							<text class="h-text">预约记录</text>
						</view>
						<view class="f-box" @click="coupon()">
							<view class="jgbox">
								<image src="../../static/detection/yhq.png" mode=""></image>
							</view>
							<text class="h-text">优惠券</text>
						</view>

						<view class="f-box" @click="gohomecar()">
							<view class="j-icon" v-if="appAndPick.pickNum != 0">
								<text>{{appAndPick.pickNum }}</text>
							</view>
							<view class="jgbox">
								<image src="../../static/detection/xxxxx.png" mode=""></image>
							</view>
							<text class="h-text">上门取车</text>
						</view>

            <view class="f-box" @click="goPresent">
              <view class="j-icon" v-if="appAndPick.pickNum != 0">
                <text>{{appAndPick.pickNum }}</text>
              </view>
              <view class="jgbox" style="width: 32px;height: 32px">
                <image src="../../static/detection/present.png" mode=""></image>
              </view>
              <text class="h-text">使用说明</text>
            </view>
					</view>
				</view>

				<view class="bottom-box" style="margin-top: 10px;">
					<view class="x-title">当日订单信息</view>
					<view class="x-top">
						<view class="dix-zuo">车型</view>
						<view class="dix-you">
							<view class="zuo">销量</view>
							<view class="you" style="text-align: left;">营业额</view>
						</view>
					</view>
					<view class="x-cont" v-for="(item,index) in ping" :key="index" @click="gosb()">
						<view class="dix-zuo">
							<view class="paim" v-if="index != 0 && index != 2 && index != 1">{{index+1}}</view>
							<view class="v-icon" v-if="index == 0">
								<image src="../../static/detection/dy.png" mode=""></image>
							</view>
							<view class="v-icon" v-if="index == 1">
								<image src="../../static/detection/dr.png" mode=""></image>
							</view>
							<view class="v-icon" v-if="index == 2">
								<image src="../../static/detection/ds.png" mode=""></image>
							</view>
							<view class="paim-you">{{item.goodsName}}</view>
						</view>
						<view class="dix-you">
							<view class="jzuo">{{item.salesNum}}</view>
							<view class="ju">￥{{item.salesAmount / 100}}</view>
						</view>
					</view>
				</view>
			</view>

		</view>
		<!-- 底部 -->
		<view style="width: 100%; height: 50px;"></view>
		<!-- 	<tabBar :msg="msg " ></tabBar> -->
	</view>
</template>

<script>
	import config from '@/config'
	import request from '../../utils/request';
	import tabBar from '../../components/tabBar/tabBar.vue'
	export default {
		data() {
			return {
				msg: '1',
				chuan: '',
				isWorking: false,
				user: {},
				baseUrl: '',
				animate: false,
				partnerId: '',
				threenum: {},
				showScroll: true,
				scrollDuration: 3000, // 滚动间隔时间，单位为毫秒
				items: [],
				ping: [],
				appAndPick: {
					appointNum: 0,
					pickNum: 0
				},
        present: {},
			}
		},
		onLoad() {
			this.baseUrl = this.$baseUrl
			this.startScrolling();
      this.getPresent()
		},
		onShow() {
			this.getindex()
			this.getAppointAndPickNum()
			this.getbottom()
		},
		components: {
			tabBar,
		},
		methods: {
      goPresent(){
        if (!this.present){
          uni.showToast({
            title: '暂无使用说明',
            icon: 'none'
          })
          return
        }
        let old = this.present.filePath
        if (old[0] !== '/'){
          old = "/" + old
        }
        uni.downloadFile({
          url: this.$baseImageUrl+old,
          success: function (res) {
            var filePath = res.tempFilePath;
            uni.openDocument({
              filePath: filePath,
              showMenu: true,
              success: function (res) {
              }
            });
          }
        });
      },
      getPresent(){
        request({
          url: '/inspectionFile/inspectionFile/getPresent',
          method: 'get'
        }).then(res => {
          if (res.data){
            this.present = res.data
          }
        })
      },
			async getAppointAndPickNum() {
				let res = await request({
					url: '/partnerOwn/partner/getAppointAndPickNum',
					method: 'get'
				})
				if (res.code == 200) {
					this.appAndPick = res.data
				}
			},

			// 底部消息
			async getbottom() {
				let data = {
					partnerId: uni.getStorageSync('partnerId')
				}
				let res = await request({
					url: '/appInspection/news/newMsgNum',
					method: 'get',
					params: data
				})
				if (res.code == 200) {
					this.chuan = res.data
				}
			},
			//初始化获取
			async getindex() {
				// 首页信息
				let res = await request({
					url: '/partnerOwn/partner/shopInfo',
					method: 'get',
				})
				this.user = res.data
				this.partnerId = res.data.partnerId
				uni.setStorageSync('partnerId', res.data.partnerId)
				if (res.data.isWorking == "0") {

					this.isWorking = false
				}
				if (res.data.isWorking == "1") {
					this.isWorking = true
				}
				// 中间统计
				let reszj = await request({
					url: '/partnerOwn/partner/statisticsInfo?partnerId=' + this.partnerId,
					method: 'get',
				})
				let nums = {
					orderAmount: reszj.data.orderAmount / 100,
					orderNum: reszj.data.orderNum,
					todayOrderAmount: reszj.data.todayOrderAmount / 100,
					todayOrderNum: reszj.data.todayOrderNum,
					workedNum: reszj.data.workedNum,
					workingNum: reszj.data.workingNum,
					srlNum: reszj.data.srlNum,
					hgNum: reszj.data.hgNum,

				}
				this.threenum = nums

				// 热销产品
				let resrx = await request({
					url: '/partnerOwn/partner/hotGoodsList?partnerId=' + this.partnerId,
					method: 'get',
				})
				this.ping = resrx.data
				// this.getswitch()
			},
			gosb() {
				uni.navigateTo({
					url: '/pages/index/ordermanage'
				})
			},
			getback() {
				uni.navigateBack()
			},
			gostatistics() {
				uni.navigateTo({
					url: '/pages/statistics/statistics'
				})
			},
			coupon() {
				uni.navigateTo({
					url: '/pages/coupon/coupon'
				})
			},
			goyggl() {
				uni.navigateTo({
					url: '/pages/index/Staffmanagement'
				})
			},
			goordermanage() {
				uni.navigateTo({
					url: "/pages/index/ordermanage",

				})
			},
			reservations() {
				uni.navigateTo({
					url: "/pages/order/reservationlist",

				})
			},

			gohomecar() {
				uni.navigateTo({
					url: "/pages/index/homecar",
				})
			},
			gocode() {
				uni.navigateTo({
					url: "/pages/my/rwm",

				})

			},
			getswitch() {
				if (this.user.isWorking == "0") {
					this.isWorking = false
				}
				if (this.user.isWorking == "1") {
					this.isWorking = true
				}
			},
			async getying() {

				let data = {
					partnerId: this.partnerId
				}
				let res = await request({
					url: '/partnerOwn/partner/startOrEnd',
					method: 'post',
					params: data
				})
				this.getindex()
			},
			goorder() {
				uni.navigateTo({
					url: '/pages/order/order'
				})
			},
			gorelease() {
				uni.navigateTo({
					url: '/pages/Tollannouncement/Tollannouncement'
				})
			},
			startScrolling() {
				this.showScroll = true;
				setInterval(() => {
					this.scrollItems();
				}, this.scrollDuration);
			},
			scrollItems() {
				this.items.push(this.items.shift());
			}
		}
	}
</script>

<style scoped lang="scss">
	.content {
		box-sizing: border-box;
		width: 100%;
		height: 100%;
		height: calc(160vh);
		background-color: #F4F4F4;
	}

	.c-top {
		width: 100%;
		height: 283px;
		background-color: cornflowerblue;
		background: url("../../static/detection/mybj.png") center no-repeat;
		background-size: 100% 100%;
		position: relative;
	}

	.top-ail {
		width: 100%;
		box-sizing: border-box;
		padding: 20px;
	}

	.dix {
		display: flex;
		align-items: center;
	}

	.top-two {
		width: 100%;
		display: flex;
		align-items: center;
		justify-content: space-between;
	}

	.bai-title {
		font-size: 20px;
		font-weight: bold;
		color: white;
	}

	.touxiang {
		width: 30px;
		height: 30px;
		border-radius: 50%;
		overflow: hidden;
		background-color: whitesmoke;

		image {
			width: 100%;
			height: 100%;
		}
	}

	.t-title {
		font-size: 18px;
		font-weight: bold;
		color: #FFFFFF;
		margin-left: 5px;
	}

	.baizi {
		font-size: 14px;
		font-weight: 400;
		color: #FFFFFF;
	}

	.threebox {
		width: 100%;
		display: flex;
		justify-content: space-between;
		align-items: center;
		margin-top: 30px;
	}

	.t-box {
		width: 33%;
		text-align: center;
	}

	.xbai {
		font-size: 15px;
		font-weight: 400;
		color: #FFFFFF;
		margin-bottom: 5px;
	}

	.xxbai {
		font-size: 13px;
		font-weight: 400;
		color: #FFFFFF;
		margin-bottom: 15px;

	}

	.dbai {
		font-size: 25px;
		font-weight: 600;
		color: #FFFFFF;
		margin-bottom: 5px;
	}

	.t-bottom {
		width: 100%;
		z-index: 999;
		// height: 141px;
		background: #FFFFFF;
		border-radius: 8px;
		// margin: 0 auto;
		box-sizing: border-box;
		padding: 15px;
		background-color: white;
		margin-top: 8px;
		// position: absolute;
		// bottom: -px;
		// transform: translate(-50%);
		// left: 50%;
	}

	.x-title {
		font-size: 16px;
		font-weight: 600;
		color: #333333;
	}

	.jgbox {
		width: 42px;
		height: 42px;
		background: #EFF2FC;
		border-radius: 50%;
		margin: 0 auto;
		margin-bottom: 5px;
		overflow: hidden;

		image {
			width: 100%;
			height: 100%;

		}
	}

	.f-box {
		width: 25%;
		margin-bottom: 10px;
		text-align: center;
		position: relative;

	}

	.j-icon {
		position: absolute;
		width: 15px;
		height: 15px;
		display: flex;
		align-items: center;
		background: red;
		border-radius: 50%;
		justify-content: center;
		color: white;
		top: 0px;
		right: 10px;
		z-index: 999;
		font-size: 12px;

	}

	.fourbox {
		width: 100%;
		display: flex;
		// justify-content: space-between;
		align-items: center;
		flex-wrap: wrap;
		margin-top: 20px;
	}

	.h-text {
		font-size: 13px;
		font-weight: 400;
		color: #333333;
	}

	.bai-box {
		width: 100%;
		// height: 121px;
		background: #FFFFFF;
		border-radius: 8px;
		margin: 0 auto;

		box-sizing: border-box;
		padding: 15px;
	}

	.hui-box {
		width: 100%;
		background: #E7E8FD;
		border-radius: 8px;
		margin: 0 auto;
		box-sizing: border-box;
		padding: 1px;
		margin-top: 15px;
		margin-bottom: 15px;
		margin-top: 160px;
	}

	.hui-top {
		box-sizing: border-box;
		padding: 15px;
	}

	.l-bai {
		width: 100%;
		height: 220px;
		box-sizing: border-box;
		padding: 15px;
		background: #FFFFFF;
		border-radius: 5px;
		white-space: nowrap;
		overflow: hidden;
	}

	.l-box {
		margin-top: 5px;
		width: 100%;
		border-bottom: 1px solid #EEEEEE;
	}

	.l-text {
		font-size: 15px;
		font-weight: 400;
		color: #333333;
		margin-bottom: 10px;
	}

	.time {
		font-size: 14px;
		font-weight: 400;
		color: #999999;
		margin-bottom: 10px;
	}

	.mubu {
		background-color: #F4F4F4;
		box-sizing: border-box;
		padding: 15px;
		z-index: -9;
	}

	.bottom-box {
		width: 100%;
		background-color: white;
		border-radius: 8px;
		margin: 0 auto;
		box-sizing: border-box;
		padding: 15px;

	}

	.x-top {
		width: 100%;
		display: flex;
		justify-content: space-between;
		align-items: center;
		font-size: 14px;
		font-weight: 400;
		color: #666666;
		margin: 15px auto;
	}

	.x-cont {
		margin: 10px auto;
		width: 100%;
		display: flex;
		justify-content: space-between;
		align-items: center;
	}

	.dix-zuo {
		width: 50%;
		display: flex;

		justify-content: space-between;
	}

	.dix-you {
		width: 50%;
		display: flex;
		align-items: center;
		justify-content: space-between;

		.zuo {
			width: 50%;
			text-align: center;
		}

		.you {
			width: 50%;
			text-align: center;
		}
	}

	.jzuo {
		width: 50%;
		font-size: 15px;
		font-weight: 400;
		color: #333333;
		text-align: center;
	}

	.ju {
		width: 50%;
		text-align: left;
		font-size: 15px;
		font-weight: 400;
		color: #FF571A;
	}

	.paim {
		width: 15%;
		text-align: center;
	}

	.paim-you {
		width: 80%;
	}

	.v-icon {
		width: 30px;
		height: 30px;

		image {
			width: 100%;
			height: 100%;
		}
	}
</style>
