<template>
    <div>
        <NavBar :showIcon="true" :showTitle="true" title="测试登录" backgroundBox="#ffffff"></NavBar>
        <p>
            手机号
            <input type="text" v-model="phone" />
        </p>
        <button @tap="login">登录</button>
    </div>
</template>

<script setup>
import { testLogin, getSmsCode } from "@/api/user";
import { setToken } from "@/utils/token";
import { getLoginUserApi } from "@/api/user";
const phone = ref("");
const login = async () => {
    const a = await getSmsCode({ username: phone.value });
    testLogin({
        username: phone.value,
        code: "000000",
        userType: "consumer",
    }).then(res => {
        console.log(res);
        if (res.code === 200) {
            setToken(res.data);
            getLoginUserApi().then(res => {
                uni.setStorageSync("userInfo", res.data);
            });
            uni.switchTab({
                url: "/pages/postionList/index"
            });
        }
    });
};
</script>

<style lang="scss" scoped></style>
