<template>
    <view :loading="loading">
        <view class="mine">
            <view class="mine-nav" @click="jump('changePhone')" style="box-shadow: 0 4rpx 8rpx #e7e7e74c">
                <view class="mine-nav-label">更换手机号</view>
                <uni-icons type="forward" color="#aaa" size="20"></uni-icons>
            </view>
            <view class="mine-nav" @click="jump('changePwd')">
                <view class="mine-nav-label">修改密码</view>
                <uni-icons type="forward" color="#aaa" size="20"></uni-icons>
            </view>
            <view class="mine-nav" @click="jump('deleteUser')" style="border-bottom: none">
                <view class="mine-nav-label">账号注销</view>
                <uni-icons type="forward" color="#aaa" size="20"></uni-icons>
            </view>
            <!-- <view class="mine-nav" @click="jump('setupMessage')" style="margin-top:20rpx;border-bottom: none; ">
                <view class="mine-nav-label">消息配置</view>
                <uni-icons type="forward" color="#aaa" size="20"></uni-icons>
            </view> -->
            <view class="mine-nav" @click="jump('agreement')" style="margin-top: 20rpx">
                <view class="mine-nav-label">用户协议</view>
                <uni-icons type="forward" color="#aaa" size="20"></uni-icons>
            </view>
            <view class="mine-nav" @click="jump('policy')">
                <view class="mine-nav-label">隐私政策</view>
                <uni-icons type="forward" color="#aaa" size="20"></uni-icons>
            </view>
            <view class="mine-nav" @click="jump('system')">
                <view class="mine-nav-label">系统介绍</view>
                <uni-icons type="forward" color="#aaa" size="20"></uni-icons>
            </view>
            <view class="mine-nav" @click="jump('book')">
                <view class="mine-nav-label">使用手册</view>
                <uni-icons type="forward" color="#aaa" size="20"></uni-icons>
            </view>
            <!-- <view class="mine-nav" @click="jump('database')">
                <view class="mine-nav-label">资料库</view>
                <uni-icons type="forward" color="#aaa" size="20"></uni-icons>
            </view> -->
            <view class="mine-nav" @click="jump('company')">
                <view class="mine-nav-label">公司介绍</view>
                <uni-icons type="forward" color="#aaa" size="20"></uni-icons>
            </view>
            <!-- <view class="mine-nav" @click="jump('feedback')">
                <view class="mine-nav-label">意见反馈</view>
                <uni-icons type="forward" color="#aaa" size="20"></uni-icons>
            </view> -->
            <!-- @click="jump('about')" -->
            <view class="mine-nav" style="border-bottom: none">
                <view class="mine-nav-label">版本信息</view>
                <view style="color: #828282; font-size: 24rpx">V{{ version }}</view>
                <!-- <uni-icons type="forward" color="#aaa" size="20"></uni-icons> -->
            </view>
            <view class="mine-nav" @click="jump('layout')" style="margin-top: 20rpx; border-bottom: none">
                <view class="mine-nav-label" style="text-align: center">退出登录</view>
            </view>
        </view>
    </view>
</template>

<script>
import { queryPersonSet } from '@/common/api/mine.js'
export default {
    data() {
        return {
            loading: false,
            version: '1.0.0',
        }
    },
    methods: {
        async init() {
            const isDev = process.env.NODE_ENV === 'development'
            if (isDev) {
                return console.log('开发环境，不执行更新检查')
            }
            plus.runtime.getProperty(plus.runtime.appid, (info) => {
                this.version = info.version // 当前本地版本号
            })
        },
        jump(type) {
            switch (type) {
                case 'changePwd':
                    uni.navigateTo({
                        url: `/pages/user/changePwd`,
                    })
                    break
                case 'changePhone':
                    uni.navigateTo({
                        url: `/pages/user/changePhone`,
                    })
                    break
                case 'book':
                    uni.openDocument({
                        filePath: '/static/user_manual.docx',
                        success: function (res) {
                            console.log('打开文档成功')
                        },
                    })
                    break
                case 'layout':
                    uni.showModal({
                        title: '提示',
                        content: '是否确认退出登录？',
                        success: (res) => {
                            if (res.confirm) {
                                uni.removeStorageSync(this.$cacheKey.messageCount)
                                // #ifdef APP-PLUS
                                plus.runtime.setBadgeNumber(0)
                                // #endif
                                uni.reLaunch({
                                    url: `/pages/user/login`,
                                })
                            }
                        },
                    })
                    break
                default:
                    uni.navigateTo({
                        url: `/pages/mine/${type}`,
                    })
                    break
            }
        },
    },
    onLoad() {
        this.init()
    },
}
</script>

<style lang="scss">
.mine {
    padding-top: 20rpx;

    .mine-header {
        padding: 200rpx 34rpx 34rpx;
        display: flex;
        align-items: center;
        background: $uni-theme-white;
        margin-bottom: 20rpx;
        box-shadow: 0 4rpx 8rpx #e7e7e74c;

        .mine-header-head {
            margin-right: 30rpx;
            height: 128rpx;
            width: 128rpx;
            border-radius: $uni-theme-radius;
            overflow: hidden;
        }

        .mine-header-name {
            margin-right: 30rpx;
            flex: 1;
            font-size: 36rpx;
            color: #111;
            font-weight: 700;
        }
    }

    .mine-nav {
        padding: 34rpx;
        display: flex;
        align-items: center;
        background: $uni-theme-white;
        border-bottom: 1rpx solid #e8e8e8;

        &-icon {
            margin-right: 30rpx;
            height: 44rpx;
            width: 44rpx;
            border-radius: $uni-theme-radius;
            overflow: hidden;
        }

        &-label {
            margin-right: 30rpx;
            flex: 1;
            font-size: 28rpx;
            color: #111;
        }
    }
}
</style>
