<template>
	<view class="">
		<view class="index_personal bg-rgba-255 r-20 bor-f1 row-justify-sb center p-40">
			<view class="center">
				<image class="wh-100 r-circle" v-if="!memberData.head_img" src="/static/img/index/index-avatar.png" mode="aspectFill">
				<image class="wh-100 r-circle" v-else :src="memberData.head_img" mode="aspectFill">
				</image>
				<view class="m-l20">
					<text class="text-color-fff">HI，{{ memberData.name ? memberData.name : memberData.nickname }}</text>
					<view class="text-color-fff size-24 text-center r-20 line-30 p-tb6 p-lr20 m-t10 "
						style="background-color: rgba(0, 0, 0, 0.2);opacity: 0.6;">
						{{memberData.position_name?memberData.position_name:'无'}}
					</view>
				</view>
			</view>
			<image class="wh-80 r-circle is-hover" src="/static/img/index/index-system.png" @click="onSystemShow">
			</image>
		</view>
		<uni-popup background-color="#fff" ref="popup" type="left" border-radius="10px 10px 0 0"
			@touchmove.stop.prevent="moveHandle">
			<SystemPopup ref="system" :member-data="memberData" ></SystemPopup>
		</uni-popup>
	</view>
</template>

<script>
	import SystemPopup from "@/common/system_popup/system_popup.vue"
  import {getMemberInfo} from "@/api/user";

	export default {
		name: 'index_personal',
		components: {
			SystemPopup
		},
		props: {
			is_admin: {
				type: Boolean,
				default: true
			},
			data: {
				type: Object,
				default: () => {}
			},
		},
    data(){
      return{
        memberData: {
          position_name: "",
          head_img: "",
          id: 5,
          name: "",
          nickname: "",
          phone: "",
          status: 1,
          user_type: 1,
          accomplish_num: 0,
          take_num: 0,
          manage_num: 0,
          use_num: 0,
          end_num: 0,
          grand_num: 0,
        },
      }
    },
    mounted() {
      this.getMemberInfo();
      uni.$on('updateMemberInfo', () => {
        this.getMemberInfo();
      })
    },
		methods: {
      getMemberInfo() {
        getMemberInfo({
          'type': 1
        }).then((res) => {
          if (res.code === 1) {
            this.memberData = res.data;
            uni.setStorageSync('receivingType', res.data.receivingType)
            uni.setStorageSync('enteringType', res.data.enteringType)
            this.$emit('setMemberData',this.memberData)
          }
        })
      },
			onSystemShow() {
				this.$refs.popup.open('left')
			},
			moveHandle() {
				return false
			},
		}
	}
</script>

<style>
	.index_personal {
		box-shadow: 0 0 5px rgba(0, 0, 0, 0.2);
	}
</style>