<template>
	<view>
		<u-navbar title="设置" title-color="#101010"></u-navbar>
		<u-cell-group>
			<!-- <u-cell-item title="个人信息" @click="gotoUrl('/pages/mine/personInfos')"></u-cell-item> -->
			<u-cell-item title="修改密码" @click="gotoUrl('/pages/mine/changePassword')"></u-cell-item>
			<u-cell-item title="修改手机号" :value="personInfo.phone" @click="gotoUrl('/pages/mine/changePhone')"></u-cell-item>
			<u-cell-item title="注销账号" @click="gotoUrl('/pages/mine/cancelAccount')"></u-cell-item>
		</u-cell-group>

		<view class="exit" @click="signOut">
			退出账号
		</view>

		<u-modal v-model="show1" @confirm="confirm" confirm-color="#FF3D00" :show-cancel-button="true" ref="uModal"
			:asyncClose="true" title="退出账号" content="是否退出当前账号?" :content-style="{color: '#333333'}"></u-modal>

	</view>


</template>

<script>
	import * as userApi from '@/apis/pagejs/user.js'
	// import * as API from '@/apis/pagejs/index.js'

	export default {
		data() {
			return {
				personInfo: {},
				show1: false,
			}
		},
		onLoad() {
			if(this.carhelp.getPersonInfoPlus()) {
				var data = this.carhelp.getPersonInfoPlus();
				this.personInfo = data.regUser;
				if(this.personInfo.phone != null) {
					var phone = this.personInfo.phone;
					phone = phone.slice(0,3) + '****' + phone.slice(-4);
					this.personInfo.phone = phone;
				}
			}
			//this.homePage()
		},
		methods: {
			signOut() {
				this.show1 = true;
			},
			confirm() {
				uni.showLoading({
					title: "加载中",
					mask: true,
				})
				userApi.logout().then((res) => {
					uni.hideLoading();
					this.show1 = false;
					this.carhelp.logoff()
					uni.redirectTo({
						url: '/pages/login/login'
					})
				}).catch(error => {
					uni.showToast({
						title: error,
						icon: "none"
					})
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	/deep/.u-cell_title {
		color: rgba(51, 51, 51, 1);
	}

	/deep/.u-cell__value {
		color: #777777;
	}

	;

	.exit {
		background-color: #fff;
		margin: 24rpx 0 0 0;
		text-align: center;
		line-height: 96rpx;
		color: rgba(238, 49, 56, 1);
		font-size: 32rpx;
	}
</style>