zhangxiaoxu123456
2021-12-06 f32f7d699607bb159d25dcf441942370aba2c968
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
249
250
251
252
253
254
255
256
257
258
259
260
<template>
    <view class="login-wrap">
        <view class="login-wrap-inside">
            <view class="login-main">
                <text class="title">金隅太行水泥智慧工会</text>
                <view class="login-main-inside">
                    <text class="welcom">欢迎登陆!</text>
                </view>
                <view class="user-box">
                    <u-form :model="valiFormData" ref="valiFormData">
                        <u-form-item label="账号" prop="loginName">
                            <u-input v-model="valiFormData.loginName" class="uni-input" placeholder="请输入账号"/>
                        </u-form-item>
                        <u-form-item label="密码" prop="password">
                            <view class="login-flex-box">
                                <u-input :password-icon="true" type="password" v-model="valiFormData.password" placeholder="请输入密码"></u-input>
                            </view>
                        </u-form-item>
                    </u-form>
                    <u-button plain hover-class="none" class="dengluBtn" size="mini" open-type="getUserInfo" @getuserinfo="appLoginWx('valiFormData')">绑定</u-button>
                </view>
            </view>
        </view>
    </view>
</template>
 
<script>
    export default {
        data() {
            return {
                valiFormData: {
                    loginName: '',
                    password: '', 
                    openid:''
                },
                rules: {
                    loginName:[
                        {
                            required: true,
                            message: '账号不能为空',
                            trigger: ['change', 'blur']
                        }
                    ],
                    password: [
                        {   
                            required: true,
                            min:6,
                            message: '密码长度不能小于6个字符',
                            trigger: ['change', 'blur']
                        }
                    ]
                },
                showPassword: false,
                type_text: "text",
                type_password: "password",
                psdType:"password"
            }
        },
        onLoad(options) {
            console.log('options----',options)
            if(options.openid) {
                this.valiFormData.openid = options.openid
            }
        },
        onReady() {
            this.$refs.valiFormData.setRules(this.rules)
        },
        methods: {
            changePassword: function() {
                this.showPassword = !this.showPassword
            },
            appLoginWx(ref) {
                // this.$u.toast('Hello uView!');
                this.$refs.valiFormData.validate(valid => {
                    if(valid) {
                        console.log(' this.valiFormData.loginName----',this)
                        this.$u.api.loginIndex(this.valiFormData).then(res => {
                            console.log('this.valiFormData----',this.valiFormData)
                            if(res.success) {
                                    this.setStore("userInfo",res.obj)
                                    uni.switchTab({
                                        url: '/pages/learn/learn'
                                    });
                                }
                        })
                        // uni.request({
                        //     header: {
                        //         'content-type': 'application/x-www-form-urlencoded' //自定义请求头信息
                        //     },
                        //     // url: 'http://39.96.92.240:8099/user/login',
                        //     url: 'https://hesuancj.cn:8889/user/login',
                        //     method: 'post',
                        //     data: {
                        //         loginName: this.valiFormData.loginName,
                        //         password:this.valiFormData.password,
                        //         openid:this.valiFormData.openid
                        //     },
                        // }).then(data => {
                        //     var [error, res ] = data;
                        //     console.log(res,'............')
                        //     console.log(' this----',this.valiFormData)
                        //     this.$u.toast(res.data.message);
                        //     if(res.data.success) {
                        //         this.setStore("userInfo",res.data.obj)
                        //         uni.switchTab({
                        //             url: '/pages/learn/learn'
                        //         });
                        //     }
                            
                            // this.$refs.uToast.show({
                            //     title: res.message,
                            //     type: res.success,
                            //     url: '/pages/learn/learn'
                            // })
                        // })
                    }
                })
                
                // uni.getProvider({
                //     service: 'oauth',
                //     success: function(res) {
                //         if (~res.provider.indexOf('weixin')) {
                //             uni.login({
                //                 provider: 'weixin',
                //                 success: (res2) => {
                //                     uni.getUserInfo({
                //                         provider: 'weixin',
                //                         success: (info) => { //这里请求接口
                //                             console.log(res2);
                //                             console.log(info);
                //                             uni.request({
                //                                     url: 'http://39.96.92.240:8099/wx/login'
                //                                 })
                //                                 .then(data => {//data为一个数组,数组第一项为错误信息,第二项为返回数据
                //                                     var [error, res]  = data;
                //                                     console.log(res.data);
                //                                 })
 
                //                         },
                //                         fail: () => {
                //                             uni.showToast({
                //                                 title: "微信登录授权失败",
                //                                 icon: "none"
                //                             });
                //                         }
                //                     })
 
                //                 },
                //                 fail: () => {
                //                     uni.showToast({
                //                         title: "微信登录授权失败",
                //                         icon: "none"
                //                     });
                //                 }
                //             })
 
                //         } else {
                //             uni.showToast({
                //                 title: '请先安装微信或升级版本',
                //                 icon: "none"
                //             });
                //         }
                //     }
                // });
            }
        }
    }
</script>
 
<style>
 
</style>
<style lang="scss" scoped>
    /deep/ .uni-forms-item {
        border-bottom: 1px solid #ffffff;
    }
 
    /deep/ .uni-forms-item__inner {
        padding-top: 36rpx;
        padding-bottom: 22rpx;
    }
    /deep/ .u-btn--default{
        background-color: transparent!important;
        color: #fff!important;
    }
    /deep/ .u-hairline-border:after{
        border:none!important;
    }
    /deep/ .u-size-mini{
        width: 100%!important;
    }
    .login-wrap {
        width: 100%;
        height: 100vh;
        background: $login-bj;
        background-size: 100% 100%;
        display: flex;
        justify-content: center;
    }
    .login-flex-box{
        display: flex;
    }
    .login-wrap-inside {
        width: 60%;
        display: flex;
        justify-content: center;
 
        .login-main {
            display: flex;
            flex-direction: column;
            margin-top: 50%;
 
            .title {
                text-align: center;
                color: #34404e;
                font-size: 42rpx;
                text-shadow: 0px 4px 4px rgba(0, 0, 0, 0.4);
            }
        }
    }
 
    .login-main-inside {
        margin-top: 100rpx;
 
        .welcom {
            color: #ff3c2e;
            font-size: 36rpx;
        }
    }
 
    // /deep/.uni-input-wrapper {
    //     /* #ifndef APP-NVUE */
    //     display: flex;
    //     /* #endif */
    //     padding: 8px 13px;
    //     flex-direction: row;
    //     flex-wrap: nowrap;
    // }
 
    .user-box {
        margin-top: 60rpx;
    }
 
    .dengluBtn {
        background-color: #ff4e00!important;
        color: #fff;
        font-size: 30rpx;
        border-radius: 50rpx;
        width: 450rpx;
        height: 74rpx;
        display: flex;
        justify-content: center;
        align-items: center;
        margin-top: 60rpx;
    }
 
    
 
    
</style>