<template>
	<view class="content">

		<view class="top_">
			<view class="logo_imgs">
				<image src="/static/imgs/logo.png" mode=""></image>
			</view>
			<view class="t_box">
				<view class="d_s">
					<view class="picture_">
            <image @click="showUserDetail" style="width: 104rpx;height: 104rpx;border-radius: 50%;"
                   v-if="userInfo && userInfo.avatar === null" :src="defaultAvatar" mode="scaleToFill" @error="avatarErr"></image>
            <image @click="showUserDetail" style="width: 104rpx;height: 104rpx;border-radius: 50%;" v-else
                   :src="userInfo.avatar" mode="scaleToFill" @error="avatarErr"></image>
					</view>
					<view class="">
						<view class="name_">
              {{ userInfo.nickname }}
						</view>
						<view class="bqing_">{{ userInfo.roleNames }}</view>
					</view>
				</view>
				<view class="d_s">
					<view class="icon1" @click="goNotice()">
						<image src="/static/imgs/xiaoxi.png" mode=""></image>
					</view>
					<view class="icon1">
						<image src="/static/imgs/gengduo.png" mode=""></image>
					</view>
				</view>

			</view>
		</view>
		<view class="three_">
			<view class="three_box1">
				<view class="">当日订单</view>
				<view class="num_">{{ threenum.todayOrderNum }}</view>
			</view>
			<view class="three_box2">
				<view class="">合规合格</view>
				<view class="num_">{{ threenum.hgNum }}</view>
			</view>
			<view class="three_box3">
				<view class="">双燃料合格</view>
				<view class="num_">{{ threenum.srlNum }}</view>
			</view>

		</view>
		<view class="hang_"></view>
		<view class="jg_box">
			<view class="jg_top">2024-12-30 星期一 11:05</view>
			<view class="jg_ds">
				<view class="jg_ys">
					<image src="/static/imgs/jg1.png" mode="" @click="goordermanage"></image>
					<view class="">订单管理</view>
				</view>
				<view class="jg_ys">
					<image src="/static/imgs/jg2.png" mode=""></image>
					<view class="">业务统计</view>
				</view>
				<view class="jg_ys">
					<image src="/static/imgs/jg3.png" mode=""></image>
					<view class="">通知公告</view>
				</view>
				<view class="jg_ys" @click="goInternalManagement">
					<image src="/static/imgs/jg4.png" mode=""></image>
					<view class="">内部管理</view>
				</view>
				<view class="jg_ys" @click="show =!show">
					<image src="/static/imgs/jg5.png" mode=""></image>
					<view class="">更多功能</view>
				</view>
			</view>
			<view class="jg_bt" v-if="show">
				<view class="jg_ys1">
					<image src="/static/imgs/jg6.png" mode=""></image>
					<view class="">发布商品</view>
				</view>
				<view class="jg_ys1">
					<image src="/static/imgs/jg7.png" mode=""></image>
					<view class="">商品管理</view>
				</view>
				<view class="jg_ys1">
					<image src="/static/imgs/jg8.png" mode=""></image>
					<view class="">订单核销</view>
				</view>
				<view class="jg_ys1">
					<image src="/static/imgs/jg9.png" mode=""></image>
					<view class="">优惠券</view>
				</view>
				<view class="jg_ys1">
					<image src="/static/imgs/jg10.png" mode=""></image>
					<view class="">使用说明</view>
				</view>
			</view>
		</view>
		<view class="hang_"></view>
		<view class="list_">
			<view class="title_">预约记录</view>
			<view class="box_" v-for="(item,index) in 10" :key="index">
				<view class="box_ds">
					<view class="box_title">小型汽车（含5座）</view>
					<image src="/static/imgs/ns.png" style="width: 88rpx; height: 44rpx; " mode=""></image>
				</view>
				<view class="box_bd">
					<view class="box_ds">
						<image src="/static/imgs/car.png" style="width: 36rpx; height: 36rpx; " mode=""></image>
					<view class="size_">车牌号：鲁A00000</view>
					</view>
					<image src="/static/imgs/tel.png" style="width: 36rpx; height: 36rpx; " mode=""></image>
				</view>
				<view class="bd">
					<view class="left_">预约人</view>
					<view class="right_">王五</view>
				</view>
				<view class="bd">
					<view class="left_">电话</view>
					<view class="right_">128 1234 5678</view>
				</view>
				<view class="bd">
					<view class="left_">预约时间</view>
					<view class="right_">2025年01月01日</view>
				</view>
				<view class="bd">
					<view class="left_">客户来源</view>
					<view class="right_">代办</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
