<template>
    <view>
        <!-- subpages/settings/pages/index/index.wxml -->
        <view class="card">
            <view class="item">
                <view class="left">用户协议</view>
                <image src="/static/images/right.png" mode="" />
            </view>
            <view class="item">
                <view class="left">隐私协议</view>
                <image src="/static/images/right.png" mode="" />
            </view>
            <view class="item" @tap="toChangePassword">
                <view class="left">修改密码</view>
                <image src="/static/images/right.png" mode="" />
            </view>
        </view>

        <button hover-class="btn-hover" @tap="handelLogout">退出登录</button>
    </view>
</template>

<script>
// subpages/settings/pages/index/index.js
import api from '../../../../utils/api';
export default {
    data() {
        return {};
    }
    /**
     * 生命周期函数--监听页面加载
     */,
    onLoad(options) {},
    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady() {},
    /**
     * 生命周期函数--监听页面显示
     */
    onShow() {},
    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide() {},
    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload() {},
    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh() {},
    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom() {},
    /**
     * 用户点击右上角分享
     */
    onShareAppMessage() {},
    methods: {
        handelLogout() {
            uni.showModal({
                title: '提示',
                content: `确定退出?`,
                confirmText: '确认',
                showCancel: false,
                success: (res) => {
                    api.logout()
                        .then((res) => {
                            uni.reLaunch({
                                url: '/pages/login/login'
                            });
                            uni.removeStorage({
                                key: 'token'
                            });
                            console.log(res);
                        })
                        .catch((err) => {
                            console.log(err);
                        });
                }
            });
        },

        toChangePassword() {
            uni.navigateTo({
                url: '/subpages/settings/pages/changePassword/changePassword'
            });
        }
    }
};
</script>
<style>
/* subpages/settings/pages/index/index.wxss */
page {
    background-color: #f7f7f7;
    overflow: hidden;
    padding: 20rpx;
    box-sizing: border-box;
}
.card {
    border-radius: 20rpx;
    background-color: #fff;
    padding: 0 20rpx;
    box-sizing: border-box;
}
.card .item {
    display: flex;
    justify-content: space-between;
    height: 100rpx;
    align-items: center;
    font-size: 32rpx;
    font-family: PingFang SC;
    font-weight: 500;
    color: #333333;
    border-bottom: 2rpx solid #f7f7f7;
}
.card .item image {
    width: 20rpx;
    height: 20rpx;
}
button {
    background: linear-gradient(to right, #82b4fd, #3e93fe);
    font-size: 33rpx;
    width: 600rpx !important;
    height: 84rpx;
    text-align: center;
    color: #fff;
    border-radius: 84rpx;
    position: fixed;
    bottom: 100rpx;
    left: 50%;
    transform: translateX(-300rpx);
}
</style>
