<template>
	<view>
		<view class="page tabbar-page tabbar-page-padding">
			<view class="w100 h-180 relative">
				<uni-nav-bar title="我的" :border="false" backgroundColor="transparent" class="fw-b" color="#fff"></uni-nav-bar>
				<image class="w-40 h-40 absolute" src="/static/images/sz.png" mode="" style="bottom: 20rpx;left: 20rpx;" @click="$tools.goNext('/pageOne/mes/setUp')"></image>
			</view>
			<view class="w100 rows rowsm rowsb mt-20 pl-20">
				<view class="rows rowsm" @click="$tools.goNext('/pageOne/mes/information')" v-if="infor&&infor.id">
					<view class="w-164 h-164 br-24 mr-20" style="border: 4rpx solid #fff;">
						<image class="w100 h100 br-24" :src="$tools.oss(infor.avatar)" mode="aspectFill"></image>
					</view>
					<view class="h-164 rows rowsl rowsb">
						<view class="rows rowsm">
							<view class="fs-36 fw-b colfff mr-20 one_overflow" style="max-width: 250rpx;">{{infor.nickname}}</view>
							<!-- <view class="pl-10 pr-10 bgff rows rowsc rowsm h-38 col fs-24 fw-b br-100" v-if="infor.level==1">酒鬼</view>
							<view class="pl-10 pr-10 bgff rows rowsc rowsm h-38 col fs-24 fw-b br-100" v-if="infor.level==2">酒圣</view>
							<view class="pl-10 pr-10 bgff rows rowsc rowsm h-38 col fs-24 fw-b br-100" v-if="infor.level==3">酒王</view>
							<view class="pl-10 pr-10 bgff rows rowsc rowsm h-38 col fs-24 fw-b br-100" v-if="infor.level==4">酒仙</view>
							<view class="pl-10 pr-10 bgff rows rowsc rowsm h-38 col fs-24 fw-b br-100" v-if="infor.level==5">酒神</view>
							<view class="pl-10 pr-10 bgff rows rowsc rowsm h-38 col fs-24 fw-b br-100" v-if="infor.level==6">酒佛</view> -->
						</view>
						<view class="rows rowsc rowsm w-160 br-10 h-40 colfff fs-26 fw-b" style="border: 2rpx solid #fff;">ID：{{infor.invitation||''}}</view>
						<text class="fs-28 colfff fw-b">{{infor.mobile||''}}</text>
					</view>
				</view>
				<view class="rows rowsm" @click="login" v-else>
					<view class="w-164 h-164 br-24 mr-20" style="border: 4rpx solid #fff;">
						<image class="w100 h100 br-24" src="/static/other/4s.png" mode="aspectFill"></image>
					</view>
					<view class="h-164 rows rowsl rowsc">
						<view class="fs-36 fw-b colfff">未登录</view>
					</view>
				</view>
				<view class="w-190 h-60 rows rowsc rowsm col bgff" style="border-radius: 38rpx 0 0 38rpx;" @click="$tools.goNext('/pageOne/mes/invitation')">
					<text class="fw-b fs-24 mr-14">分享二维码</text>
					<image class="w-20 h-20" src="/static/images/cef.png" mode=""></image>
				</view>
			</view>
			<!-- <view class="w100 pl-20 colfff fs-28 fw-b mt-20">我的账户</view>
			<view class="w100 rows rowsm rowsa mt-20">
				<view class="rows rowsl rowsm colfff" style="width: 50%;" @click="$tools.goNext('/pageOne/mes/aaa?type=2&name=消费积分')">
					<text class="fs-44 fw-b">{{infor.score||0.00}}</text>
					<text class="fs-26 mt-10">消费积分</text>
				</view>
				<view class="rows rowsl rowsm colfff" style="width: 50%;" @click="$tools.goNext('/pageOne/mes/aaa?type=1&name=余额')">
					<text class="fs-44 fw-b">{{infor.money||0.00}}</text>
					<text class="fs-26 mt-10">余额</text>
				</view>
			</view>
			<view class="w100 rows rowsm rowsa mt-40">
				<view class="rows rowsl rowsm colfff" style="width: 50%;" @click="$tools.goNext('/pageOne/mes/aaa?type=3&name=分红积分')">
					<text class="fs-44 fw-b">{{infor.share_price||0.00}}</text>
					<text class="fs-26 mt-10">分红积分</text>
				</view>
				<view class="rows rowsl rowsm colfff" style="width: 50%;" @click="$tools.goNext('/pageOne/mes/aaa?type=4&name=未释放分红')">
					<text class="fs-44 fw-b">{{infor.freeze_price||0.00}}</text>
					<text class="fs-26 mt-10">未释放分红</text>
				</view>
			</view> -->
			<view class="w100 rows rowsc mt-30">
				<view class="w-710 p-all-20 rows rowsl rowsc br-24 pl-10 pr-10 bgff">
					<view class="w100 rows rowsm rowsb" @click="$tools.goNext(`/pageOne/mes/orderList?id=66`)">
						<text class="fs-30 fw-b">订单中心</text>
						<view class="rows rowsm">
							<text class="fs-26 col666 mr-10">查看全部</text>
							<image class="w-28 h-24" src="/static/images/cd.png" mode=""></image>
						</view>
					</view>
					<view class="w100 rows rowsm mt-32 relative">
						<view class="rows rowsl rowsm" style="width: 25%;" v-for="(item,index) in order"
						@click="$tools.goNext(item.url)">
							<image class="w-52 h-52" :src="item.icon" mode=""></image>
							<text class="fs-28 col333 mt-20">{{item.name}}</text>
						</view>
					</view>
				</view>
			</view>
			<view class="w100 rows rowsc mt-30">
				<view class="w-710 p-all-20 rows rowsl rowsc br-24 pl-10 pr-10 bgff">
					<view class="w100 rows rowsm rowsb">
						<text class="fs-30 fw-b">常用功能</text>
					</view>
					<view class="w100 rows rowsm mt-32">
						<view class="rows rowsl rowsm" style="width: 25%;" v-for="(item,index) in menu" :key="index"
						@click="jumpPage(item)">
							<image class="w-72 h-72" :src="item.icon" mode=""></image>
							<text class="fs-28 col333 mt-20">{{item.name}}</text>
						</view>
					</view>
				</view>
			</view>
			<!-- <view class="w100 rows rowsc mt-30">
				<image class="w-710 h-246 br-20" src="/static/other/3.png" mode="aspectFill" @click="$tools.goNext('/pageOne/mes/myPoints')"></image>
			</view> -->
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				order:[
					{id:0,name:'待付款',icon:'/static/images/qqa.png',url:`/pageOne/mes/orderList?id=0`},
					{id:1,name:'待发货',icon:'/static/images/wdsd.png',url:`/pageOne/mes/orderList?id=1`},
					{id:2,name:'待收货',icon:'/static/images/bth.png',url:`/pageOne/mes/orderList?id=2`},
					// {id:3,name:'待评价',icon:'/static/images/csd.png',url:`/pageOne/mes/orderList?id=3`},
					{id:4,name:'已完成',icon:'/static/images/yuh.png',url:`/pageOne/mes/orderList?id=4`}
				],
				baseMenu:[
					{id:1,name:'收货地址',icon:'/static/images/04_erfg.png',url:`/pageOne/mes/address`},
					{id:2,name:'我的收藏',icon:'/static/images/04_we.png',url:`/pageOne/mes/collection`},
					{id:4,name:'开通会员',icon:'/static/images/04_we.png',url:`/pageOne/mes/member`},
					{id:3,name:'联系客服',icon:'/static/images/04_ghi.png',url:``}/* /pageOne/mes/service */
				],
				menu:[],
				infor:{},
				tel:'',
				promotionUnlocked: false
			}
		},
		onLoad() {
			this.richText()
			this.syncPromotionStatus()
			uni.$on('promotionUnlocked', this.syncPromotionStatus)
		},
		onShow() {
			this.syncPromotionStatus()
			this.syncCustomTabBar()
			this.index()
		},
		onUnload() {
			uni.$off('promotionUnlocked', this.syncPromotionStatus)
		},
		methods: {
			syncCustomTabBar() {
				this.$tools.setTabbarSelectedPath('/pages/tabbar/me')
				if (typeof this.getTabBar === 'function') {
					const tabBar = this.getTabBar()
					if (tabBar && typeof tabBar.syncPromotionStatus === 'function') {
						setTimeout(() => {
							tabBar.syncPromotionStatus('/pages/tabbar/me')
						}, 0)
					}
				}
			},
			syncPromotionStatus() {
				this.promotionUnlocked = this.$tools.getPromotionUnlocked()
				const menu = this.baseMenu.slice()
				if (this.promotionUnlocked) {
					menu.push({
						id: 4,
						name: '我的推广',
						icon: '/static/images/04_ghidf.png',
						url: '/pageOne/mes/promotion'
					})
				}
				this.menu = menu
			},
			login(){
				uni.showModal({
					title: '温馨提示',
					content: '尚未登录或登录已过期，是否前往登录？',
					success: (res) => {
						if(res.confirm){
							this.$tools.clearLoginStorage()
							uni.navigateTo({
								url: "/pages/login/login"
							})
						}
					}
				})
			},
			index(){
				this.$tools.axiosFrom("POST","user/index").then(res => {
					this.infor = res.data
				})
			},
			richText(){
				this.$tools.axios("POST","index/richText").then(res => {
					this.tel = res.data.call
				})
			},
			jumpPage(item){
				if(item.id==3){
					uni.showModal({
						title: '提示',
						content: '确定要联系客服吗？',
						success: (res) => {
							if (res.confirm) {
								uni.makePhoneCall({
									phoneNumber: this.tel
								})
							} 
						}
					})
				}else{
					this.$tools.goNext(item.url)
				}
			}
		}
	}
</script>

<style>
	page{
		background-color: #F7F6FA;
	}
	.page{
		width: 750rpx;
		min-height: 100vh;
		background: linear-gradient( 180deg, #E73232 0%, rgba(231,50,50,0.94) 30.45%, rgba(231,50,50,0.91) 53.88%, rgba(231,50,50,0.8) 69.29%, rgba(231,50,50,0.54) 81.67%, rgba(231,50,50,0.26) 90.37%, rgba(231,50,50,0) 100%);
	}
</style>
