<template>
    <div class="page">
        <NavBar :showTitle="true" title="登录" />
        <!-- pages/login/login.wxml -->
        <view class="login-page">
            <nav-bar class="nav-bar">
                <template #title>   <text class="student">登录</text> </template>
            </nav-bar>
            <view class="title">
                <img src="@/static/image/icon/login.png" alt="">
                <text class="t2">安全、便捷的就业、创业服务平台</text>
            </view>
            <button class="login-btn" @click="login">授权手机号登录</button>
        </view>
        {{ res }}
    </div>
</template>

<script setup>
import NavBar from "@/components/navBar/index.vue";
import { xinhuaMpLogin } from "@/api/user.js";
import { setToken, getToken } from "@/utils/token";
const res = ref("");

onLoad(() => {
    // const token = getToken();
    // if (token) {
    //     uni.switchTab({
    //         url: "/pages/postionList/index"
    //     });
    // }
});
const login = () => {
    xma.xh.getUserProfile({
        range: ["ACCOUNT", "MOBILE"],
        success(info) {
            xinhuaMpLogin({ encryptedData: info.data.uMobile, userType: "consumer" })
                .then(data => {
                    res.value = data;
                    console.log("datadatadata", data);
                    setToken(data.data);
                    uni.switchTab({
                        url: "/pages/postionList/index"
                    });
                })
                .catch(err => {
                    res.value = err;
                });
        },
        fail(err) {
            test.value = err;
        }
    });
    getLoginUserApi().then(res => {
        console.log(res);
    });
};
</script>

<style lang="scss" scoped>
.page {
    height: 100%;
    background-color: #eaf5ff;
}
.login-page {
    height: 100%;
    background-image: url("https://lygsh-image.wjzpgz.com/login/loginBG.png");
    background-repeat: no-repeat;
    background-position: 50% 50%;
    background-size: auto 100%;
    .student {
        font-size: 36rpx;
        font-weight: 600;
        color: #1b2026;
        text-align: center;
    }
    .title {
        display: flex;
        flex-direction: column;
        margin-top: 176rpx;
        text-align: center;
        img{
            width: 368rpx;
            margin: 0 auto;
        }
        .t2 {
            font-size: 24rpx;
            color: #1b2026;
            margin-top:28rpx ;
        }
    }
    .login-btn {
        position: absolute;
        bottom: 336rpx;
        left: 50%;
        width: 640rpx;
        height: 96rpx;
        font-size: 34rpx;
        line-height: 96rpx;
        color: #ffffff;
        background-color: #1f86ff;
        transform: translate(-50%, 0);
    }
}
</style>
