fix
lefengyang
3 days ago 317203135b0faba447e3c47298976709d28dc56f
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
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
<template>
    <view class="page_bg">
        <uv-navbar title=" " :placeholder="true" leftIcon="" bgColor="rgba(0,0,0,0)"
            titleStyle="color:#fff"></uv-navbar>
        
        <view class="login_logo">
            <image class="ph" src="/static/img/logo.png" mode="widthFix"></image>
            <view class="name">     
                欢迎,请登录
            </view>
        </view>
        
        <view class="register">
            <view class="item">
                <uv-input placeholder="请输入手机号/邮箱" border="none" v-model="userName"></uv-input>
            </view>
            <view class="item">
                <uv-input placeholder="请输入密码" :password="isEye" border="none" v-model="password"></uv-input>
                <view class="eye" @click="isEye = !isEye">
                    <uv-icon v-if="isEye" name="eye-off" color="#666" size="40rpx"></uv-icon>
                    <uv-icon v-else name="eye" color="#666" size="40rpx"></uv-icon>
                </view>
            </view>
            <view class="item_login">
                <navigator class="link" url="/pages/register/register" hover-class="none">
                    还没有账号?去注册
                </navigator>
            </view>
            <view class="item_agree">
                <uv-checkbox-group v-model="agree" size="28rpx" labelSize="28rpx">
                    <uv-checkbox activeColor="#268DFF" name="agree" label="我已阅读并同意" labelColor="#666"></uv-checkbox>
                    <navigator class="link" url="/pages/policy/policy?id=1" hover-class="none">《用户协议》</navigator>
                    和
                    <navigator class="link" url="/pages/policy/policy?id=2" hover-class="none">《隐私政策》</navigator>
                </uv-checkbox-group>
            </view>
            <view class="item_btn">
                <uv-button text="登录" color="linear-gradient( 142deg, #6FD2FF 0%, #268DFF 100%)" shape="circle" size="large" @click="clickLogin()"></uv-button>
            </view>
        </view>
        
        <!-- 协议同意弹出框 -->
        <uv-popup ref="popupAgree" round="15" :safeAreaInsetBottom="false">
            <view class="popup_agree">
                <view class="title">
                    请阅读并同意以下条款
                </view>
                <view class="text">
                    我已阅读并同意
                    <navigator class="link" url="/myPages/agreement/agreement" hover-class="none">《服务协议》</navigator>和
                    <navigator class="link" url="/myPages/privacy/privacy" hover-class="none">《隐私政策》</navigator>
                </view>
                <view class="btn">
                    <view class="btn_item">
                        <uv-button type="primary" shape="circle" text="取消" :plain="true" :custom-style="customStyle" @click="clickAgreeClose"></uv-button>
                    </view>
                    <view class="btn_item">
                        <uv-button type="primary" shape="circle" text="同意" color="#268DFF" @click="clickAgreeOk"></uv-button>
                    </view>
                </view>
            </view>
        </uv-popup>
        
        
    </view>
</template>
 
<script>
    import { login,userInfo } from '@/api/api.js'
    export default {
        data() {
            return {
                userName: '18646195977',
                password: '123456',
                agree: [],
                isEye: true
            }
        },
        onLoad() {
 
        },
        methods: {
            clickAgreeClose(){
                this.$refs.popupAgree.close();
            },
            clickAgreeOk(){
                this.agree = ['agree']
                this.$refs.popupAgree.close();
            },
            clickLogin(){
                if(!this.userName){
                    uni.showToast({
                        title: '请输入账号',
                        duration: 2000,
                        icon: 'none'
                    });
                    return
                }
                if(!this.password){
                    uni.showToast({
                        title: '请输入密码',
                        duration: 2000,
                        icon: 'none'
                    });
                    return
                }
                if(this.agree.length == 0){
                    this.$refs.popupAgree.open();
                    return
                }
                uni.showLoading({
                    title: '登陆中'
                });
                login({
                    username: this.userName,
                    password: this.password
                }).then(res=>{
                    console.log('登陆----',res)
                    if(res.code == 200){
                        uni.setStorageSync('token', res.token)
                        userInfo().then(res=>{
                            uni.setStorageSync('userId', res.user.userId)
                            uni.hideLoading();
                            uni.reLaunch({
                                url: '/pages/index/index'
                            });
                        })
                    }
                    else{
                        uni.hideLoading();
                        uni.showToast({
                            title: res.msg,
                            duration: 2000,
                            icon: 'none'
                        });
                    }
                })
            },
            changeAgree(e){
                //console.log(e.detail.value.length)
                this.agree = e.detail.value.length
            },
        }
    }
</script>
 
<style lang="scss" scoped>
    .popup_agree{
        width: 650rpx;
        box-sizing: border-box;
        padding:50rpx 40rpx;
        .title{
            text-align: center;
            font-size: 34rpx;
            color:#000;
            font-weight: bold;
            line-height: 50rpx;
        }
        .text{
            color: #333;
            font-size: 28rpx;
            line-height: 40rpx;
            display: flex;
            align-items: center;
            justify-content: center;
            padding:30rpx 0 50rpx;
            .link{
                color: #3086F3;
                font-size: 28rpx;
                line-height: 40rpx;
            }
        }
        .btn{
            display: flex;
            align-items: center;
            justify-content: space-between;
            .btn_item{
                width: 47%;
            }
        }
    }
    .register{
        padding:0 60rpx;
        .item_agree{
            display: flex;
            align-items: center;
            font-size: 27rpx;
            color: rgba(0,0,0,0.85);
            line-height: 30rpx;
            margin-top: 80rpx;
            .link{
                font-size: 27rpx;
                color: #3086F3;
            }
            .item_agree_info{
                display: flex;
                align-items: center;
            }
        }
        .item_btn{
            margin-top: 40rpx;
        }
        .item{
            margin-top: 46rpx;
            height: 100rpx;
            background: #ECEFF6;
            border-radius: 23rpx 23rpx 23rpx 23rpx;
            display: flex;
            align-items: center;
            justify-content: space-between;
            box-sizing: border-box;
            padding:0 20rpx;
        }
        .item_login{
            padding:20rpx 0;
            .link{
                font-size: 27rpx;
                color: #3086F3;
                line-height: 40rpx;
            }
        }
    }
    .login_logo{
        display: flex;
        align-items: center;
        justify-content: center;
        flex-direction: column;
        padding-top: 100rpx;
        .ph{
            width: 200rpx;
            height: 200rpx;
            flex-shrink: 0;
        }
        .name{
            font-weight: 600;
            font-size: 38rpx;
            color: rgba(0,0,0,0.65);
            line-height: 50rpx;
            margin-top: 30rpx;
        }
    }
    .page_bg {
        width: 100%;
        min-height: calc(100vh - var(--window-bottom));
        background: url('/static/img/bg_2.jpg') no-repeat center top;
        background-size: 100% auto;
    }
</style>