<template>
    <view class="box">
        <view class="header">
            <view class="headerPng">
                <image :src="headerImg" mode="" />
            </view>
            <!-- <view class="nickName">你的昵称</view> -->
            <view class="phone">{{ phone }}</view>
        </view>

        <view class="meauList">
            <!-- <view class="menu-item" @click="updateOTA()">
                <view class="meanLeft">
                    <image src="../../static/update.png" mode="" />
                    <text>OTA升级</text>
                </view>
                <view class="meanRight">
                    <image src="../../static/arrTwo.png" mode="" />
                </view>
            </view> -->
            <view class="menu-item" @click="gotoShare('sure')">
                <view class="meanLeft">
                    <image src="../../static/share.png" mode="" />
                    <text>分享确认</text>
                </view>
                <view class="meanRight">
                    <image src="../../static/arrTwo.png" mode="" />
                </view>
            </view>

            <view class="menu-item" @click="gotoShare('list')">
                <view class="meanLeft">
                    <image src="../../static/list.png" mode="" />
                    <text>分享记录</text>
                </view>
                <view class="meanRight">
                    <image src="../../static/arrTwo.png" mode="" />
                </view>
            </view>

            <view class="menu-item" @click="goAbnormalInfo()">
                <view class="meanLeft">
                    <image src="../../static/list.png" mode="" />
                    <text>统计信息</text>
                </view>
                <view class="meanRight">
                    <image src="../../static/arrTwo.png" mode="" />
                </view>
            </view>
            <!-- <view class="menu-item" @click="deaAccount()">
                <view class="meanLeft">
                    <image src="../../static/logoff.png" mode="" />
                    <text>注销账户</text>
                </view>
                <view class="meanRight">
                    <image src="../../static/arrTwo.png" mode="" />
                </view>
            </view> -->
        </view>

        <view class="logoutBtn" @click="goLogout">退出登录</view>

        <!-- <tenMinutes v-if="isIniTenMinutes" /> -->
        <alarModel v-if="showModle" />
    </view>
</template>

<script>
import MqttService from "../../utils/globalMqtt";

export default {
    data() {
        return {
            headerImg: "../../static/headerInfo.png",
            phone: uni.getStorageSync("phone"),
            showModle: false,
        };
    },
    methods: {
        updateOTA() {
            uni.navigateTo({
                url: "/pagesA/OTA/OTA",
            });
        },
        gotoShare(shareType) {
            uni.navigateTo({
                url: "/pagesA/shareList/shareList?shareType=" + shareType,
            });
        },
        goLogout() {
            uni.showModal({
                title: "提示",
                content: "是否确认退出登录？",
                success: function (res) {
                    if (res.confirm) {
                        MqttService.disconnectAll();
                        uni.clearStorageSync();
                        uni.reLaunch({
                            url: "/pagesA/loginNew/loginNew",
                        });
                    } else if (res.cancel) {
                    }
                },
            });
        },
        deaAccount() {
            uni.showModal({
                content: "是否确认注销登录",
                complete: (res) => {
                    if (res.confirm) {
                        this.$http
                            .post(
                                "wap/user/wx/logout",
                                { userId: uni.getStorageSync("userId") },
                                {
                                    header: {
                                        "Content-Type":
                                            "application/json;charset=UTF-8",
                                    },
                                }
                            )
                            .then((res) => {
                                if (res.data.code == 200) {
                                    uni.showToast({
                                        title: "注销成功",
                                        icon: "success",
                                        duration: 1500,
                                    });
                                    uni.clearStorageSync();
                                    uni.reLaunch({
                                        url: "/pagesA/loginNew/loginNew",
                                    });
                                } else {
                                    uni.showToast({
                                        title: res.data.message,
                                        icon: "none",
                                        duration: 1500,
                                    });
                                }
                            });
                    }
                },
            });
        },
        serverchange() {
            uni.navigateTo({
                url: "/pagesA/serChange/serChange",
            });
        },
        goAbnormalInfo() {
            uni.navigateTo({
                url: "/pagesA/abnormalInfo/abnormalInfo",
            });
        },
    },
    onShow() {
        this.isIniTenMinutes = true;
        this.showModle = true;
    },
    onLoad() {},
    onHide() {
        this.showModle = false;
    },
    onUnload() {},
};
</script>

<style lang="less" scoped>
// Main Styles
.box {
    padding: 10rpx 18rpx;
    width: 100vw;
    height: 100vh;
    background: linear-gradient(180deg, #faede2 0%, #f4f4f4 100%);
    box-sizing: border-box;

    .header {
        margin: 0 auto;
        width: 710rpx;
        height: 325rpx;
        background: linear-gradient(114.42deg, #a27867 0%, #74483d 100%),
            #ffffff;
        border-radius: 35rpx;
        box-sizing: border-box;

        .headerPng {
            display: flex;
            align-items: center;
            justify-content: center;
            padding-top: 40rpx;

            image {
                width: 115rpx;
                height: 115rpx;
                border-radius: 50%;
            }
        }

        .nickName {
            margin-top: 30rpx;
            font-weight: 500;
            color: #ffffff;
            font-size: 38rpx;
            text-align: center;
        }

        .phone {
            margin-top: 40rpx;
            color: #ffffff;
            font-size: 32rpx;
            text-align: center;
        }
    }

    .meauList {
        width: 710rpx;
        margin: 18rpx auto 0 auto;
        background: #fff;
        border-radius: 37rpx;
        box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.03);
        padding: 0;
        box-sizing: border-box;

        .menu-item {
            display: flex;
            align-items: center;
            justify-content: space-between;
            margin: 0 32rpx;
            padding: 32rpx 0;
            border-bottom: 1rpx solid #f0f0f0;

            &:last-child {
                border-bottom: none;
            }

            .meanLeft {
                display: flex;
                align-items: center;
                justify-content: center;

                image {
                    width: 38rpx;
                    height: 38rpx;
                }

                text {
                    margin-left: 10rpx;
                    color: #111111;
                    font-size: 32rpx;
                }
            }

            .meanRight image {
                width: 16rpx;
                height: 26rpx;
            }
        }
    }

    .logoutBtn {
        width: 710rpx;
        margin: 48rpx auto 0 auto;
        height: 88rpx;
        background: #fff;
        color: #b48a7c;
        font-size: 32rpx;
        border-radius: 30rpx;
        display: flex;
        align-items: center;
        justify-content: center;
        box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.03);
    }
}
</style>
