<template>
	<view class="mine">
		<statusBar />
		<view class="p30">
			<view class="mine_header">
				<view class="mine_header_img">
					<up-avatar size="150rpx" :src="info.avatar"></up-avatar>
				</view>
				<!-- <image :src="info.avatar" class="mine_header_img" mode="aspectFill"></image> -->
				<view class="mine_header_user">
					<view>{{ info.nickName }}</view>
					<view>{{ info.phone || '' }}</view>
				</view>
				<image class="mine_header_sett" @click="toEarnings" src="/static/icon/sett.png"></image>
			</view>
			<view class="mine_money">
				<view class="flex-acsb flex1 mine_money_top" style="width: 100%">
					<view class="mine_money_left" @click="navTo('/pages/mine/incomeList')">
						<view>{{ info.balance || 0 }}</view>
						<view>钱包余额</view>
					</view>
					<view class="mine_money_left" @click="navTo('/pages/mine/incomeList')">
						<view>0</view>
						<view>赠送余额</view>
					</view>
				</view>
				<view class="flex1 mine_money_bottom" style="display: flex; align-items: center">
					<!-- class="mine_money_right" -->
					<!-- class="mine_money_right" -->
					<view @click="navTo(`/pageMake/refund/refund?balance=${info.refundableAmount}`)">退款</view>
					<view @click="navTo('/pages/money/recharge')">充值</view>
				</view>
			</view>

			<view class="mine_grid">
				<view class="mine_grid_tit">常用功能</view>
				<view class="mine_grid_views">
					<view class="mine_grid_views_block" v-for="(item, index) in gridList" :key="index" @click="nav(item)">
						<image :src="item.img" mode="widthFix"></image>
						<view>{{ item.name }}</view>
					</view>
				</view>
			</view>

			<!-- 			<view class="mine_fun">
				<view class="mine_fun_view" @click="navTo('/pages/mine/card')">
					<image class="mine_fun_view_left" src="/static/icon/ka.png"></image>
					<view class="mine_fun_view_name">充电卡</view>
					<image class="mine_fun_view_right" src="/static/icon/9you.png" mode="widthFix"></image>
				</view>
			</view> -->
		</view>

		<view style="width: 100%; height: 100vh; background: #f7f7f7; position: absolute; top: 0; left: 0; z-index: -1"></view>

		<cc-myTabbar :tabBarShow="4"></cc-myTabbar>
		<!-- <tabbar path="/pages/mine/mine"></tabbar> -->
	</view>
</template>

<script setup>
import { onShow } from '@dcloudio/uni-app';
import { userInfo } from '@/api/api.js';
import { ref } from 'vue';
import { useNav } from '@/hooks/useNav.js';
const { nav, navTo } = useNav();
let info = ref({});

let gridList = ref([
	{
		name: '我的电卡',
		img: '/static/icon/dk_mine.png',
		path: '/pages/mine/card',
		type: 'nav'
	},
	{
		name: '充电订单',
		img: '/static/icon/cd_mine.png',
		path: '/pages/order/order',
		type: 'switchTab'
	},
	{
		name: '余额明细',
		img: '/static/icon/ye_mine.png',
		path: '/pages/mine/incomeList',
		type: 'nav'
	},
	{
		name: '客服中心',
		img: '/static/icon/kf_mine.png',
		call: true
	}
]);

onShow(async () => {
	uni.hideTabBar();
	let _res = await userInfo();
	info.value = _res;
});

const toEarnings = () => {
	uni.navigateTo({
		url: './sett'
	});
};
</script>

<style lang="scss" scoped>
.mine {
	&_header {
		@include flex($space: space-between);
		&_img {
			width: 150rpx;
			height: 150rpx;
			// border-radius: 50%;
			margin-right: 15rpx;
		}
		&_user {
			flex: 1;
			view:nth-child(1) {
				font-weight: bold;
				font-size: 32rpx;
				color: #232323;
				margin-bottom: 15rpx;
			}
			view:nth-child(2) {
				font-weight: bold;
				font-size: 44rpx;
				color: #232323;
			}
		}
		&_sett {
			width: 42rpx;
			height: 42rpx;
		}
	}
	&_money {
		margin-top: 35rpx;
		@include flex($direction: column);
		width: 100%;
		// height: 152rpx;
		background: linear-gradient(178deg, #9ab6ff 0%, #4879e6 100%);
		border-radius: 16rpx 16rpx 16rpx 16rpx;
		padding: 20rpx 0rpx 0;

		&_top {
			padding: 0 150rpx;
		}

		&_bottom {
			width: 100%;
			@include flex($space: center);
			border-top: 1rpx solid rgba(255, 255, 255, 0.3);
			margin-top: 20rpx;
			padding: 15rpx 0;
			view {
				width: 50%;
				display: flex;
				align-items: center;
				justify-content: center;
				font-size: 30rpx;
				color: #fff;
			}
		}

		&_left {
			@include flex($direction: column, $space: center);
			view:nth-child(1) {
				font-weight: bold;
				font-size: 48rpx;
				color: #ffffff;
				margin-bottom: 5rpx;
			}
			view:nth-child(2) {
				font-weight: bold;
				font-size: 20rpx;
				color: #ffffff;
			}
		}

		&_right {
			@include flex($space: center);
			width: 124rpx;
			height: 54rpx;
			background: rgba(255, 255, 255, 0.24);
			border-radius: 140rpx 140rpx 140rpx 140rpx;
			font-weight: bold;
			font-size: 24rpx;
			color: #ffffff;
		}
	}

	&_grid {
		width: 100%;
		padding: 20rpx 30rpx;
		background-color: #fff;
		border-radius: 15rpx;
		margin-top: 30rpx;
		&_tit {
			font-size: 30rpx;
			color: #333;
			opacity: 0.8;
		}
		&_views {
			margin-top: 20rpx;
			display: flex;
			flex-wrap: wrap;
			align-items: center;
			justify-content: space-between;
			width: 100%;
			&_block {
				height: 95rpx;
				display: flex;
				flex-direction: column;
				align-items: center;
				justify-content: space-between;
				font-size: 30rpx;
				color: #333;
				image {
					width: 45rpx;
					height: 45rpx;
				}
			}
		}
	}

	&_fun {
		margin-top: 35rpx;
		width: 100%;
		// background: linear-gradient(180deg, #ffffff 0%, #f7f7f7 100%);
		background-color: #fff;
		border-radius: 16rpx 16rpx 16rpx 16rpx;
		padding: 35rpx;

		&_view {
			@include flex($space: space-between);
			margin-bottom: 35rpx;
			&_left {
				width: 58rpx;
				height: 58rpx;
				margin-right: 20rpx;
				// background: #eeeeee;
			}
			&_name {
				flex: 1;
				font-weight: bold;
				font-size: 24rpx;
				color: #232323;
			}
			&_right {
				width: 24rpx;
				height: 24rpx;
			}
		}
	}
}
</style>
