<template>
	<view class="content">
		<view class="top">
			<view style="display: flex;align-items: center;" class="">
				<image v-if="!info.avatar" src="/static/avater.png"
					style="width: 100rpx; height:100rpx;margin-right: 30rpx;" mode="" @click="gologin"></image>
				<image v-else :src="info.avatar" style="width: 100rpx; height:100rpx;margin-right: 30rpx;" mode="">
				</image>
				<p v-if="!info.nickname" @click="gologin">未登录</p>
				<p v-else>{{info.nickname}}</p>
			</view>
			<view class="">
				<image src="/static/Frame@2x.png" style="width: 40rpx; height: 40rpx;" mode="" @click="goEdit">
				</image>
			</view>

		</view>
		<view class="box">
			<view style="display: flex;flex-direction: column;align-items: center;" v-for="item in list"
				@click="go(item)">
				<image class="imgBox" :src="item.url" mode=""></image>
				<p style=" color: #000000e6;font-size: 26rpx;font-weight: 400;">{{item.title}}</p>
			</view>
		</view>
		<view style="background: #f7f8faff; padding: 32rpx;">


			<view class="bottomBox" v-for="item in list1" style="padding: 24rpx;" @click="go(item)">
				<view style="display: flex;align-items: center;" class="">
					<image style="width: 48rpx; height: 48rpx;margin-right: 22rpx;" :src="item.url" mode=""></image>
					<p style="color: #0d1013e6;font-size: 28rpx;font-weight: 500;">{{item.title}}</p>
				</view>
				<view class="">
					<image src="/static/my/ic-arrow(1).png" style="width: 16rpx;height: 32rpx;" mode=""></image>
				</view>
			</view>
		</view>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				info: {

				},
				list: [{
						url: '/static/my/2999.png',
						title: '我的设备',
						route: '/pages/my/myDevice'
					},

					{
						url: '/static/my/3000.png',
						title: '我的需求',
						route: '/pages/my/myNeeds'
					},
					{
						url: '/static/my/3001.png',
						title: '我的收藏',
						route: '/pages/my/myStars'
					},
					{
						url: '/static/my/3002.png',
						title: '最近浏览',
						route: '/pages/my/history'
					},
				],
				list1: [{
						url: '/static/my/ic-us.png',
						title: '关于我们',
						route: '/pages/my/aboutUs'
					},
					{
						url: '/static/my/Fram.png',
						title: '联系客服'
					},
					{
						url: '/static/my/ic-building.png',
						title: '合伙人加盟',
						route: '/pages/subPages/join'
					},
					{
						url: '/static/my/ic-yijian.png',
						title: '意见反馈',
						route: '/pages/subPages/ad'
					},
					{
						url: '/static/my/ic-setting.png',
						title: '设置',
						route: '/pages/my/setting'
					},
				]

			}

		},
		methods: {
			gologin() {
				uni.reLaunch({
					url:'/pages/index/login'
				})
			},
			go(item) {
				if(item.title == '联系客服'){
					uni.makePhoneCall({
						phoneNumber: this.info.cooperation_phone //仅为示例
					});
				}else{
					uni.navigateTo({
						url: item.route
					})
				}
				
			},
			goEdit() {
				uni.navigateTo({
					url: '/pages/my/setting'
				})
			},
			getList() {
				uni.$u.http.get('/api/user/index').then(res => {
					console.log(res);
					if(res.code == 1){
						this.info = res.data
						uni.setStorageSync('phone',res.data.mobile)
						uni.setStorageSync('kfphone',res.data.cooperation_phone)
					}else{
						this.info = {}
					}
				}).catch(err => {
					console.log(err);
					this.info = {}
				})
			}
		},
		onLoad() {
			this.getList()
		},
		onShow() {
			this.getList()
		}
	}
</script>

<style>
	.bottomBox {
		opacity: 1;
		background: #ffffffff;
		display: flex;
		align-items: center;
		justify-content: space-between;
	}

	.imgBox {
		width: 80rpx;
		height: 80rpx;
		margin-bottom: 13rpx;
	}

	.box {
		height: 204rpx;
		border-radius: 16rpx;
		opacity: 1;
		background: #ffffffff;
		margin: 32rpx;
		display: flex;
		align-items: center;
		justify-content: space-evenly;
	}

	.content {
		height: 560rpx;
		border: 1rpx solid #e8eaedff;
		background: linear-gradient(137.9deg, #ffffffff 0%, #cde1ffff 100%);
	}

	.top {
		display: flex;

		margin: 80rpx 40rpx;
		padding-top: 80rpx;
		justify-content: space-between;
		align-items: center;
	}
</style>