<template>
	<view>
		<view class="user-header" v-if="userInfo">
			<view class="avatar-btn">
				<image :src="userInfo?userInfo.avatar:'https://inmei-print.oss-cn-guangzhou.aliyuncs.com/logo.png'"></image>
			</view>
			<view class="user-info">
				<view class="name">{{userInfo.nickname}}</view>
			</view>
		</view>
		<view class="user-header" v-else>
			<view class="avatar-btn">
				<image src="https://inmei-print.oss-cn-guangzhou.aliyuncs.com/logo.png"></image>
			</view>
			<view class="user-info">
				<view class="name" @click="toLogin">请先登录</view>
			</view>
		</view>
		<view class="user-menu">
			<!-- <view class="menu-item">
				<view class="icon"><image src="/static/image/info.png"></image></view>
				<view class="name">个人信息</view>
				<view class="right"><image src="/static/image/right.png"></image></view>
			</view> -->
			<navigator hover-class="none" url="/pages/user/address?type=1" class="menu-item">
				<view class="icon"><image src="/static/image/address.png"></image></view>
				<view class="name">会员地址</view>
				<view class="right"><image src="/static/image/right.png"></image></view>
			</navigator>
			<!-- <view class="menu-item" @click="showService()">
				<view class="icon"><image src="/static/image/service.png"></image></view>
				<view class="name">客服</view>
				<view class="right"><image src="/static/image/right.png"></image></view>
			</view> -->
			<navigator hover-class="none" class="menu-item" url="/pages/user/license">
				<view class="icon"><image src="/static/image/zizhi.png"></image></view>
				<view class="name">服务资质</view>
				<view class="right"><image src="/static/image/right.png"></image></view>
			</navigator>
			<view class="menu-item" @click="outLogin">
				<view class="icon"><image src="/static/image/out.png"></image></view>
				<view class="name">退出</view>
				<view class="right"><image src="/static/image/right.png"></image></view>
			</view>
		</view>
	</view>
</template>

<script>
var app;
import * as Api from "@/static/api/user.js";
export default {
	data() {
		return {
			userInfo:null
		}
	},
	onLoad() {
		app = this;
		app.getData()
	},
	methods: {
		getData(){
			Api.info({}).then((res)=>{
				if (res.code == 0) {
					return app.$dialog.showSuccess(res.msg)
				}
				app.userInfo = res.data;
			})
		},
		outLogin(order){
			app.$dialog.showError("确定要退出登录吗",function(res){
				if (res.confirm) {
					app.userInfo = null;
					uni.clearStorageSync();
				}
			})
		},
		callMobile(mobile){
			uni.makePhoneCall({
				phoneNumber:mobile,
				success(res) {
					console.log(res)
				},fail(res) {
					console.log(res)
				}
			})
		},
		showService(){
			
		}
	}
}
</script>

<style>
page{background-color: #f8f8f8;}
.user-header{background-color: #005bac;padding: 40upx;display: flex;align-items: center;background: linear-gradient(to right, #094d89, #007aff);width: calc(95% - 80upx);margin: 40upx auto;border-radius: 10upx;}
.user-header image{width: 100upx;height: 100upx;border-radius: 100upx;}
.user-header .user-info{margin-left: 20upx;}
.user-header .name{font-size: 32upx;color: #fff;}
.user-header .desc{font-size: 24upx;color: #f8f8f8;margin-top: 20upx;}
.user-menu{width: 95%;margin: 40upx auto;border-radius: 10upx;background-color: #fff;}
.user-menu .menu-item{height: 100upx;line-height: 100upx;display: flex;align-items: center;font-size: 28upx;color: #333;padding: 0 20upx;border-bottom: 2upx solid #f8f8f8;}
.user-menu .menu-item .icon{margin-right: 20upx;display: flex;align-items: center;justify-content: center;}
.user-menu .menu-item .right{margin-right: 0;margin-left: auto;}
.user-menu .menu-item .icon image{width: 40upx;height: 40upx;}
.user-menu .menu-item .right image{width: 40upx;height: 40upx;}

.service-popup .item{height: 100upx;line-height: 100upx;text-align: center;font-size: 28upx;color: #333;border-bottom: 2upx solid #f8f8f8;}
.service-popup .item .btn{background-color: #fff;border: 0;height: 100upx;line-height: 100upx;text-align: center;font-size: 28upx;color: #333;}
.service-popup .item .btn::after{border: 0;}
.service-popup .foot{height: 100upx;line-height: 100upx;text-align: center;font-size: 28upx;color: #333;border-top: 20upx solid #f8f8f8;}
</style>
