|
@@ -1,214 +1,247 @@
|
1
|
1
|
<template>
|
2
|
|
- <view class="login">
|
3
|
|
- <view class="login_title"> 医疗服务中心转运系统 </view>
|
4
|
|
- <form @submit="login" class="form">
|
5
|
|
- <view class="form_item">
|
6
|
|
- <view class="form_title">用户名:</view>
|
7
|
|
- <input class="form_input" name="username" :value="username" placeholder="请输入用户名" />
|
8
|
|
- </view>
|
9
|
|
- <view class="form_item">
|
10
|
|
- <view class="form_title">密<text class="placeholder"></text>码:</view>
|
11
|
|
- <input class="form_input" name="password" :value="password" password placeholder="请输入密码" />
|
12
|
|
- </view>
|
13
|
|
- <view class="form_item">
|
14
|
|
- <checkbox-group name="savePassword">
|
15
|
|
- <label>
|
16
|
|
- <checkbox value="true" :checked="savePassword" /><text>记住密码</text>
|
17
|
|
- </label>
|
18
|
|
- </checkbox-group>
|
19
|
|
- </view>
|
20
|
|
- <view class="form_submit">
|
21
|
|
- <button form-type="submit">登录</button>
|
22
|
|
- </view>
|
23
|
|
- </form>
|
24
|
|
- <view class="tips red">
|
25
|
|
- (此系统为护士人员使用,其他科室人员请勿进行操作)
|
26
|
|
- </view>
|
|
2
|
+ <view class="login">
|
|
3
|
+ <view class="login_title"> 医疗服务中心转运系统 </view>
|
|
4
|
+ <form @submit="login" class="form">
|
|
5
|
+ <view class="form_item">
|
|
6
|
+ <view class="form_title">用户名:</view>
|
|
7
|
+ <input class="form_input" name="username" :value="username" placeholder="请输入用户名" />
|
|
8
|
+ </view>
|
|
9
|
+ <view class="form_item">
|
|
10
|
+ <view class="form_title">密<text class="placeholder"></text>码:</view>
|
|
11
|
+ <input class="form_input" name="password" :value="password" password placeholder="请输入密码" />
|
|
12
|
+ </view>
|
|
13
|
+ <view class="form_item">
|
|
14
|
+ <view class="form_title">域<text class="placeholder"></text>名:</view>
|
|
15
|
+ <input class="form_input" name="ip" :value="ip" placeholder="请输入域名或IP地址" />
|
|
16
|
+ </view>
|
|
17
|
+ <view class="form_item">
|
|
18
|
+ <checkbox-group name="savePassword">
|
|
19
|
+ <label>
|
|
20
|
+ <checkbox value="true" :checked="savePassword" /><text>记住密码</text>
|
|
21
|
+ </label>
|
|
22
|
+ </checkbox-group>
|
|
23
|
+ </view>
|
|
24
|
+ <view class="form_submit">
|
|
25
|
+ <button form-type="submit">登录</button>
|
|
26
|
+ </view>
|
|
27
|
+ </form>
|
|
28
|
+ <view class="tips red">
|
|
29
|
+ (此系统为护士人员使用,其他科室人员请勿进行操作)
|
|
30
|
+ </view>
|
27
|
31
|
<seiminModel ref="seiminModel"></seiminModel>
|
28
|
|
- </view>
|
|
32
|
+ </view>
|
29
|
33
|
</template>
|
30
|
34
|
|
31
|
35
|
<script>
|
32
|
|
- import {
|
33
|
|
- encryptByEnAES,
|
34
|
|
- encryptByDeAES
|
35
|
|
- } from "../../utils/index.js";
|
36
|
|
- import {
|
37
|
|
- mapActions,
|
38
|
|
- mapMutations
|
39
|
|
- } from "vuex";
|
40
|
|
- export default {
|
41
|
|
- data() {
|
42
|
|
- return {
|
|
36
|
+ import {
|
|
37
|
+ changeIP,
|
|
38
|
+ } from "../../request/config.js";
|
|
39
|
+ import {
|
|
40
|
+ encryptByEnAES,
|
|
41
|
+ encryptByDeAES
|
|
42
|
+ } from "../../utils/index.js";
|
|
43
|
+ import {
|
|
44
|
+ mapActions,
|
|
45
|
+ mapMutations
|
|
46
|
+ } from "vuex";
|
|
47
|
+ export default {
|
|
48
|
+ data() {
|
|
49
|
+ return {
|
43
|
50
|
reFresh: '',
|
44
|
|
- username: "", //用户名
|
45
|
|
- password: "", //密码
|
46
|
|
- savePassword: false, //是否记住密码
|
47
|
|
- };
|
48
|
|
- },
|
49
|
|
- methods: {
|
50
|
|
- ...mapActions("login", ["vxLogin"]),
|
51
|
|
- ...mapMutations("other", ["changeSeiminModel", "resetVxOther"]),
|
52
|
|
- ...mapMutations("dictionary", ["resetVxDictionary"]),
|
53
|
|
- ...mapMutations("login", ["resetVxLogin"]),
|
54
|
|
- ...mapMutations("system", ["resetVxSystem"]),
|
55
|
|
- // 重置vuex数据
|
56
|
|
- resetVuex() {
|
57
|
|
- this.resetVxOther();
|
58
|
|
- this.resetVxDictionary();
|
59
|
|
- this.resetVxLogin();
|
60
|
|
- this.resetVxSystem();
|
61
|
|
- },
|
62
|
|
- // 登录
|
63
|
|
- login(e) {
|
64
|
|
- let {
|
65
|
|
- username, //账号
|
66
|
|
- password, //密码
|
67
|
|
- savePassword, //是否记住密码
|
68
|
|
- } = e.detail.value;
|
69
|
|
-
|
70
|
|
- savePassword = savePassword.length > 0;
|
71
|
|
- username = username.trim();
|
72
|
|
- password = password.trim();
|
73
|
|
-
|
74
|
|
- // 用户名,密码,域名(ip)不能为空
|
75
|
|
- if (username === "" || password === "") {
|
76
|
|
- uni.showToast({
|
77
|
|
- icon: "none",
|
78
|
|
- title: "账号或密码错误",
|
79
|
|
- });
|
80
|
|
- return;
|
81
|
|
- }
|
82
|
|
-
|
83
|
|
- uni.showLoading({
|
84
|
|
- title: "登录中",
|
85
|
|
- mask: true,
|
86
|
|
- });
|
87
|
|
-
|
88
|
|
- let postData = {
|
89
|
|
- username,
|
90
|
|
- password,
|
91
|
|
- type: "APP",
|
92
|
|
- };
|
93
|
|
-
|
94
|
|
- this.vxLogin(postData).then((res) => {
|
95
|
|
- uni.hideLoading();
|
96
|
|
-
|
97
|
|
- if (res.status == 200) {
|
98
|
|
- //获取角色信息
|
99
|
|
- res.user = res.user || {};
|
100
|
|
- res.user.user = res.user.user || {};
|
101
|
|
- let role = res.user.user.role || [];
|
102
|
|
- // 护士角色才能登录
|
103
|
|
- let nurseRole = role.some((item) => item.rolecode === "nurse");
|
104
|
|
- if (!nurseRole) {
|
105
|
|
- uni.showToast({
|
106
|
|
- icon: "none",
|
107
|
|
- title: "暂无护士角色权限!",
|
108
|
|
- });
|
109
|
|
- return;
|
110
|
|
- }
|
111
|
|
-
|
112
|
|
- // 如果记住密码,则缓存到本地
|
113
|
|
- if (savePassword) {
|
114
|
|
- //记住密码
|
115
|
|
- uni.setStorageSync("savePasswordObj", {
|
116
|
|
- username: encryptByEnAES(username), //用户名
|
117
|
|
- password: encryptByEnAES(password), //密码
|
118
|
|
- effectiveDuration: Date.now(), //当前时间戳
|
119
|
|
- });
|
120
|
|
- } else {
|
121
|
|
- uni.removeStorageSync("savePasswordObj");
|
122
|
|
- }
|
123
|
|
- // 跳转到首页(isShowSeiminModel,是否显示切换科室弹窗)
|
|
51
|
+ username: "", //用户名
|
|
52
|
+ password: "", //密码
|
|
53
|
+ ip: "", //域名
|
|
54
|
+ savePassword: false, //是否记住密码
|
|
55
|
+ };
|
|
56
|
+ },
|
|
57
|
+ methods: {
|
|
58
|
+ ...mapActions("login", ["vxLogin"]),
|
|
59
|
+ ...mapMutations("other", ["changeSeiminModel", "resetVxOther"]),
|
|
60
|
+ ...mapMutations("dictionary", ["resetVxDictionary"]),
|
|
61
|
+ ...mapMutations("login", ["resetVxLogin"]),
|
|
62
|
+ ...mapMutations("system", ["resetVxSystem"]),
|
|
63
|
+ // 重置vuex数据
|
|
64
|
+ resetVuex() {
|
|
65
|
+ this.resetVxOther();
|
|
66
|
+ this.resetVxDictionary();
|
|
67
|
+ this.resetVxLogin();
|
|
68
|
+ this.resetVxSystem();
|
|
69
|
+ },
|
|
70
|
+ // 登录
|
|
71
|
+ login(e) {
|
|
72
|
+ let {
|
|
73
|
+ username, //账号
|
|
74
|
+ password, //密码
|
|
75
|
+ ip, //域名
|
|
76
|
+ savePassword, //是否记住密码
|
|
77
|
+ } = e.detail.value;
|
|
78
|
+
|
|
79
|
+ savePassword = savePassword.length > 0;
|
|
80
|
+ username = username.trim();
|
|
81
|
+ password = password.trim();
|
|
82
|
+ ip = ip.trim();
|
|
83
|
+
|
|
84
|
+ // 用户名,密码不能为空
|
|
85
|
+ if (username === "" || password === "") {
|
|
86
|
+ uni.showToast({
|
|
87
|
+ icon: "none",
|
|
88
|
+ title: "账号或密码错误",
|
|
89
|
+ });
|
|
90
|
+ return;
|
|
91
|
+ }
|
|
92
|
+
|
|
93
|
+ // 域名ip正则验证
|
|
94
|
+ let regUrl =
|
|
95
|
+ /^https?:\/\/([\w-]+\.)+((com)|(net)|(org)|(gov\.cn)|(info)|(cc)|(com\.cn)|(net\.cn)|(org\.cn)|(name)|(biz)|(tv)|(cn)|(mobi)|(name)|(sh)|(ac)| (io)|(tw)|(com\.tw)|(hk)|(com\.hk)|(ws)|(travel)|(us)|(tm)|(la)|(me\.uk)|(org\.uk)|(ltd\.uk)|(plc\.uk)|(in)|(eu)|(it)|(jp))(\:([0-9]|[1-9]\d{1,3}|[1-5]\d{4}|6[0-5]{2}[0-3][0-5]))?$/;
|
|
96
|
+ let regIp =
|
|
97
|
+ /^https?:\/\/((25[0-5])|(2[0-4]\d)|(1\d\d)|([1-9]\d)|\d)(\.((25[0-5])|(2[0-4]\d)|(1\d\d)|([1-9]\d)|\d)){3}(\:([0-9]|[1-9]\d{1,3}|[1-5]\d{4}|6[0-5]{2}[0-3][0-5]))?$/;
|
|
98
|
+ if (!regUrl.test(ip) && !regIp.test(ip)) {
|
|
99
|
+ uni.showToast({
|
|
100
|
+ icon: "none",
|
|
101
|
+ title: "请输入正确的域名或IP",
|
|
102
|
+ });
|
|
103
|
+ return;
|
|
104
|
+ }
|
|
105
|
+
|
|
106
|
+ uni.showLoading({
|
|
107
|
+ title: "登录中",
|
|
108
|
+ mask: true,
|
|
109
|
+ });
|
|
110
|
+
|
|
111
|
+ let postData = {
|
|
112
|
+ username,
|
|
113
|
+ password,
|
|
114
|
+ type: "APP",
|
|
115
|
+ };
|
|
116
|
+
|
|
117
|
+ changeIP(ip);
|
|
118
|
+
|
|
119
|
+ this.vxLogin(postData).then((res) => {
|
|
120
|
+ uni.hideLoading();
|
|
121
|
+
|
|
122
|
+ if (res.status == 200) {
|
|
123
|
+ //获取角色信息
|
|
124
|
+ res.user = res.user || {};
|
|
125
|
+ res.user.user = res.user.user || {};
|
|
126
|
+ let role = res.user.user.role || [];
|
|
127
|
+ // 护士角色才能登录
|
|
128
|
+ let nurseRole = role.some((item) => item.rolecode === "nurse");
|
|
129
|
+ if (!nurseRole) {
|
|
130
|
+ uni.showToast({
|
|
131
|
+ icon: "none",
|
|
132
|
+ title: "暂无护士角色权限!",
|
|
133
|
+ });
|
|
134
|
+ return;
|
|
135
|
+ }
|
|
136
|
+
|
|
137
|
+ // 如果记住密码,则缓存到本地
|
|
138
|
+ if (savePassword) {
|
|
139
|
+ //记住密码
|
|
140
|
+ uni.setStorageSync("savePasswordObj", {
|
|
141
|
+ username: encryptByEnAES(username), //用户名
|
|
142
|
+ password: encryptByEnAES(password), //密码
|
|
143
|
+ ip, //域名
|
|
144
|
+ effectiveDuration: Date.now(), //当前时间戳
|
|
145
|
+ });
|
|
146
|
+ } else {
|
|
147
|
+ uni.removeStorageSync("savePasswordObj");
|
|
148
|
+ }
|
|
149
|
+ // 跳转到首页(isShowSeiminModel,是否显示切换科室弹窗)
|
124
|
150
|
this.changeSeiminModel(true);
|
125
|
|
- uni.navigateTo({
|
126
|
|
- url: "/pages/index/index",
|
127
|
|
- });
|
128
|
|
- } else {
|
129
|
|
- this.$refs.seiminModel.show({
|
130
|
|
- skin: "toast",
|
131
|
|
- icon: "error",
|
132
|
|
- content: res.remarks || "登录失败",
|
133
|
|
- });
|
134
|
|
- throw new Error(res.remarks || "登录失败");
|
135
|
|
- }
|
136
|
|
- });
|
137
|
|
- },
|
138
|
|
- },
|
139
|
|
- onLoad() {
|
140
|
|
- // 清除vuex
|
141
|
|
- this.resetVuex();
|
142
|
|
- // 是否记住密码
|
143
|
|
- let savePasswordObj = uni.getStorageSync("savePasswordObj");
|
144
|
|
- if (savePasswordObj) {
|
145
|
|
- let {
|
146
|
|
- username,
|
147
|
|
- password,
|
148
|
|
- effectiveDuration
|
149
|
|
- } = savePasswordObj;
|
150
|
|
- if (Date.now() - effectiveDuration < 10 * 24 * 60 * 60 * 1000) {
|
151
|
|
- //记住密码,10天内有效
|
152
|
|
- this.username = encryptByDeAES(username);
|
153
|
|
- this.password = encryptByDeAES(password);
|
154
|
|
- this.savePassword = true;
|
155
|
|
- }
|
156
|
|
- }
|
157
|
|
- },
|
158
|
|
- };
|
|
151
|
+ uni.navigateTo({
|
|
152
|
+ url: "/pages/index/index",
|
|
153
|
+ });
|
|
154
|
+ } else {
|
|
155
|
+ this.$refs.seiminModel.show({
|
|
156
|
+ skin: "toast",
|
|
157
|
+ icon: "error",
|
|
158
|
+ content: res.remarks || "登录失败",
|
|
159
|
+ });
|
|
160
|
+ throw new Error(res.remarks || "登录失败");
|
|
161
|
+ }
|
|
162
|
+ });
|
|
163
|
+ },
|
|
164
|
+ },
|
|
165
|
+ onLoad() {
|
|
166
|
+ // 清除vuex
|
|
167
|
+ this.resetVuex();
|
|
168
|
+ // 是否记住密码
|
|
169
|
+ let savePasswordObj = uni.getStorageSync("savePasswordObj");
|
|
170
|
+ // 初始化数据
|
|
171
|
+ this.username = '';
|
|
172
|
+ this.password = '';
|
|
173
|
+ this.ip = 'http://zzzx.tjh.com';
|
|
174
|
+ this.savePassword = false;
|
|
175
|
+ if (savePasswordObj) {
|
|
176
|
+ let {
|
|
177
|
+ username,
|
|
178
|
+ password,
|
|
179
|
+ ip,
|
|
180
|
+ effectiveDuration
|
|
181
|
+ } = savePasswordObj;
|
|
182
|
+ if (Date.now() - effectiveDuration < 10 * 24 * 60 * 60 * 1000) {
|
|
183
|
+ //记住密码,10天内有效
|
|
184
|
+ this.username = encryptByDeAES(username);
|
|
185
|
+ this.password = encryptByDeAES(password);
|
|
186
|
+ this.ip = ip;
|
|
187
|
+ this.savePassword = true;
|
|
188
|
+ }
|
|
189
|
+ }
|
|
190
|
+ },
|
|
191
|
+ };
|
159
|
192
|
</script>
|
160
|
193
|
|
161
|
194
|
<style lang="scss" scoped>
|
162
|
|
- .login {
|
163
|
|
- padding: 180rpx 32rpx 32rpx;
|
164
|
|
- height: 100vh;
|
165
|
|
- background: url("../../static/imgs/background.png") no-repeat center bottom;
|
166
|
|
- background-size: contain;
|
167
|
|
-
|
168
|
|
- .login_title {
|
169
|
|
- text-align: center;
|
170
|
|
- color: $defaultColor;
|
171
|
|
- font-weight: bold;
|
172
|
|
- }
|
173
|
|
-
|
174
|
|
- .form {
|
175
|
|
- .form_item {
|
176
|
|
- margin-top: 32rpx;
|
177
|
|
- @include flex;
|
178
|
|
-
|
179
|
|
- .form_title {
|
180
|
|
- @include flex(flex-start, center);
|
181
|
|
- width: 4em;
|
182
|
|
-
|
183
|
|
- .placeholder {
|
184
|
|
- display: inline-block;
|
185
|
|
- width: 1em;
|
186
|
|
- }
|
187
|
|
- }
|
188
|
|
-
|
189
|
|
- .form_input {
|
190
|
|
- box-sizing: content-box;
|
191
|
|
- flex: 1;
|
192
|
|
- padding: 16rpx;
|
193
|
|
- background-color: #fff;
|
194
|
|
- }
|
195
|
|
- }
|
196
|
|
-
|
197
|
|
- .form_submit {
|
198
|
|
- margin-top: 60rpx;
|
199
|
|
- border-radius: 16rpx;
|
200
|
|
-
|
201
|
|
- uni-button {
|
202
|
|
- @include btn_background;
|
203
|
|
- color: #fff;
|
204
|
|
- font-weight: bold;
|
205
|
|
- }
|
206
|
|
- }
|
207
|
|
- }
|
208
|
|
-
|
209
|
|
- .tips {
|
210
|
|
- font-size: 28rpx;
|
211
|
|
- margin-top: 16rpx;
|
212
|
|
- }
|
213
|
|
- }
|
|
195
|
+ .login {
|
|
196
|
+ padding: 180rpx 32rpx 32rpx;
|
|
197
|
+ height: 100vh;
|
|
198
|
+ background: url("../../static/imgs/background.png") no-repeat center bottom;
|
|
199
|
+ background-size: contain;
|
|
200
|
+
|
|
201
|
+ .login_title {
|
|
202
|
+ text-align: center;
|
|
203
|
+ color: $defaultColor;
|
|
204
|
+ font-weight: bold;
|
|
205
|
+ }
|
|
206
|
+
|
|
207
|
+ .form {
|
|
208
|
+ .form_item {
|
|
209
|
+ margin-top: 32rpx;
|
|
210
|
+ @include flex;
|
|
211
|
+
|
|
212
|
+ .form_title {
|
|
213
|
+ @include flex(flex-start, center);
|
|
214
|
+ width: 4em;
|
|
215
|
+
|
|
216
|
+ .placeholder {
|
|
217
|
+ display: inline-block;
|
|
218
|
+ width: 1em;
|
|
219
|
+ }
|
|
220
|
+ }
|
|
221
|
+
|
|
222
|
+ .form_input {
|
|
223
|
+ box-sizing: content-box;
|
|
224
|
+ flex: 1;
|
|
225
|
+ padding: 16rpx;
|
|
226
|
+ background-color: #fff;
|
|
227
|
+ }
|
|
228
|
+ }
|
|
229
|
+
|
|
230
|
+ .form_submit {
|
|
231
|
+ margin-top: 60rpx;
|
|
232
|
+ border-radius: 16rpx;
|
|
233
|
+
|
|
234
|
+ uni-button {
|
|
235
|
+ @include btn_background;
|
|
236
|
+ color: #fff;
|
|
237
|
+ font-weight: bold;
|
|
238
|
+ }
|
|
239
|
+ }
|
|
240
|
+ }
|
|
241
|
+
|
|
242
|
+ .tips {
|
|
243
|
+ font-size: 28rpx;
|
|
244
|
+ margin-top: 16rpx;
|
|
245
|
+ }
|
|
246
|
+ }
|
214
|
247
|
</style>
|