<template>
	<view class="content-wrap">
		<view class="head-wrap">
			<view class="content-info">
				<!-- 轮播图 -->
				<view class="head-bg">
					<u-swiper :list="bannerList" :height="340"></u-swiper>
				</view>
				<view class="content">
					<!-- 用户信息 -->
					<view @click="perfectUserInfo()" class="user-info">
						<view class="user-head">
							<image v-if="userInfo.selfPhotoUrl" :src="userInfo.selfPhotoUrl" mode=""></image>
							<image v-else src="../../static/logo.png" mode=""></image>
						</view>
						<view class="h-content">
							<view class="user-name">
								<text>HI,亲爱的{{ userInfo.ncikName }}</text>
							</view>
							<view class="user-desc">
								<view class="h-text">
									<text>你当前的个人资料尚不完善</text>
									<text>去完善</text>
								</view>
								<view class="h-arrow">
									<u-icon name="arrow-right" color="#333333" size="16"></u-icon>
								</view>
							</view>
						</view>
					</view>

					<view class="balance-info">
						<view class="balance-name">
							<text>我的资产</text>
						</view>
						<view class="h-content">
							<view class="button-wrap">
								<view @click="gotoRechargeService()" class="btn">
									<view class="icon">
										<u-icon name="/static/me/u701.png" color="red" size="30"></u-icon>
									</view>
									<view class="h-name">
										<view class="name">
											余额
										</view>
										<view class="num">
											￥{{ userInfo.balance }}
										</view>
									</view>
								</view>
							</view>
							<view class="button-wrap">
								<view @click="gotoIntgral" class="btn">
									<view class="icon">
										<u-icon name="/static/me/u680.png" color="red" size="30"></u-icon>
									</view>
									<view class="h-name">
										<view class="name">
											积分
										</view>
										<view class="num">
											{{ userInfo.integral }}
										</view>
									</view>
								</view>
							</view>
							<view class="button-wrap">
								<view @click="gotoCoupon" class="btn">
									<view class="icon">
										<u-icon name="/static/me/u687.png" color="red" size="30"></u-icon>
									</view>
									<view class="h-name">
										<view class="name">
											优惠券
										</view>
										<view class="num">
											{{ userInfo.coupon }}
										</view>
									</view>
								</view>
							</view>
							<view class="button-wrap">
								<view class="btn">
									<view class="icon">
										<u-icon name="/static/me/u694.png" color="red" size="30"></u-icon>
									</view>
									<view class="h-name">
										<view class="name">
											电子币
										</view>
										<view class="num">
											{{ userInfo.electronicCurrency }}
										</view>
									</view>
								</view>
							</view>
						</view>
					</view>

					<view class="nav-bar">
						<view class="nav-content">
							<view class="nav-info">
								<view class="logo">
									<image src="../../static/me/u1796.png" mode=""></image>
								</view>
								<view class="nav-desc">
									<view class="nav-name">
										<view class="">贡献奖励记录</view>
									</view>
									<view class="change-store"></view>
								</view>
								<view class="arrow-right">
									<u-icon name="arrow-right" color="#666" size="18"></u-icon>
									<!-- <image src="../../static/index/u10.png" mode=""></image> -->
								</view>
							</view>
						</view>
						<view class="custom-line"></view>
						<view @click="gotoRealNameAuth()" class="nav-content">
							<view class="nav-info">
								<view class="logo">
									<image src="../../static/me/u1803.png" mode=""></image>
								</view>
								<view class="nav-desc">
									<view class="nav-name">
										<view class="">实名认证</view>
									</view>
									<view class="change-store">
										<text v-if="userInfo.isAttestation">已认证</text>
										<text v-else>未实名认证，去认证</text>
									</view>
								</view>
								<view class="arrow-right">
									<u-icon name="arrow-right" color="#666" size="18"></u-icon>
									<!-- <image src="../../static/index/u10.png" mode=""></image> -->
								</view>
							</view>
						</view>
						<view class="custom-line"></view>
						<view @click="gotoServiceObjectMgt()" class="nav-content">
							<view class="nav-info">
								<view class="logo">
									<image src="../../static/me/u1812.png" mode=""></image>
								</view>
								<view class="nav-desc">
									<view class="nav-name">
										<view class="">服务对象管理</view>

									</view>
									<view class="change-store"></view>
								</view>
								<view class="arrow-right">
									<u-icon name="arrow-right" color="#666" size="18"></u-icon>
									<!-- <image src="../../static/index/u10.png" mode=""></image> -->
								</view>
							</view>
						</view>
						<view class="custom-line"></view>
						<view class="nav-content">
							<view @click="gotoSystemSwitch()" class="nav-info">
								<view class="logo">
									<image src="../../static/me/u1833.png" mode=""></image>
								</view>
								<view class="nav-desc">
									<view class="nav-name">
										<view class="">新老系统切换</view>

									</view>
									<view class="change-store"></view>
								</view>
								<view class="arrow-right">
									<u-icon name="arrow-right" color="#666" size="18"></u-icon>
									<!-- <image src="../../static/index/u10.png" mode=""></image> -->
								</view>
							</view>
						</view>
						<view class="custom-line"></view>
						<view @click="gotoRechargeService()" class="nav-content">
							<view class="nav-info">
								<view class="logo">
									<image src="../../static/me/u826.png" mode=""></image>
								</view>
								<view class="nav-desc">
									<view class="nav-name">
										<view class="">储值服务</view>
									</view>
									<view class="change-store"></view>
								</view>
								<view class="arrow-right">
									<u-icon name="arrow-right" color="#666" size="18"></u-icon>
									<!-- <image src="../../static/index/u10.png" mode=""></image> -->
								</view>
							</view>
						</view>
					</view>

					<view class="nav-bar">
						<view @click="aboutOur()" class="nav-content">
							<view class="nav-info">
								<view class="logo">
									<image src="../../static/me/u1829.png" mode=""></image>
								</view>
								<view class="nav-desc">
									<view class="nav-name">
										<view class="">关于我们</view>
									</view>
									<view class="change-store"></view>
								</view>
								<view class="arrow-right">
									<u-icon name="arrow-right" color="#666" size="18"></u-icon>
									<!-- <image src="../../static/index/u10.png" mode=""></image> -->
								</view>
							</view>
						</view>
						<view class="custom-line"></view>
						<view @click="perfectUserInfo()" class="nav-content">
							<view class="nav-info">
								<view class="logo">
									<image src="../../static/me/u10.png" mode=""></image>
								</view>
								<view class="nav-desc">
									<view class="nav-name">
										<view class="">个人信息</view>
									</view>
									<view class="change-store"></view>
								</view>
								<view class="arrow-right">
									<u-icon name="arrow-right" color="#666" size="18"></u-icon>
									<!-- <image src="../../static/index/u10.png" mode=""></image> -->
								</view>
							</view>
						</view>
						<view class="custom-line"></view>
						<view @click="gotoSetting()" class="nav-content">
							<view class="nav-info">
								<view class="logo">
									<image src="../../static/me/u101.png" mode=""></image>
								</view>
								<view class="nav-desc">
									<view class="nav-name">
										<view class="">设置</view>
									</view>
									<view class="change-store"></view>
								</view>
								<view class="arrow-right">
									<u-icon name="arrow-right" color="#666" size="18"></u-icon>
									<!-- <image src="../../static/index/u10.png" mode=""></image> -->
								</view>
							</view>
						</view>

					</view>
				</view>
			</view>
		</view>
		<view class="tabBarLineHeight"></view>
		<view class="tabBarView">
			<tab-bar :tabIndex="tabIndex"></tab-bar>
		</view>
	</view>