import {getStorageWithExpiry, setStorageWithExpiry} from "@/utils/auth";
import request from "@/utils/request";
import config from "@/config";

export default {
		data() {
			return {
				titles: "首页",
				msg: "1",
				List: [],
				show: false,
				status: 'loading',
        warnMsg: [],
        chuan: '',
        titlemodeal: '通知',
        isWorking: false,
        user: {},
        baseUrl: '',
        animate: false,
        partnerId: '',
        threenum: {},
        showScroll: true,
        scrollDuration: 3000, // 滚动间隔时间，单位为毫秒
        items: [],
        ping: [],
        dateStr: '',
        week: '',
        is_mandatory: false,
        url: 'http://159.75.168.143:88/apk/lanan.apk',
        title: '版本升级',
        contents: '新版本上线了，根据您自己的选择是否升级',
        appAndPick: {
          appointNum: 0,
          pickNum: 0
        },
        baseImageUrl: this.$baseImageUrl,
        noReadNum: 1,
        userInfo: {},
        defaultAvatar: require('@/static/icons/avatar.png'),
			}
		},
		onShow() {
			// this.actList = ["1", "1", "1", "1", "1", ]
			// this.status = "nomore" 底部刷新结束
      this.getUserInfo()
      this.getindex()
      // this.getwarnMsglist()
      this.getbottom()
      this.getUserInfo()
      this.getWarnCount()
      this.getAppointAndPickNum()
		},
		onPullDownRefresh() {
			console.log("刷新");
			uni.stopPullDownRefresh()
		},
		onReachBottom() {
			// this.show = true
			setTimeout(() => {
				console.log("加载执行");
			}, 2000)
		},

		methods: {
			goInternalManagement(){
				uni.navigateTo({
					url:'/pages/manage/internalManagement'
				})
			},
      goordermanage(){
        uni.navigateTo({
          url:'/pages/index/ordermanage'
        })
      },
			goNotice(){
				uni.navigateTo({
					url:'/pages/notice/notice'
				})
			},
			goback() {
				uni.navigateBack()
			},
      showUserDetail(){
        uni.navigateTo({
          url: '/pages/index/UserInfo'
        })
      },
      avatarErr(err) {
        console.log('err', err)
        this.userInfo.avatar = this.defaultAvatar
      },
      getUserInfo() {
        let roleNames = getStorageWithExpiry("roleNames")
        if (!roleNames){
          request({
            url: '/inspection/util/getRoleName',
            method: 'get'
          }).then(res => {
            roleNames = res.data
            setStorageWithExpiry("roleNames", roleNames)
          })
        }
        const data = getStorageWithExpiry("userInfo")
        if (!data) {
          request({
            url: '/system/user/profile/get',
            method: 'get'
          }).then(res => {
            this.userInfo = res.data
            if (this.userInfo.avatar) {
              this.userInfo.avatar = config.baseImageUrl + this.userInfo.avatar
            }
            this.userInfo.roleNames = roleNames
            setStorageWithExpiry("userInfo", this.userInfo)
          })
        } else {
          this.userInfo = data
        }
      },
      getWarnCount(){
        request({
          url: '/warnMsg/warnMsg/getCount',
          method: 'get',
        }).then(res => {
          if (res.data){
            this.noReadNum = 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 resxf = await request({
        // 	url:'/partnerOwn/partner/orderInfo?partnerId='+this.partnerId,
        // 	method: 'get',
        // })
        // this.items = resxf.data
        // 热销产品
        let resrx = await request({
          url: '/partnerOwn/partner/hotGoodsList?partnerId=' + this.partnerId,
          method: 'get',
        })
        this.ping = resrx.data
        // this.getswitch()
      },
		}
	}
</script>

<style scoped lang="scss">
	image {
		width: 100%;
		height: 100%;
	}

	.content {}


	.top_ {
		width: 100%;
		height: 284rpx;
		background: linear-gradient(180deg, #054DF3 0%, #55A3FF 100%);
		box-sizing: border-box;
		padding: 30rpx;
		padding-top: 80rpx;
	}

	.logo_imgs {
		width: 160rpx;
		height: 40rpx;
		margin: 20rpx 0rpx;

	}

	.t_box {
		display: flex;
		align-items: center;
		justify-content: space-between;
	}

	.picture_ {
		overflow: hidden;
		width: 90rpx;
		height: 90rpx;
		border-radius: 50%;
		margin-right: 20rpx;
	}

	.d_s {
		display: flex;

	}

	.name_ {
		font-size: 32rpx;
		color: #FFFFFF;
		margin-bottom: 10rpx;
	}

	.bqing_ {
		border-radius: 16rpx;
		border: 2rpx solid #FFFFFF;
		box-sizing: border-box;
		color: #FFFFFF;
		font-size: 22rpx;

		padding: 2px 5px;
	}

	.icon1 {
		width: 56rpx;
		height: 56rpx;
		margin-left: 30rpx;
	}

	.three_ {
		width: 100%;
		box-sizing: border-box;
		padding: 30rpx;
		display: flex;
		align-items: center;
		justify-content: space-between;
	}

	.jg_box {
		width: 100%;
		box-sizing: border-box;
		padding: 30rpx;
	}

	.list_ {
		width: 100%;
		box-sizing: border-box;
		padding: 30rpx;
	}

	.three_box1 {
		width: 216rpx;
		height: 116rpx;
		background-image: url('/static/imgs/t1.png');
		background-size: 100% 100%;
		box-sizing: border-box;
		padding: 14rpx 18rpx;
		font-size: 24rpx;
		color: #101A3E;

	}

	.three_box2 {
		width: 216rpx;
		height: 116rpx;
		background-image: url('/static/imgs/t2.png');
		background-size: 100% 100%;
		box-sizing: border-box;
		padding: 14rpx 18rpx;
		font-size: 24rpx;
		color: #101A3E;
	}

	.three_box3 {
		width: 216rpx;
		height: 116rpx;
		background-image: url('/static/imgs/t3.png');
		background-size: 100% 100%;
		box-sizing: border-box;
		padding: 14rpx 18rpx;
		font-size: 24rpx;
		color: #101A3E;
	}

	.num_ {
		font-size: 36rpx;
		color: #101A3E;
		margin-top: 20rpx;
	}

	.hang_ {
		width: 100%;
		height: 30rpx;
		background: #F7F8FC;
	}

	.jg_top {
		font-size: 32rpx;
		color: #000000;
		box-sizing: border-box;
		padding-bottom: 30rpx;
		border-bottom: 1px solid #F5F5F5;
	}

	.jg_ds {
		width: 100%;
		display: flex;
		align-items: center;
		justify-content: space-between;
		box-sizing: border-box;
		padding: 30rpx 0rpx;
		border-bottom: 1px solid #F5F5F5;
	}

	.jg_bt {
		width: 100%;
		display: flex;
		align-items: center;
		justify-content: space-between;
		box-sizing: border-box;
		padding: 30rpx 0rpx;
	}

	.jg_ys {
		font-size: 24rpx;
		color: #101A3E;
		text-align: center;

		image {
			width: 80rpx;
			height: 80rpx;
			margin-bottom: 5rpx;
		}
	}

	.jg_ys1 {
		font-size: 24rpx;
		color: #101A3E;
		text-align: center;

		image {
			width: 48rpx;
			height: 48rpx;
			margin-bottom: 5rpx;
		}
	}
	.title_{
		font-size: 32rpx;
		color: #000000;
		margin-bottom: 30rpx;
	}
	.box_{
		width: 100%;
		box-sizing: border-box;
		padding: 30rpx;
		background: #F7F8FC;
		border-radius: 8rpx;
		margin-bottom: 30rpx;

	}
	.box_ds{
		display: flex;
		align-items: center;
	}
	.box_bd{
		display: flex;
		align-items: center;
		justify-content: space-between;
		margin-top: 24rpx;
		box-sizing: border-box;
		padding-bottom: 20rpx;
			border-bottom: 1px solid #E3ECFB;
	}
	.bd{
		display: flex;
		align-items: center;
		justify-content: space-between;
		font-size: 28rpx;
		margin: 20rpx 0rpx;
	}
	.box_title{
		font-size: 32rpx;
		color: #101A3E;
		margin-right: 10rpx;
	}
	.size_{
		font-size: 24rpx;
		color: #366FFF;
		margin-left: 10rpx;

	}
	.left_{
		font-size: 28rpx;
		color: #8D90A6;
	}
	.right_{
		font-size: 28rpx;
		color: #101A3E;
	}
</style>
