jiangping
2024-05-16 a4945c89ee72aa8b6f2c0a75653a3256a2b30b4f
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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
<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 class="a">
            <view style=" display: inline-flex;align-items: center;">
                <checkbox-group  @change="onCheckboxChange" >
                    <checkbox    > </checkbox> 
                </checkbox-group>
             我已阅读和同意《
             <view class="c" @click="goAgreement(0)" style="color: dodgerblue;cursor: pointer">服务协议</view>》和《
             <view class="c"   @click="goAgreement(1)" style="color: dodgerblue;cursor: pointer">隐私协议</view>》
             </view>
        </view>
    </view>
</template>
 
<script>
    export default {
        data() {
            return {
                backgroundImg: require('@/static/background/login_bg@2x.png'),
                from: {
                    username: '',
                    password: '',
                    readed:false
                }
            };
        },
        methods: {
            onCheckboxChange(e){
                 let val = e.detail.value
                    if(val.length>0){
                      this.from.readed =true
                    }else{
                      this.from.readed =false
                    } 
                console.log(this.from.readed)
            },
            goAgreement(type){
                uni.navigateTo({
                    url: `/pages/login/agreement?type=${type}`
                })
            },
            login() {
                var that = this;
                if (!that.from.username) return uni.showToast({
                    title: '请输入账号',
                    icon: 'none'
                })
                if (!that.from.password) return uni.showToast({
                    title: '请输入密码',
                    icon: 'none'
                })
                if (!that.from.readed  ) 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>
    .a{
        font-size:12px;
        bottom: 10px;
        position: absolute;
        width: 100%;
        display: block;
        text-align: center;
    }
     .b{width: 12px;height: 12px;display: inline; }
     /* #ifdef MP-WEIXIN */
     checkbox {
         transform: scale(0.67);
         border-radius: 50rpx;
     }
     
     checkbox .wx-checkbox-input {
         border-radius: 50%;
         border-color: #AAAAAA !important;
     }
     
     checkbox .wx-checkbox-input.wx-checkbox-input-checked {
         background: #f50;
         border-color: #f50 !important;
         color: #fff;
     }
     /* #endif */
     
  
    .c{font-size: 12px;color:darkblue; display: inline;}
    .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>