<template>
	<view class="page" :style="{'height':sysHeight}">
		<uni-nav-bar  :fixed="true" background-color="#FFE05C" :border="false" :statusBar="true"   title="我的" />
			<view class="useInfo  flex-row">
				<view class="profileView" @click="goUserInfo">
					<image class="profile" :src="userInfo.avatar  || '/static/logo.png'"></image>
				</view>
				<view class="usermsg flex-col">
					<view class="name">
						<text @click="goUserInfo">{{userInfo.nickName}}</text>
					</view>
					<view class="other flex-row">
						<text @click="goUserInfo">{{userInfo.phonenumber}}</text>
						<u-icon name="arrow-right" color="#333333" size="18"></u-icon>
					</view>
				</view>
			</view>
			<view class="statistics flex-col">
				<view class="statisticsTitle">
					<text >今日业绩统计</text>
				</view>
				<view class="flex-row justify-center ">
					<view class="statisticsItem flex-col ">
						<view class="flex-row justify-center">
							<u-icon name="/static/my/fuwuNmber.png" size="28"></u-icon>
						</view>
						<view class="flex-row justify-center statisticsKey">
							<text>总服务次数（次）</text>
						</view>
						<view class="flex-row justify-center statisticsValue">
							<text>{{staticsData.serviceTotal || 0}}</text>
						</view>
					</view>
					<view class="statisticsItem flex-col ">
						<view class="flex-row justify-center">
							<u-icon name="/static/my/fuwuTimeLong.png" size="28"></u-icon>
						</view>
						<view class="flex-row justify-center statisticsKey">
							<text>总服务金额（元）</text>
						</view>
						<view class="flex-row justify-center statisticsValue">
							<text>{{staticsData.avgServiceTime || 0}}</text>
						</view>
					</view>
				</view>
			</view>
			<view class="list">
				<uni-list>
					<uni-list-item :to="item.to" :title="item.title" showArrow :thumb="item.thumb" thumb-size="medium" :rightText="item.rightText" v-for="(item,index) in group1" :key="index"/>
				</uni-list>
			</view>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				storeId:'',
				userInfo:'',
				staticsData:'',
				sysHeight:'',
				group1: [
					{thumb: '/static/my/idcard.png', title: '个人信息', rightText: '', to: '/pages/userInfo/userInfo'}
				],
			}
		},
		onLoad(){

			let sysInfo = uni.getSystemInfoSync()
			this.sysHeight = sysInfo.windowHeight + 'px'
			console.log(this.sysHeight)
		},
		onShow(){
			this.storeId = uni.getStorageSync('storeId')
			this.getUserInfo()
			if (!(this.storeId === '' || this.storeId === null)){
				this.statics()
			}
		},

		methods: {
			goUserInfo(){
				uni.navigateTo({
					url: '/pages/userInfo/userInfo'
				})
			},

			getUserInfo(){
				this.$api.user.getUserInfo().then(res=>{
					this.userInfo = res.data.data.user
				})
			},


			statics(){
				this.$api.service.statics({
					storeId:this.storeId
				}).then(res=>{
					this.staticsData = res.data.data
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	@import './index.rpx.css';
</style>
