马宇豪
2023-06-20 bfdcdce6e21118977ed026eb5e4c06b1777bc32c
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
<template>
    <view class="box">
        <view class="header">
            <view class="titleFirst"><b>新疆维吾尔自治区自然灾害综合监测预警</b></view>
            <view class="titleSecond"><b>自然灾害综合风险预警发布及响应联动系统</b></view>
        </view>
        <view>    
            <u-form :model="form" ref="uForm" class="form" >
                <u-form-item ><u-input color="#fff" v-model="form.name" placeholder="请输入用户名"  /></u-form-item>
                <u-form-item ><u-input color="#fff" v-model="form.pwd" type="password" placeholder="请输入密码"  /></u-form-item>
                <!-- <view class="loginPsw">
                       <u-checkbox-group >
                            <u-checkbox disabled="true"></u-checkbox><text style="color: #fff;">自动登录</text>
                       </u-checkbox-group>
                        <text style="color: lightblue;">忘记密码</text>
                </view> -->
                <u-form-item ><u-button  type="primary" style="width: 100%;" @click="Login">登录</u-button></u-form-item>
                <view style="color: white;margin-left:25%;margin-top: 70%;">技术支持:中国科学院</view>
            </u-form>
        </view>
    </view>
</template>
 
<script>
    import {login} from '../../api/index.js';
    import store from '@/store/index.js'
    export default {
        data() {
            return {
                form: {
                    name: '',
                    pwd: ''
                },
                type: ''
            }
        },
        onShow() {
            uni.clearStorageSync();
            uni.clearStorage();
        },
        methods: {
            Login(){
                login(this.form).then(res => {
                    console.log("res",res)
                    if (res.code === 100) {
                        uni.setStorageSync("tk", res.data.tk);
                        uni.setStorageSync("uid",res.data.uid);
                        uni.setStorageSync('user', res.data);
                        uni.setStorageSync('roleName', res.data.role.roleName);
                        if(res.data.role.roleName == '工作人员'){
                            this.$store.commit('setRoleId', 'user_other');
                            uni.switchTab({
                                 url: '/pages/tabBar/notice/notice'
                              });
                        }else if (res.data.role.roleName == '管理员'){
                            this.$store.commit('setRoleId', '');
                            uni.showToast({
                                icon: "none",
                                title: '管理员请使用平台登录'
                            });
                        }else{
                            this.$store.commit('setRoleId', 'user_leader');
                            uni.switchTab({
                                url: '/pages/tabBar/examine/examine'
                            });
                        }
                    }
                }).catch(err=>{
                })
            },
        }
    }
</script>
 
<style>
.box{
    width: 100%;
    height: 100vh;
    background: url('../../static/bg.jpeg') no-repeat;
    background-size: 100% 100%;
    background-attachment: fixed;/* 不设置的话页面滑动时,背景会不铺满*/
    display: flex;
    flex-direction: column;
}
.titleFirst{
    text-align: center;
    font-size: 18px;
    color:#fff;
}
.titleSecond{
    text-align: center;
    font-size: 19px;
    color:#fff;
    margin-top: 10px;
}
.header {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding-top:100px;
    text-shadow:0 0 1px #000;
}
.form{
    width: 80%;
    margin: 100px auto 0px;
    
}
.loginPsw{
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
}
</style>