MrShi
2024-10-25 de76f9f6d15f4e0688b961452d180b94d4cdded3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
<template>
    <view class="box">
        <view class="box_login">
            <view class="box_login_head">预选清单-主播端</view>
            <view class="box_login_item">
                <view class="box_login_item_icon">
                    <image src="@/static/ic_account@2x.png" mode="widthFix"></image>
                </view>
                <input v-model="from.account" placeholder-class="box_login_item_pl" type="text" placeholder="请输入账号" />
            </view>
            <view class="box_login_item">
                <view class="box_login_item_icon">
                    <image src="@/static/ic_passwd@2x.png" mode="widthFix"></image>
                </view>
                <input type="password" v-model="from.password" placeholder-class="box_login_item_pl" placeholder="请输入密码" v-if="!isSee" />
                <input type="text" v-model="from.password" placeholder-class="box_login_item_pl" placeholder="请输入密码" v-else />
                <view class="box_login_item_see" @click="isSee = !isSee">
                    <image src="@/static/ic_visible@2x.png" mode="widthFix" v-if="!isSee"></image>
                    <image src="@/static/ic_invisible@2x.png" mode="widthFix" v-else></image>
                </view>
            </view>
            <view class="box_login_btn" @click="logins">登录</view>
        </view>
    </view>
</template>
 
<script>
    import { loginH5, getByLogin, getUserInfo } from '@/apis/index.js'
    
    export default {
        data() {
            return {
                isSee: false,
                from: {
                    account: '',
                    password: ''
                }
            };
        },
        methods: {
            logins() {
                if (!this.from.account) return uni.showToast({ title: '账号不能为空', icon: 'error', duration: 2000 });
                if (!this.from.password) return uni.showToast({ title: '密码不能为空', icon: 'error', duration: 2000 });
                loginH5({
                    password: this.from.password,
                    username: this.from.account
                }).then(async(res) => {
                    this.$store.commit('setToken', res.data)
                    let user = await getUserInfo()
                    this.$store.commit('setUser', user.data)
                    let result = await getByLogin()
                    this.$store.commit('setConfig', result.data)
                    uni.showToast({ title: '登录成功', icon: 'success', duration: 2000 });
                    uni.redirectTo({ url: '/pages/index_2/index' });
                })
            }
        }
    }
</script>
 
<style lang="scss" scoped>
    .box {
        width: 100vw;
        min-height: 100vh;
        display: flex;
        justify-content: center;
        align-items: center;
        background-image: url('@/static/mb.png');
        background-repeat: no-repeat;
        background-size: 100% 100%;
        .box_login {
            width: 600px;
            height: 460px;
            padding: 60px;
            display: flex;
            align-items: center;
            flex-direction: column;
            justify-content: space-between;
            box-sizing: border-box;
            background: #0d1e41;
            box-shadow: 0px 4px 12px 0px rgba(0,0,0,0.19);
            border-radius: 8px;
            .box_login_head {
                font-size: 36px;
                font-family: PingFangSC-Medium, PingFang SC;
                font-weight: 500;
                color: #FFFFFF;
            }
            .box_login_item {
                width: 100%;
                height: 72px;
                background: rgba(137,159,197,.16);
                border-radius: 8px;
                padding: 0 24px;
                display: flex;
                align-items: center;
                box-sizing: border-box;
                border: 1px solid rgba(137,159,197,.6);
                margin-top: 30px;
                .box_login_item_icon {
                    flex-shrink: 0;
                    width: 30px;
                    height: 30px;
                    margin-right: 20px;
                    image {
                        width: 100%;
                        height: 100%;
                    }
                }
                .box_login_item_see {
                    flex-shrink: 0;
                    width: 30px;
                    height: 30px;
                    cursor: pointer;
                    image {
                        width: 100%;
                        height: 100%;
                    }
                }
                input {
                    flex: 1;
                    height: 100%;
                    font-size: 28px;
                    font-family: PingFangSC-Regular, PingFang SC;
                    font-weight: 400;
                    color: #FFFFFF;
                }
                .box_login_item_pl {
                    font-size: 28px;
                    font-family: PingFangSC-Regular, PingFang SC;
                    font-weight: 400;
                    color: rgba(255,255,255,0.5);
                }
            }
            .box_login_btn {
                width: 100%;
                height: 72px;
                line-height: 72px;
                text-align: center;
                background: #899fc5 linear-gradient(180deg,hsla(0,0%,100%,.35),rgba(0,0,0,.21));
                border-radius: 8px;
                margin-top: 30px;
                font-size: 28px;
                font-family: PingFangSC-Regular, PingFang SC;
                font-weight: 400;
                color: #FFFFFF;
                cursor: pointer;
            }
        }
    }
</style>