k94314517
2024-04-09 02bc3bfe47e3d5311a0bb041c94e70a34b1ca73c
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
<template>
    <view class="login">
        <view class="login_bg" :style="{ backgroundImage: 'url(' + backgroundImg + ')' }"></view>
        <view class="login_box">
            <view class="login_box_icon">
                <image src="@/static/icon/logo@2x.png" mode="widthFix"></image>
            </view>
            <view class="login_box_title">云易保客户服务系统</view>
            <view class="login_box_list">
                <view class="login_box_list_item">
                    <image src="@/static/icon/login_ic_account@2x.png" mode="widthFix"></image>
                    <input type="text" v-model="from.username" placeholder="账号" />
                </view>
                <view class="login_box_list_item">
                    <image src="@/static/icon/login_ic_account@2x.png" mode="widthFix"></image>
                    <input type="password" v-model="from.password" placeholder="密码" />
                </view>
                <!-- <view class="login_box_list_item">
                    <image src="@/static/icon/login_ic_password@2x.png" mode="widthFix"></image>
                    <input type="text" placeholder="验证码" />
                    <text class="login_box_list_item_code">获取验证码</text>
                </view> -->
            </view>
            <view class="login_box_btn">
                <u-button text="立即登录" shape="circle" color="#437CB3" size="large" @click="login"></u-button>
            </view>
        </view>
    </view>
</template>
 
<script>
    export default {
        data() {
            return {
                backgroundImg: require('@/static/background/login_bg@2x.png'),
                from: {
                    username: '',
                    password: ''
                }
            };
        },
        methods: {
            login() {
                var that = this;
                if (!that.from.username) return uni.showToast({
                    title: '请输入账号',
                    icon: 'none'
                })
                if (!that.from.password) return uni.showToast({
                    title: '请输入密码',
                    icon: 'none'
                })
                uni.login({
                    provider: 'weixin',
                    success: async function (loginRes) {
                        let { code } = loginRes;
                        let res = await that.$u.api.loginByWxMini({
                            code,
                            ...that.from
                        })
                        if (res.code === 200) {
                            that.$store.commit('setCookies', res.data)
                            let user = await that.$u.api.getUserInfo()
                            if (user.code === 200) {
                                that.$store.commit('setUserInfo', user.data)
                                uni.reLaunch({
                                    url: '/pages/index/index'
                                })
                            }
                        }
                    }
                });
            }
        }
    }
</script>
 
<style lang="scss" scoped>
    .login {
        width: 100vw;
        height: 100vh;
        background: linear-gradient( 180deg, rgba(67,124,179,0.2) 0%, rgba(67,124,179,0) 100%);
        .login_bg {
            position: fixed;
            top: 0;
            left: 0;
            width: 100vw;
            height: 50vh;
            background-repeat: no-repeat;
            background-size: 100% 100%;
        }
        .login_box {
            width: 100vw;
            padding: 0 60rpx;
            display: flex;
            align-items: center;
            justify-content: center;
            flex-direction: column;
            box-sizing: border-box;
            position: relative;
            top: 50%;
            transform: translate(0, -70%);
            .login_box_icon {
                width: 180rpx;
                height: 180rpx;
                image {
                    width: 100%;
                    height: 100%;
                }
            }
            .login_box_title {
                font-weight: 600;
                font-size: 44rpx;
                color: #333333;
                font-style: normal;
                margin-top: 40rpx;
                margin-bottom: 120rpx;
            }
            .login_box_list {
                width: 100%;
                display: flex;
                flex-direction: column;
                .login_box_list_item {
                    width: 100%;
                    height: 98rpx;
                    background: #FFFFFF;
                    border-radius: 8rpx;
                    margin-bottom: 40rpx;
                    padding: 0 40rpx;
                    box-sizing: border-box;
                    display: flex;
                    align-items: center;
                    &:last-child {
                        margin: 0 !important;
                    }
                    image {
                        width: 40rpx;
                        height: 40rpx;
                        flex-shrink: 0;
                        margin-right: 24rpx;
                    }
                    input {
                        flex: 1;
                        height: 100%;
                        font-weight: 400;
                        font-size: 30rpx;
                        color: #222222;
                        font-style: normal;
                    }
                    .login_box_list_item_code {
                        flex-shrink: 0;
                        font-weight: 400;
                        font-size: 26rpx;
                        color: #437CB3;
                        font-style: normal;
                        margin-left: 24rpx;
                    }
                }
            }
            .login_box_btn {
                width: 100%;
                margin-top: 80rpx;
            }
        }
    }
</style>