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
<template name="index">
<view class="index">
<view class="temp">
<view class="btnList">
<button class="btnStaff" type="primary" @click="staff">首次填报</button>
<button class="btnSecurity" type="primary" @click="fillInDay">每日签到</button>
<button class="btnSecurity" type="primary" @click="getScancode">安保测温</button>
<image class="img" :src="imgSrc" mode="widthFix" @click="modalName = 'Image'">
<view class="tips">入园请向门卫出示健康码</view>
</view>
</view>
<view class="cu-modal" :class="modalName=='Image'?'show':''" @tap="modalName=''">
<view class="cu-dialog">
<view class="bg-img">
<view class="cu-bar justify-end text-black">
<view class="action" @tap="modalName = ''">
<text class="cuIcon-close"></text>
</view>
</view>
</view>
<image :src="imgSrc" mode="widthFix"></image>
<view class="cu-bar bg-white">
<view class="action margin-0 flex-sub solid-left text-right" @tap="modalName = ''"></view>
</view>
</view>
</view>
</view>
</template>
<script>
export default {
components: {},
name: "home",
data() {
return {
imgSrc:'',
modalName:'',
flag:true,
securityFlag:false,
userId:''
};
},
onLoad: function(option) {
let that = this
// #ifdef MP-WEIXIN
wx.login({
success(res) {
if (res.code) {
let code = res.code
that.getUserInfo(code)
} else {
console.log('登录失败!' + res.errMsg)
}
}
})
// #endif
},
onShow() {
if(this.$store.state.user.userInfo.idCard){
this.getUserInfo(code)
}
},
methods: {
getImg(){
this.$http.get(`/sict-ncov/user/qrcode`).then(res => {
const d = res.data
if (d.code == 1) {
this.imgSrc = d.object
}
}).catch(err => {
console.log(err)
})
},
// 员工跳转
staff() {
uni.navigateTo({
url: `/pages/fillIn/fillIn`
})
},
// 安保跳转
// security() {
// uni.navigateTo({
// url: `/pages/security/security?userId=${this.userId}`
// })
// },
getScancode(){
if(this.$store.state.user.userInfo.roleId == '1003'){
var _this = this;
// 允许从相机和相册扫码
wx.scanCode({
success: (res) => {
_this.userId = res.result;
if(_this.securityFlag&&_this.userId){
uni.navigateTo({
url: `/pages/security/security?userId=${_this.userId}`
})
}
}
})
}else{
uni.showToast({
icon: 'none',
title: '暂无权限,仅安保人员有此权限!'
})
}
},
fillInDay() {
if(!this.$store.state.user.userInfo.idCard){
uni.showToast({
icon: 'none',
title: '请先上报个人资料!'
})
}else{
uni.navigateTo({
url:`/pages/fillInDay/fillInDay`
})
}
},
// 获取用户信息
getUserInfo(code) {
this.$http.post(`/sict-ncov/user/auth?code=${code}`).then(res => {
const d = res.data
if (d.code == 1) {
let userInfo = d.object
if(userInfo.roleId == '1003'){
this.securityFlag=true
}
let obj = Object.assign({}, this.$store.getters.userInfo)
if (obj.avatarUrl) {
userInfo.avatarUrl = obj.avatarUrl
}
this.$store.dispatch('user/setInfo', Object.assign(obj, userInfo))
this.$store.dispatch('user/setToken', d.result)
this.getImg()
if(this.userId){
this.security()
}
}
}).catch(err => {
console.log(err)
})
},
}
}
</script>
<style lang="scss" scoped>
.temp {
font-size: 40px;
text-align: center;
height: 100vh;
width: 100vw;
background-repeat: no-repeat;
background-size: cover;
background-image: url('http://139.9.163.126/gastric/static/background.jpg');
.btnList{
padding-top: 395upx;
.btnStaff,.btnSecurity{
background-color: #92d0f1;
color: #FFFFFF;
border-radius: 60upx;
width: 52%;
text-align: center;
}
.btnSecurity{
margin-top:45upx;
}
.img{
margin-top:45upx;
width: 200upx;
height: 200upx;
}
.tips{
margin-top:25upx;
font-weight: bold;
font-size: 28upx;
color:#FFFFFF;
}
}
}
</style>