<template>
	<view class="topbg" @tap="gourl" data-url="../index"></view>
	<view :style="{height:header_statusbar_height+'px'}"></view>
	<view style="padding-top:1em;">
		<view class="avartop">
			<image :src="file_stor(me.icon?me.icon:'/avar/1.png')" mode="scaleToFill" />
		</view>
	</view>

	<view class="maincard" style="margin-top: -2.5em;">
		<view class="flex flex-center">
			<view class="nick" @tap="gourl" data-url="$/pages/me/user_info">{{me.name?me.name:'登录/注册'}}</view>
			<view class="icon zy" style="margin-left:1em;" v-if="showbalance" @tap="getbalance(2)"></view>
			<view class="icon by" style="margin-left:1em;" v-else @tap="getbalance(1)"></view>
		</view>
		<view class="usrnum">
			<view>
				<view class="num" v-if="showbalance">
					<ciy-shownum :value="me.money" unit=",100,2|万,1000000,3|亿,10000000000,3"></ciy-shownum>
				</view>
				<view class="num" v-else>---</view>
				<view class="tit" data-url="$/pages/xx/me_cash" @tap="gourl">钱包</view>
			</view>
			<view>
				<view class="num" v-if="showbalance">
					<ciy-shownum :value="me.mypnt" unit=",1,0|万,10000,2|亿,100000000,2"></ciy-shownum>
				</view>
				<view class="num" v-else>---</view>
				<view class="tit" data-url="$/pages/xx/me_pnt" @tap="gourl">积分</view>
			</view>
		</view>
	</view>
	<view class="maincard">
		<view class="ciy-grid">
			<view class="grid">
				<view class="icon">
					<ciy-svgimg :src="ciysvg"></ciy-svgimg>
				</view>
				<view class="name">图标名称</view>
			</view>
			<view class="grid">
				<view class="icon">
					<ciy-svgimg src="/img/demo.svg"></ciy-svgimg>
				</view>
				<view class="name">图标名称</view>
			</view>
			<view class="grid">
				<view class="icon">
					<ciy-svgimg src="/img/face.png"></ciy-svgimg>
				</view>
				<view class="name">图标名称</view>
			</view>
			<view class="grid">
				<view class="icon">
					<ciy-svgimg :src="ciysvg"></ciy-svgimg>
				</view>
				<view class="name">图标名称</view>
			</view>
		</view>
	</view>
	<view style="margin:1em;border-radius: 0.5em;overflow: hidden;border:1px solid var(--bg6);">
		<ciy-swipelist title="我的消息" right="通知" reddot="13"></ciy-swipelist>
		<ciy-swipelist title="修改密码" @tap="gourl" data-url="/pages/xx/chgpass" noborder more></ciy-swipelist>
	</view>
	<ciy-swipelist title="绑定手机号" right="131222200**" style="border-top:1px solid var(--bg6);"></ciy-swipelist>
	<ciy-swipelist title="修改密码" @tap="gourl" data-url="/pages/xx/chgpass" more></ciy-swipelist>
	<ciy-swipelist title="版本号" @tap="upver" :right="version"></ciy-swipelist>
	<ciy-swipelist title="重新登录" @tap="relogin" more></ciy-swipelist>
	<ciy-swipelist title="退出" @tap="logout" more></ciy-swipelist>
	<ciy-tabbar ref="tabbar"></ciy-tabbar>
</template>

