<!-- 个人中心 -->
<template>
    <view id="register">
		<view class="register_li">
			<view class="register_li_min" @click="goPage('datum')">
				<view>修改资料</view>
			    <view class="view-three-type" :class="state==0?'colorA':'colorB'">{{state==0?'审核未通过':'审核已通过'}}</view>
				<img class="right-img" src="@/images/basicsModules/icon_04.png">
			</view>
			<view class="register_li_min" @click="goPage('password')" style="border: none;">
				<view>修改密码</view>
				<view></view>
				<img class="right-img" src="@/images/basicsModules/icon_04.png">
			</view>
		</view>
		<view class="sub_btn" @click="clickOut()">退出登录</view>
	</view>
</template>

<script>
    import {logout} from '@/api/apiDemo/index.js'
	import { config } from '@/api/request/config.js'
    export default {
        data() {
            return {
				form:{
					name:'',
				},
				state:null,
            }
        },
        onLoad(option) {//审核状态（0：未审核，1:审核通过，2：审核未通过）
			this.state=option.state
        },
        onShow(){

        },

        methods: {
			//页面跳转
			goPage(type){
			    if(type == 'datum'){//修改资料
					uni.redirectTo({
					    url: '/pages_supplier/register/register?pageStatus=1',//注册页面
					});
				}else if(type == 'password'){//修改密码
			        uni.redirectTo({
			            url: '/pages_supplier/mine/changePassword',
			        });
				}
			},
			//退出按钮
			clickOut(){
			    let self = this;
			    uni.showModal({
			        // title: '确认要退出吗?',
			        content: '确认要退出吗',
			        cancelColor:"#999",
			        confirmColor:"#0183FA",
			        success: function (res) {
			            if (res.confirm) {
			                self.logout();
			                console.log('用户点击确定');
			            } else if (res.cancel) {
			                console.log('用户点击取消');
			            }
			        }
			    });
			},
			//退出登录
			async logout() {
			    let self = this;
			    const {data} = await logout();
			    if(data.code == 200){
			        uni.removeStorageSync('token');
			        uni.removeStorageSync('userId');
			        uni.removeStorageSync('userType');
			        uni.redirectTo({
			            url: '/pages/login',
			        });
			    }
			},
        }
    }
</script>

<style lang="stylus" scoped>
    #register{
        height:100%;
        width:100%;
        display flex
        flex-direction column;
		padding-bottom: 220rpx;
		.register_li{
			background #fff;
			padding:20rpx 0;
			box-sizing: border-box;

			.register_li_min{
				margin:0 26rpx;
				display flex;
				align-items center;
				border-bottom: 1px solid #F5F5F5;
				display flex;
				view{
					line-height:110rpx;
					font-size:28rpx;
				}
				view:nth-child(1){
					font-size: 30rpx;
					font-family: PingFang SC;
					font-weight: 500;
					color: #333333;
					line-height: 110rpx;

				}
				view:nth-child(2){
					font-size: 28rpx;
					font-family: PingFang SC;
					font-weight: 500;
					line-height: 110rpx;
					flex:1;
					text-align: right;
				}
				.colorA{
					color:#FF3131!important;
				}
				.colorB{
					color:#999999!important;
				}
				>img{
					width: 12rpx;
					height: 24rpx;
					margin-left: 26rpx;
				}
			}
		}
		/* 按钮 */
		.sub_btn{
			width: 650rpx;
			height: 100rpx;
			background: #0183FA;
			border-radius: 20rpx;
			font-size: 28rpx;
			font-family: PingFang SC;
			font-weight: 500;
			color: #FFFFFF;
			line-height: 100rpx;
			text-align: center;
			margin-left: 50rpx;
			position: fixed;
			bottom:30rpx;
			z-index: 1000;
		}

	}

</style>