</template>

<script >
import tabBar from "../../components/tabBar/tabBar";
export default {
	components: {
		tabBar
	},
	data() {
		return {
			title: 'Hello',
			tabIndex: 4,
			bannerList: [
				'/static/me/u655.png',
			],
			userInfo: {
				selfPhotoUrl: null
			}
		}
	},
	mounted() {
		this.pageTop();
		// 用户信息
		try {
			const value = uni.getStorageSync('userInfo');
			if (value) {
				this.userInfo = value
			}
		} catch (e) {
			// error
		}
		console.log(this.userInfo, '11111111111111111111111');
	},
	// 分享到朋友圈
	onShareTimeline() { },
	// 分享到用户
	onShareAppMessage(OBJECT) { },
	onLoad() { },
	methods: {
		// 页面内容置顶
		pageTop() {
			uni.pageScrollTo({
				scrollTop: 0,
				duration: 100, // scroll animation duration in milliseconds
				success: function () {
					console.log('Scrolled to the top successfully');
				},
				fail: function (err) {
					console.log('Failed to scroll to the top', err);
				}
			});
		},
		// 保存微信用户信息
		saveWechatUserInfo() {
			let that = this;
			// 保存用户信息
			saveWechatUser(null, { data: this.userInfo }).then((res) => {
				console.log(res.data);
			}).catch(() => {
				uni.showToast({
					title: "操作失败"
				})
			})
		},
		// 积分详细页面
		gotoIntgral() {
			uni.$u.route({
				url: '/pages/integral/integral',
				params: {
					name: 'lisa'
				}
			})
		},
		/* 用户信息 */
		perfectUserInfo() {
			uni.navigateTo({
				url: '/pages/me/user-info',
				params: {
					name: 'lisa'
				}
			})
		},
		// 关于我们
		aboutOur() {
			uni.navigateTo({
				url: '/pages/me/about-our',
				params: {
					name: 'lisa'
				}
			})
		},
		// 设置
		gotoSetting() {
			uni.navigateTo({
				url: '/pages/setting/setting',
				params: {
					name: 'lisa'
				}
			})
		},
		// 服务对象管理
		gotoServiceObjectMgt() {
			uni.navigateTo({
				url: '/pages/me/service-object-mgt',
				params: {
					name: 'lisa'
				}
			})
		},
		// 储值服务
		gotoRechargeService() {
			uni.navigateTo({
				url: '/myPages/recharge/index'

			})
		},
		// 去实名认证
		gotoRealNameAuth() {
			let that = this;
			console.log(that.userInfo.id)
			uni.navigateTo({
				url: '/pages/me/real-name-auth',
			})
		},
		// 去优惠劵页面
		gotoCoupon() {
			uni.navigateTo({
				url: '/myPages/coupon/index',
			})
		},
		// 去新老系统切换
		gotoSystemSwitch() {
			if (this.$isDataEmpty(this.userInfo.createWay)) {
				uni.navigateTo({
					url: '/pages/system/system-switch',
					params: {}
				})
			}
			if (this.userInfo.createWay == 1) { // 判断是否同步过老系统
				uni.showToast({
					title: "你已经同步过，无需重复操作"
				})
			}
		},
	}
}
</script>

<style scoped lang="scss" >
@import '/common/css/common.css';
@import './index.rpx.scss';
</style>