<style>
	.topbg {
		height: 10em;
		overflow: hidden;
		position: absolute;
		top: 0;
		left: 0;
		right: 0;
	}

	.topbg::before {
		content: '';
		left: -5em;
		right: -5em;
		border-radius: 0 0 100vw 100vw;
		height: 100%;
		background: linear-gradient(60deg, var(--e-userbg1), var(--e-userbg2));
		position: absolute;
		top: 0;
		pointer-events: none;
		z-index: 0;
	}

	.avartop {
		position: relative;
		display: flex;
		margin: 0 0 0 1.5em;
		width: 5em;
		height: 5em;
		border-radius: 50%;
		background: var(--bg2);
		border: 2px solid var(--bg1);
		overflow: hidden;
		z-index: 3;
	}

	.avartop>image {
		width: 100%;
		height: 100%;
	}

	.maincard {
		position: relative;
		background: var(--bg1);
		color: var(--txt6);
		min-height: 7em;
		padding: 0.5em;
		margin: 0 1em 1em 1em;
		border-radius: 0.3em;
		box-shadow: 0 4px 8px var(--bg6);

	}

	.maincard .nick {
		font-size: 1.2em;
		font-weight: bold;
		padding-left: 4.5em;
	}

	.usrnum {
		padding-top: 1em;
		padding-bottom: 0.5em;
		display: flex;
	}

	.usrnum>view {
		flex: 1;
		text-align: center;
	}

	.usrnum .num {
		height: 2.5rem;
		padding-top: 0.2rem;
		font-size: 1.3em;
	}

	.usrnum .tit {
		font-size: 0.9em;
	}

	.icon {
		width: 1.5em;
		height: 1.5em;
	}

	.icon.by {
		background-image: url("data:image/svg+xml;base64,PHN2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ExMzYgNTEyIDM3NS4zMTEzNnoiIGZpbGw9IiM2NjY2NjYiPjwvcGF0aD48L3N2Zz4=");
	}
</style>

<script>
	export default {
		data() {
			return {
				version: '',
				showbalance: false,
				ciysvg: '<svg viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg"><path d="M987.136 384.512C919.552 131.584 668.16-22.528 415.232 27.136c219.648-41.984 434.176 79.36 488.96 283.136 57.344 214.016-82.944 437.76-313.344 499.2-49.664 13.312-78.848 64-65.536 113.152 13.312 49.664 64 78.848 113.152 65.536 263.168-70.144 418.816-340.48 348.672-603.648zM116.224 713.216C58.88 499.2 199.68 275.456 430.08 214.016c49.664-13.312 78.848-64 65.536-113.152C482.816 51.2 432.128 21.504 382.464 34.816c-263.68 70.656-419.84 340.992-349.184 604.16 67.584 252.928 319.488 407.04 571.392 356.864-219.648 42.496-433.664-78.848-488.448-282.624z m93.184-203.776L291.84 449.536c44.544-32.256 90.112-32.256 133.12-0.512l83.456 60.928-149.504-230.4-149.504 229.888z m516.096-60.416L808.96 509.952l-149.504-229.888-149.504 229.376 82.432-59.904c44.544-32.256 90.112-32.256 133.12-0.512z m-366.08 291.84L441.856 680.96c44.544-32.256 90.112-32.256 133.12-0.512l83.456 60.928-149.504-230.4-149.504 229.888z" fill="#56a4ef"></path></svg>',
			}
		},
		onLoad() {
			var app = getApp();
			this.version = app.globalData._version;
		},
		onShow() {
			this.getinit();
		},
		methods: {
			async getinit() {},
			async getbalance(act) {
				if (act == 2) {
					this.showbalance = false;
					return;
				}
				this._loading = true;
				var retjson = await this.callfunc({
					func: 'me.balance_get',
					data: {}
				});
				this._loading = false;
				if (retjson.code != 1)
					return this.alert(retjson.errmsg);
				this.showbalance = true;
				this.me = this.objdeepmerge(this.me, retjson.user);
				this.setstorage('me', this.me);
			},
			upver() {
				var app = getApp();
				app.appupdate('all', async verinfo => {
					return await this.askmsg(verinfo, '更新') == 'ok';
				});
			},
			relogin() {
				this.getauth('relogin');
			},
			logout() {
				this.removestorage('me');
				this.me = {
					id: 0
				};
			}
		}
	}
</script>