<template>
    <view class="container">
        <navigator class="mt16 bgf br8" target url="../changePsw/index?type=1" hover-class="hcb" open-type="navigate">
            <view class="changePsw fsa">
                <view>修改密码</view>
                <view>
                    <view class="iconfont icon-gengduo11"></view>
                </view>
            </view>
        </navigator>
        <view class="userinfo mt16">
            <navigator class target url="../../serviceTerm/index" hover-class="hcb" open-type="navigate">
                <view class="useravatar fsa">
                    <view>用户协议</view>
                    <view>
                        <view class="iconfont icon-gengduo11"></view>
                    </view>
                </view>
            </navigator>

            <navigator class target url="../../secret/index" hover-class="hcb" open-type="navigate">
                <view class="userName fsa">
                    <view>隐私政策</view>
                    <view>
                        <view class="iconfont icon-gengduo11"></view>
                    </view>
                </view>
            </navigator>

            <navigator class target url="../versionPage/index" hover-class="hcb" open-type="navigate">
                <view class="gender fsa">
                    <view>关于一才</view>
                    <view class="fsa c9">
                        <view class hover-class="none" :hover-stop-propagation="false">版本{{ version }}</view>
                        <view class="iconfont icon-gengduo11 ml8"></view>
                    </view>
                </view>
            </navigator>
        </view>
        <view class="loginOut23" @click.stop="loginOut" hover-class="thover">
            <view class>
                <text class="f16">退出登录</text>
            </view>
        </view>
    </view>
</template>

<script>
// pages/setting/index.js
const app = getApp();
export default {
    data() {
        return {
            version: app.globalData.version
        };
    }
    /**
     * 生命周期函数--监听页面加载
     */,
    onLoad(options) {},
    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady() {},
    /**
     * 生命周期函数--监听页面显示
     */
    onShow() {},
    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide() {},
    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload() {},
    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh() {},
    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom() {},
    methods: {
        /**
         * 用户点击右上角分享
         */
        onShareAppMessage1() {},

        loginOut: function () {
            uni.showModal({
                title: '退出登录',
                content: '确定要退出登录吗?',
                confirmColor: '#ff4400',
                success(res) {
                    if (res.confirm) {
                        console.log('用户点击确定');
                        app.globalData.logout().then(() => {
                            uni.reLaunch({
                                url: '/pages/login/index'
                            });
                            app.globalData.getServiceInfo().then(() => {
                                uni.setStorageSync('ServiceInfo', app.globalData.serviceInfo);
                            });
                        });

                        // wx.navigateBack({
                        //   delta: 1
                        // })
                    } else if (res.cancel) {
                        console.log('用户点击取消');
                    }
                }
            });
        }
    }
};
</script>
<style>
@import './index.css';
</style>
