<template>
	<view class="container">
	  <view class="header">
	    <view class="left">
	      <image class="avatar" :src="userInfo.img"></image>
	    </view>
	    <view class="right">
	      <view class="user_name" @click="handleUserInfoClick">
	        {{ userInfo.user_name ? userInfo.user_name : '微信用户' }}
	        (ID:{{userInfo.user_id}})
	      </view>
	      <view class="share_poster" @click="handleShareClick">推广海报</view>
	    </view>
	  </view>
	  <!-- 推广下级 -->
	  <view class="main">
	    <view class="item">
	      <view class="text">{{0}}</view>
	      <view class="desc">累计推广下级</view>
	    </view>
	    <view class="item">
	      <view class="text">{{0}}</view>
	      <view class="desc">累计邀请业主</view>
	    </view>
	    <view class="item">
	      <view class="text">{{0}}</view>
	      <view class="desc">累计推广订单</view>
	    </view>
	    <view class="item has-margin-bottom">
	      <view class="text">{{0}}</view>
	      <view class="desc">今日推广下级</view>
	    </view>
	    <view class="item has-margin-bottom">
	      <view class="text">{{0}}</view>
	      <view class="desc">今日邀请业主</view>
	    </view>
	    <view class="item has-margin-bottom">
	      <view class="text">{{0}}</view>
	      <view class="desc">今日推广订单</view>
	    </view>
	  </view>
	  <view class="navigation">功能管理</view>
	  <view class="order">
	    <!-- 功能列表 -->
			<u-grid col="4" :border="false" >
				<u-grid-item  @click="headerOrderClick(item)" v-for="(item, index) in functional_List" :key="index">
					<image class="nav_icon" :src="item.image" mode=""></image>
					<text class="grid-text">{{item.name}}</text>
				</u-grid-item>
			</u-grid>
	  </view>
		
		<nav-footer />
	</view>
</template>

<script>
	import { NavgateTo, picUrl, request } from '../../../utils';
	import { apiArr } from '../../../api/login';
	export default {
		data() {
			return {
				functional_List: [{
						"image": "https://static.hshuishang.com/User/_assets/Group_25.png",
						"name": "推广海报",
						"url": "/packages/user/share/index",
						"type": "h5"
					},
					{
						"image": "https://static.hshuishang.com/User/_assets/Group_26.png",
						"name": "我的下级",
						"url": "",
						"type": "h5"
					},
					{
						"image": "https://static.hshuishang.com/User/_assets/Group_35.png",
						"name": "下级订单",
						"url": "",
						"type": "h5"
					},
					{
						"image": "https://static.hshuishang.com/User/_assets/Group_30.png",
						"name": "联系平台",
						"url": "",
						"type": "h5"
					},
				],
				userInfo: {},
			}
		},
		methods: {
			async init() {
				const res = await request(apiArr.loginInfo, 'POST', {});
				const newRes = {
					...res,
					img: picUrl + res.img || 'https://static.hshuishang.com/person/Group_309.png',
				}
				this.userInfo = newRes;
			},
			
			handleUserInfoClick() {
				NavgateTo('/packages/user/index/index')
			},
			handleShareClick() {
				NavgateTo('/packages/user/share/index')
			},
			
			headerOrderClick(event) {
				console.log('11111', event)
				const { url } = event;
				if (!url) {
					uni.showModal({
						title: '提示',
						content: '此功能暂未开通！',
						showCancel: false,
					})
				} else {
					NavgateTo(url)
				}
			},
			
			
		},
		 onLoad() {
		 	this.init();
		 }
	}
</script>

<style>
	@import url("./index.css");
</style>