<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.avatarUrl  || '/static/ud4.png'"></image>
				</view>
				<view class="usermsg flex-col">
					<view class="name">
						<text @click="goUserInfo">{{userInfo.name}}</text>
					</view>
					<view class="other flex-row">
						<text @click="goUserInfo">{{userInfo.post}}</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 " @click="goperList(0)">
						<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 statisticsItemBorder flex-col " @click="goperList(1)">
						<view class="flex-row justify-center">
							<u-icon name="/static/my/jinriyeji.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.todayTotal || 0}}</text>
						</view>
					</view>
					<view class="statisticsItem statisticsItemBorder flex-col "@click="goperList(2)">
						<view class="flex-row justify-center">
							<u-icon name="/static/my/benyueyeji.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.monthTotal || 0}}</text>
						</view>
					</view>
				</view>
			</view>

			<view class="tuoke ">
				<view class="statisticsTitle ">
					<text >拓客统计</text>
				</view>
				<view class="flex-row justify-center ">
					<view class="statisticsItem flex-col" :style="{'width':'50%'}">
						<view class="flex-row justify-center">
							<u-icon name="/static/my/jinrirenwu.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.todayTask || 0}}</text>
						</view>
					</view>

					<view class="statisticsItem statisticsItemBorder flex-col" :style="{'width':'50%'}">
						<view class="flex-row justify-center">
							<u-icon name="/static/my/benyuerenwu.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.finishTask || 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()
			this.statics()
		},

		methods: {
			goperList(index){
				uni.navigateTo({
					url:"/pages/performanceList/performanceList?index="+ index
				})
			},
			goUserInfo(){
				uni.navigateTo({
					url: '/pages/userInfo/userInfo'
				})
			},

			getUserInfo(){
				this.$api.user.getUserInfo().then(res=>{
					this.userInfo = res.data.data
					uni.setStorageSync('userInfo', this.userInfo )
					if (this.userInfo.avatar){
						this.getImgUrlByOssId(this.userInfo.avatar)
					}
				})
			},

			getImgUrlByOssId(ossId){
				this.$api.service.getImgUrlByOssId({ossId:ossId}).then(res=>{
					this.$set(this.userInfo,'avatarUrl', res.data.data[0].url.replace(/^http:/, "https:"))
					uni.setStorageSync('userInfo', this.userInfo )
				})
			},


			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>
