xwt
2025-06-10 676db89a661ba8af8da04f4503c39b1bc0d2c25e
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
<template>
    <uni-base-page>
        <view slot="page"
            style="background-color:#e6e6e6;margin-top: 5%;margin-left:15px;margin-right:15px;padding: 20px;border-radius: 10px;">
            <view class="image-container">
                <image src="../../static/img/bj/bg2.png" style=" max-width: 99%;"></image>
            </view>
            <uni-input-row type="text" title="账号" v-model="account" :focus="accountFocus"
                @resetFocus="e=>{accountFocus=e;}" clearable placeholder="请输入账号"></uni-input-row>
            <uni-input-row type="password" title="密码" v-model="password" :focus="passwordFocus"
                @resetFocus="e=>{passwordFocus=e}" displayable @confirm="bindLogin" placeholder="请输入密码"></uni-input-row>
            <view class="btn-row">
                <button type="primary" class="primary" @tap="bindLogin">登录</button>
            </view>
        </view>
    </uni-base-page>
</template>
 
<script>
    import {
        downWgt
    } from '../../common/update.js';
 
    export default {
        data() {
            return {
                accountFocus: false,
                passwordFocus: false,
                tokenId: '',
                account: '',
                userName: '',
                password: '',
                factoryArray: [],
                //selectFactory: { value: this.$loginInfo.factoryKey||'',text:this.$loginInfo.factoryName||'',index: this.$loginInfo.factoryIndex}, //选择的账套信息
                selectFactory: {},
                selectLanguage: {}, //选择的语言
            };
        },
        async onReady() {
            this.account = this.$loginInfo.account || '';
            this.selectFactory = this.$loginInfo.factory || 0;
            this.selectLanguage = this.$loginInfo.language || 0;
        },
        methods: {
            bindLogin() {
                if (!this.account) {
                    uni.showToast({
                        icon: 'none',
                        title: '请输入账号'
                    });
                    this.accountFocus = true;
                    return;
                }
                if (!this.password) {
                    uni.showToast({
                        icon: 'none',
                        title: '请输入密码'
                    });
                    this.passwordFocus = true;
                    return;
                }
                uni.showLoading({
                    mask: true,
                    title: "登录中..."
                });
                uni.request({
                    url: this.$store.state.serverInfo.serverAPI + '/login/login',
                    method: "POST",
                    header: {
                        'content-type': "application/json"
                    },
                    data: {
                        userID: this.account,
                        userPass: this.password
                    },
                    success: res => {
                        if (res.data.status == 0) {
                            this.toMain(res.data.data.tbBillList[0]);
                        } else {
                            uni.showToast({
                                icon: 'none',
                                title: res.data.message
                            });
                        }
                    },
                    fail(err) {
                        uni.showToast({
                            icon: 'none',
                            title: "服务器断开"
                        });
                    },
                    complete: () => {
                        uni.hideLoading();
                    }
                });
            },
            toMain(user) {
                this.$loginInfo.account = this.account;
                this.$loginInfo.userName = this.userName;
                this.$loginInfo.factory = this.selectFactory;
                this.$loginInfo.language = this.selectLanguage;
                this.$loginInfo.menu = this.menu;
                this.$loginInfo.deptNo = user.departmentid;
                this.$loginInfo.chineseName = user.fname;
                this.$loginInfo.id = user.fid;
                this.$loginInfo.roleid=user.roleids;
                this.$login();
                if (this.$loginInfo.forcedLogin) {
                    uni.reLaunch({
                        url: 'main'
                    });
                } else {
                    uni.navigateBack();
                }
            }
        }
    };
</script>
 
<style>
    .action-row {
        display: flex;
        flex-direction: row;
        justify-content: center;
    }
 
    .action-row navigator {
        color: #007aff;
        padding: 0 10px;
    }
 
    .btn-row {
        /* margin-top: 20px; */
        padding: 10px;
    }
 
    button.primary {
        background-color: #0faeff;
    }
 
    .img-container {
        width: 100%;
        height: auto;
        max-width: 100%;
    }
 
    .img-container image {
        max-width: 100%;
        height: auto;
        display: block;
    }
    
    @media screen and (min-width: 768px) {
      .img-container {
        max-width: 50%; /* 根据实际情况设置适当的宽度 */
      }
    }
</style>