<template>
    <div class="page">
        <div class="main">
            <div class="tit">用户登录</div>
            <div class="inp-box">
                <input
                    type="text"
                    name="userName"
                    v-model="userName"
                    placeholder="请输入账号"
                />
            </div>
            <div class="inp-box">
                <input
                    type="password"
                    name="password"
                    v-model="password"
                    placeholder="请输入密码"
                />
            </div>
            <button class="btn" @click="submit">确定</button>
        </div>
    </div>
</template>

<script>
import MyImage from "../../components/image/index";

export default {
    name: "",
    components: { MyImage },
    // 数据
    data() {
        return {
            userName: "",
            password: "",
        };
    },

    onLoad() {
        uni.hideLoading();
    },

    onShow() {},

    // 函数
    methods: {
        submit() {
            if (!this.userName) {
                this.fn.showToast(`请输入账号`);
                return;
            }
            if (!this.password) {
                this.fn.showToast(`请输入密码`);
                return;
            }

            uni.showLoading({
                title: "提交中",
            });
    //         uni.login({
    //             provider: "weixin",
				// fail:err=>{
				// 	console.log('err',err)
				// },
    //             success: (result) => {
				// 	console.log('ok',reset)
                    this.api
                        .post("/Login/LoginByAccount", {
                            userName: this.userName,
                            password: this.password,
                            // code: result.code,
                        })
                        .then((res) => {
                            uni.hideLoading();
								console.log(res);

                            if (res.success) {
                                // 判断权限
                                if (res.data.authStatus === 0) {
                                    // 未注册
                                    this.router.replace({
                                        path: "/pages/manage/mina/register",
                                    });
                                } else if (res.data.authStatus === 90) {
                                    // 等待注册
                                    this.router.replace({
                                        path: "/pages/manage/mina/query",
                                    });
                                } else {
                                    // 正常用户
                                    this.$store.commit("user/login", res.data);
                                    this.$store.commit("common/update", {
                                        curShop: {},
                                    });
                                    this.router.replace({
                                        isReLaunch: true,
                                        path: "/pages/index/index",
                                    });
                                    this.fn.roleHandle();
                                }
                            } else {
                                this.fn.showModal({
                                    title: "提交失败",
                                    content: res.message,
                                    showCancel: false,
                                });
                            }
                        });
            //     },
            // });
        },
    },

    // 数据计算
    computed: {},

    // 数据监听
    watch: {},
};
</script>


<style lang="scss" scoped>
.page {
    height: 100%;
    background-color: #fff;
}
.main {
    padding-top: px(120);
    padding-left: px(40);
    padding-right: px(40);
}
.tit {
    font-size: px(50);
    padding-bottom: px(100);
    text-align: center;
    padding-bottom: px(60);
}
.inp-box {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #c3c1c2;
    padding: px(30) 0;
    margin-bottom: px(30);
}
.inp-box span {
    font-size: px(32);
    color: #e92e25;
    border-radius: px(15);
    border: 1px solid #e92e25;
    width: px(230);
    height: px(80);
    text-align: center;
    line-height: px(80);
    flex-shrink: 0;
    margin-left: px(30);
}
.inp-box input {
    width: 100%;
}
.inp-box .dis {
    color: #999;
    border-color: #999;
    pointer-events: none;
}
.btn {
    margin-top: px(120);
    color: #fff;
    background-color: #e92e25;
    font-size: px(44);
}
</style>